# Question
Title: Retrieving a Store Field from Inside a Relationship Field
Using EE 2.10.1 and Store v2.4.0 I need to get the value of a Store field out from a related entry. My code is currently this (abbreviated to make it easier to read):

```
{exp:channel:entries channel="products" limit="1"}   <!-- main product tag -->
  {exp:store:product_form}                           <!-- starts the form allowing multi add to cart submit -->
    {related_item}                                   <!-- opens tag pair for relationship field and loops related items -->
      {exp:store:product entry_id="{related_item:entry_id}" disable_form="yes"} <!-- output individual related item-->
        <p>{related_item:title} - {price}</p>        <!-- Really really want Store field access here! -->
      {exp:store:product}
    {/related_item}
  {/exp:store:product_form}
{/exp:channel:entries}

```

However I've tried any number of ways to get the price (or any other Store value) to show without any luck e.g.

```
{price}
{related_item:price}
{related_item:regular_price}
{related_item:store_field_name:price}

```

but so far no joy with anything. Is this even possible?!

# Answer
> 0 votes
Have you tried putting the store item in an embed?

Sample template code

```
{exp:channel:entries channel="products" limit="1"}
  {related_item}
    {embed="_embed-template" the_id="{related_item:entry_id}"}
  {/related_item}
{/exp:channel:entries}

```

Then in the embed:

```
{exp:store:product entry_id="{embed:the_id}" disable_form="yes"}
  {title} - {price}
{/exp:store:product}

```

That should work...

# Answer
> 0 votes
OK - I am a little ashamed... I have found the answer and it was in my code all along... I enabled template debugging and it showed me that I hadn't closed the {exp:store:product} tag correctly (missed the slash) @bluedreamer - your code was spot on and also simplified the template a little too

---
Tags: expresso-store, relationships
---


# Question
Title: Major glitch with EE3 and multiple file fields
I've got a channel that uses a file field for a logo and another file field for a building beauty shot. In EE3, if I change the image on one field, then change the file on the other, it change BOTH to the same image. The only workaround I can find is to change one, save, then change the other and save.

Even worse is to use this with the Grid setup, which I use for photo albums. Say I finally get 20 images added to an album (add 1, save, add 2, save, etc). If I try to edit multiple images between saves, it changes all the images I edited to the same image. So if I change image2, then image15, then image12, all three change.

This is absurd! Is anyone else seeing this (hopefully fixed it), or is it just my install?

EE3.4.1

# Answer
Nevermind. This is a known bug in 3.4.1 and is supposed to have been fixed in 3.4.2. I will update and confirm.
> 0 votes

---
Tags: grid, ee3, files
---


# Question
Title: Issue with grid field and loading images, last image loaded keeps replacing all others
I'm having an issue with loading images to the grid field from the file manager: I'll add a first row and image, and then add a 2nd row, and add a second image, the first image get's replaced by the 2nd image. Then I'll add a 3rd row, and a 3rd image, and that image replaces all of the others. Basically, the last image loaded replaces all of the others. Weird.

I have a screencast showing this here: screencast showing file/grid field issue

Note/Edit: I tested with uploading new images to the file manager, and it does not occur when I do this, so it's just something with selecting images from the file manager? Screencast: showing the issue doesn't occur with new files

I've tried it with disabling extensions, same thing happens.

I don't have any errors in the console.

Any ideas what could be causing this?

ExpressionEngine v3.4.1

# Answer
I just dealt with this myself today. Update your system to 3.4.2 and you're golden.
> 0 votes

---
Tags: file-uploads, grid, image, files
---


# Question
Title: static caching with stash and spa behaviour
our website is SPA, so only first request is loading the whole page with css/js stuff. every next load is an ajax request. the initial request caches the whole site as expected. code is:

```
{layout="ech:base/.base_ech"}

{layout:set name="meta"}
    {exp:social_tags description="Start | Energy"}
{/layout:set}

<!-- load data for home -->
{stash:embed:ech:stash_featured stash:rubricid="0" stash:limit="7"}
{stash:embed:ech:stash_entries stash:rubricid="0" stash:hideFeatured="7"}
{stash:embed:ech:stash_disrupters stash:rubricid="26"}
{stash:embed:ech:stash_teasers stash:rubricid="41"}

{exp:stash:parse process="end"}

<!-- featured home section -->
{in:sert:index/.homeFeatured}
<!-- all other entries on home -->
{in:sert:index/.homeBrandnew}
<!-- all other entries on home -->
{in:sert:index/.homeAktuell}
<!-- all other entries on home -->
{in:sert:index/.homeArchive}

{/exp:stash:parse}

{exp:stash:static name="home" refresh="15"}

```

I find the whole site cached under stashCache/1/index.html Navigating from domain.com to domain.com/site2 and then back to domain.com will overwrite my index.html cache but with missing elements, because we cut them out while loading with ajax.

example:

```
{if !is_ajax_request}
<!DOCTYPE html>
<html lang="en">
<head>
... // thing not to load with every request
{/if}

```

loading the landingpage over a XMLHttpRequest will not break the site, but will overwrite the cache for index.php. if I really reload then with F5, the site has no styles, because the cached template has no

any suggestions for static caching and SPA sites?

# Answer
> 0 votes
There is a mod\_rewrite condition in the `.htaccess` file that excludes ajax requests from being rewritten to the cache file. You could choose to comment this out so that your ajax requests are cached. Note that your ajax requests should be to unique urls:

```
# Exclude AJAX
# RewriteCond %{HTTP:X-Requested-With} !=XMLHttpRequest

```

(see: https://github.com/croxton/Stash/wiki/Static-cache-setup)

Alternatively, you could exclude ajax requests from caching:

```
{if !is_ajax_request}
   {exp:stash:static}
{/if}

```

---
Tags: stash, ajax, caching, static, mustash
---


title: EE embed inside stash parse process end

text:
# Question
Title: EE embed inside stash parse process end
can I do an embed within a stash:parse with process end?

```
{exp:stash:parse process="end"}
    {embed="index/.homeFeatured"}
{/exp:stash:parse}

```

I just got the the embed line printed on the screen, without parsing.

actually my whole code looks like this:

```
{stash:embed:ech:stash_featured stash:rubricid="0" stash:limit="7"}
{stash:embed:ech:stash_entries stash:rubricid="0" stash:hideFeatured="7"}
{stash:embed:ech:stash_disrupters stash:rubricid="26
{stash:embed:ech:stash_teasers stash:rubricid="41"}

{exp:stash:parse process="end"}
   {in:sert:index/.homeFeatured} // inside here there is my embed which is not getting parsed
   {in:sert:index/.homeBrandnew}
   {in:sert:index/.homeAktuell}
   {in:sert:index/.homeArchive}
{/exp:stash:parse}

```

# Answer
Stash will not parse EE embeds, only it's own embeds.
> 1 votes

---
Tags: stash, embeds, parse
---


title: displaying expired entries

text:
# Question
Title: displaying expired entries
Is there a way where i can create a function that only displays expired entries? I have a page set up that displays, up and coming and pervious events click here when the user clicks on the pervious button it displays all past events.

```
{exp:channel:entries
            channel="events"
            disable="member_data|pagination|trackbacks"
            dynamic="no"
            sort="asc"
            start_on="{current_time format='%Y-%m-%d %H:%i'}"
            show_future_entries="no"
        }

```

i current have the tags above to display the events i have used the tag **start\_on** to displays dates etc on the page. What tag(s) do i need to apply in order for my pervious template to display past events only?

# Answer
```
{exp:channel:entries
   show_expired="yes"
   stop_before="{current_time format='%Y-%m-%d %H:%i'}"
}

```
> 3 votes

# Answer
To expound on my comment to this answer, and I acknowledge this is a bit unorthodox, this solution will improve performance by only executing one channel entries tag. The query tag will fetch the entry IDs, and dynamically build an embed variable that we will use on a single channel entries tag for this page request.

```
{exp:query sql="SELECT entry_id FROM exp_channel_titles WHERE expiration_date < {current_time} AND expiration_date != 0 AND channel_id = 9" limit="100"}
    {if count == 1}{embed="embeds/_expired_entries" entry_ids="{/if}
    {entry_id}{if count != total_results}|{/if}
    {if count == total_results}"}{/if}
{/exp:query}

```

The embed tag will only be created if the query has results, and the `{embed:embed_ids}` variable will contain something like `134|224|313|425`

Then on the `embeds/_expired_entries` template we will put our channel entries tag, and feed it those entry IDs:

```
{exp:channel:entries channel="your_channel" status="open|closed" entry_id="{embed:entry_ids}" dynamic="no" show_expired="yes" disable="pagination|member_data|categories"}
    {title}, {custom_field}
    {pagination}{pagination_links}{/pagination}
{/exp:channel:entries}

```
> 3 votes

# Answer
If you use the expiration date in EE then all you need to do is set a conditional in the channel:entries tag that compares the expiration date to the current date like this:

```
{if expiration_date < current_time}
    display your content
{/if}

```

If you don't use expiration date but do have an {event\_end\_date} or similarly named field then you can swap expiration\_date with {event\_end\_date}.

Also remove the start\_on parameter from your channel:entries tag because this will keep previous entries from being parsed.
> 2 votes

# Answer
The only way to do this and keep pagination every 100 would be like so:

```
{exp:query sql="SELECT entry_id FROM exp_channel_titles WHERE expiration_date < {current_time} AND expiration_date != 0 AND channel_id = 9" limit="100"}
{exp:channel:entries channel="your_channel" status="open|closed" entry_id="{entry_id}" dynamic="no" show_expired="yes" limit="1" disable="pagination|member_data|categories"}
{title}, {custom_field}
{/exp:channel:entries}
{pagination}{pagination_links}{/pagination}
{/exp:query}

```

Brad
> 0 votes

# Answer
I changed the code above to disinclude pagination and custom fields, and place the output in a numbered list, linking back to the CP/edit of each entry.

```
<ol>
{exp:query sql="SELECT entry_id FROM exp_channel_titles WHERE expiration_date < {current_time} AND expiration_date != 0"}
{exp:channel:entries status="open|closed" entry_id="{entry_id}" dynamic="no" show_expired="yes" limit="1" disable="pagination|member_data|categories" limit="1000"}
<li><a href="{site_url}admin.php?/cp/publish/edit/entry/{entry_id}">{title}</a></li>
{/exp:channel:entries}
{/exp:query}
</ol>

```
> 0 votes

---
Tags: templates, categories, conditionals
---


# Question
Title: Managing multiple segments in template routes
For one of my templates, I need two extra segments.

If I have the following in template routes, the page only loads if there is 1 segment.

```
/gallery/{alpha_dash}

```

If I add the following, it fails:

```
/gallery/{alpha_dash}/{alpha_dash}

```

The following works for two or one extra segment, but not just /gallery.

```
/gallery/{a:alpha_dash}/{b:alpha_dash}

```

Can anyone explain how I can have it work for all segments:

```
/gallery
/gallery/...
/gallery/.../...

```

# Answer
If you have the `segments required?` flag in the template manager is set to "no", then your longest route (i.e. `/gallery/{alpha_dash}/{alpha_dash}`) should work for all your test cases. If it doesn't, try turning the two `alpha_dash` instances into separate variables - e.g. `/gallery/{a:alpha_dash}/{b:alpha_dash}`
> 0 votes

---
Tags: url, segments, template-routes
---


title: if Child Categories, esle show Entries

text:
# Question
Title: if Child Categories, esle show Entries
I'm looking to show parent categories that have children, but if parents have no children, I need to show channel entries for the parent cats using the same segment\_3.

```
{if "child_categories"!=""}
   This Has Child Categories
     {if:else}
   This Doesn't - Show Entries in Parent
{/if}

```

Edit: Trying this:

```
{exp:gwcode_categories cat_url_title="{segment_2}" max_depth="2"}
{if '{has_children_in_output}' != ''}
This Has Stuff Show Children Cats
{if:else} This Doesn't Have Children - Show Entries for Parent Cat
{/if} {/exp:gwcode_categories}

```

I'm just not sure whow to show entries inside GW Cat tags. Maybe I need to store GW output as a variable to reuse in a Channel Tag?

# Answer
> 1 votes
You should be aware that GWCode Categories has not been updated since 2012, and only works with EE2 (see more details here http://gwcode.com/add-ons/gwcode-categories/release-notes) - so while it is incredibly handy it is not a robust long-term solution.

Fortunately there is an alternatives - find out more here https://buzzingpixel.com/software/category-construct/documentation/template-tags

As for doing the conditional you are trying to do, you probably can do it using the `{construct:has_children}` tag - which would seem to do all you need.

HTH

# Answer
> 0 votes
For anyone else looking for a solution.

```
{exp:gwcode_categories cat_url_title="{segment_2}" max_depth="1" style="linear"}
{if '{has_children_in_output}' != ''}
{!-- Show Nothing --}
{if:else}
{exp:channel:entries channel="products" custom_fields="yes" category="{segment_category_ids}"}
          <!-- Your Stuff -->
{/exp:channel:entries}
{/if}
{/exp:gwcode_categories}

```

---
Tags: child-categories
---


title: Switchee with 4 segments?

text:
# Question
Title: Switchee with 4 segments?
I need to switch on 4 segments. I'm a little confused.

```
{exp:switchee variable="{segment_2}" parse="inward"}
{case value="#^P(\\\\d+)$#|''"}
         Show all categories
{/case}
    {case default="Yes"}
        {switchee variable="{segment_3}" parse="inward"}

            {case value="#^P(\\\\d+)$#|''"}
            Show a specific category
            {/case}

            {case default="Yes"}
            Show a specific sub-categories entries
            {/case}

            <!-- I need a fourth segment -->
            {case default="Yes"}
            Show a specific product
            {/case}
            <!-- I need a fourth segment -->

        {/switchee}
    {/case}
{/exp:switchee}

```

# Answer
I'd try and start on the 4th segment then work your way back thru the segments using switchee. As it stands segment 2 will always be true (not sure what your regex is testing for though) pagination ?
> 0 votes

# Answer
This does the trick:

```
{exp:switchee variable="{segment_2}" parse="inward"}
{case value="#^P(\\\\d+)$#|''"}
Show all categories
{/case}

{case default="Yes"}

    {switchee variable="{segment_3}" parse="inward"}

        {case value="#^P(\\\\d+)$#|''"}
        Show main category
        {/case}

        {case default="Yes"}

            {switchee variable="{segment_4}" parse="inward"}

                {case value="#^P(\\\\d+)$#|''"}
                Show subcategory products
                {/case}

                {case default="Yes"}
                Show product
                {/case}

            {/switchee}

        {/case}

    {/switchee}

{/case} {/exp:switchee}

```
> 0 votes

---
Tags: switchee
---


# Question
Title: Implementing Google Trusted Stores on EE Site
I'm trying to implement Google Trusted Stores on my Expression Engine site using Expresso Store addon.

I was able to get the GTS Badge code/part to work, however I can't get the 2nd code/part to work. Here is an example of Google's code:

```
<!-- START Google Trusted Stores Order -->
<div id="gts-order" style="display:none;" translate="no">

  <!-- start order and merchant information -->
  <span id="gts-o-id">MERCHANT_ORDER_ID</span>
  <span id="gts-o-email">CUSTOMER_EMAIL</span>
  <span id="gts-o-country">CUSTOMER_COUNTRY</span>
  <span id="gts-o-currency">CURRENCY</span>
  <span id="gts-o-total">ORDER_TOTAL</span>
  <span id="gts-o-discounts">ORDER_DISCOUNTS</span>
  <span id="gts-o-shipping-total">ORDER_SHIPPING</span>
  <span id="gts-o-tax-total">ORDER_TAX</span>
  <span id="gts-o-est-ship-date">ORDER_EST_SHIP_DATE</span>
  <span id="gts-o-est-delivery-date">ORDER_EST_DELIVERY_DATE</span>
  <span id="gts-o-has-preorder">HAS_BACKORDER_PREORDER</span>
  <span id="gts-o-has-digital">HAS_DIGITAL_GOODS</span>
  <!-- end order and merchant information -->

  <!-- start repeated item specific information -->
  <!-- item example: this area repeated for each item in the order -->
  <span class="gts-item">
    <span class="gts-i-name">ITEM_NAME</span>
    <span class="gts-i-price">ITEM_PRICE</span>
    <span class="gts-i-quantity">ITEM_QUANTITY</span>
    <span class="gts-i-prodsearch-id">ITEM_GOOGLE_SHOPPING_ID</span>
    <span class="gts-i-prodsearch-store-id">ITEM_GOOGLE_SHOPPING_ACCOUNT_ID</span>
  </span>
  <!-- end item 1 example -->
  <!-- end repeated item specific information -->

</div>
<!-- END Google Trusted Stores Order -->

```

My question is, how do I pulled the customer email, customer country, etc details into the script. I tried using the Expresso Store tags for the data {order\_total} etc, but that didn't work. I also tried that again after placing the Google script inside of my {exp: expresso store loop.

Using EE 2.8.1 and Expresso Store is up-to-date.

Thanks in advance!!

# Answer
> 0 votes
This code is on your order success page right? If so the information will be available within your

```
{exp:store:orders order_hash="{segment_xx}"}
  order info is all here
{/exp:store:orders}

```

loop

For example:

```
{exp:store:orders order_hash="{segment_3}"}
  <span id="gts-o-email">{order_email}</span>
  <span id="gts-o-country">{billing_country_name}</span>
<!-- now show each cart line -->
{items}
  <span class="gts-i-name">{title}</span>
  <span class="gts-i-price">{item_subtotal}</span>
  <span class="gts-i-quantity">{item_qty}</span>
{/items}
{/exp:store:orders}

```

Remember, if you want currency values that are not pre-formatted, just add \_val to the end of each variable for a pure number i.e.

```
{item_subtotal} becomes {item_subtotal_val}

```

---
Tags: expresso-store, devdemon, google
---


# Question
Title: Cannot Upload File Thumbnail could not be created for the image. Please make sure the thumbnail directory is writable
EE 3.4.0 Windows 10

So I haven't seen this stick it's head out of the closet in a while... I know it's discussed frequently, but nothing is allowing this to go through.

Channel Images is fine, gives me no issues on uploads deletes, etc, but native File (images) is giving me hell. Full permissions given, but still no dice. Tried the usual things first... Delete thumbs folder, etc... Any ideas how to get past this?

# Answer
> 0 votes
I received this answer from Dean Matsueda in a Slack chat. Apparently, in Windows, you have to change the directory separators from '/' to '\\'. Both ways will pass the "check" for the path, but one will fail every time.

Another solution, provided by TJ Draper, was to use your config file for your directories and simply use the `DIRECTORY_SEPARATOR` constant to be environmentally friendly.

---
Tags: file-uploads, image, file-manager
---


# Question
Title: Server Side Includes with EE? is it possible?
I've been trying to get SSI to work with EE, I can see the SSI code in the source but from some reason in EE it's not parsed, can anyone help with this issue?

I don't want to enable php on the page or use php includes.

I'm using SSI to include css and js assets. SSI are much faster then php include or EE templates.

# Answer
I am 99% sure this is not possible. We just tried to do something similar in EE2 (you didn't specify what version of EE you are working with).

We got SSI working in .html and .php but could not get them working for any page that was handled by EE, regardless of template type ('static' didn't work for example) or whether PHP was enabled in the template.

It looks to me like CodeIgniter Security is preventing their execution. We just end up seeing the SSI code in the browser source.
> 0 votes

---
Tags: apache
---


title: When to make a channel vs just a field

text:
# Question
Title: When to make a channel vs just a field
EE novice here. This question has to do with best practices.

When is it necessary to make a channel for dynamic editing for your users vs simply making a channel field and simply attache that to an existing channel?

For example, if I want to make a blog, duh...I will need channel and field groups for that. However, if I just need to change headings on a specific page. Do I need to make a channel\>field group \> etc? Or just a field group that is aptly named and then throw that under any other pre-existing channel I already have up (this seems haphazard in my opinion)? In summary, I want to be professional (a.k.a. clear and efficient!)

# Answer
> 1 votes
Good question. For controlling non-entry content like this, I almost always install Low Variables as a sort of second admin area within the control panel. It's an indispensible add-on IMHO.

But you could also take some inspiration from the method outlined in this now-very-old (but still relevant) piece by Ryan Masuga about using a single-entry channel for controlling this kind of stuff - especially with EE3's new "maximum entries" feature for channels.

The downside of this approach is that every channel field you add bloats the number of columns in `exp_channel_data`, and if you create, say, 10-20 fields to control custom bits of content, that's 20-40 extra columns in that table (every field gets two columns) that will be empty for all but one of your channel entries.

---
Tags: ee3
---


# Question
Title: Passing a GET variable back in a query while using mysqli_real_escape_string()
I'm trying to take a variable that's passed in a query string (GET) and then use that variable to do a SELECT based on it...

```
// Assign query string to a variable while sanitizing it against XSS
$event = ee()->input->get_post('event', TRUE);

// Build query
$sql = "SELECT t.entry_id
    FROM exp_channel_titles t
    LEFT join exp_channel_data d
    ON t.entry_id = d.entry_id
    WHERE
        field_id_42 LIKE '" . mysqli_real_escape_string($event) . "';";

// Execute query
$query  = ee()->db->query( "$sql" );

```

It executes as expected, however I am seeing the following error in the error log:

`Severity: Warning --> mysqli_real_escape_string() expects exactly 2 parameters, 1 given`

What is the 'EE way' to pass the required connection parameters to the mysqli\_real\_escape\_string() function?

# Answer
> 1 votes
Use `ee()->db->escape_str($event)` \- it's the native way to escape potentially-unsafe data in EE.

---
Tags: ee2, database, query, mysql, api
---


# Question
Title: How to change default C2 - C3 base cateogry urls to their actual name
For the life of me, I don't understand why EE uses C's for category urls by default and not their actual names. I get the concept but it's not that SEO friendly.

For instance, using normal channel tags to pull entries in, if I hack the URL to /sandbox/C2 it displays all entries within Category 1 (electric)

If i have a child category, the child category id is 10 so /sandbox/C10/ displays the correct child category. /electric/flat-wound-electric

But if out use the actual url\_title sandbox/electric outputs all products in the parent category electric

But...When I hack the url to /electric/flat-wound-electric it only displays the parent.

Are there any add-ons anyone is aware of that handles this without using bulky tag pairs and conditionals to display categories properly?

# Answer
> 0 votes
Two things you can do:

1. Configure the Category URL and Category URL Segment preferences. This will make native category paths look like (for example) `/category/electric`.
2. Have a look at Low Seg2Cat. Dead simple add-on which allows you to bypass the Category URL Segment entirely.

---
Tags: categories, ee3
---


# Question
Title: Expresso Store - Modify quantity in backend
When I want to modify quantity of products up or down in the backend I can change some of the items and some not.

If not possible the save button stays light-gray and nothing happens.

Any idea? Thx

# Answer
I think I found the solution.

The modification typ was 'Variation' and for one position the minimal order quantitiy was missing.

Thx
> 0 votes

---
Tags: expresso-store
---


title: Changing the <img> tag with CE Image?

text:
# Question
Title: Changing the <img> tag with CE Image?
So if you may or may not know, Google rolled out Amp'd pages and displaying these websites that are 'Amp ready' higher on the search results. Without getting into the details of Amp, we need to change a few html tags (thanks Google).

The problem we're facing right now is changing `<img src="">` tags to `<amp-img src="">`. We're using WYGWAM and CE-Image and allowing authors to upload images to the main content area. On the template side of things, we're wrapping the main content with ce\_img:bulk to resize all images.

Is there a way to change the img tag with amp-img tag?

```
{exp:ce_img:bulk max_width="780" bucket="site" hide_relative_path="yes" attributes="itemprop='image'"}
   {content}
{/exp:ce_img:bulk}

```

Amp documentation: https://ampbyexample.com/components/amp-img/

Any help would be great!

# Answer
> 1 votes
CE image does not have the ability to change the name of the image tag. You could, however, simply wrap your final html in a plugin with a replace method. For example, this is how to do that with CE String:

```
{exp:ce_str:ing replace='<img|<amp-img'}
    <!-- your final html -->
{/exp:ce_str:ing}

```

---

Disclaimer: I am the author of both the CE Image and CE String add-ons.

# Answer
> 0 votes
I found the answer. For those of you who are curious, I used Low Replace to find `<img` and replace it with `<amp-img` Here is what the part of the template looks like:

```
{exp:ce_img:bulk max_width="780" bucket="site" hide_relative_path="yes" attributes="itemprop='image'"}
   {exp:low_replace find="<img" replace="<amp-img"}{content}{/exp:low_replace}
{/exp:ce_img:bulk}

```

---
Tags: wygwam, ce-image, google
---


# Question
Title: Low Search show multiple selected categories
I am using Low Search with 2 category select field filters. I'd like to display the selected categories on the page, but when only one category group is used, the results effect the other categories display.

For example:

```
<p>Industry: {if '{low_search_category}' != ''}{exp:channel:categories show="{low_search_category}" channel="attorneys" category_group="2" style="linear"}{category_name}{/exp:channel:categories}{if:else}All{/if}</p> <p>Practice Area: {if '{low_search_category}' != ''}{exp:channel:categories show="{low_search_category}" channel="attorneys" category_group="3" style="linear"}{category_name}{/exp:channel:categories}{if:else}All{/if}</p>

```

I have 2 select fields, Industry & Practice Areas. If I select a category from the Industry select field but not from the Practice Area select field, I need the above code to show the correct category for Industry (which it does) but show "All" for Practice Areas since nothing was selected.

With the above code, nothing gets displayed for Practice Areas instead of "All" because `{low_search_category}` does not distinguish between the 2 different category groups.

Is there any way to achieve this?

# Answer
> 0 votes
Take a look at the Category Groups option. That might be better for your use case.

**Edit:** Something along these lines, if you're allowing only one selection per group:

### Form

```
{exp:low_search:form query="{segment_3}"}
    <select name="category:industry">
        <option value="">All industries</option>
        {exp:channel:categories channel="attorneys" category_group="2" style="linear"}
            <option value="{category_id}"{if low_search_category:industry == category_id} selected{/if}>
                {category_name}
            </option>
        {/exp:channel:categories}
    </select>

    <select name="category:area">
        <option value="">All practice areas</option>
        {exp:channel:categories channel="attorneys" category_group="3" style="linear"}
            <option value="{category_id}"{if low_search_category:area == category_id} selected{/if}>
                {category_name}
            </option>
        {/exp:channel:categories}
    </select>

    <button type="submit">Go</button>
{/exp:low_search:form}

```

### Filters

```
{exp:low_search:filters query="{segment_3}"}
    <p>
        Industry:
        {if low_search_category:industry != ''}
            {exp:channel:categories show="{low_search_category:industry}" channel="attorneys" category_group="2" style="linear"}
                {category_name}
            {/exp:channel:categories}
        {if:else}
            All
        {/if}
    </p>
    <p>
        Practice Area:
        {if low_search_category:area != ''}
            {exp:channel:categories show="{low_search_category:area}" channel="attorneys" category_group="3" style="linear"}
                {category_name}
            {/exp:channel:categories}
        {if:else}
            All
        {/if}
    </p>
{/exp:low_search:filters}

```

### Search results

```
{exp:low_search:results query="{segment_3}"}
    ...
{/exp:low_search:results}

```

---
Tags: low-search
---


# Question
Title: Channel form entry status always set to closed
I have a site that I recently upgraded, and converted a safecracker form to a channel form. Since the upgrade, every entry posted through the form has its status set to closed, no matter what the status field is set to in the form. I use the same form for editing, and I am able to edit an existing entry and change the status, but EE seems to be ignoring the status set via the form when the entry is created.

I have custom status set up for the channel, and have 'held' set as the channel default. I tried stripping out the status field entirely, and adding

```
<input type="hidden" name="status" value="held" />

```

but that didn't change anything.

The channel has my custom status group assigned to it, and all members have access to my custom statuses.

It doesn't matter whether I'm logged in as a regular member or a superadmin, new entries posted through the channel form always have the status set to closed.

Is there some way around this? Relevant form code is below:

```
{exp:channel:form
 channel="calendar_events"
 include_assets="no"
 use_live_url="no"
 return="schedule/appointment/confirm/{if segment_4 ==     "edit"}edit/{/if}ENTRY_ID"
 {if segment_4 == "edit"}entry_id="{last_segment}"{/if}
 logged_out_member_id="6"
 rules:appointment-time="required"
 }
{!-- Set Entry Status --}
<!-- {status} -->
<dt><label for="status">Status</label></dt>
<dd><select name="status" id="status">
  <option value="Held" {if status == "Held"}selected{/if}>Hold</option>
  <option value="Booked" {if status == "Booked"}selected{/if}>Book</option>
  {if logged_in_group_id == "1" OR logged_in_group_id == "7"}
  <option value="open" {if status == "open"}selected{/if}>Delete</option>
  <option value="closed" {if status == "closed"}selected{/if}>Closed</option>
  {/if}
</select></dd>
</dl>
</fieldset>
<input type="submit" class="submit" name="submit" value="Submit" />
{/exp:channel:form}

```

# Answer
> 0 votes
I totally missed the new Channel Form Settings admin panel. Once I set the default status there, everything works fine.

---
Tags: safecracker, status, saef
---


# Question
Title: DevDemon Forms Field Settings popup doesn't show up in correct location when field is in a column
I am using EE 2.11.2 and Forms 3.5.3

In the form builder tool, when you click the gear icon to edit the field settings, the Field Settings popup shows up. It is supposed to appear right where that element is in the form. This works for most form elements, but it doesn't work properly for form elements within a multi-column layout. The popup shows up at the very top of the form, which means you have to scroll all the way up there to edit the settings.

# Answer
To fix this, I added a line after 379 of form\_builder.js, so

```
var Parent = $(e.target).parents('div.FormElem').last();

```

becomes

```
var Parent = $(e.target).parents('div.FormElem').last();
var Parent_Scroll = $(e.target).parents('div.FormElem').last();

```

I added Parent\_Scroll as the element that determines the position that the Settings modal should scroll down to. Then I had to update what is now lines 393 and 394 from

```
var TopBefore = Settings[0].offsetTop+Parent[0].offsetTop+Settings.height();
var TopAfter = Settings[0].offsetTop-Parent[0].offsetTop;

```

to

```
var TopBefore = Settings[0].offsetTop+Parent_Scroll[0].offsetTop+Settings.height();
var TopAfter = Settings[0].offsetTop-Parent_Scroll[0].offsetTop;

```

and now the Field Settings popup shows up where it should!
> 0 votes

---
Tags: forms, jquery, devdemon-forms
---


# Question
Title: Load Entry Via Ajax - After filtering from dropdown menu
I am wondering if you can point me in the right direction here. Here is what I want to happen.

1) Site visitor visits the site and sees an elected official displayed on the home page. Next to this elected official is a dropdown list with a listing of all the counties for their state. 2) The user can select another county from this list and then hit a submit button. 3) That portion of the web page refreshes (filters) and the picture and content of the elected official is displayed to match the county (entry) for that official per the users selection.

Because this is housed on the home page, I would like for it (the entry) to load via ajax. So when a visitor chooses a new county and hits the submit button, you see the new entry displayed without reloading.

The county for the official is saved as a custom field text box within their entry.

Any recommendations on how to do this? Does this make sense?

# Answer
> 0 votes
Just curious. Something like this? This page is still under development but I think it's sort of what you're looking for. If it is, I'll explain in detail. http://sitstringsdesign.com/products/pedal-steel-lap-steel/sc8e7th

---
Tags: ee2, channel, entries, ajax, filter
---


# Question
Title: Any way to get EE to upload not-properly encoded mp3s?
**here's the problem (edit):**

I'm unable to upload some mp3s through the publish page or the file manager, whereas other mp3s would upload just fine. Now, thanks to the assistance of a support person at the host (Nexcess), I've found that the mp3's that don't work didn't have all the encoding they need, and the mp3's that *did* work had the encoding, like this:

The mp3's that were working look like this:

```
$ file /dev/audio-upload/*.mp3
example01.mp3: Audio file with ID3 version 2.2.0, contains: MPEG ADTS, layer III, v1, 192 kbps, 44.1 kHz, Stereo
example02.mp3: Audio file with ID3 version 2.2.0, contains: MPEG ADTS, layer III, v1, 192 kbps, 44.1 kHz, Stereo
example03.mp3: Audio file with ID3 version 2.2.0, contains: MPEG ADTS, layer III, v1, 160 kbps, 44.1 kHz, Stereo

```

The mp3's that weren't working look like this (they're missing the encoding info):

```
$ file /dev/mp3s-for-eval/*.mp3
example01.mp3: Audio file with ID3 version 2.2.0, contains:
example02.mp3: Audio file with ID3 version 2.2.0, contains:
example03.mp3: Audio file with ID3 version 2.2.0, contains:

```

So a solution was to re-convert the unencoded files to mp3. But the problem remains: the mp3's that wouldn't upload (the ones missing the encoding info) play just fine. Is there a way to get EE to allow these un-encoded mp3's so my client doesn't get confused if they have files like this?

Also, these test mp3's that didn't upload were created by converting AIFF files in iTunes; any ideas as to why they didn't get the encoding?

**(this is my original question:)**

I'm having a mysterious time trying to get certain mp3's uploaded through a Grid field.

I'm developing a music site using EE 2.10.1; one of the channels is "Albums" which holds info on different music CDs. In this channel I have a Grid field that contains info about the different tracks on the CD and also the mp3 of the track.

My upload location is set to "all file types" and when I check the PHP info, it looks like the max file size allowed is 64MB.

When I try to upload the mp3's I need for the first entry, I get a cryptic "file not allowed" message; 'cryptic' because it's not saying it's an invalid file type or that the file is too big:

So I’ve been testing to see what I can--and can’t--upload. I've been able to successfully upload a 13.7MB jpg through the Grid field, so I'm assuming that size isn't an issue (the mp3's are all smaller than that).

Further testing reveals that I'm able to upload *some* mp3's, ranging in size from 1.4MB to 8.2MB. But the majority of mp3's I try give me the error message. Also, I've tried uploading the mp3's that don't work directly through the File Manager, but I also get the error message that way.

Any ideas or thoughts about what the problem could be? I have no idea if this is somehow a server issue, an EE issue or an issue with particular files (I can play the mp3's that won’t upload, so I don’t think they’re corrupt).

Thanks in advance for your assistance!

# Answer
> 0 votes
Following up on this, the issue turned out to be incorrectly created MP3s! I was using iTunes to convert AIFFs into MP3s and for some reason -- even though the MP3s would play -- they were not correctly formatted in some way. Converting the AIFFs with a different program correctly formatted the MP3s and then they would upload. So the problem was that EE was seeing bad file formats, there wasn't any size-limit or anything.

# Answer
> 1 votes
Try to disable XSS filtering in your security preferences. It looks like EE flags those files as suspicious.

---
Tags: file-uploads
---


# Question
Title: Front end registration form stopped working
The front end registration form on my client's site takes the info and even acknowledges success - and the admin gets notified. But the info isn't getting into the db/ee back end anymore.

This registration form has been working OK for years, the rest of the site is OK as well.

The form uses User 3.4.5 which is no longer supported by Solspace.

The site was recently moved to a new server - en masse with the rest of my hosted accounts.

---

My server admin looked at this and here's what he got when he turned on error reporting. I have no idea how to use this information.

A Database Error Occurred Error Number: 1366 Incorrect integer value: '' for column 'last\_activity' at row 1 INSERT INTO exp\_members (group\_id, username, password, salt, ip\_address, unique\_id, join\_date, email, screen\_name, time\_format, url, location, occupation, interests, language, last\_activity, bday\_d, bday\_m, bday\_y, aol\_im, yahoo\_im, msn\_im, icq, bio, profile\_views, timezone, signature) VALUES (4, 'mobin', '42b3f050b4c607c33200dde2ab4f3df36ea3b7b35dc26b283055f6e03ed600912a722257daf584162a46c7ab818ef727bd455cb6eb033840e3192e3066aee0d3', 'm0)ByGfjPC\>\\'sA=$*j6\>NAX\\"QU?,M8XghPKF(/\\"@u*c\\.N=T-v,I\\'@K$RaaD=uf-uE\>yV,SCRbBb#~AxGOC0OscBE%:3i?6~F\]EnEl.}C(&3vB?#/7)I!S:~Qh\\'zs,', '123.63.124.188', 'f8f835d49114da34eabf03cc60d807a7adda72b2', 1474251848, 'mobin.xavier@idologic.com', 'Mobin Idologic', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '') Filename: third\_party/user/mod.user.php

# Answer
> 0 votes
Sounds like it might be a system path issue somewhere. Check your config file and other system settings. Try turning on error reporting, level 2 (show errors to all) and try a registration. See if any errors report back. The obvious thing you changed was migrating to another server. Is the php version the same? php configuration the same?

# Answer
> 0 votes
The problem turned out to be mysql wasn't in strict mode on the old server, it was on the new one, so we disabled that and everything was fine again. :)

---
Tags: ee2, solspace-user, registration
---


title: One email form, different recipeints

text:
# Question
Title: One email form, different recipeints
I am building a site that lists different service providers.

On each service provider's page there is a contact form (the same form for each service provider).

The email address of each service provider (the recipient) is in the channel entry.

How can I get the email sent to each respective service provider - as well as the site owner?

I am trying to avoid using a different script for each form - and I don't want to expose the recipient's email address in the page code.

# Answer
If you look at the Template Parsing order, you will see that segment variables are parsed before Preload Replace Variables. You can take advantage of that.

```
{if segment_2 == "foo"}
    {preload_replace:pr-recipient="contact@foo.com,"}
{if:elseif segment_2 == "bar"}
    {preload_replace:pr-recipient="sales@bar.com,"}
{/if}

    {preload_replace:pr-recipient=""}

{exp:email:contact_form user_recipients="no" recipients="{pr-recipient}site-owner@example.com" charset="utf-8"}

    [...]

{/exp:email:contact_form}

```
> 1 votes

# Answer
I'm not exactly sure how the above answer would have worked, I'm really not sure I understood it. :/

However, I was able to accomplish what I wanted pretty easily with Solspace's Freeform. Also I needed custom fields which Freeform is great at doing.

Also I need to mention Solspace has ***awesome*** support.
> 1 votes

---
Tags: email, email-contact-form
---


# Question
Title: Channel Entries API Error: Undefined property: EE::$stats
This error appears during execution of the Channels Entry API in an API extension:

> A PHP Error was encountered Severity: Notice Message: Undefined property: EE::$stats Filename: api/Api\_channel\_entries.php

The API library is loaded successfully:

```
 ee()->load->library('api');
 ee()->api->instantiate('channel_entries');
 ee()->api->instantiate('channel_fields');

```

and I am making sure the API user has permission (SuperAdmin).

The data array looks like this:

```
$data = array(
'title'         => $tTourTitle,
'field_id_127'  => $tTourDuration,
'field_id_136'  => $pCountry,
'field_id_137'  => "$tTourCity",
'field_id_141'  => "$tIncludes",
'field_id_142'  => "$tExcludes",
'field_id_143'  => "$tNotes",
'field_id_144'  => "$tDescription",
'field_id_145'  => "$pTour->Opt",
'field_id_149'  => $tTourPreferred
);

```

and I am executing the call according to EE 2.11.1 documentation:

```
ee()->api_channel_fields->setup_entry_settings($this->aEESettings['experiences_channel_id'], $data);

if($pTourId !== ''){
  $updateResult = ee()->api_channel_entries->save_entry($data, $this->aEESettings['experiences_channel_id'], $pTourId);
} else {
  $updateResult = ee()->api_channel_entries->save_entry($data, $this->aEESettings['experiences_channel_id']);
}

```

Why would I get this stats object error? Do I need to load any other models/apis to get this working?

Not sure if this matters, but we are using the Structure AddOn.

Thanks in advance for your input.

# Answer
> 0 votes
In the meantime I have figured out this problem. When using the API library, it is required to also load the stats library. Like so:

```
 ee()->load->library('api');
 ee()->load->library('stats');
 ee()->api->instantiate('channel_entries');
 ee()->api->instantiate('channel_fields');

```

---
Tags: channel-entries-api, api
---


title: Stash variables not working in EE3

text:
# Question
Title: Stash variables not working in EE3
I'm using Stash 3.0.3 (from the EE3 branch) with EE 3.4.2 and I'm having some issues getting the Stash variables to display.

I have a page setup that is using the following EE template:

```
{!-- Get the page layout --}
{stash:embed:layouts:range}

{!-- Get the page model --}
{stash:embed:models:range stash:url_title="{segment_1}"}

```

The first piece of code is correctly getting the page layout as I can see this when I go to the particular page in the browser.

However, none of the stash variables on the page are actually displaying what they're supposed to - instead they're just showing for example:

```
{stash:rangeTitle}

```

Here's the code for this in the `{stash:embed:models:range stash:url_title="{segment_1}"}` template:

```
{exp:channel:entries channel="product_ranges" url_title="{stash:url_title}" dynamic="no" limit="1" disable="member_data|pagination" cache="yes" refresh="10080"}
    {exp:stash:set name="rangeTitle"}{title}{/exp:stash:set}
{/exp:channel:entries}

```

And then the code in the layout `{stash:embed:layouts:range}`:

```
{stash:rangeTitle}

```

I have these exact templates on an EE 2.9 site (but using the latest version of Stash for EE2) and they work perfectly. But I can't seem to get this working on EE3.

I have also tried simply replacing the url\_title to the actual page url title to discount this and the variables still didn't display properly.

I was wondering if anyone else has had such an issue?

# Answer
> 0 votes
`cache="yes" refresh="10080"`

That tells EE to cache and return the output of the channel entries tag, however there is no output from a stash:set. On subsequent views of the template containing this tag, the stash set will not run.

I'd guess you may have had tag caching disabled on the EE 2.x site so didn't notice.

---
Tags: stash, ee3
---


title: Freemember login errors with Transcribe

text:
# Question
Title: Freemember login errors with Transcribe
I am using EE version 2.9.2, transcribe 1.6.1 and Freemember 2.3.2

I have a login form which works fine in the original language with error\_handling set to inline. However, when I viewed in the translated language the error\_handling parameter causes the form to redirect to the home page without the language prefix when a bad username is entered.

If I remove error\_handling-"inline" the problem disappears but of course the error shown is in the original language not the desired one.

Does anyone know how to fix this? Cheers

# Answer
> 1 votes
This looks to be a bug within FreeMember, as a Transcribed entry is much like any other normal entry.

I would try logging the bug over at FreeMembers Issue Queue, to try and get a 1st aprty response. Otherwise stay posted, I don't have a suitable test set up so I couldn't debug this for you, but there's pleanty of transcribe/freemember users on here...

# Answer
> 1 votes
Im a little late to the party, but I just spent a day tracking down the cause of this bug. The issue is that transmit deals with ACT actions differently to normal GET requests.

In `ext.transcribe.php` on about line `995` there is a line that looks like this...

`if($submitted_action_id_data->class != 'Forms')`

By changing this to ...

`if(!in_array($submitted_action_id_data->class, ['Forms', 'Freemember']))`

... We can stop Transcribe from exiting early for POST Actions.

I hope this helps someone.

---
Tags: freemember, transcribe
---


title: Resource Router :pagination not working

text:
# Question
Title: Resource Router :pagination not working
I'm using the following (https://github.com/rsanchez/resource\_router):

```
$config['resource_router'] = [
    'news-and-resources' => 'www/news-and-resources',
    'usa/news-and-resources' => 'www/news-and-resources',
    'cn/news-and-resources' => 'www/news-and-resources',
    'zh/news-and-resources' => 'www/news-and-resources',
    'usa/news-and-resources/:pagination' => 'www/news-and-resources',
];

```

The last array item should match a url of -

```
http://www.example.com/usa/news-and-resources/P3

```

But it just throws a 404 error, even though I *know* it should load more entries.

What's causing this problem? I'm using Expression Engine 3.4.1

***Update:***

Using the Resource Router plugin (purely because I can’t get this working inside EE’s routing system) I’ve done this:

```
$config['resource_router'] = array(
    'news-and-resources/:pagination' => 'www/news-and-resources',
    '(usa|cn|zh)/news-and-resources/:pagination' => 'www/news-and-resources',
    'news-and-resources/(news|resource)/:pagination' => 'www/news-and-resources',
    '(usa|cn|zh)/news-and-resources/(news|resource)/:pagination' => 'www/news-and-resources',
);

```

So, based on the routes above, the following page requests work and load correct content:

```
http://www.example.co.uk/news-and-resources
http://www.example.co.uk/news-and-resources/P3
http://www.example.co.uk/news-and-resources/news
http://www.example.co.uk/news-and-resources/resource
http://www.example.co.uk/news-and-resources/news/P3
http://www.example.co.uk/news-and-resources/resource/P3

http://www.example.co.uk/usa/news-and-resources
http://www.example.co.uk/usa/news-and-resources/news
http://www.example.co.uk/usa/news-and-resources/resource
http://www.example.co.uk/usa/news-and-resources/news/P3
http://www.example.co.uk/usa/news-and-resources/resource/P3

```

You’ll notice the only difference is that there is no

`http://www.example.co.uk/usa/news-and-resources/P3`

And that’s because it’s the only one that doesn’t work, despite there being a route defined

`'(usa|cn|zh)/news-and-resources/:pagination' => 'www/news-and-resources`

# Answer
> 0 votes
Do the other links work as expected (like zh/news-and-resources)? Try this:

```
$config['resource_router'] = array(
    'news-and-resources' => 'www/news-and-resources',
    'usa/news-and-resources/:pagination' => 'www/news-and-resources',
    'cn/news-and-resources' => 'www/news-and-resources',
    'zh/news-and-resources' => 'www/news-and-resources',
);

```

You should only need the usa/news... once, because :pagination is an optional segment: it should match that line with or without pagination.

Update: From Robson's comment, this is also possible:

```
$config['resource_router'] = array(
    'news-and-resources' => 'www/news-and-resources',
    '(usa|cn|zn)/news-and-resources/:pagination' => 'www/news-and-resources',
);

```

To test that resource router is matching the url, you can do something like:

```
$config['resource_router'] = array(
    'usa/news-and-resources/:pagination' => function($router, $wildcard) {
        return 'This URL matched.';
    }
);

```

---
Tags: ee3, template-routes, resource-router
---


# Question
Title: Unix time (%U) off by 24,400 seconds for Solspace Calendar date variables
**SOLVED** (see below)

I have a strange error that has cropped up recently. Outputting a Solspace Calendar event's start or end date (and probably the related variables) in Unix time results in a timestamp that is off by 6 hours, 46 minutes, 20 seconds (24,400 seconds). For example, for an event that starts at 8:30 a.m. PST on October 5 `{event_start_date format="%U"}`, we get 1475657000, which actually corresponds to 1:43:20 a.m. PST on Oct. 5. (We need the Unix time for creating an .ics file.)

However, outputting those dates with standard PHP date format flags DOES show the **correct** date/time. For example `{event_start_date format="%F %j, %Y at %G:%i:%s"}` outputs October 5, 2016 at 08:30:00. Also, the Unix time formatting (%U) works correctly for the **built-in** `{entry_date}`, etc. variables - just not for custom date variables.

Additionally, I have verified that the server time is correct and the dates/times are correct in the database.

The only thing I could think of was that maybe something has changed in PHP since the module was coded and that is causing an error? We did upgrade PHP a few months ago, and it's possible these dates in Unix format have been incorrect since then. (We are running PHP 5.6.21, EE 2.10.1, Calendar 1.8.14.)

# Answer
> 0 votes
**FIX**: add `tz_id_my-calendar-url-title` parameter...

This appears to be a bug introduced in Calendar 1.8.12, where Solspace tried to address a problem in how Unix timestamps were output (they were not getting localized to the timezone, so 8:00 a.m. PDT would output as 8:00 a.m. GMT). Solspace added an undocumented parameter to specify the timezone. See: https://solspace.com/expressionengine/legacy/calendar-1/change\_log/#v1.8.12 . Basically, if you want to output date vars as Unix timestamps (%U format), you need to add the `tz_id_my-calendar-url-title` parameter to your module tag: e.g., `tz_id_community-events-calendar = 'America/Los_Angeles'`. (This only applies to the custom date variables, like `{event_start_date}`, and ONLY if you need the Unix timestamp).

I've been in touch with Solspace, so hopefully they are fixing :)

---
Tags: solspace, solspace-calendar
---


# Question
Title: Creating entry with channel entries api, redirecting to empty view page
I am on EE 2.11.2, and I am using the Channel Entries API to create a new channel entry after a user submits a form on the front-end. It saves the entry just fine, but when I redirect the user to the view template for that new entry, most of the time, the page is blank.

If I refresh the page, it displays the entry. Also, if I sleep() in PHP for a bit before redirecting, it seems to show the entry rather than the blank page more often.

Is there a way to get around this? Am I doing something wrong?

# Answer
Ifigured it out!

When creating the entry with the Channel Entries API, I was setting the entry\_date value to be `ee()->localize->now`. After it saved, and got redirected within the same second, the view page was not returning the result because the channel entries query was checking for entries with an entry\_date \< the current timestamp. So It wasn't finding this entry saved in the same second as the query!

I fixed this by setting my entry\_date to be `ee()->localize->now - 1`
> 0 votes

# Answer
Did you try to set error reporting in EE preferences to show errors to everyone? Perhaps there is an error and you just don't see it.

If the blank page means no results, the most obvious is checking entry status. By default the enties published via channel form are set to Closed status (unless you specify other status explicitely and the user has access to that status).
> 0 votes

---
Tags: safecracker, channel, add-on-development, module, channel-entries-api
---


# Question
Title: Need a regex ninja's help with replacing a YouTube string
I'm looking for some help with replacing YouTube embed codes with something that can be used with AMP pages https://www.ampproject.org/

Example, we would like replace this:

```
<iframe allowfullscreen="" frameborder="0" height="439" src="https://www.youtube.com/embed/xxxxxxxxxxx" width="780"></iframe>

```

with this:

```
<amp-youtube width="480" height="270" layout=responsive data-videoid="xxxxxxxxxxx"></amp-youtube>

```

Unfortunately, we can't simply replace the `iframe` tag with `amp-youtube` because we have other non-YouTube iframes floating around our site. To make things even more complicated, the YouTube embed codes live in our main content area as a WYGWAM field. Obviously, we'd like to also retain the video ID, illustrated above as 'xxxxxxxxxxx'

I've gotten pretty close with using Low Replace but my head can't wrap around regex. Here is the template code for our main content:

```
{exp:low_replace regex="yes" find='youtube_example' replace='amp_example' multiple="yes"}
    {exp:ce_img:bulk max_width="780" bucket="site" hide_relative_path="yes" attributes='layout="responsive"'}
        {content}
    {/exp:ce_img:bulk}
{/exp:low_replace}

```

Any help would be much appreciated!

# Answer
Easy peasy, chief. I can't deal with going through the Low Replace docs right now, so you'll have to apply the right parameters, but here you go:

Matching pattern:

```
<(iframe)(.*)(src=\"https:\/\/www\.youtube\.com\/embed)

```

Replace pattern:

```
<amp-iframe$2$3

```

This will match groups `iframe`, anything inbetween `iframe` and the beginning of the `src` tag, and the then the beginning of the `src` tag.

I give you a demo (when you click on the link, make sure to switch to `preg_replace`, not `preg_match`):

http://www.phpliveregex.com/p/hjP

That should do it, but test it as it might need tweaking.
> 1 votes

# Answer
Thank you jrothafer for the answer. For those curious, here is the fix. It probably needs some cleaning up, but it's working.

Matching pattern

```
<(iframe)(.*)(src=\"https:\/\/www\.youtube\.com\/embed)\/(.{11})" width="780"><\/iframe>

```

Replace pattern

```
<amp-youtube width="480" height="270" layout="responsive" data-videoid="$4"></amp-youtube>

```
> 1 votes

---
Tags: wygwam, low, low-replace
---


title: Diversity within Blog Entries

text:
# Question
Title: Diversity within Blog Entries
I was looking at this website: https://mobirise.com/bootstrap-template/blog.html

It's a blog page that has interesting diversity on each blog entry. I'm wondering how I can build something similar in EE. Is it possible to create a field where the user can pick from posting a video, a gallery or slider on every blog entry? If so, how?

# Answer
At the most basic, you could just create a different field for each one of those items and let the user pick 1 or more to add files or data to. Then on the template, lay out your page conditionally depending on what fields have data.

You can also spice up the fields by using some 3rd party options like Channel Videos and Ansel (for image edit/management). Another add-on that would give the user the ability to choose what fields to add per/entry is Bloqs.
> 0 votes

---
Tags: ee3, entry
---


title: curly braces in exp:channel-call?

text:
# Question
Title: curly braces in exp:channel-call?
I try to use this exp:channel:entries code to call a list of news for a year (YYYY), that is the third segment in the url … but it doesn’t work: the page is empty.

```
{exp:channel:entries
    channel="news"
    limit="5"
    year="{segment_3}"
    orderby="date"
    sort="desc"
    paginate="bottom"
}

```

if I write "2016" or "2015" as a replacement for the {segment\_3}, the code works without an error.

any ideas? thank you very much.

# Answer
Could be a parse order issue. Try adding `parse=inward` parameter to your channel call.
> 1 votes

---
Tags: channel-entries
---


# Question
Title: Parse error: syntax error, unexpected T_STRING
suddenly an error shows up on my site. It's happening only one user's profile page. All other profiles seem to work fine. It's EE 2.5.2 I have no clue where to start looking for the error.

"Parse error: syntax error, unexpected T\_STRING in expressionengine/libraries/Functions.php(680) : eval()'d code on line 245"

# Answer
> 0 votes
Did you check the data in the user´s profile? It might be a strange character. Maybe copy all the data to a text editor like sublimetext or notepad and copy -paste it back

---
Tags: error, syntax, profile
---


title: Free member is not working

text:
# Question
Title: Free member is not working
```
    `enter preformatted text here`    {exp:freemember:login return="shop/checkout" error_handling="inline" error_delimiters='<span class="error">|</span>'}

          <p>
              <label for="email">Email</label><br />
              {field:email}<br />
              {error:email}
          </p>

          <p>
              <label for="password">Password</label><br />
              {field:password}<br />
              {error:password}
          </p>

          <p>
              {field:auto_login} <label for="auto_login">Remember Me</label>
          </p>

          <p>
              <input type="submit" value="Log in" />
              <a href="{path='shop/checkout'}">Create Account</a>
          </p>

        {/exp:freemember:login}

    Trying with standared example code also not working for me.
    i have assign order field to member field in store configuration and other settings were right.
    But still not logging in.
   Updated : 02092015
    Here is the custom code that also always giving email error
    {exp:freemember:register return='shop/checkout' error_handling="inline" error_delimiters='<div class="error">|</div>'}
                <div class="mini_registration">
                    <div class="sus-username">
                      <input class="welurfield regsolofield"  type="text" name="username" value="{username}" placeholder="User Name" maxlength="32" size="25">
                            {error:username}
                    </div>
                    <div class="sus-customername">
                      <div class="sus-name"><input class="firstname" type="text" name="first_name" value="{first_name}" placeholder="First Name" maxlength="32" size="25"></div>
                      <div class="sus-name"><input class="lastname"  type="text" name="last_name" value="{last_name}" placeholder="Last Name" maxlength="32" size="25"></div>
                    </div>
                    <div>
                      <input type="text" name="username" value="{email}" placeholder="User Email" maxlength="50" size="25">
                        {error:email}
                    </div>
                    <div class="sus-password">
                      <input class="password_input"  type="text" name="password" value="{password}" placeholder="Your Password" maxlength="50" size="25">
                      {error:password}
                    </div>
                    <div class="sus-passconfirm">
                      <input class="passconfirm_input"  type="text" name="password_confirm" value="{password_confirm}" placeholder="Password Again" maxlength="32" size="25">
                      {error:password_confirm}
                    </div>
                    <div class="sus-regcaptcha">
                      {if captcha}
                        <div class="welcome_captcha"><span class="captchaline">Please enter the following characters into the box below:</span><br />
                          <div class="captchaline">{captcha}</div>
                          <div class="captchaline">{field:captcha}</div>
                          <div class="captchaline">{error:captcha}</div>
                        </div>
                      {/if}
                    </div>
                    <div class="sus-terms">
                      <div class="sus-termswrap">
                        <div class="sus-termstext"><input class="us-btn-orange" type="checkbox" name="accept_terms" value="1" {accept_terms} /><div class="termstext">Accept applicable www.susdus.com- T&C's</div></div>
                        {error:accept_terms}
                        <div class="sus-submit ">
                          <div class="submit_value"><input class="submit_input us-btn us-btn-smallbuy us-btn-orange" type="submit" name="submit" value="Sign Up"></div>
                        </div>
                      </div>
                    </div>
                  </div>
                 {/exp:freemember:register} This is the code i am using and always giving me email field required error

```

# Answer
> 0 votes
Do you have an htaccess that adds a trailing slash at the end? That prevents freeform from working. You can disable it for POST requests with the line `RewriteCond %{REQUEST_METHOD} !=POST` above the rule in .htaccess

More info https://github.com/devdemon/freemember/issues/81

---
Tags: freemember
---


title: Save Revisions for Template Manager

text:
# Question
Title: Save Revisions for Template Manager
I can't remember how to enable revisions for templates in Expression Engine 2.11.3. Does anyone have any idea? Anyone?

# Answer
> 3 votes
it's in the template general preferences admin.php?cp/design/global\_template\_preferences

---
Tags: revisions
---


title: Send HTML Email for Notifications

text:
# Question
Title: Send HTML Email for Notifications
I have set the Default Mail Format in Email Configuration to HTML but email notifications are still being sent as plain text.

I have looked at the other posts regarding this issue but I could not find a definitive answer on how to get this to work.

Any help is appreciated.

# Answer
You need to go into the notification templates and add what ever markup you want to include. By default, they are text only. Design-\>Message Pages-\>Email Notifications
> 1 votes

# Answer
I have created an add-on to ensure that system emails obey that HTML setting:

https://github.com/cld-agency/ee-html-email

Please note that if you are using any Freeform notifications, they will also need to be formatted with HTML.
> 0 votes

---
Tags: html-email
---


# Question
Title: Auto-Generated Emails Not Being Sent as HTML
In Admin \> Email Configuration, I set “Default Mail Format” to “HTML”. Then I went to Design \> Message Pages \> Email Notifications and entered the following code into the “Member Account Activation Instructions” template:

```
<html>
 <head>
  <title>{site_name} Member Account Activation</title>

  <meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type" />

  <style type="text/css">
   .list a {
    color: #cc0000;
    text-transform: uppercase;
    font-family: Verdana;
    font-size: 11px;
    text-decoration: none;
   }
   p {
    color: #3e3f3a;
    font-family: Verdana;
    font-size: 13px;
    line-height: 20px;
   }
   h1 {
       color: #850d6f;
       font-family: Verdana;
       font-size: 16px;
       font-weight:normal;
   }
   a:link, a:visited {
    color: #4a94ad;
   }
  </style>
 </head>

 <body marginheight="0" topmargin="0" marginwidth="0" bgcolor="#fff" leftmargin="0">
  <table border="0" cellspacing="0" cellpadding="0" width="600">
   <tr>
    <td bgcolor="#850d6f" height="72">
     <img src="{site_url}/images/email/logo_03.png" width="121" height="40" alt="Logo 03">
    </td>
   </tr>
   <tr>
    <td>
     <h1>Thank you for your new member registration.</h1>

     <p>To activate your new account, please visit the following URL:</p>

     <p>{unwrap}{activation_url}{/unwrap}</p>

     </p>Thank You!</p>

     <p>--<a href="{site_url}">{site_name}</a></p>
    </td>
   </tr>
  </table>

  <!-- footer -->
  <table cellspacing="0" border="0" height="202" cellpadding="0" width="600">
   <tr>
    <td class="copyright" height="100" align="center" valign="top" width="600" colspan="2">
     <br>
    © <a href="{site_url}">{site_url}</a><br>
     <a href="{site_url}contact-us">Contact Us</a> | <a href="{site_url}privacy-policy-and-terms-of-use">Privacy Policy and Terms of Use</a>
    </td>
   </tr>
  </table>
 </body>
</html>

```

But when I do a test member registration, the email received is in plain text (the HTML code is visible as text). The content-type of the email is “text/plain”.

HTML email sent via the Communication panel is sent correctly with a content-type of “multipart/alternative”.

HTML email sent with MX Notify Control is also sent with the correct content-type.

# Answer
I've just had a quick look at the source code and my impression is that EE doesn't currently support HTML-formatted activation emails. Here's the relevant bit of the EE source:

```
$this->email->EE_initialize();
$this->email->wordwrap = TRUE;
$this->email->from($this->config->item('webmaster_email'), $this->config->item('webmaster_name'));
$this->email->to($row['email']);
$this->email->subject($this->functions->var_swap($template['title'], $swap));
$this->email->message(entities_to_ascii($this->functions->var_swap($template['data'], $swap)));
$this->email->send();

```

In order to send out HTML-formatted messages the `mailtype` property has to be set. In this instance it isn't even referenced, so the default behaviour (plain text) is used.

Changing this should just be a matter of inserting the line below, however I wouldn't recommend doing so as you'd inevitably forget about it in an update and users would start to wonder why they're being sent raw HTML when they register.

```
$this->email->mailtype($this->config->item('mail_format'));

```

Since this would be a single-line code change you could always submit a feature request. That said, if this is something you need in a reasonable timescale an add-on is probably the way to go.
> 8 votes

# Answer
As far as i know, specialty templates are not sent as html. maybe use something like http://madebyhippo.com/addons/view/libraree?
> 2 votes

# Answer
Based on @Dom Stubbs' answer I created this extension to workaround this.

https://github.com/cld-agency/ee-html-email

Please note that if you are using any Freeform notifications, they will also need to be formatted with HTML, since this is a system-wide change.
> 1 votes

---
Tags: html-email
---


title: Cartthrob Order Manager Settings

text:
# Question
Title: Cartthrob Order Manager Settings
Under the database table `exp_cartthrob_order_manager_settings` I have updated the 'cp\_menu' to 'no' but the eCommerce tab is still showing in the control panel. I would like to remove the tab but does not work in the settings or by updating the database. Any ideas?

# Answer
> 0 votes
Do you have `cp_menu` set in your EE or CT config file somewhere? That would override what the DB and CP are set to.

---
Tags: cartthrob, mysql
---


# Question
Title: exp:assets:files fixed_order parameter not working
Assets 2.6 EE 2.9.3

I have the following test code in an otherwise empty template

```
{exp:assets:files fixed_order="3922|834|3991" }
<p>{file_id}</p>
{/exp:assets:files}

```

I would expect it to output in the order of the fixed\_order parameter but it does not instead I see this:

834

3922

3991

Any idea why this is not working as expected?

# Answer
> 0 votes
According to the docs you need to supply a folder\_id

```
Note: Either the folder or folder_id param must be present for {exp:assets:files} to output anything.

```

---
Tags: assets, parameters
---


title: SEO Lite Parse Error

text:
# Question
Title: SEO Lite Parse Error
I'm getting the following parse error when I click to view the SEO Lite settings in the control panel:

Parse error: syntax error, unexpected '\[' in /nfs/c11/h01/mnt/196778/domains/hallettperrin.thedesigncore.com/html/engine/user/addons/seo\_lite/views/index.php on line 19

EE v3.4.2 Seo Lite v1.5.3

Thanks for any help.

# Answer
this was a compatibility issue with PHP 5.3 and has been fixed in SEO Lite 1.5.4 - please download it here: https://github.com/bjornbjorn/SEO-Lite
> 0 votes

---
Tags: seo-lite
---


# Question
Title: Using FocusLab MasterConfig Upload Preferences
I'm using FocusLab MasterConfig to set my upload preferences but strangely only the **name** of the Upload preference gets set by my code. Here is the code in config.master.php

```
$resources_folder = 'resources';
$resources_path = $base_path . DIRECTORY_SEPARATOR . $resources_folder;
$resources_url  = $base_url . '/' . $resources_folder;

$env_config['upload_preferences'] = array(
    7 => array(
        'name'        => 'Landing Page Banners',
        'server_path' => $resources_path . '/images/banners/landing/',
        'url'         => $images_url  . '/images/banners/landing/'
    ),
    8 => array(
        'name'        => 'Home Page Banners',
        'server_path' => $resources_path . '/images/banners/home/',
        'url'         => $images_url  . '/images/banners/home/'
    ));

```

Anyone know why the server\_path and url (which are the important values) have no effect on the values shown in the CP?

# Answer
Did you test out an upload to your directories? It looks like only the name is read from the config variable, while the path / url in the CP will show what's in the database. But in use, reading and uploads to the file directories should use what you have in the Master Config settings -- overriding what's in the database.
> 0 votes

---
Tags: file-uploads, focus-lab-master-config, config-overrides
---


title: Browser Caching

text:
# Question
Title: Browser Caching
I am trying to use the .htaccess file to "leverage browser caching" and get the users browser to cache the static assets.

Right now, I have my htaccess doing the index.php rewrite then this block of code.

```
<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType image/jpg "access 1 year"
    ExpiresByType image/jpeg "access 1 year"
    ExpiresByType image/gif "access 1 year"
    ExpiresByType image/png "access 1 year"
    ExpiresByType text/css "access 1 month"
    ExpiresByType text/html "access 1 month"
    ExpiresByType application/pdf "access 1 month"
    ExpiresByType text/x-javascript "access 1 month"
    ExpiresByType application/x-shockwave-flash "access 1 month"
    ExpiresByType image/x-icon "access 1 year"
    ExpiresDefault "access 1 month"
</IfModule>

```

According to tools.pingdom my site still doesn't have any browser caching. Any ideas on this and how to get it to work?

I have tested this code on a static HTML site and it works for static asset caching.

# Answer
> 2 votes
Since my guess in the comments was correct I am adding it as an answer:

Check that mod\_expires is installed in Apache (one way to quickly check in EE is to look at the phpinfo page in the control panel).

---
Tags: caching
---


# Question
Title: Low Search ignore field when distance:radius is present
I have a form where a user can select a city from a dropdown list. I've set this up as a custom field filter. When a city is selected there is some JavaScript populating a hidden distance:from field behind the scenes. At the foot of the form is a distance:radius field.

Is there a way to ignore the city field if distance:radius exists? The idea being that the user wants to see the results within the radius, regardless of whether the result is in the city. If no radius is selected the results should be based on the city field.

```
// Search form
{exp:low_search:form query='{segment_3}'}

    <select name="search:city">
        <option value=""{if low_search_search:city == ''} disabled selected{/if}>
            Select a city
        </option>
        <option value="City 1"{if low_search_search:city == 'City 1'} selected{/if}>
            City 1
        </option>
        <option value="City 2"{if low_search_search:city == 'City 2'} selected{/if}>
            City 2
        </option>
        <option value="City 3"{if low_search_search:city == 'City 3'} selected{/if}>
            City 3
        </option>
    </select>

    <select name="distance:radius">
        <option value=""{if low_search_distance:radius == ''} disabled selected{/if}>Select distance</option>

        {exp:low_list:each items="5|10|20|30|50" as="distance"}
        <option value="{distance}"{if distance == low_search_distance:radius} selected{/if}>
            {distance} miles
        </option>
        {/exp:low_list:each}

    </select>

    <input type="hidden" name="distance:from" {if low_search_distance:from}value="{low_search_distance:from}"{/if} id="coord-field">

{/exp:low_search}

// Results
{exp:low_search:results query='{segment_3}' limit='12' distance:to='cf_lat|cf_lng' distance:unit='mi'}

    ... Results

{/exp:low_search:results}

```

Is this at all possible? Thanks in advance.

# Answer
Not natively with Low Search itself, but since you're already using JavaScript, you could create a function that would disable or clear the City select element when a radius is selected. Adding a `disabled` property to a form input/select element will not send that field when the form is submitted.
> 1 votes

---
Tags: low-search
---


title: Order feed in CSV format

text:
# Question
Title: Order feed in CSV format
I need to set up an order feed to supply order details to a reviews website, it has to have specific field names and be in CSV format.

Is there an option to do this in cartthrob? Or will I need to create a template, if so are there tags available for orders?

# Answer
> 1 votes
The best way to do this is to make a template and use tags, or use something like this: https://devot-ee.com/add-ons/ajw-export

Orders are just channel entries, so you can do a standard `exp:channel:entries` loop with the `channel=` parameter filled in to output them.

# Answer
> 0 votes
https://devot-ee.com/add-ons/zeal-smart-export can be a good option to export the data. The best part is, You don't need to create a templates or write any query here. It is simply select and download.

---
Tags: cartthrob
---


title: How to reduce CE Cache Size?

text:
# Question
Title: How to reduce CE Cache Size?
I installed the CE Cache plugin on my ExpressionEngine v. 2.11.1. Everything started working well the first two weeks but now it is taking too long to load a page from the site, and sometimes I got disconnected.

Here is my current configuration:

```
//// CE cache settings
$config['ce_cache_drivers'] = 'file|db';
$config['ce_cache_file_permissions'] = 0644;
$config['ce_cache_dir_permissions'] = 0775;
$config['ce_cache_seconds'] = 300;

```

Next, doing a research on my server I found that the ce\_cache\_db\_driver table is around 10 GB size and the file cache directory is some GBs on size... This is going to consume all my hard drive and my DB.. Also, since it is a really big cache, I am not able to view the files on the EE Control Panel.

Any ideas about how to purge both, DB and File Cache?

# Answer
To remove the rows in the database you could do this:

```
TRUNCATE `exp_ce_cache_tagged_items`;

```

And

```
TRUNCATE `exp_ce_cache_db_driver`;

```

To remove them in the file system you could:

```
rm -rf /path/to/your/cache/directory/

```

I'd guess that if your cache is that large that perhaps you have not set up CE Cache correctly or your site is not strict about using canonical urls...

Am also curious why you would have such a short duration on the cache.
> 1 votes

---
Tags: ee2, ee, ce-cache
---


title: Filtering output of entries tag?

text:
# Question
Title: Filtering output of entries tag?
Forms: 3.5.3

ExpressionEngine: 2.11.1

(This started as a question, but I figured out a solution - and since it doesn't seem to be documented, I decided to post anyway as a suggestion for inclusion in the documentation and/or for anyone else in the same boat\_

I'm using the Forms addon for a basic post-order customization setup, and I've used a bit of a kludge to dynamically pass an order ID number to a hidden field (basically just hardcoded the HTML for the field after the {forms:fields} & filled in its value with the {entry\_id} tag). Not terribly elegant, but it works.

The problem was that I unable to find a way to limit/filter by order (when displaying submissions using the {exp:forms:entries}), to display only the customization data for the current order - if any.

Turns out that the the {exp:forms:entries} tag apparently supports the same search:field\_name parameter as the {exp:channel:entries} tag:

https://docs.expressionengine.com/latest/channel/channel\_entries.html#search-field-name

So it worked when added **search:order\_id="{segment\_4}"** to the forms:entries tag:

{exp:forms:entries entry\_id="XX" member\_id="{author\_id}" search:order\_id="{segment\_4}"}

The order ID is in the 4th URL segment, could have also used entry\_id instead since that code is inside a channel:entries loop.

# Answer
Turns out that the the {exp:forms:entries} tag apparently supports the same search:field\_name parameter as the {exp:channel:entries} tag:

https://docs.expressionengine.com/latest/channel/channel\_entries.html#search-field-name

So it worked when I added **search:order\_id="{segment\_4}"** to the forms:entries tag:

```
{exp:forms:entries entry_id="XX" member_id="{author_id}" search:order_id="{segment_4}"}

```

The order ID is in the 4th URL segment, could have also used entry\_id instead since that code is inside a channel:entries loop.
> 0 votes

---
Tags: forms, devdemon
---


# Question
Title: Column layout used for form, but not for display of entries
Forms: 3.5.3

ExpressionEngine: 2.11.1

I have a fairly long form that has where a good portion of the fields are setup in 2 columns - that layout is used when viewing/entering data into the form itself. But when I output submissions to the form using the {exp:forms:entries} tag, the output is all in a single column (the fields are also not in the same order as they are when editing/viewing the form itself, but that's a separate issue).

Is there any way to make the output of the {exp:forms:entries} use the same layout as the {exp:forms:form} tag?

Edit: just occurred to me, is it possible that using columns is the cause of the entries tag not displaying fields in the correct order?

# Answer
Does DevDemon no longer support this software? This is the method the devdemon.com website recommends on their website for obtaining support, since their support forum is now read-only - but for more than a month, there's been no response to this & another Forms-related question I've posted.

Anyway, I ended up cobbling together a workaround, requiring a number of add-ons:

Stash - https://devot-ee.com/add-ons/stash String Explode Tag - https://devot-ee.com/add-ons/string-explode-tag Find and Replace Plus VMG Nested

StackExchange won't allow posting the last 2 links... but both should be easy enough to find through google/devot-ee. Here's the code:

```
{exp:query sql="select field_id, title as field_title, description, field_type, field_settings, field_order from exp_forms_fields WHERE (form_id = '9' AND parent_id = '' AND field_type != 'pagebreak' AND field_type != 'hidden_field' AND field_id != '350' ) ORDER BY field_order"}
    {if field_type == "html"}
        {exp:replace_plus find=";s|:QUOTE:" replace="" multiple="yes"}{exp:strexplode delimiter=":" string='{field_settings}' index="6"}{/exp:replace_plus}
    {if:elseif field_type == "columns_2"}
        <p>
            <!-- field_title: {field_title} -->
            {if "{field_title}" != "2 Columns"}<span class="column-title"><strong>{field_title}</strong></span><br />{/if}
            {!-- QUERY TO GET "CHILD" FIELDS --}
            {exp:vmg_nested:query prefix="column" sql="select field_id, title as field_title, field_type, field_settings from exp_forms_fields WHERE (form_id = '9' AND parent_id = '{field_id}') ORDER BY field_order" parse="inward"}
                <strong>{column:field_title}:</strong>

                {!-- QUERY TO GET CHILD FIELD DATA --}
                {embed="snippets/child-field-data" field_id="{column:field_id}" segment_4="{segment_4}" fentry_query="{exp:stash:get name='fentry_query'}"}
                {!-- /QUERY TO GET CHILD FIELD DATA --}

            {/exp:vmg_nested:query}
            {!-- /QUERY TO GET "CHILD" FIELDS --}
        </p>
        <p> </p>
    {if:elseif field_type == "file_upload"}
        <p><strong>{field_title}: </strong><br />
        {if "{description}" != ""}<br /><small><em>{description}</em></small><br />{/if}
        {!-- QUERY TO GET FIELD DATA --}
            {exp:vmg_nested:query prefix="data_reg" sql="select fid_{field_id} from exp_forms_entries WHERE (form_id = '9' AND fid_371 = '{segment_4}' AND fid_{field_id} !='') LIMIT 1"}
                {if "{data_reg:fid_{field_id}}" != ""}
                    <a href="/library/form-uploads/{data_reg:fid_{field_id}}"><img style="max-width: 70%; height: auto;" src="/scripts/thumbgen/thumbgen.php?src=/library/form-uploads/{data_reg:fid_{field_id}}&w=800" /></a>
                    <br />
                {/if}
                <em>{data_reg:fid_{field_id}}</em>
            {/exp:vmg_nested:query}
        {!-- /QUERY TO GET FIELD DATA --}
    {if:else}
        <p><strong>{field_title}: </strong>
        {if "{description}" != ""}<br /><small><em>{description}</em></small><br />{/if}
        {!-- QUERY TO GET FIELD DATA --}
            {exp:vmg_nested:query prefix="data_reg" sql="select fid_{field_id} from exp_forms_entries WHERE (form_id = '9' AND fid_371 = '{segment_4}' AND fentry_id = '{segment_5}') LIMIT 1"}
                {data_reg:fid_{field_id}}
            {/exp:vmg_nested:query}
        {!-- /QUERY TO GET FIELD DATA --}
        </p>
    {/if}
{/exp:query}

```

And the contents of the embedded "snippets/child-field-data" template are:

```
{!-- QUERY TO GET CHILD FIELD DATA --}
    {exp:query sql="select fid_{embed:field_id} from exp_forms_entries WHERE (form_id = '9' AND fid_371 = '{embed:segment_4}' {embed:fentry_query}) LIMIT 1"}

        <!-- query: select fid_{embed:field_id} from exp_forms_entries WHERE (form_id = '9' AND fid_371 = '{embed:segment_4}') LIMIT 1<br /> -->
        {!-- GET THE FIELD TYPE --}

        {exp:stash:set name="fielddatatype"}{exp:replace_plus find=":QUOTE:|;s" replace="" multiple="yes"}{exp:strexplode delimiter=":" string='{fid_{embed:field_id}}' index="4"}{/exp:replace_plus}{/exp:stash:set}
        {exp:stash:set name="nameorarea"}{exp:replace_plus find=":QUOTE:|;s" replace="" multiple="yes"}{exp:strexplode delimiter=":" string='{fid_{embed:field_id}}' index="6"}{/exp:replace_plus}{/exp:stash:set}
        {exp:stash:set name="lastnameorphone"}{exp:replace_plus find=":QUOTE:|;:RD:" replace="" multiple="yes"}{exp:strexplode delimiter=":" string='{fid_{embed:field_id}}' index="10"}{/exp:replace_plus}{/exp:stash:set}

        {if "{exp:stash:get name='fielddatatype'}" == "first_name"}
            {exp:stash:get name='nameorarea'} {exp:stash:get name='lastnameorphone'}
        {if:elseif "{exp:stash:get name='fielddatatype'}" == "area"}
            {if "{exp:stash:get name='nameorarea'}" !=""}({exp:stash:get name='nameorarea'}) {exp:stash:get name='lastnameorphone'}<br />{/if}
        {if:else}
            {fid_{embed:field_id}}
        {/if}

        <br />
    {/exp:query}
{!-- /QUERY TO GET CHILD FIELD DATA --}

```
> 1 votes

---
Tags: forms, devdemon
---


title: Top ten suggested add-ons?

text:
# Question
Title: Top ten suggested add-ons?
Hypothetically...What would be the top ten add-ons for site that is like this?

Lets say they want a blog, be able to change the header sliders on several pages and control the image galleries, suggestions?

More specifically, which ones would be best in regard to security,sustainability and reliability as the site ages?

# Answer
> 3 votes
It depends if you're giving it to a client and if there's going to be much in the way of CMS functionality.

Looking at that template, I really can't see any need for as many as 10 addons. The only addon I'd say was worthwhile is Freeform, which handles form submissions nicely.

If giving it to a client, the ones I use most often are:

* \[CE Image\] for image manipulation.
* \[SEO Lite\] which just adds a meta title/description/keywords field (though this is not necessary and could be done through regular fields and a little logic).
* \[Structure\] which gives a nice UI to your pages which makes it much easier for a client to use and also helps with generating menus, sitemaps etc. (although again, this could be achieved with the standard EE \[Pages\]\[5\] module but Structure is far easier for clients to understand in my opinion).
* \[WYGWAM\] which is just a rich text editor (again, not necessary as the standard EE one would be fine but WYGWAM is nicer to use).

These are mostly professionally maintained and updated regularly.

EE isn't really like something like Wordpress where you'd chuck in say, an image slider plugin. The best thing about EE is that it is so simple to pull data out of it that you'd just find a javascript slider and use EE to get the images out with something like:

```
<section class="header-gallery">
    {header_images limit="4"}
        <img src="{header_images:image}">
    {/header_images}
</section>

```

# Answer
> 2 votes
For the sliders and galleries, i'd recommend \- grid/matrix with Ansel \- or Channel Images (combined with native resizing) \- and CE Image for better caching/compression control

Other top addons i'd use: \- Wygwam \- Structure \- Stash \- Low Variables \- Freeform Pro \- Minimee

# Answer
> 1 votes
It sounds like you're approaching EE from a WordPress background(?). You don't need *any* add-ons to build a site like that. The fewer add-ons you can use, the better, as they each introduce avoidable dependencies.

If you're concerned about "security, sustainability and reliability" then don't use any add-ons.

---
Tags: add-on, ee3
---


# Question
Title: Disallowed Key Characters - MX Google Maps extension
Using EE 2.8.1 I get 'Disallowed Key Characters' after setting up the field type. I have downloaded the latest MX Google Maps extension.

Any thoughts?

# Answer
I had this error error few times but not with this field type (i'm not using it). The problem occurred when the mod\_security was ON on a shared hosting... Maybe you can check that!
> 0 votes

---
Tags: mx-google-map
---


# Question
Title: htaccess removing .php ext causes infinite loop on admin login EE 2.10.1
when I use this htaccess its normal working good but it doesnt redirect .php urls

```
# Removes index.php from ExpressionEngine URLs
# RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
# RewriteCond %{REQUEST_URI} !/system/.* [NC]
# RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,NE,L]

```

but when I change it to:

```
# Removes index.php from ExpressionEngine URLs
RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
RewriteCond %{REQUEST_URI} !/system/.* [NC]
RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,NE,L]

```

all .php extensions are redirects but admin login gets infinite loop redirect. it's a siteground hosting

any idea?

# Answer
> 0 votes
the first block wouldn't mess with anything since it's all commented out. try this:

```
<IfModule mod_rewrite.c>

# Enable Rewrite Engine
# ------------------------------
RewriteEngine On
RewriteBase /

# Redirect index.php Requests
# ------------------------------
RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
RewriteCond %{THE_REQUEST} !/system/.*
RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*[^/])$ http://%{HTTP_HOST}/$1/ [L,R=301]

# Standard ExpressionEngine Rewrite
# ------------------------------
RewriteCond $1 !\.(css|js|gif|jpe?g|png) [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]

</IfModule>

```

---
Tags: ee2, htaccess, admin
---


title: Embed parameter value as stash value

text:
# Question
Title: Embed parameter value as stash value
How can I use a stash variable that has been stored up in the template as a value for an embed parameter further down?

```
{embed="template/_include" email="{exp:stash:get name="email"}"}

```

Obviously at the moment I am hitting some parse issues but I don't know how to rectify.

# Answer
> 1 votes
If you must use an EE embed rather than a Stash embed, then the easiest approach would be to set a global ("snippet") variable rather than a Stash variable:

```
{exp:stash:set name="email" type="global"}My email address{/exp:stash:set}

```

Than reference it in your embed template like so

```
{email}

```

Alternatively, use a Stash embed:

```
{exp:stash:set name="email"}My email address{/exp:stash:set}

{stash:embed:my_include}

```

Then reference the variable in the Stash embed like so:

```
{stash:email}

```

---
Tags: stash
---


title: Dynamic Template Name in URL

text:
# Question
Title: Dynamic Template Name in URL
On a single entry page, I want to display a list of categories an entry is assigned to, and these categories should link back to their respective pages. Now those categories are attached to different templates so I need to display the template name dynamically for each category (finance, corporate, real-estate, etc.)

I created this query:

```
{exp:query sql="SELECT template_name FROM exp_templates WHERE template_id = ‘{template_group}’”}{template_name}{/exp:query}

```

but unfortunately it still doesn’t display my template name.

To give you an idea, if I use this query:

```
{exp:query sql="SELECT group_name FROM exp_category_groups WHERE group_id = '{category_group}’”}{group_name}{/exp:query}

```

Then the group name shows correctly (Finance, Corporate, Real Estate, etc.), but I don’t need the group name, I need the template name!

Any suggestions to point to the right direction?

Thanks in advance!

# Answer
Are the separate templates really different enough to warrant being separate? Usually you could code in the logic for slightly different views within a single template - much simpler and more maintainable than duplicating lots of code.

Anyway, assuming you want to keep them as separate templates, I can think of 3 options:

1. As suggested by @AllInOne, specify which template should be used via a custom category field
2. Use a naming convention ensuring that your `category_url_title`s match your template group names
3. Use something like Template Routes (or third party Resource Router is even better!) to route certain URI requests to the right template.

Like I said, my personal preference would be to re-arrange things so that just a single dynamic template is used instead of lots of different ones, but it really depends how different they are from each other. (You would then feed that single template with a category name and take different actions depending on that).
> 1 votes

---
Tags: categories, url, query
---


title: Deployment server feautures

text:
# Question
Title: Deployment server feautures
Help me to deploy expressionengine in Linux CentOS Server… Medium traffic website, we have 255 MB of database, 55 GB of static file. Provide me with proper webserver, database server, hardware configuration. Site is required to load very quickly…

# Answer
Suggest you contact the hosting provider recommended by EllisLab: https://ellislab.com/community/hosting

Also read this whitepaper supplied by them: https://www.nexcess.net/expressionengine/hosting-optimization

You could Google "expressionengine hosting" and contact numerous of the hosting providers to see what they would recommend and supply, then either choose the best/cheapest or create your own based on their recommended specs, but bear in mind, it's more than just hardware!

If you're looking for someone to do this for you, I'd suggest you create a project on the EE Job board: http://director-ee.com
> 3 votes

---
Tags: assets, php
---


# Question
Title: Cartthrob 3 : how to make a custom_data field required in checkout form?
I created a custom field in Order channel and created an imput named custom\_data\[nameofmycustomfield\] in my checkout form as explained in the docs here.

But I can't make it required (validation sensitive). When I put his name as parameter 'required' 's value it doesn't work.

How can I do?

Thanks in advance.

# Answer
(I'm with Vector, the people behind CartThrob)

The fix for this is to set

`custom_data[nameofmycustomfield]`

as the field name in the `required` parameter, not just `nameofmycustomfield`.
> 2 votes

---
Tags: cartthrob, custom-data
---


title: Put add-ons to new EE site

text:
# Question
Title: Put add-ons to new EE site
EE novice here, if I download the free version of an EE site, can I still download paid add-ons to the free version and have them function without problems?

# Answer
> 0 votes
Yes, you won't have any issues. Having a free version of EE won't affect paid plugins working. Free EE just limits what you can do inside it's core features I believe

# Answer
> 0 votes
Using paid add-ons with EE Core poses no technical problems. The technically imposed limitations are noted here: https://store.ellislab.com/#ee-core

Also note that the major limitation of EE Core is what the license agreement allows you to do with it.

---
Tags: add-on, ee3
---


# Question
Title: Moved site on same server and lost all files in file manager and file upload prefs
I have a subdomain “dev.” where the site was working fine. I then created a new subdomain on the same server called “staging” and copied all my site files from dev into that. I also created a new database for staging and imported everything from dev into that.

I followed the migration instructions as I always do, exactly. https://docs.expressionengine.com/v2/operations/moving.html

Updated all paths, etc. But for some reason, none of the images show on the site that were uploaded to directories. All of the images exist in their appropriate folders on “staging.”

However, there is nothing in my file upload preferences and nothing in my file manager. It’s as if everything disappeared.

If I try to recreate an upload directory in file upload prefs, i get this error “An Error Was Encountered The name of your directory is already taken.”

Also, when I looked in the exp\_files table in the db, all the rel\_paths still have the “dev” name associated with it.

I checked and re-checked everything, all my paths are correct in config, all of my directories have the correct permissions. I’m at a loss at this point.

EE 2.11.2 on a Windows Server.

I never work on a windows server with EE, but in this instance I had to. It has been nothing but a pain. Any help in the right direction is much appreciated at this point.

# Answer
I did, and after further diving I found that my exp\_upload\_prefs table was empty. That was the last table in my “staging” db. I checked my “dev” db and there was one more table after that “exp\_wygwam\_configs.”

So the db import wasn’t 100% successful. I went through and checked each table to see what else was missing, looks like that was the only table issue. Not sure what caused the bad import. Not a huge fan of this windows hosting on hostgator.
> 0 votes

---
Tags: file-uploads, file-manager
---


title: How to check if visitor is a bot?

text:
# Question
Title: How to check if visitor is a bot?
On our site we use a plugin that uses the IP2Nation module to detect the country of the visitor.

We then output amended content if the site is viewed from abroad - so instead of encouraging visitors to view the showroom, we tell them that we export worldwide.

The thing is, I've just discovered that Google's cached versions of pages are the Export version.

So my question is... Is it possible to detect if a 'visitor' is a bot - preferably as an if statement. We could then surround the export checking if statements with a bot checker first, so that bots don't trigger the export version, but real people do.

# Answer
> 1 votes
You can use php to attempt to detect a bot, and dynamically show the desired content based on the results. Not perfect, but may help with your case. Check out this add-on https://devot-ee.com/add-ons/detect-spider for ee2 and maybe you could modify for ee3 if needed.

# Answer
> 0 votes
This is a different approach then what you are asking for, but consider adding the noindex meta tag to the version you do not want indexed.

```
<meta name="robots" content="noindex">

```

OR

```
<meta name="googlebot" content="noindex">

```

---
Tags: plugin, google
---