# Question
Title: Using conditionals to set tag parameters
I have this opening low search result tag

```
{exp:low_search:results
  {if segment_2}query="{segment_2}"{/if}
  group_id="7"
  limit="4"
  paginate="bottom"
}

```

I wanted to do more checks on segment\_2 before deciding if I should set query param(checking if the segment is for pagination such as P1 or P4).

```
{exp:low_search:results
    {if segment_2 == '' OR {exp:segment_search keyword="/^P\d+$/" segments="2" regex="yes"}}{if:else}query="{segment_2}"{/if}
     group_id="7"
     limit="4"
     paginate="bottom"
}

```

However, I don't think this will work. I think it has something to do with the parse order where you can't set complex conditionals inside a tag.

If so, is there an alternative way to set the query param?

UPDATE: The reason I am asking is because the code below does not work

```
{if {segment_2} == '' OR {exp:segment_search keyword="/^P\d+$/" segments="2" regex="yes"}}
    {exp:low_search:results
        {if segment_1 == "foo"}group_id="6"{/if}
        {if segment_1 == "bar"}group_id="7"{/if}
        limit="4"
        paginate="bottom"}
{if:else}
    {exp:low_search:results
        query="{segment_2}"
        {if segment_1 == "foo"}group_id="6"{/if}
        {if segment_1 == "bar"}group_id="7"{/if}
        limit="4"
        paginate="bottom"}
{/if}

```

I always get a `Parse error: syntax error, unexpected T_ELSE` in the code where I don't set the `query` param.

# Answer
> 6 votes
So yeah. Parse order. I take it you've seen this pdf. If not, take a look, study it well.

What you need is for the opening tag to be in order **before you hit stage 5**: the parsing of module/plugin tags. In order to do that, you can only use **simple conditionals** in combination with early parsed global variables and preload replace variables. Native early parsed vars are limited, so go and get the super useful (and free) Mo' Variables to get more useful early parsed stuff.

Once installed, you can use `{if paginated}{/if}` as a simple conditional. Just beware you don't use any `AND` or `OR` operators, nor use `{if:else}` in your conditionals, because that will turn it into an advanced one, and will be parsed too late for your use.

First of all, this: `{if {segment_2} == ''}` is an advanced conditional. The simple syntax is `{if segment_2 == ''}`. Using tags in conditionals, like you do with the `{exp:segment_search}` tag, means the conditional is advanced, too. So, avoid.

Here's my take, using preload replace vars and **simple conditionals only**.

```
{!-- Don't set the query param if there is no query --}
{if segment_2 == ''}
    {preload_replace:pre_query=''}
{/if}

{!-- Don't set the query param for non-query paginated pages --}
{if segment_3 == ''}
    {if paginated}
        {preload_replace:pre_query=''}
    {/if}
{/if}

{!-- Determine group ID based on segment 1 --}
{if segment_1 == 'foo'}
    {preload_replace:pre_group_id="6"}
{/if}

{if segment_1 == 'bar'}
    {preload_replace:pre_group_id="7"}
{/if}

{!-- Default Preload Replace vars --}
{preload_replace:pre_query='query="{segment_2}"'}
{preload_replace:pre_group_id="6|7"}

{!-- Here comes the Results tag --}
{exp:low_search:results {pre_query} group_id="{pre_group_id}" limit="4"}
  ...
{/exp:low_search:results}

```

So, note that I don't use any conditionals in the tag itself. Everything is done using simple conditionals and preload replace vars. Keeps things nice and clean. And I haven't even mentioned Switchee yet...

# Answer
> 2 votes
You problem is you're trying to do a complex conditional within the tag parameters, that's not possible.

Here's a good article regarding parsing conditionals within tags: http://johndwells.com/blog/expressionengine-parse-order-advanced-conditionals-as-tag-parameters

As you state, the problem is simple conditionals versus complex conditionals.

The problem with your second code:

```
{if {segment_2} == '' OR {exp:segment_search keyword="/^P\d+$/" segments="2" regex="yes"}}
    {exp:low_search:results
        {if segment_1 == "foo"}group_id="6"{/if}
        {if segment_1 == "bar"}group_id="7"{/if}
        limit="4"
        paginate="bottom"}
{if:else}
    {exp:low_search:results
        query="{segment_2}"
        {if segment_1 == "foo"}group_id="6"{/if}
        {if segment_1 == "bar"}group_id="7"{/if}
        limit="4"
        paginate="bottom"}
{/if}

```

...Is that you won't be able to have the opening tag in a separate conditional to the closing tag - EE parses conditionals at a separate stage to tags. It's not linear (working from top to bottom).

This *may* work:

```
{if {segment_2} == '' OR {exp:segment_search keyword="/^P\d+$/" segments="2" regex="yes"}}
    {exp:low_search:results
        {if segment_1 == "foo"}group_id="6"{/if}
        {if segment_1 == "bar"}group_id="7"{/if}
        limit="4"
        paginate="bottom"}

        {title}

    {/exp:low_search:results}
{if:else}
    {exp:low_search:results
        query="{segment_2}"
        {if segment_1 == "foo"}group_id="6"{/if}
        {if segment_1 == "bar"}group_id="7"{/if}
        limit="4"
        paginate="bottom"}

        {title}

    {/exp:low_search:results}
{/if}

```

...Where each tag pair is contained within the same conditional.

There's an additional problem in your revised conditional that is showing a parse error:

```
{if {segment_2} == '' OR {exp:segment_search keyword="/^P\d+$/" segments="2" regex="yes"}}

```

If there is no keyword, that tag will return an empty string, resulting in your conditional looking like this prior to EE parsing it: `{if {segment_2} == '' OR }`

...Which will result in the parse error. This is safer:

```
{if {segment_2} == '' OR '{exp:segment_search keyword="/^P\d+$/" segments="2" regex="yes"}'}

```

With the quotes, it can be parsed correctly as `{if {segment_2} == '' OR ''}`

Or how I'd approach it, by including in an embed and doing all the conditionals in the parent:

```
{if {segment_2} == '' OR {exp:segment_search keyword="/^P\d+$/" segments="2" regex="yes"}}
    {embed=template-group/search-results group_id="{if segment_1 == "foo"}6{/if}{if segment_1 == "bar"}7{/if}" query=""}
{if:else}
    {embed=template-group/search-results group_id="{if segment_1 == "foo"}6{/if}{if segment_1 == "bar"}7{/if}" query='query="{segment_2}"'}
{/if}

```

And in the embed template:

```
    {exp:low_search:results
        group_id="{embed:group_id}"
        {embed:query}
        limit="4"
        paginate="bottom"}

        {title}

    {/exp:low_search:results}

```

Note: for the first embed, query will be an empty string which is fine to pass as a parameter.

---
Tags: conditionals, parse-order, advanced-conditionals
---


title: Showing a member channel entries

text:
# Question
Title: Showing a member channel entries
I am trying to display a member channel entries using the tag {member\_id} in the author\_id parameter. Unfortunately the parse order is messing it up, I have tried using the parse="inward" parameter, it made no difference, i have also tried using Stash.

It works fine if i use a {segment} in the URL, but i don't want to do this. I am using an embed and placing the {member\_id} as an embed variable to pass to the channel call.

Is there a way to show an users entries without having their member ID in the URL?

Thanks

# Answer
Did you try by passing the parameter `author_id="CURRENT_USER"`
> 2 votes

---
Tags: channel-entries, entries, solspace-user, users
---


# Question
Title: Is there a way to specify where store.js is added to the page?
Working on a product page using Expresso Store and I'm encountering an intermittent javascript error:

```
Uncaught TypeError: undefined is not a function - store.js:142

```

It looks like a dependency problem (store.js depends on jQuery). The store.js is being added to the page asynchronously in the footer of the `{exp:store:product}` tag whereas jQuery is added to the page at the bottom of the page, just before the `</body>`. Depending on network performance and what is cached in the browser, occasionally the store.js loads before jQuery has loaded.

I dont want to move jQuery to the page header, so is there a way to specify where Expresso injects its JS (eg: a special JS template tag) or is there a way to force the store.js script tag to be synchronous and hence enforce the script loading order?

# Answer
UPDATE: Store 2 includes the fix mentioned below.

---

It will be an option in the next version. In the meantime, you can fix it by opening `mod.store.php`, going down to about line 235, and changing this:

```
(document.getElementsByTagName("head")[0] || document.getElementsByTagName("body")[0]).appendChild(script);

```

to this:

```
document.getElementsByTagName("body")[0].appendChild(script);

```

That should make sure the `store.js` script is added to the bottom of the page, after jQuery and other scripts.
> 5 votes

---
Tags: expresso-store, javascript, jquery
---


# Question
Title: Installing Forum 3.1.12 on EE 2.5.5 - ERROR
Trying to do an install of the Discussion Forum on EE 2.5.5 and got this error

Fatal error: Call to undefined function ee() in /(Path Here)/expressionengine/modules/forum/upd.forum.php on line 151

Any ideas? - Forum will not install.

# Answer
> 1 votes
You need to upgrade to EE 2.6+ first. The `ee()` function was added in 2.6 so that version of the forum must not be compatible with EE 2.5.5.

---
Tags: forum
---


# Question
Title: Low Variables: must new variable be entered in CP?
I just started using Low-Variables as a Snippet replacement (among other uses of course) because I need Snippets to be saved as files.

Now I am wondering if a new Low-Variable always has to be entered through the CP or not. It looks like it to me but I was hoping to have some standard variables for different projects that I could just throw in and be ready to go.

Thanks and Cheers,

Marc

# Answer
Yes, a new LV must be created through the CP. A new file will not create a new variable. Why? Check out these replies:
> 1 votes

---
Tags: low-variables
---


# Question
Title: Assets in Wygwam only inserting {assets_X} on first save
So, similar to this question when using Assets in a Wygwam field I am having to re-save an entry to get the image to output on the frontend. When I check what is getting saved to the db I get `{assets_132:{filedir_5}image.jpg}` the first time, and `{filedir_5}image.jpg` the second time.

It doesn't matter if I make the changes described in the comments of 9631, the problem is exactly the same.

Also, if I save an entry that already has an image in it that uses a `{filedir_X}image.jpg` type url, it doesn't get converted to the `{assets_X)` method. So for example if I upgrade Wygwam and Assets from an older version and then go and save the entry to get the image urls to update, they stay in their original states. To get them to change I have to delete the image and re-add it from the file browser, then they will break for the first save as described above.

I am using EE 2.6.1, Assets 2.1.3 and Wygwam 2.7.1 and running this locally with php v 5.4.13.

This is all happened after an upgrade from EE 2.4.0, Assets 1.1.5 and Wygwam 2.5.

---

EDIT: I am also unable to move any files around in Assets once they have been added to a Wygwam field in this manner. The Wygwam references don't get updated once the file has been moved.

# Answer
> 0 votes
This is a known bug in the latest version of Wygwam that will be fixed in the next release. Sending you the patched files in the support ticket in the meantime.

---
Tags: assets, wygwam
---


title: Expanding sites with MSM

text:
# Question
Title: Expanding sites with MSM
I'm doing a large redesign on an OLD EE1 site. It was built in a way that doesn't make sense to try converting. It is also going to a subdomain flow. Originally I was going to just keep all of the subdomain segments as separate sites since it is operating under the DEV -\> QA -\> PROD server flow and will be released live in waves. However, I don't want to rely on a third party search engine to crawl the site and return data. I also have needs for the native search in EE.

What is the best way of expanding a site to include new subdomains as they are developed while keeping them from being visible during development? I know I could keep the subdomain/msm site turned off while everything is being worked on and then turn it on when it is ready to go live, but this doesn't allow for the requested flow mentioned above with DEV -\> QA -\> PROD. To my knowledge there isn't any way to properly import a new site into an msm build. (Anyone?) If so, I could keep them separate and then import it when ready. This would at least allow me to fulfill the flow request.

Does anyone else have any nuggets of hope they could provide from doing anything similar?

# Answer
You could use template permissions to redirect users to where they can't see the page if they do not belong to the correct member group. Design \> Template Manager then select template and edit preferences - see screenshot.

Once there disable access to all but the super admin group and another group if necessary. Now no one can see that template. Select the redirect template that you want non-logged in members to view.

Here you could either set up a splash page, i.e. coming soon, or put in a {redirect="http://domain2.com"} and send them to a completely different site.

Now you can view the site while it's being built, but no one else can.

As for importing a new site into an MSM build it's not possible unless you copy existing templates/preferences when initially creating a new site.

Hope this helps.
> 0 votes

---
Tags: ee2, multi-site-manager, subdomain
---


# Question
Title: NavEE include_single_parent will not work when no kids exist
I have the following code.

```
<nav class="nav nav--secondary">
{exp:navee:custom
    nav_title="primary"
    parent_selected_class="is-current"
    selected_class="is-current"
    selected_class_on_parents="true"
    start_nav_from_parent="true"
    start_nav_from_parent_depth="2"
    display_all_children_of_selected="true"
    include_single_parent="true"
    wrap_type="ol"
}

    <li class="nav__item">
        <a href="{link}" class="nav__link {class}">
            {text}
            <i class="icn icn--arrow-right" aria-hidden="true"></i>
        </a>
        {if has_kids}<div class="nav nav--tertiary">{kids}</div>{/if}
    </li>

{/exp:navee:custom}

```

EE v2.5.5
NavEE v2.2.7

The outcome I am aiming for is: display selected nav item and kids of selected nav item. Everything is working great unless the selected nav item has no kids. When that happens, nothing appears. When the selected nav item has kids, the selected nav will show along with the kids. I have this exactly how I want it to behave except I can't get the selected nav to show up when it does not have kids. I would appreciate any input on this matter. Also happy to clarify if needed.

Here are the two pages:
Displaying nav items properly (it has kids)
Not displaying nav at all (it has no kids)

# Answer
What happens when you remove/alter either {start\_nav\_from\_parent="true"} or {start\_nav\_from\_parent\_depth="2"}

It's not even adding the on the page without children (just thinking outloud)....
> 1 votes

---
Tags: navee
---


# Question
Title: Show Entries Associated with Category Using Structure
I am designing a site for a wedding show at the moment and I am struggling to get my head around displaying entries related to categories. Basically I have 28 categories Beauty Therapists, Bridalwear, Wedding Cars etc and each of these categories will have entries associated with them.

The page `www.mysite.com/exhibitors/` displays all my categories. I'd like the link to the entries to be `www.mysite.com/exhibitors/beauty-therapists/` and that link to display all the beauty therapists at the show. But at the moment I cannot get the entries to display on the page, in fact I can't even get the page to display.

I'm using the latest version off EE and Structure, I have Zoo Triggers installed also with exhibitors as my trigger keyword.

I can post code if needs be but it is probably something fairly simple, I am new(ish) to EE, have built about 6 sites now but this is the first to incorporate categories. Any help would be muchly appreciated.

Thanks. Stephen.

**\*****\******* UPDATE 2 *****\*****\******

This is now working correctly. Updated code below in case anyone else come across the same issues. I had to set the setting in Freebie 'Always parse pagination' to yes to make it work.

Happy days.

**\*****\******* UPDATE 1 *****\*****\******

I now have the categories displaying correctly and the entries associated with those categories displaying when the category is clicked, the issue I have now is that I would like to paginate these entries but the pagination is not working.

I should also note this install is in a 'development' folder on my server which is located at www.mysite.com/development.

Exhibitors template code:

```
{embed="includes/siteHeader"}

<body>

{embed="includes/siteTopDetails"}

{embed="includes/brandAndNav"}

{embed="includes/pageHeading"}

{if freebie_1 == "exhibitors" && freebie_2 == ""}
<section class="mainPage">
    <div class="pageWidth">
        <div class="content noBottomPadding">
            <h3>Exhibitors at the Show</h3>
            <p class="featureText">Over 90 exhibitors ranging from Florists to Photographers to Cake Makers will showcase their products at the Ayrshire Wedding Show over the two days.</p>
        </div><!-- End content -->
    </div><!-- End pageWidth -->
    <div class="exhibitorsWidth">
        <div class="content noTopPadding">
            <div class="exhibitors">
                <ul>
                    {exp:channel:categories channel="exhibitor_individual" style="linear" show_empty="no"}
                    <li><a href="{structure:page:url}{category_url_title}">{category_name}</a></li>
                    {/exp:channel:categories}
                </ul>
            </div><!-- End exhibitors -->
        </div><!-- End content -->
    </div><!-- End exhibitorsWidth -->
</section><!-- End mainPage section -->
{/if}

{if freebie_1 == "exhibitors" && freebie_2 != ""}
<section class="mainPage">
    <div class="pageWidth">
        <div class="content noBottomPadding">
            <h3>{exp:freebie:category_name segment="2"}</h3>
        </div><!-- End content -->
    </div><!-- End pageWidth -->
    <div class="exhibitorsWidth">
        <div class="exhibitorsContent">
            <div class="exhibitorsHolder clear">
                {exp:channel:entries channel="exhibitor_individual" dynamic="no" limit="2" category="{exp:freebie:category_id segment='2'}" parse="inward" paginate="bottom" paginate_base="{structure:page:uri}/{exp:freebie:category_name segment='2'}"}
                <div class="exhibitorIndividual">
                    <hgroup>
                    <h4>{company_name}</h4>
                    <h5>Stand(s) {stand_number}</h5>
                    </hgroup>
                    <div class="exhibitorDetailsHolder">
                        <p class="exhibitorDetails"><strong>{exhibitor_name}</strong></p>
                        <p class="exhibitorDetails">{exhibitor_telephone_number}</p>
                        <p class="exhibitorDetails"><a href="http://{exhibitor_web_address}" target="_blank">{exhibitor_web_address}</a></p>
                    </div>
                    {if special_offer_heading}
                    <a href="#" class="offerLink" data-reveal-id="specialOfferModal" data-animation="fade">Special Offer</a>
                    <!-- Special Offer Modal -->
                    <div id="specialOfferModal" class="reveal-modal">
                        <hgroup>
                            <h3>{special_offer_heading}</h3>
                            <h4>{special_offer_sub_heading}</h4>
                        </hgroup>
                        <p>{special_offer_text}</p>
                        <a class="close-reveal-modal">×</a>
                    </div>
                    <!-- Special Offer Modal -->
                    {/if}
                </div><!-- End exhibitorIndividual -->
          {paginate}
         <div class="pagination">
         {pagination_links}
            <ul>
                {previous_page}
                        <li><a href="{pagination_url}" class="page-previous">Prev</a></li>
                {/previous_page}

                {page}
                        <li><a href="{pagination_url}" class="page-{pagination_page_number} {if current_page}active{/if}">{pagination_page_number}</a></li>
                {/page}

                {next_page}
                        <li><a href="{pagination_url}" class="page-next">Next</a></li>
                {/next_page}
            </ul>
        <p>Page {current_page} of {total_pages} pages</p>
         {/pagination_links}
         </div><!-- End pagination -->
         {/paginate}
                {/exp:channel:entries}
            </div><!-- End exhibitorsHolder -->
        </div><!-- End exhibitorContent -->
        <div class="pageWidth">
            <div class="content noTopPadding noBottomPadding">
                <div class="backToExhibitors">
                    <p class="icon-back"><a href="/development/exhibitors">Back to Exhibitors</a></p>
                </div><!-- End backToExhibitors -->
            </div><!-- End content -->
        </div><!-- End pageWidth -->
    </div><!-- End exhibitorsWidth -->
    <div class="exhibitorsWidth">
        <div class="content noTopPadding">
            <h3>Exhibitor Categories</h3>
                <div class="exhibitorCategories">
                    <ul>
                        {exp:channel:categories channel="exhibitor_individual" style="linear" show_empty="no"}
                                <li><a href="{structure:page:url}{category_url_title}">{category_name}</a></li>
                                    {/exp:channel:categories}
                    </ul>
            </div><!-- End exhibitorCategories -->
        </div><!-- End content -->
    </div><!-- End exhibitorsWidth -->
</section><!-- End mainPage -->
{/if}

{embed="includes/siteFooter"}

</body>
</html>

```

# Answer
> 1 votes
Currently with your template setup, there is no way for EE/Structure to tell which template to route to once `segment_2` is available. I've never used Zoo Trigger's before, so this answer is specific using the 3rd party addon - Freebie:

> Take control of your URLs — define segments that you want EE to ignore completely. Use 'freebie' segments to trigger template behavior, build dynamic archives inside Structure, or just build special URLs for analytics purposes. Freebie allows you to use segments in powerful, flexible ways without the hassle of dealing with strict URL parsing (like Structure's).

In order for this to work, a conditional is needed to determine what type of page is present based of the URL, so if `segment_2` is empty, to show the category listing, if not, show entries specific to present category. The first step is to set a ***breaking segment*** in Freebie's settings: `exhibitors`. Now anything after this segment will be ignored by EE, thus allowing you to use 1 template to control the content. Update the '*Exhibitor*' template with the code below once Freebie is installed & setup.

```
{if freebie_2 == ""} {!-- If segment_2 or freebie_2 is empty, show category listing --}

    <section class="mainPage">
        <div class="pageWidth">
            <div class="content noBottomPadding">
                <h3>Exhibitors at the Show</h3>
                <p class="featureText">Over 90 exhibitors ranging from Florists to Photographers to Cake Makers will showcase their products at the Ayrshire Wedding Show over the two days.</p>
            </div><!-- End content -->
        </div><!-- End pageWidth -->
        <div class="exhibitorsWidth">
            <div class="content noTopPadding">
                <div class="exhibitors">
                    <ul>
                        {exp:channel:categories channel="exhibitors" style="linear"}
                        <li><a href="{category_url_title}">{category_name}</a></li>
                        {/exp:channel:categories}
                    </ul>
                </div><!-- End exhibitors -->
            </div><!-- End content -->
        </div><!-- End exhibitorsWidth -->
    </section><!-- End mainPage section -->

{if:else} {!-- If freebie_2 is present, show single entry category listing --}

    <section class="mainPage">
        <div class="pageWidth">
            <div class="content noBottomPadding">
                <h3>{exp:freebie:category_name segment="2"}</h3>
            </div><!-- End content -->
        </div><!-- End pageWidth -->
        <div class="exhibitorsWidth">
            <div class="exhibitorsContent">
                <div class="exhibitorsHolder clear">
                    {exp:channel:entries channel="exhibitor_individual" category="{exp:freebie:category_id segment="2"}" disable="member_data"}
                    <div class="exhibitorIndividual">
                        <hgroup>
                        <h4>{company_name}</h4>
                        <h5>{stand_number}</h5>
                        </hgroup>
                        <div class="exhibitorDetailsHolder">
                            <p class="exhibitorDetails"><strong>{exhibitor_name}</strong></p>
                            <p class="exhibitorDetails">{exhibitor_telephone_number}</p>
                            <p class="exhibitorDetails"><a href="http://{exhibitor_web_address}" target="_blank">{exhibitor_web_address}</a></p>
                        </div>
                        {if special_offer_heading}
                        <a href="#" class="offerLink" data-reveal-id="specialOfferModal" data-animation="fade">Special Offer</a>
                        <!-- Special Offer Modal -->
                        <div id="specialOfferModal" class="reveal-modal">
                            <hgroup>
                                <h3>{special_offer_heading}</h3>
                                <h4>{special_offer_sub_heading}</h4>
                            </hgroup>
                            <p>{special_offer_text}</p>
                            <a class="close-reveal-modal">×</a>
                        </div>
                        <!-- Special Offer Modal -->
                        {/if}
                    </div><!-- End exhibitorIndividual -->
                    {/exp:channel:entries}
                </div><!-- End exhibitorsHolder -->
            </div><!-- End exhibitorContent -->
        </div><!-- End exhibitorsWidth -->
    </section><!-- End mainPage -->

{/if}

```

---
Tags: categories, structure, zoo-triggers
---


# Question
Title: Adding new channel fields takes 5 minutes
I work with an EE website that has 293 custom fields, and 125k entries. Nowadays, whenever I am adding a new channel field, it takes between 4 and 5 minutes to complete the task! Also, it can take up to 2 minutes to delete a channel field.

I understand that this task requires adding a row to the exp\_channel\_fields table, as well as adding at least 2 columns to the exp\_channel\_data table.

Anybuddy have any insight into why this is taking so long? Any tricks to speed this up?

Thanks!

* EE 2.5.5

# Answer
> 1 votes
...wow. Just...wow. That's a hell of a lot of content, AND a lot of fields!! It sounds like the database is just getting very very large, so of course it's slowing down.

You didn't mention why you're adding all these new channel fields. Do you have multiple channels? If so, is it at all possible to consolidate channel field groups, so that similar channels use the same fields (and only display certain ones on the front end?) If that's possible, you'd have to do some work to consolidate the fields/channels/content, but that would both start the optimization process, AND make expansion easier - if you tried to re-use wherever possible, instead of creating new field groups for each channel.

(You might also want to speak with your server admin/web host, see if they have any suggestions for optimizing server performance / SQL responsiveness. But this should not be a substitute for optimizing the database itself.)

---
Tags: ee2, custom-fields, database
---


# Question
Title: Member Group Tabs - Admins being logged out Tab URL
I'm having issues with the Member Group Tabs. My admins are being logged out when they click on menu items.

I think the issue is on the url tab. I've tried a variety of urls but nothing works. Not even the example url :

/admin.php?&D=cp&C=design&M=manager

# Answer
Member Group Tabs v1.2 is now EE 2.6 and above compatible.

https://github.com/surprisehighway/member-group-tabs
> 1 votes

---
Tags: regular-expressions
---


# Question
Title: is there any Payway Net payment gateway module for exp-resso store
I am planning to use Exp-resso to built a new online store. But i want to know if we can integrate is there any "Payway Net" payment gateway module for exp-resso store.

Payway Net is an advance version of Westpac Quickweb

Below mention re the links to these payment gateway https://www.payway.com.au/core/AboutView http://docs.woothemes.com/document/westpac-payway-net-payment-gateway/

Kindly confirm so that i can proceed accordingly

# Answer
> 1 votes
Currently Store does not have a Payway Net gateway. You can see the list of all available payment gateways in the documentation.

Currently all payment gateways are based off of the open source CI-Merchant (or GitHub) if you wanted to build your own. In the next version of Store the underlying credit card processing is going to be handled by Omnipay.

You can also contact support@exp-resso.com if you wanted to discuss having the gateway developed.

---
Tags: expresso-store, ecommerce, payment-gateway
---


title: Content entries not being saved

text:
# Question
Title: Content entries not being saved
We've just launched our EE2 based website and are now experiencing an odd problem:
In the control-panel it is no longer possible to save any changes to the sites content entries (or create new ones). When pressing 'Submit' or 'Save Revision' the edit-form is displayed again (containing the changed content).

Everything else on the site and control-panel work as expected, including changing settings and templates.

I activated all possible debug mechanisms (EE-Log, Debug Preference:1 (I am Super Admin), apache-log, Output-Profiler & Template-Debugging), but nothing shows up.
The SQL-Trace doesn't even contain an update statement for the channel tables and I manually tested, that the application user is permitted to access/update those tables.
I've also tried changing the "Process form data in Secure Mode" and "Deny Duplicate Data" optional without noticeable effect.

Any ideas where to look for the problem or any other options to try?

Thank you!

Best Regards,

Jan

# Answer
Have you customised the publish layout at all? If you have a hidden field that is required, it won't allow you to save, and obviously won't be visible so you can see that it's required! Ensure that all fields are visible and when it returns to the edit screen (without saving), check all the tabs and all fields to ensure there's none highlighted as being required.

Then try entering values into all fields to see if that allows for saving.

If still no joy, disable extensions (not individually, just the global disable in top right of Extensions page) and try again (there may be PHP errors, but at least it may narrow it down).

Finally, try creating a new channel (default options) with no custom fields - can that be saved? If so, try adding the same field group to this new test channel and see if the problem re-occures. If it does re-occur, you know there's a problem with a field type preventing saving, if it saves without problem, you know there's a problem with the channel settings.

Update - try these suggestions: Unable to publish new channel entry
> 3 votes

# Answer
Jan, can you check other tab of entry edit form like Options and Date. Basically "Options" tab and see if correct Author is selected.
> 0 votes

---
Tags: ee2, control-panel
---


# Question
Title: Membrr - {exp:membrr:order_form} not retaining values on error
I am using {exp:membrr:order\_form} to submit billing information.

I tried entering some dummy data for credit card and sure enough, I get redirected to the same page and I get error messages.

My problem is that the input values I entered prior to submission like name, address, etc did not persist. They are all blank.

Is there a way to make them persist?

# Answer
> 1 votes
Are you passing the related template variable into value attribute of input type. Like:

```
<input type="text" id="first_name" name="first_name" value="{first_name}" />

```

---
Tags: membrr
---


# Question
Title: Safecracker Registration - Entry Ids are all 0
I have this code in safecracker registration form

```
<select required name="gender" data-content="{instructions:gender}" data-title="Help" data-placement="right" data-trigger="focus" id="gender">
    <option value=""></option>
    {exp:channel:entries channel="genders" disable="categories|category_fields|member_data|pagination" orderby="entry_id" sort="asc" dynamic="no"}
        <option value="{entry_id}">{gender_name}</option>
    {/exp:channel:entries}
</select>

```

When I first load the page, it outputs correct entry\_ids for the gender.

The problem arises when I try to submit a form that causes an error. I get redirected to the same page but the difference is that in the field above, ALL entry\_ids are 0.

```
<select required name="gender" data-content="{instructions:gender}" data-title="Help" data-placement="right" data-trigger="focus" id="gender">
    <option value=""></option>
    <option value="0">Male</option>
    <option value="0">Female</option>
</select>

```

Any idea why this is the case?

EDIT: I forgot to say that this code is in a Snippet. It probably is relevant to the discussion.

# Answer
> 1 votes
My guess this is an EE parse order issue. Assuming you are registering for a new member, the default entry\_id is obviously 0 since there is no entry yet. Safecracker is actually parsing the entry\_id incorrectly before your entries loop runs. This should have nothing to do with Safecracker Registration, as the same thing would happen with a regular SC form too.

You have two options:

1) Use my Entries addon and prefix your nested tag so there is no parsing conflict. Entries is stable, I just haven't actually released it yet.

https://objectivehtml.com/entries

2) Use Stash to parse that entries loop outside of the Safecracker tag.

Let me know if you have any more questions.

---
Tags: safecracker, safecracker-registration
---


title: Only show months that have a blog entry

text:
# Question
Title: Only show months that have a blog entry
I'm just wondering if it's possible to hide all the months that don't have a blog entry?

```
{exp:low_yearly_archives channel="blog" start_month="1" status="not closed" sort="desc"}
  {year}
       {months}
              <li>
              {if num_entries != 0}
              <a href="{path=index.php/corporate/blog}/{year}/{month_num}/" title="{num_entries} entries in {month} {year}">{month_short} ({num_entries})</a>
              {if:else}
              {month_short}
              {/if}
              </li>
       {/months}
{/exp:low_yearly_archives}

```

I only have blog entries in the month on July at the moment, but it's showing me every month from January. I may be able to work around this by using "month\_start" but, if there's ever a case I miss a month with a blog entry then I wouldn't want the month showing with no archives. Also, if i remove "month\_short", it takes away the names, but still leaves a space for the month.

I hope this makes sense, thanks in advanced!

# Answer
> 3 votes
Get rid of the if:else and you'll only display months with entries

```
 {if num_entries != 0}
        <a href="{path=index.php/corporate/blog}/{year}/{month_num}/" title="{num_entries} entries in {month} {year}">{month_short} ({num_entries})</a>
 {/if}

```

---
Tags: low-yearly-archives
---


# Question
Title: Error saving entry with Matrix - Undefined index: field_id
After upgrading from Matrix 2.5 to 2.5.4 (and then to 2.5.5 today), I am now getting errors when I save entries with Matrix fields. The error reads:

```
A PHP Error was encountered
Severity: Notice
Message: Undefined index: field_id
Filename: matrix/ft.matrix.php
Line Number: 2644

```

The site also runs Solspace Super Search 2.0.7.

ExpressionEngine version is 2.5.0

Anyone running into this issue?

# Answer
Since I'm not a big fan of commenting out whole bloc of code my take was to change this line

```
if (isset($this->cache['keywords'][$this->settings['field_id']]))

```

and make it look like this

```
if (isset($this->settings['field_id']) AND isset($this->cache['keywords'][$this->settings['field_id']]))

```

I had this issue only when saving an entry from the channel used by Structure which doesn't use a matrix field in the first place.

This worked with EE 2.6.1 and Matrix 2.5.5
> 2 votes

# Answer
Yep, this was happening to me too. I commented out the entire function since I needed to get it up and running.

This is what I commented out:

```
function third_party_search_index($data)
{
    // Did the entry just save?
    if (isset($this->cache['keywords'][$this->settings['field_id']]))
    {
        return $this->cache['keywords'][$this->settings['field_id']];
    }
    else
    {
        return $data;
    }
}

```

Seems to have worked (nothing is broken as far as I can tell).
> 1 votes

# Answer
Had something similar recently, had to upgrade EE to at least 2.5.4.
> 0 votes

# Answer
The new Matrix version 2.5.6 solves this problem.
> 0 votes

---
Tags: matrix, pixelandtonic, solspace, supersearch
---


# Question
Title: Call to undefined method EE_Pagination::create()
I have this code in my module

```
$this->EE->load->library('pagination');
$pagination = $this->EE->pagination->create(__CLASS__);
...

```

The problem is that I get this error

```
Fatal error: Call to undefined method EE_Pagination::create() in ...

```

I am using EE 2.5.5

Is there some changes that make this code not work? Is there a new way to do this?

# Answer
> 1 votes
create() method in pagination library was only added in EE 2.6

In one of my modules, I use this code:

```
if ($this->EE->config->item('app_version') >= 260)
{
$pagination = $this->EE->pagination->create(__CLASS__);
}
else
{
$pagination = new Pagination_object(__CLASS__);
}

```

# Answer
> 0 votes
There is no create method, there's create\_links or render.

Two methods I use:

```
//###   Prep the Pagination   ###
$this->EE->load->library('pagination');
$pagination = new Pagination_object(__CLASS__);
//###   Set any settings   ###
$pagination->dynamic_sql = TRUE;
$pagination->basepath = $this->EE->functions->create_url($this->EE->uri->uri_string);
$pagination->per_page  = ( !is_numeric($this->EE->TMPL->fetch_param('limit')) )  ? $defaultLimit : $this->EE->TMPL->fetch_param('limit');
$pagination->build($total, $primarySQL);
$tagdata = $pagination->render($tagdata);

```

...or:

```
    $this->EE->load->library('pagination');
    $config['base_url'] = $base_url;
    $config['total_rows'] = $total;
    $config['per_page'] = $per_page;
    $config['num_links'] = 3;
    $config['uri_segment'] = 4;
    $config['first_link'] = '1';
    $config['first_tag_open'] = '<div class="pag-first">';
    $config['first_tag_close'] = '</div>';
    $config['next_tag_open'] = '';
    $config['next_tag_close'] = '';
    $config['num_tag_open'] = '';
    $config['cur_tag_open'] = '<strong>';
    $config['prev_tag_open'] = '';
    $config['last_link'] = ceil($total/$per_page);
    $config['last_tag_open'] = '<div class="pag-last">';
    $config['last_tag_close'] = '</div>';

    $this->EE->pagination->initialize($config);

    return $this->EE->pagination->create_links();

```

References:

http://ellislab.com/expressionengine/user-guide/development/module\_tutorial.html http://ellislab.com/codeigniter/user-guide/libraries/pagination.html

---
Tags: pagination
---


title: LinkedIn / OAuth question

text:
# Question
Title: LinkedIn / OAuth question
I have a client that has an (I think) odd request: I know there are modules like Social Login Pro that connect someone's Facebook / LinkedIn to a member account, but what my client wants to do is:

Allow users to submit "tips". To submit a tip, you don't need to register, you just enter your tip, after which you're prompted to either "enter your personal information yourself" or "use your linkedin profile". This should be stored with the entry, not in a member-profile, and people should be allowed to submit multiple tips.

How would this even work OAuth-wise? Are you allowed to request someone's personal info again?

Any input would be greatly appreciated!

Thanks!

# Answer
With Social Login Pro, you can let user add connection to LinkedIn profile after he's already registered and logged in to your system.

If that is what you're asking, as the question is not too clear :)
> 1 votes

---
Tags: safecracker, twitter, social, oauth
---


# Question
Title: How to get group_id of a Channel entry's author?
I need to implement some business rules based on the following:

1. The current user's `{group_id}`
2. The group id of the author of a particular Channel entry

I need to implement this rule within the {exp:channel:entries}, I suppose. In that loop, I'll have access to {author\_id}, which possibly could be used somehow to get it's associated group id???

# Answer
Documentation is a good place to start:

http://ellislab.com/expressionengine/user-guide/templates/globals/single\_variables.html

http://ellislab.com/expressionengine/user-guide/modules/member/index.html#custom-profile-data-tag

```
{member_group} or {group_id}
{member_id}

```

also (if in channel:entries tag pair and don't want conflict):

```
{logged_in_member_id}
{logged_in_group_id}

```

Entry Authors details:

```
{exp:channel:entries}
    {author_id} or {member_id} will be the same inside entries loop
    {group_id} will be authors group inside entries loop
{/exp:channel:entries}

```

Get custom member details:

```
{exp:member:custom_profile_data member_id="?????"}
{/exp:member:custom_profile_data}

```
> 5 votes

---
Tags: channel-entries, templates
---


# Question
Title: Removing Directory from URL with .htaccess
I have a site setup with a template directory called “pages” so I can call to the pages with the following URL:

http://sitename.com/pages/page-name

However, for SEO reasons I would prefer to remove the “pages” part of the URL so that it reads as:

http://sitename.com/page-name

A search on Google has presented some possible solutions but there is some type of conflict. Perhaps with the my rules to remove “index.php”? Can anyone offer any pointers? Below is my current redirect conditions.

```
<IfModule mod_rewrite.c>
  Options +FollowSymlinks
# Options +SymLinksIfOwnerMatch
  RewriteEngine On
# BEGIN ExpressionEngine Rewrite
  RewriteBase /
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
  RewriteRule ^(.*)$ /index.php?$1 [L]
# END ExpressionEngine Rewrite
</IfModule>

```

# Answer
Does the 'pages' group contain your homepage? If so, just turn Strict URLs off. Then you can access /pages/my-page at /my-page.

Turning off Strict URLs makes the URLs less... strict. You will have to more 404 handling yourself. You will have to put some conditionals in your pages to check for extra segments.

For example, the template blog/post might display a post with a URL of /blog/post/my-blog-post.
However, you could access the exact same page at /blog/post/my-blog-post/extra/segments/blah/blah. Google would see these as different pages. Duplicate content, bad for SEO.

To fix this, add to your template something like:

```
{if segment_3}{redirect="404"}{/if}

```
> 1 votes

---
Tags: htaccess
---


title: Expresso Store core files

text:
# Question
Title: Expresso Store core files
MY question is there core file in Expresso Store extension which is not update when we update Expresso Store extension .I want to call a hook after payment successful so i want if Expresso Store update my code not remove

# Answer
> 2 votes
There are a few hooks available which will allow you to latch on to the process at various points. If you want to run an extension after payment has been processed then `store_order_payment_end` (docs link) is the hook you'd need to look to use in your custom extension.

---
Tags: expresso-store, add-on, expresso
---


# Question
Title: How to handle ampersands in URL segments
I'm using the channel entries search parameter to filter entries based on the value in a segment. However, I've just spotted that some of these segments contain ampersands, and these don't work correctly when filtering channel entries in this way. Is there a way around this?

Here's an example URL that I'm having issues with: mywebsite.com/regions/Yorkshire & Humberside

The spaces work fine as they are automatically converted into %20, like this: mywebsite.com/regions/Yorkshire%20&%20Humberside, which seems to work fine in EE. But the ampersand doesn't get converted into anything, so my segment is being ignored after the ampersand, so my filtering isn't working correctly.

I've tried changing the ampersand to **%26**, like this: mywebsite.com/regions/Yorkshire%20%26%20Humberside but that doesn't make any difference. I've also tried changing the ampersand to **& amp;** (I've added a space here as EESE keeps converting this into an ampersand if I write it out correctly) like this: mywebsite.com/regions/Yorkshire%20& amp;%20Humberside, but that just gave me the following error: The URI you submitted has disallowed characters.

Here's what my channel entries tag looks like:

```
{exp:channel:entries channel="location" status="open" limit="1000" dynamic="no" search:cf_location_region="{segment_2}"}

```

Can anyone think of any workarounds to this? I can't use categories due to the way in which I'm getting the data from an external data source. Thanks.

# Answer
> 1 votes
Been testing this further and I found that the channel search parameter does seem to be working correctly, even with the ampersand in the URL.

The thing that was making me think it wasn't working correctly was the fact that the title at the top of the page, \< h1\>{segment\_2}\< /h1\> was being cut off after the ampersand (like this: \< h1\>Yorkshire\< /h1\>, instead of outputting \< h1\>Yorkshire & the Humber\< /h1\>, so I assumed that the same issue was also be happening to the {segment\_2} in the channel search parameter.

To work around the issue with the title being cut off with the segment variable, I'm using a Zoo Triggers variable to output the page title instead (\< h1\>{triggers:segment\_2}\< /h1\>), and that outputs the full title correctly: \< h1\>Yorkshire & the Humber\< /h1\>.

I've no idea why the standard segment variable is being cut off after the ampersand, or why the Zoo Triggers variable works fine, but it's outputting what I want so I'll move on. :)

---
Tags: channel-entries, url, segments
---


title: How to use Playa in Low Variables?

text:
# Question
Title: How to use Playa in Low Variables?
Given a Playa field in Low Variables called `widgets`, how would I output the title of each widget? Below is what I'd expect, but it outputs nothing.

```
      {exp:low_variables:parse var="widgets"}
        {title}
      {/exp:low_variables:parse}

```

# Answer
> 4 votes
I fixed this issue. It was/is a bug in Playa. Pixel and Tonic now knows about it and will include a fix in the next release. In the meantime, here is my solution:

Change Line 2484 of ft.playa.php to...

```
$data = array(
'parent_var_id' => $this->var_id,
'parent_is_draft' => 0
);

```

Basically added 'parent\_is\_draft' =\> 0

# Answer
> 1 votes
I'm just confirming that this works in Playa 4.4.4 + Low Variables 2.3.5 with EE 2.6.

# Answer
> 0 votes
Matt,

Have you seen Low's answer? His first example should work for you:

```
{exp:low_variables:pair var="lv_settings_home_feature_items" limit="3"}
    ...more code here...
{/exp:low_variables:pair}

```

If it's not working, can you post your EE version, Playa version, and LV version?

Thanks!

-Lisa, P&T

---
Tags: playa, low-variables
---


title: Duplicate an entry

text:
# Question
Title: Duplicate an entry
I have a channel that has a lot of fields and several entries are similar to each other. So I want to be able to duplicate an entry and then make changes to it instead of having to retype everything from scratch.

Is there a way to do this in the CP?

# Answer
Never mind. Found this extension: http://devot-ee.com/add-ons/mx-cloner
> 1 votes

---
Tags: channel-entries
---


title: Can't Get Views Count (entry tracking)

text:
# Question
Title: Can't Get Views Count (entry tracking)
On the page that I display the details of a single Channel entry, I have the following:

```
{exp:channel:entries
    channel="blogs"
    disable="categories|category_fields|pagination"
    dynamic="no"
    track_views="one"
    url_title="{segment_3}"
}

```

The URL where this page is displayed looks like this: `www.domain.com/blogs/post/hello-world`. Because I am not using the second segment to contain the entry id or URL title (I reserve that for the pagination and Low Search hash), I have to set `dynamic="no"` and `url_title="{segment_3}"`.

The EE documentation says:

> Single entry pages are ones that show only a single entry, specified dynamically by the ID number or URL Title in the URL, such as comment or permalink pages.

I have gone to "Tracking Preferences" and all tracking options are enabled. I have also set "Enable Caching?" to "No" for the template file containing my loop.

Does my setup mean I can't track views? Currently, I do not think it is working.

**UPDATE 1:**

In my page that lists all the blog entries, I create links using `{url_title_path='blog/post'}`. On my single entry page, I thought I had to set `dynamic="no"`, but it doesn't seem that I need to. The following works:

```
{exp:channel:entries
    channel="blogs"
    disable="categories|category_fields|pagination"
    track_views="one"
    url_title="{segment_3}"
}

```

Have I met all the requirements to enable entry tracking? It's still not working for me, though. I am able to make comments work -- doesn't that have similar requirements as entry tracking?

**EDIT 2:**

Here's my entire template file (which is being embedded in another template):

```
{exp:low_replace find="\r|\n|\t" replace="" regex="yes"}
    {exp:channel:entries
        channel="blogs"
        disable="categories|category_fields|pagination"
        track_views="one"
        url_title="{segment_3}"
    }
        <h3>{title}</h3>
        <img src="http://placehold.it/640x260/" width="640" height="260" alt=""/>
        <ul class="inline post-details">
            <li>
                <span class="icon-user"></span>By <a href="/profile/#/">{author}</a>
            </li>
            <li>
                <span class="icon-time"></span>{exp:nice_time date="{entry_date}" format="{format.date.international}"}
            </li>
            <li>
                <span class="icon-comment"></span>{comment_total} Comments
            </li>
            <li>
                <span class="icon-eye-open"></span>{view_count_one} Views
            </li>
        </ul>
        {blog}
    {/exp:channel:entries}
    {embed="common/.comments"}
{/exp:low_replace}

```

# Answer
Have you tried out relaxed\_track\_views? You'd add it to /system/expressionengine/config/config.php:

```
$config['relaxed_track_views'] = 'y';

```

Based on the comments you have Query Caching on, so in the end it wasn't a template issue at all - but needing to use the config.php option or turn off Query Caching.
> 1 votes

# Answer
Because view tracking has to be unique, if it's not based on a unique dynamic URL then EE doesn't know it's unique, so you could be rendering out multiple entries on the same URL but specifying different segments or even hard-coding url\_title and EE won't know which one is the unqiue one for that URL/page.

To answer your question: no you can't use dynamic="no" and expect track\_views parameter to save it.

So where does that leave you? Either you have to restructure your URLs so they can be dynamic or cheat:

Use an add-on: http://devot-ee.com/add-ons/external-entries

SQL:

```
UPDATE exp_channel_titles SET view_count_one = view_count_one + 1 WHERE url_title = "{segment_3}"

```

Or add PHP to a template (remember to activate PHP on template - set to output):

```
<?php
    $EE = & get_instance();
    $EE->db->query("UPDATE exp_channel_titles SET view_count_one = view_count_one + 1 WHERE url_title = '".$EE->uri->segment(3)."'");
?>

```

This shortened version might work (would need to test it):

```
<?php
    ee()->db->query("UPDATE exp_channel_titles SET view_count_one = view_count_one + 1 WHERE url_title = '".ee()->uri->segment(3)."'");
?>

```

Or even...:

```
<?php
    $this->EE->db->query("UPDATE exp_channel_titles SET view_count_one = view_count_one + 1 WHERE url_title = '".$this->EE->uri->segment(3)."'");
?>

```

Or neater:

```
<?php
    $this->EE->db->where(url_title, $this->EE->uri->segment(3));
    $this->EE->db->update('channel_titles', view_count_one = view_count_one + 1);
?>

```

Obviously this would need to be thoroughly tested! You will need EE conditionals around the PHP to prevent false triggering under different circumstances. Then if the conditional is false, the PHP won't get parsed by EE.

Also note, there's a good reason the EE query tags don't support UPDATE and INSERT, so by adding it to your template, not only could there be security issues, but it could also muck up your tables.

Edit: Updated to reflect Yuri's suggestion
> 3 votes

# Answer
Assuming that **blogs** is your template group, and **post** is your template, then you don't need to pass the `url_title`. So your opening Channel Entries tag should look like this:

```
{exp:channel:entries
    channel="blogs"
    disable="categories|category_fields|pagination"
    track_views="one"
}

```

Using the URL structure you mention, and this tag, `track_views` should indeed work.

Are you perhaps using a caching module like CE Cache? That would prevent the views from incrementing.

If you enable the output profiler, you can actually see which MySQL queries are being executed when the page loads - you should see an entry that looks like:

```
UPDATE exp_channel_titles SET view_count_one = (view_count_one + 1) WHERE url_title = 'hello-world';

```
> 0 votes

---
Tags: channel-entries
---


# Question
Title: Custom marker icons (by category) for Google Maps for EE
EE v2.5.5
Google Maps Addon v3.2.2

I'm currently building a site that shows companies on a map. A requirement is to display custom POI icons per each entry's category.

Since the exp:gmap:marker tag pair sets the POI icon via the "icon" parameter, I don't have any way to pass in the entry category data.

**Is there a different or better way to render these POIs that gives me custom icon abilities?**

I'm currently using exp:gmap:results because the results page is displayed as a response to an address/location search with search radius specified.

# Answer
> 1 votes
It turns out the solution involves using the latest version of Google Maps for ExpressionEngine and then using match\_no\_categories="true" as well as match\_categories="true" on the exp:gmap:results tag pair.

This allows the use of {category\_ids} for example in building a path to your icon images in the exp:gmap:marker icon parameter.

---
Tags: google-maps-for-ee
---


title: freeform Ajax submission

text:
# Question
Title: freeform Ajax submission
This is the first time trying this with Freeform 4 but I don’t see any reason why this shouldn’t work.

I have a basic contact form:

```
{exp:freeform:form
form_id="2"
ajax="yes"
required="name|email"
return="embeds/thankyou"
form:class="contact-form"
form:id="contact-form"
}

<fieldset>
    <label for="name">Name</label>
    <input type="text" id="name" name="name" class="form-text" />

</fieldset>

<fieldset>
    <label for="email">Email</label>
    <input type="email" name="email" id="email" class="form-text" />
</fieldset>

<fieldset>
    <label for="message">Message</label>
    <textarea id="message" name="message"></textarea>
    <p class="form-help">Tell us if you'd like to adopt a dog or support us.</p>
</fieldset>

<fieldset class="form-actions">
    <input type="submit" class="btn--orange  btn--x-large" value="Contact" />
</fieldset>

{/exp:freeform:form}
<div id="contact-thanks"></div>

```

and it works fine without Ajax. Form gets submitted, email gets sent, user gets redirected. I add my JS into the mix (adding my jQuery and plugin call before it)

```
$('#contact-form').ajaxForm({
    target: '#contact-thanks',
    success: function() {
        $('#contact-form').hide();
        $('#contact-thanks').fadeIn('slow');
    }
});

```

the form submits, email gets sent but the success message doesn’t load into the placeholder.

Is there anything glaringly obvious I’ve missed? This did work on other sites albeit they were using Freeform 3.

# Answer
> 1 votes
So it appears with the new version of Freeform I need to set the ajax parameter to ajax="no" for use with Malsup's form plugin otherwise the output is a JSON response.

Hopefully that will help others.

---
Tags: javascript, solspace-freeform, jquery, ajax
---


title: Single entry for segment_2

text:
# Question
Title: Single entry for segment_2
I use the following code for a single entry:

```
{exp:channel:entries
channel="pages"
entry_id="24"
limit="1"
require_entry="yes"
dynamic="no"
disable="categories|category_fields|member_data|pagination"
}
{if no_results}{redirect="404"}{/if}
{page_body}
{/exp:channel:entries}

```

It works as expected for segment\_1 urls (i.e. www.someurl.com/about-us), but if the template is not the index page of a template group, the same code throws a 404 error (i.e. www.someurl.com/abount-us/leadership).

If I remove limit="1" & require\_entry="yes", it works fine.

What is going on here?

# Answer
From the documentation of `require_entry` parameter:

> This parameter tells the channel tag that it should expect the URL to contain a valid entry ID or a valid URL title. If an ID is not found in the URL, the tag will not display any data. Normally, the channel tag will show something, even if the URL doesn’t point to a particular entry. For example, your main channel page will typically show several of your most recent entries. Whereas your “single entry” pages, like your comment page, will show a single entry based on information in the URL. However, if one of your single entry pages is requested, but it doesn’t contain a valid ID, this parameter will tell the tag that you do not wish the template to display anything.

So, you shouldn't and don't need to use the both parameters `entry_id` and `require_entry` together. The strange behavior you're experiencing on your code looks like a conflict.

If you use the parameters `entry_id` or `url_title`, the `no_results` will work fine even without the parameter `require_entry`.

In my opinion, you should prefer to use the pages module.
> 1 votes

---
Tags: 404
---


title: {options:my_field_name} not working

text:
# Question
Title: {options:my_field_name} not working
I have this code in my safecracker form

```
<select class="span2" data-title="Help" data-placement="right" data-trigger="focus" data-content="{instructions:gender}" disabled id="gender">
 {options:gender}
   <option value="{option_value}" {selected}>{option_name}</option>
 {/options:gender}
</select>

```

`genders` is a relationship field. According to the documentation, I should be able to generate options for a select field using this syntax

```
<select name="my_field_name">
        {options:my_field_name}
                <option value="{option_value}"{selected}>{option_name}</option>
        {/options:my_field_name}
</select>

```

This doesn't work for me.

However, using

`{field:gender}`

works but outputs a select dropdown. I don't want this since I want to specify some attributes for the select tag as you can see above.

Any idea why this is the case?

I am using EE 2.5.5

# Answer
> 1 votes
You can try like this code example:

```
{custom_fields}
    {if relationship AND field_name == 'gender'}
        <select id="{field_name}" name="{field_name}[data][]">
            {options}
                <option value="{option_value}"{selected}>{option_name}</option>
            {/options}
        </select>
    {/if}
{/custom_fields}

```

I hope, it would work for you.

---
Tags: custom-fields, forms, fields
---


# Question
Title: Moved MSM site to new server now images wont show on frontend
I moved my MSM installation to a new server and now am unable see uploaded images on the front end of either site.

My setup looks like this:

```
└── domain1.com
    ├── admin.php
    ├── index.php
    └── assets
        ├── css
        ├── img
        ├── js
        └── templates
             ├── default
             └── domain2
    ├── images
    ├── system
    ├── themes
    └── domain2.com
        ├── admin.php
        └── index.php

```

If I visit domain1.com or domain2.com front end I can only see background images set through css (contained in '/assets/img' folder. I cannot see any of the images rendered through EE in the 'images' folder. Permissions are set to '777' for all image folders.

If I log into the backend I can see the images in file manager and view them as well by clicking on them - images are rendered correctly. I changed image uploaded preference paths for all folders after moving the site and assume these are correct as I can see the images in the back end as previously mentioned.

I am a bit baffled here. I have cleared browser and EE cache. Any ideas?

\** Edits to included information requested \**

.htaccess

```
Options -Indexes

<IfModule mod_rewrite.c>
        RewriteEngine On

        # Removes index.php from ExpressionEngine URLs
        RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule ^(.*)$ /index.php?/$1 [L]
</IfModule>

```

I have simply dropped in the .htaccess from the previous domain, but I have noticed that this is not working. To access deeper pages I am still have to add the "index.php" unfortunately. This htaccess did work correctly on previous domain.

* Check your upload preferences paths are correct. On the frontend can you target the (uploaded) images directly? Yes, I can navigate directly to an image so I assume the path are correct.
* Can you access domain2.com from the frontend? Yes, and domain2 has the exact same issue as well, backend css images work, images uploaded through CP do not.
* With that folder structure you might have issues with being able to access domain2 from domain1. e.g. domain1.com/domain2.com – I may need to clarify: I was using domain1.com and domain2.com for simplicity really I am dealing with a cPanel and an addon domain. So domain one is in the cPanel account and domain2.com is simple a folder inside that currently. I am going to add the subdomains dev.domain1.com and dev.domain2.com to these sites as I figured this would allow more direct access for EE and maybe the url structure is confusing EE.

# Answer
The Image resizer plugin you're referring to has been abandon, so there has been no support or development for many years. I'd highly recommend using CE Image, I've used this on numerous sites, including MSM and the paths can easily be set via the config file:

http://www.causingeffect.com/software/expressionengine/ce-image/user-guide/configuration#msm\_config
> 2 votes

---
Tags: multi-site-manager
---


title: Parse Order of embeds that embed

text:
# Question
Title: Parse Order of embeds that embed
Assume the following:

1. Template A embeds Template B
2. Template B embeds Template C
3. Template C is a simple Channel entries loop that outputs a particular field value

In the above setup, nothing is outputted by Template C. However, if Template A embeds Template C directly, it works fine.

What's going on here? How do I make Template C work when embedded by Template B?

# Answer
Depth isn't an issue with embeds and neither is URLs, so if the embed works from template A, it will work from Template B. So it isn't any parameter issue (unless you use embed variables in the parameters - see 2 below).

Three factors that are most likely:

1. The embed in Template B is within a conditional which is not being met.
2. You're passing embed variables from template A and incorrectly passing them to Template C from B.
3. There's a error in Template C which means it doesn't render (add-on?) - dump a test string outside any channel:entries tag pair to check if the template is accessed at all (this is also a good test for no. 2).

Seeing as we don't know your template code, I'm going to guess at no. 2 as being at fault (it's the one that usually catches me out the most).
> 2 votes

# Answer
Can you just check by outputting anything out of channel entry tag and see if its working.

If its working check channel entry tag. Also check by using parameter dynamic="no" within channel entry tag.
> 0 votes

---
Tags: templates, parse-order, embeds, template-scripting, template-partials
---


# Question
Title: Safecracker Registration & EE's registration process, Forgot Password
I'm using Safecracker Registration. There are a few things I want to improve for my registration process. I'm not sure if this is something I need to do in Safecracker Registration or in EE.

**Registration Process Questions**

Upon submitting the registration form, users are NOT loggged in and are directed to a page that tells them to verify their email address. Everything is good so far.

1. When the user checks their email and clicks the activation link, I want the user to be directed to a page that I specify instead of EE's default page.
2. When the user gets to the activation page (whether it's mine or EE's), I want the user automatically logged in. The assumption is that only the user has access to his/her email and clicking the activation link essentially confirmed the identity of the user -- thus, this is safe.

**Forgot Password**

1. This process sends an initial email to the user, which then sends another email with the new password if the user clicks the link in the initial email. How do I get these links to direct to my template pages instead of EE's?

**Synchronizing Information**

1. My member's Channel (the one associated via SafeCracker Registration) has a `{profile_name}` field. Whenever this is set, I'd like to sync it up with EE's `{screen_name}`. How do I do this?

# Answer
> 1 votes
> **Synchronizing Information**
>
> My member's Channel (the one associated via SafeCracker Registration) has a {profile\_name} field. Whenever this is set, I'd like to sync it up with EE's {screen\_name}. How do I do this?

I took a glace at "SafeCracker Registration" module settings but there isn't any such type of settings. You can develop a small extension with hook entry\_submission\_end. The author\_id of that member entry will be the member id of newly created member. So it would be easy to update the member's screen\_name with entry's profile\_name field value.

# Answer
> 0 votes
For your registration process questions, the add-on Member Activation Redirect fulfils both requirements.

# Answer
> 0 votes
I'm not sure whether Safecracker Registration handles templating the forgot password process, but if not there are other add-ons which can do this. For example, Freemember lets you template your own reset password page once the user clicks a link in their email.

---
Tags: members, registration, safecracker-registration, member-details, forgot-password
---


title: Strip HTML from checkout fields

text:
# Question
Title: Strip HTML from checkout fields
A client I have built an Expresso-store site for has just had a pretty comprehensive Penetration Test performed on it. One of the areas they highlighted, and the client wants to be addressed, is the limited sanitisation performed on checkout process fields.

Here is the actual report entry:

> Whilst testing, 2-sec attempted to see it was possible to generate cross-site scripting errors within the application using the HTML tag in certain input fields. From this, it was found that the application sanitised certain inputs, which could be attributed to input blacklisting. 2-sec identified that whilst the tag was sanitised it allowed other HTML tags to be used. Below are a list of tags allowed by the application:

```
<a> <h1> <p> <table>

```

> When entered into a form field the application rendered these tags as html, so for example when the tag was input then the name of the user could be converted into a link on their billing name during the checkout process. Although these tags are usually considered harmless, it does identify that limited sanitisation is carried out by the application.

Could you suggest the best way of achieving this without modifying the core code from the Store module?

Thanks

# Answer
> 2 votes
Thanks Peter

As the fields already clean out 'dangerous' tags I just created a small jQuery function to strip out the highlighted tags on submission. It seemed the quickest way to keep the auditors happy with minimal effort!

# Answer
> 0 votes
Without hacking the Store module core code:

Create an extension that sanitises the fields as you want them utilising the Store hooks: https://exp-resso.com/docs/store/extension\_hooks.html#store\_order\_submit\_start

Contact Expresso Store providing your findings, as I'm sure they'd be more than willing to incorporate changes in future versions.

Or parse and validate in JavaScript prior to form submission (not ideal as still hackable be someone who is determined).

---
Tags: expresso-store
---


title: Stash - what is the scope of variables?

text:
# Question
Title: Stash - what is the scope of variables?
I'm trying to get a Channel entry made by a particular member id (there will always be just 1 entry) and store it in a Stash variable:

```
{exp:channel:entries
    author_id="{segment_2}"
    channel="profiles"
    disable="categories|category_fields|custom_fields|member_data|pagination"
    dynamic="no"
}
    <h4>Works: {entry_id}</h4>
    {exp:stash:entry_id}{entry_id}{/exp:stash:entry_id}
    <h4>Works: {exp:stash:entry_id}</h4>
{/exp:channel:entries}

<h4>Does NOT Work: {exp:stash:entry_id}</h4>

```

**Why do I not have access to the Stash variable's value outside the loop?**

My ultimate goal is to use that variable in another loop:

```
{exp:channel:entries
    channel="profiles"
    disable="categories|category_fields|member_data|pagination"
    entry_id="{exp:stash:entry_id}"
    limit="1"
}

```

(I'm already worried I'll run into parse order issues.

# Answer
> 5 votes
The reason you do not have access to that variable outside the loop is because your stash tags (getters and setters) are not parsed at the same time. EE module tags are parsed recursively from the outwards inwards, peeling them one after another like a oignon.

In your code above, your stash set tags are inside an entry loop (level 2), while your get tag is at the root (level 1). That means your get tags are still empty when processed.

**Solution One:**

Use `process=end` on your getter to force it to be processed later than your setter

With a single value:

```
{exp:channel:entries channel="blogposts" disable="categories|category_fields|custom_fields|member_data|pagination" dynamic="no" limit="1"}
        {exp:stash:st_entryid}{entry_id}{/exp:stash:st_entryid}
{/exp:channel:entries}

<p>Stash output entry id: {exp:stash:st_entryid process="end"}</p>

```

With a list

```
{exp:channel:entries channel="blogposts" disable="categories|category_fields|custom_fields|member_data|pagination" dynamic="no" limit="5"}
    {exp:stash:append_list name="st_blogposts_ids" parse_tags="yes"}
        {stash:st_entryid}{entry_id}{/stash:st_entryid}
    {/exp:stash:append_list}
{/exp:channel:entries}

{exp:stash:get_list name="st_blogposts_ids" parse_conditionals="yes" process="end"}
    {if count == 1}<ul>{/if}
        <li>Entry ID: {st_entryid}</li>
    {if count == total_results}</ul>{/if}
{/exp:stash:get_list}

```

**Solution Two:**

Put the setters and the getters on the same "oignon" layer by wrapping your setters around the channel entries tag. That's usually the method I use whenever possible. With lists, you have the added value that the performance of `{exp:stash:set_list}` is better than `{exp:stash:append_list}`

Single value:

```
{exp:stash:st_testid parse_tags="yes" trim="yes"}
    {exp:channel:entries channel="blogposts" disable="categories|category_fields|custom_fields|member_data|pagination" dynamic="no" limit="1"}
            {entry_id}
    {/exp:channel:entries}
{/exp:stash:st_testid}

<p>Stash output entry id: {exp:stash:st_testid}</p>

```

List:

```
{exp:stash:set_list name="st_test_ids" parse_tags="yes"}
    {exp:channel:entries channel="blogposts" disable="categories|category_fields|custom_fields|member_data|pagination" dynamic="no" limit="5"}
            {stash:st_entryid}{entry_id}{/stash:st_entryid}
    {/exp:channel:entries}
{/exp:stash:set_list}

{exp:stash:get_list name="st_test_ids" parse_conditionals="yes"}
    {if count == 1}<ul>{/if}
        <li>Entry ID: {st_entryid}</li>
    {if count == total_results}</ul>{/if}
{/exp:stash:get_list}

```

Hope that helps.

# Answer
> 0 votes
Not sure if this is the most trim way to do what you're asking, but it should work:

```
{exp:stash:set_list name="cached_entryid" parse_tags="yes"}
    {exp:channel:entries
        author_id="{segment_2}"
        channel="profiles"
        disable="categories|category_fields|custom_fields|member_data|pagination"
        dynamic="no"
    }
        {stash:eid}{entry_id}{/stash:eid}
    {/exp:channel:entries}
{/exp:stash:set_list}

{exp:stash:get_list name='cached_entryid'}
    {exp:channel:entries
        channel="profiles"
        disable="categories|category_fields|member_data|pagination"
        entry_id="{eid}"
        limit="1"
    }
        ENTRY ID: {eid}
    {/exp:channel:entries}
{/exp:stash:get_list}

```

Uses set\_list instead of set.

# Answer
> 0 votes
You can probably wrap the channel entries loop with stash tags, like this:

```
{exp:stash:set parse_tags="yes"}
  {exp:channel:entries ...}
    {stash:entry_id}{entry_id}{/stash:entry_id}
  {/exp:channel:entries}
{/exp:stash:set}

{exp:stash:get name="entry_id"}
or {exp:stash:entry_id}

```

---
Tags: templates, stash, template-scripting
---


# Question
Title: Redirect to static page if EE database is down
We have a client that would like to see a branded, non-EE error message if there is a problem with the EE database connection. Their database is hosted on a different server and has, on one or two occasions, lost the connection – causing EE to render a plain error message.

We'd either like to redirect to a static HTML page which contains a nice, branded apology for the site being down, or to edit the source code of the default message. I tried the Custom Messages add-on but it seems that this requires EE and the DB to be functioning correctly in order to work.

Any thoughts on how best to approach this scenario?

Gaz

# Answer
> 1 votes
This might help:

https://stackoverflow.com/questions/5148033/how-do-i-check-if-php-is-connected-to-a-database-already

I suspect you will have to insert something like this in the site root index.php for it to work, you could then include a static template from somewhere else on the server when a connection can't be made and serve a 404 header?

---
Tags: database, error-pages
---


# Question
Title: Assets Blank not Updating after migration
Migrated to a new server and my server path has changed.

I changed the path in all the file upload preferences etc. but Pixel and Tonic Assets seems to want to hold on to the original path.

If I look at the database in MySQL, the old paths are there. When I go to Assets and hit "Update" indexes", nothing happens and the button gets greyed out. When I go to the Assets file manager there are no files. Just the spinning icon to the right.

So I figured I would just change the paths in the `config.php` file as such:

```
$config['upload_preferences'] = array(

        6 => array(                                                            // ID of upload destination
            'name'        => 'Homepage Images',                          // Display name in control panel
            'server_path' => '/home/content/02/xxxxxxxxx/html/images/uploads/homepage/', // Server path to upload directory
            'url'         => 'http://www.xxxxxxxxx.com/images/uploads/homepage/'      // URL of upload directory
        ),
        5 => array(                                                            // ID of upload destination
            'name'        => 'Images',                          // Display name in control panel
            'server_path' => '/home/content/02/xxxxxxxxx/html/images/', // Server path to upload directory
            'url'         => 'http://www.xxxxxxxxxxxxx.com/images/'      // URL of upload directory
        )
    );

```

But that does not seem to help either. There are a lot of files. Do I just need to leave it on the Assets file manager page and wait for the spinning icon to stop?

# Answer
> 3 votes
Thanks to the great people at PixelandTonic I have this resolved.

I was having session issues with another plugin earlier and the solution to this was to change the session preferences in the control panel from "Sessions IDs only" to "Cookies only". As usual, fixing one thing will break three. The response from P&T:

> In your security and session preferences, CP Session type was set to "cookies only" and User session type was set to "session ID only".
>
> Assets makes a lot of Ajax requests and due to the nature of EE, they can only be made via frontend, so User session is used there to determine the access privileges, and when making those requests, Assets could not determine that the user was a valid CP user, so it denied every request as a security precaution.
>
> I set them both to use Cookies only and now it all works fine. Another workable scenarion is Admin: Session And Cookies, User: Cookies.

This actually fixed a couple of other unrelated issues I was having in the control panel.

In conclusion, the issue was not due to the migration, it was always there. Just an annoyance to fix later. The migration just brought the issue to depth con 5.

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


# Question
Title: Low Search with more than one form in a single template?
I'm sure what I'm trying to do is possible but frustratingly I just can't get it to work. I have a form setup and working fine which uses category checkboxes and everything works well on the results page. However I have tried adding a similar form which searches different categories originally expecting it to work with the same results page but it doesn't output anything. I have tried giving it a different results page and again nothing is output between the low search results tag. I tried differentiating the searches by giving them different collections but this didn't work either..

Is it possible to have more than one low search form per page in this way?

Here is the form code, with the bottom one working perfectly...

```
    {exp:low_search:form collection="barristers" search_mode="all" result_page="search-barrister-practice-areas/{segment_2}" query="{segment_3}"}
                <p class="checkboxes-right">
                    {exp:channel:categories channel="barristers" style="linear" category_group="1" show="1|2|3"}
                        <input type="checkbox" name="category[]" id="{if category_id == "1"}commercial{/if}{if category_id == "2"}eu{/if}{if category_id == "3"}publiclaw{/if}" value="{category_id}"{if category_id IN ({low_search_category})} checked="checked"{/if} /> {category_name}<br/>
                    {/exp:channel:categories}
                </p>
                <input type="submit" value="SUBMIT" class="button" />
                <hr class="dotted" />
{/exp:low_search:form}

                <h3>Seniority</h3>
                <p class="checkboxes-left">
                    <input type="checkbox" name="all" value="All" id="seniorityall" /> All
                </p>

{exp:low_search:form collection="barristers" search_mode="all" result_page="search-barristers/{segment_2}" query="{segment_3}"}
                <p class="checkboxes-right">
                    {exp:channel:categories channel="barristers" style="linear" category_group="2" show="7|8|9"}
                        <input type="checkbox" name="category[]" id="{if category_id == "7"}qc{/if}{if category_id == "8"}junior{/if}{if category_id == "9"}doortenant{/if}" value="{category_id}"{if category_id IN ({low_search_category})} checked="checked"{/if} /> {category_name}<br/>
                    {/exp:channel:categories}
                </p>
                <input type="submit" value="SUBMIT" class="button" />
                <hr class="dotted" />
{/exp:low_search:form}

```

I have this test code in the results page for the form which is not outputting anything:

```
        {exp:low_search:results query="{segment_3}" collection="barristers" orderby="date" sort="desc" status="not closed" disable="member_data"}

            <p><strong> {low_search_category} </strong></p>
            {title}

        {/exp:low_search:results}

```

I'd be so grateful if someone could help with this...

Thanks,

Alex

# Answer
> 1 votes
Answering for visibility. Yes, it is totally possible to have multiple forms on one page targeting the same Results page. You do have to make sure, however, that the selected category has entries assigned to it in order for it to return results.

---
Tags: search, low-search
---


# Question
Title: Stash Issue Not Getting Values In IE 8/10 & Safari
I'm having a huge issue, not sure what caused it though. I'm using stash to get 2 values of a users account. I've been using Stash for the past 3 months to load these values into a form with no issue. This morning it no longer works in IE or Safari however works correctly in Firefox and Chrome. Any suggestions on what I should look for or what have caused this to stop working? No updates have been done to Stash or ExpressionEngine.

# Answer
> 0 votes
So apparently my server date/time was off which was causing an issue with Stash from being able to load those in Internet Explorer and Safari.

---
Tags: stash
---


# Question
Title: Calling extension or module method from plugin
I need to call an extension or module method from a plugin.

Anyone know how to do that?

Eventually solved with this code:

```
include_once(PATH_THIRD.'extension/mod.extension.php');
$this->EE->load->add_package_path(PATH_THIRD.'extension/');
$ext = new Extensionclass();
$PI = $ext->extension_function($params);

```

# Answer
> 4 votes
You can do it with the following example code within your plugin:

```
require_once PATH_THIRD."modulename/modulefilename";
$obj = new ModuleClass();
$obj->module_method();

```

Hope, it would help you.

---
Tags: module, plugin, extension
---


title: Every URL Displays Homepage

text:
# Question
Title: Every URL Displays Homepage
I'm migrating a site from Media Temple (GS) to (DV), but every URL without `index.php` returns the homepage. URLs *with* `index.php` display correctly.

FastCGI is disabled, here are the contents of my .htaccess file:

```
AuthUserFile /path/to/my/password.file
AuthName "Please Log In"
AuthType Basic

require valid-user

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
    RewriteRule ^(.*)$ /index.php?/$1 [L]
</IfModule>

```

EE 2.6.1

# Answer
> 1 votes
normally I've found this to be the URI\_PROTOCOL config setting.

Go through the range of options in config.php and you should be good.

# Answer
> 0 votes
Unless your server requires the ? to make anything that follows index.php a querystring, it's probably not necessary in your RewriteRule and could lead to the behavior you're describing.

```
RewriteRule ^(.*)$ /index.php?/$1 [L]

```

becomes:

```
RewriteRule ^(.*)$ /index.php/$1 [L]

```

---
Tags: .htaccess
---


# Question
Title: Display content if url segment does not match a url_title
I am using pages to display content on a page called Speed Sales. I display the entry by checking for segment\_2 and matching it to a channel entry basically. I need to display content in case someone spells the url wrong and it doesn't match a url\_title in my speed\_sales channel. Any ideas?

I'm assuming I might have to include a channel:entries tag with the channel="speed\_sales" and check if segment\_2 == a url\_title for an entry, then display default content if it doesn't, but am unsure how to do this correctly.

EDIT:

I have updated my template to the following:

```
<article class="text-block">
        {exp:channel:entries channel="speed_sales" dynamic="no" url_title="{segment_2}"}
                {if url_title == "{segment_2}"}
                    <h2 class="heading1 excludestrip single left">{title}</h2>
                    {if lead_copy}<p class="lead">{lead_copy}</p>{/if}
                    {if subtitle}
                        <hr/>
                        <h3 class="excludestrip">{subtitle}</h3>
                    {/if}
                    {newsletter_copy}
                {/if}
                {if segment_2 == "" || no_results}
                    <h2 class="heading1 single">Speed Sales</h2>
                    <p class="lead">You may have reached this page in error (a typo in a link, or you backspaced the URL). Please choose a newsletter from below:</p>
                        {!-- {embed="speed_sales/.newsletter_list"} --}
                {/if}
        {/exp:channel:entries}
</article>

```

The reason I included the segment\_2 check in my no\_results conditional, is because it displays nothing in the no\_results conditional (since there is no segment\_2). The page url this would need to show up on is /speed\_sales or anything under /speed\_sales. What happens is everything works properly, but the if no\_results conditional block displays multiple times instead of just once. It must be reading the amount of entries in the channel and repeating it that many times. I commented out the embedded list template to check, and it still repeats the block anyways.

# Answer
> 2 votes
The `no_results` conditional should work, something like:

```
{exp:channel:entries channel="speed_sales" dynamic="no" url_title="{embed:url_title}"}
    {if no_results}
        <!-- Content for no results -->
        {if:else}
        <!-- Otherwise ... -->
            <h2>{title}</h2>
            {if lead_copy}<p class="lead">{lead_copy}</p>{/if}
            {if subtitle}
                <hr/>
                <h3>{subtitle}</h3>
            {/if}
        {newsletter_copy}
    {/if}
{/exp:channel:entries}

```

(code untested)

See http://ellislab.com/expressionengine/user-guide/modules/channel/channel\_entries.html#if-no-results for more info.

# Answer
> 0 votes
If there's no segment\_2, the channel:entries variable pair will parse as:

```
{exp:channel:entries channel="speed_sales" dynamic="no" url_title=""}

```

See? The docs says that the default value of the `limit` parameter is 100. So, this loop will runs up to one hundred times!

My suggestion is, first, to put your code for no\_results on a snippet and set its as, let's say, `snip_no_speed_sales`:

```
<h2 class="heading1 single">Speed Sales</h2>
<p class="lead">You may have reached this page in error (a typo in a link, or you backspaced the URL). Please choose a newsletter from below:</p>

```

Then, you need to separate your conditionals to avoid the parsing of `channel:entries` variable pair and to improve the performance.

```
<article class="text-block">
    {if segment_2}
    {exp:channel:entries channel="speed_sales" dynamic="no" url_title="{segment_2}"}
        <h2 class="heading1 excludestrip single left">{title}</h2>
        {if lead_copy}<p class="lead">{lead_copy}</p>{/if}
        {if subtitle}
            <hr/>
            <h3 class="excludestrip">{subtitle}</h3>
        {/if}
        {newsletter_copy}
        {if no_results}
            {snip_no_speed_sales}
        {/if}
    {/exp:channel:entries}
    {/if}
    {if segment_2 == ''}
        {snip_no_speed_sales}
    {/if}
</article>

```

---
Tags: conditionals, embeds, url-title, segments
---


title: Date Field Format not working properly

text:
# Question
Title: Date Field Format not working properly
I have this code

```
<div class="control-group {if error:birthdate}error{/if}">
        <label class="control-label" for="birthdate">{label:birthdate}</label>
        <div class="controls">
            {if logged_out}
                <input class="span2" data-title="Help" data-placement="right" data-trigger="focus" data-content="{instructions:birthdate}" required type="date" name="birthdate" value="{if '{exp:parameters:post name="birthdate"}'}{exp:parameters:post name="birthdate"}{/if}" id="birthdate">
            {if:else}
                {birthdate}
                <input class="span2" data-title="Help" data-placement="right" data-trigger="focus" data-content="{instructions:birthdate}" disabled type="date" value="{birthdate format="%Y-%m-%d"}" id="birthdate">
            {/if}
            {if error:birthdate}
                <span class="help-inline">{error:birthdate}</span>
            {/if}
        </div>
</div>

```

The problem is that while `{birthdate}` is outputting properly, `{birthdate format="%Y-%m-%d"}` is **always** outputting `1970-01-01`.

Any idea why this is the case? I am using EE 2.5.5

UPDATE:

The actual value stored in the exp\_channel\_data is `503150405`. Converting this timestamp using this site yielded

`GMT: Wed, 11 Dec 1985 12:00:05 GMT`

The output using `{birthdate}` yields

`1985-12-12 12:00 AM`

So I think the data is not the problem.

# Answer
What is output by {birthdate} without adding any formatting?

What fieldtype are you using to store {birthdate}?

If you are using a text field, do you perhaps have the formatting set to Auto or XHTML which would cause an issue with the content being converted to a date and so fall back to the default of 1970-01-01
> 1 votes

---
Tags: date
---


# Question
Title: Set expiration_date when status changes to open
Users are able to submit an entry and it defaults to a status of 'Awaiting Moderation'. When our administrator reviews the entry and changes its status to 'Open', I would like to set the expiration date 60 days in the future.

In my extension, I've tried using the entry\_submission\_ready hook and the entry\_submission\_end hook, but I don't seem to be able to detect a difference in status.

```
public function set_expiration_date( $meta = array(), $data = array(), $auto_save = array() ) {

    $old_status = isset( $meta['status'] ) ? strtolower( $meta['status'] ) : '';
    $new_status = isset( $_POST['status'] ) ? strtolower( $_POST['status'] ) : '';

    if ( 'open' != $old_status && 'open' == $new_status && '14' == $data['channel_id'] && 'mydata' == $data['field_id_123'] ) {
        // set expiration date 60 days in the future
        $future = date('Y-m-d', time() + 60*24*60*60);
        $exp_time = strtotime(  $future . ' 23:59:59' );
        $data['expiration_date'] = $exp_time;
    } else {
        return;
    }
}

```

When using entry\_submission\_ready, `$old_status` and `$new_status` always seems to be the previous status. And with entry\_submission\_end, `$old_status` and `$new_status` are always the next status. So `$_POST` is changed.

I don't understand how to use this EE hook. What am I missing?

# Answer
> 0 votes
The extension hook entry\_submission\_ready is being called just prior to insertion / update so you should use this hook rather than entry\_submission\_end.

As you are calling this extension while an entry is being updated so you can get the Status of that entry using the SQL like:

```
$old_status = ee()->db->select('status')->where('entry_id', $data['entry_id'])->get('channel_titles')->row('status');

$new_status = $meta['status'];

```

You can do further processing as your code.

I hope, it would help you.

---
Tags: status
---


# Question
Title: Expresso Store - Why is there no action="" attribute tag?
## When Store generates a form from a tag such as:

```
{exp:store:product entry_id="{entry_id}"}

```

**This outputs the below:**

```
<form method="post" id="" name="" class="store_product_form">
<div style="margin:0;padding:0;display:inline;">
<input type="hidden" name="return_url" value="products">
<input type="hidden" name="entry_id" value="45">
<input type="hidden" name="ACT" value="88">
<input type="hidden" name="RET" value="products">
<input type="hidden" name="site_id" value="1">
<input type="hidden" name="_params" value="Uy1bcQE4CWMFIFZ9AXhQDgsxU2cBLgAyBSYDZgA1UCcJfFUhUjYHOgVjDHZdeAF1UndXa105AlwLKAc2DHNVPFQ4U3FWdFI9D2cFLg==">
<input type="hidden" name="XID" value="6642e568194f9a1872e398f2739ce8aa591a6436">
</div>
</form>

```

Why is there no **action=""** set on this form? It appears to be using the ACT to submit to the index.php but if that isn't set in the config it falls over.

**Is this an expression engine philosophy or just store?**

I also wanted to know what the logic/thought behind this decision and if it's able to be modified?

# Answer
> 4 votes
It's a combination of Store's philosophy and ExpressionEngine's internals.

Leaving out the action attribute in a form tag is valid HTML5, and simply means "post to the current page". We've tested this back to IE6 and have found no compatibility issues.

Store used to use EE's native methods to get the current page URL, and use that when generating the form as the action attribute. However, these days lots of people are using plugins like Structure, and routing plugins like Freeway which modify the page URL, and trick EE into displaying a different page to the URL. In those cases, Store would submit the form to a different page than the current page, which would lead to unexpected behavior like displaying a totally different page if there were errors on the form. That is why it is preferrable to just tell the browser "post to the current page", and let the browser figure out the URL rather than trying to do anything complex in EE.

Now, the second part is how ExpressionEngine handles form submissions. If you POST to *any* url of an EE site, with an ACT parameter, EE treats this as an action request. It's exactly the same as requesting `index.php?ACT=123` \- the ACT parameter can be sent via POST or GET, it doesn't matter. In this case, the ACT parameter belongs to Store, which handles the form submission. Store processes the request, and if there were errors, it simply instructs EE to continue rendering the current page (which is why we post to the same URL, so we can display inline errors). If there were no errors, Store updates the cart, and redirects appropriately. This is exactly the same process Safecracker and many other add-ons use to render inline errors.

So, to answer your question - yes, it's expected behavior, and no, you can't change it (without hacking Store's files). I don't know what you mean by "if that isn't set in the config it falls over", but you shouldn't have to configure anything to make it work.

---
Tags: expresso-store, add-on
---


# Question
Title: DB error after upgrading to Playa 444: Duplicate column name 'parent_var_id'
After updating an EE 2.5.5 site to the latest playa 4.4.4., an error showed up when trying to access the FieldType settings screen.

> A Database Error Occurred
>
> Error Number: 1060
>
> Duplicate column name 'parent\_var\_id'
>
> ALTER TABLE exp\_playa\_relationships ADD parent\_var\_id INT(6) UNSIGNED AFTER parent\_row\_id, ADD INDEX (parent\_var\_id)
>
> Filename: \[redacted\]/playa/ft.playa.php
>
> Line Number: 423

I was in the process of upgrading the site to EE 2.6.1. so I carried on and the error still shows after performing the upgrade. It seems that the site is still functional, I see no error when accessing pages making use of playa or when using the fieldtype in the CP.

Anyone experienced this? P&T guys?

# Answer
The guys at P&T did come back to me in less than 24 hours with a fix. I'll post it here in case someone runs into the same problem.

> Take a look at the columns in exp\_playa\_relationships table in the database.
>
> * Does it have a field parent\_var\_id? If no, then the version you should set is 4.1.
> * If yes, does it have a field parent\_is\_draft? If no, then the version you should set is 4.3
> * If yes, then the version you should set is 4.4.4
>
> Now, set the version number we determined in the previous three steps for the Playa field in the exp\_fieldtypes table and go visit the Add-ons -\> Fieldtypes -\> Playa page and hit submit.
>
> Everything should be all working now.
> 21 votes

---
Tags: playa, error, upgrade
---


# Question
Title: User:Register, checkboxes for multiple mailing lists?
I'm trying to implement checkboxes to allow new members to signup for multiple mailing lists instead of the multiple select dropmenu option.

Any help would be greatly appreciated.

Thanks in advance.

# Answer
> 0 votes
You don't *have* to create a **select** field for mailinglists in `{exp:user:register}`. You can modify the code in the docs (http://www.solspace.com/docs/user/register/#select\_mailing\_lists) for your own purposes, for example to something like:

```
{select_mailing_lists}
<input type="checkbox" name="mailinglist_subscribe[]" value="{list_id}" id="mailing_list_{list_id}" /> <label for="mailing_list_{list_id}">{list_title}</label>
{/select_mailing_lists}

```

The key here (and in many EE forms) is to pass the right name="". Please note the brackets `[]` in each field's name="" attribute. This allows for multiple selected mailing lists to be submitted with the form.

---
Tags: solspace-user
---


title: https in Broken in Chrome with Store

text:
# Question
Title: https in Broken in Chrome with Store
When I test my new story (express-store) in chrome and I get to the checkout part and the https kicks in the style sheet breaks. and the yellow lock icon appears in the address bar. The images load on the page but not the styles. However, in Safari or Firefox this does NOT happen and it lets me complete the purchase. Running the last version of both EE and Express-Store).

# Answer
Sounds like your CSS/JS is not being loaded from a secure URL. Check your developer console to see where they are being loaded from.
> 0 votes

---
Tags: expresso-store
---