# Question
Title: Freeform Pro: Notifying Any Email Except Domain Email
I've tried searching the the forums for an answer, but this one's got me buggered.

I set up Freeform Pro the same way I've always done. I originally tested it using my email address, and everything worked fine.

But when I changed the "admin\_notify" email to the client's email, they don't get the message. I confirmed that it's not going in their spam folder.

I had them give me an alternate email. They gave me a personal Hotmail email, submitted the form, and they got the form submission.

So it seems like any email other than their domain email will go through. Sounds like a server/email issue, but any thoughts?

Here's my Freeform Pro code just in case I'm missing something.

```
        {exp:freeform:form
        form_id="3"
        form:class="required"
        notify_admin="yes"
        user_email_field="email"
        admin_notification_template="contact_notify"
        admin_notify="info@creativeitaz.com"
        return="contact/thank-you"
        }

```

# Answer
> 3 votes
A few things to look at here;

Do they route their email through a different server to the web traffic? i.e. Do they have an MX record set up for their domain. If so, does that same MX record exist for the server currently hosting the site?

I see this from time to time with some sites I host where the client has their email handled elsewhere (say by a mail filtering service or to an exchange server). Because I have configured the hosting account to serve the website for somedomain.com it assumes that it also handles the email. So when email is generated by the site (ie within it's own network) it tries to deliver it within its own network. The solution is to add the MX record to the server so it sends mail to the right place.

Some mail servers will blackhole email that appears to come from the same domain sending it but has originated elsewhere or mail which doesn't have a sender name and email information. So check that you are including a sending name and email and, if the sender's email is the same domain as the recipient check that an actual mailbox/account exists for the sender.

To put it more simply, if your form appears to come from website@creativeitaz.com then ensure there is actually an account for website@creativeitaz.com

---
Tags: solspace-freeform, notification
---


title: alternative to php var in template?

text:
# Question
Title: alternative to php var in template?
It's been a solid year since my last ee project. The things you forget over time :)

At the top of my template I show the latest featured entry (limit="1" search:featured="yes"). Later in my template I'm showing all entries but need to add an additional class to the above featured entry.

By enabling php on the template I can save the entry\_id in a variable and then check it in the lower exp:channel:entries.

Are there any issues with enabling php for something minor like this - performance, security? Is there a better way to hold this value?

Thanks! Amanda

# Answer
> 2 votes
You'll need an embed, with or without stash.

I always prefer to not use add-ons if I can. So, without stash:

```
{exp:channel:entries status="featured" limit="1"}
    <div class="featured">
    [...]
    </div>
    {embed="entries/.list" featured_id="{entry_id}"}
    {if no_results}
        {embed="entries/.list" featured_id="0"}
    {/if}
{/exp:channel:entries}

```

On the embed entries/.list:

```
{exp:channel:entries status="featured|open"}
    <div {if entry_id == {embed:featured_id} }class="featured" {/if} >
    [...]
    </div>
{/exp:channel:entries}

```

# Answer
> 1 votes
Amanda,

I'm reading this as you have two different channel:entries tag where the first tag only displays the featured entries and the second tag displays all entries. If this is correct then you can use a conditional inside the second tag go do what you want as per my example below.

```
<div class="whatever {if featured="yes"}my_class{/if}">
more code
</div>

```

If I have misread, please clarify wiht more details and/or template code.

You could also look at using Stash if the above isn't what you need, but I've never been able to fully grok Stash.

# Answer
> 0 votes
Just to add the alternative, an example using Stash:

```
{exp:channel:entries channel="your_channel" limit="1" status="Featured"}

    {exp:stash:set name="cached_featured_entry_id" trim="yes" output="no"}
        {entry_id}
    {/exp:stash:set}

    <p>{title}</p>

{/exp:channel:entries}

{exp:channel:entries channel="your_channel" status="open|Featured"}

    <p {if {exp:stash:get name='cached_featured_entry_id'} == {entry_id}}style="font-weight:bold;"{/if}>
        {title}</p>

{/exp:channel:entries}

```

---
Tags: templates, php, variable
---


# Question
Title: Create (generate) download links from files on server
My client wants to hold its PDF documents library for reference and easy-always-wherever access. The problem is that the library holds more than a thousand study documents. It's impossible to manually create an entry for each document, so I was wondering if there's a simpler way to just create a list of links for every document in a specific folder.

Notice that the "entries" won't have a link to a special page, or comments, description, don't need to show creation date or any other metadata. It would be sufficient with just a link to the PDF and that's it.

# Answer
You could also achieve this using the Files module and File Entries tags. The Files module works much like Entries but you don't have to create them. Simply create an upload directory and put the files in there. Then sync the directory. To add a file to the directory you can use the File upload feature of the CP.
> 1 votes

# Answer
You could use Channel Files or Assets and have all of those documents attached to 1 single entry.

Avoid using raw PHP in templates. If you must use PHP, extract it to a plugin.
> 2 votes

# Answer
It can be possible with the PHP code within the template. Just create a template with "Allow PHP?" as "Yes" and use following code example:

```
$library_dir = "/library/directory/path/";

$pdfs = glob($library_dir . "*.pdf");

foreach($pdfs as $pdf)
{
    echo "<a href='[YOUR SITE URL]".$pdf."'>".$pdf."</a><br />";
}

```

I hope, it would help you.
> 1 votes

---
Tags: plugin, list, files
---


title: PHP Cart Object for Expresso:Store

text:
# Question
Title: PHP Cart Object for Expresso:Store
Is there a cart object for Expresso:Store? Something like "$this-\>EE-\>cartObject" where I can access the items that is in the cart? The purpose of this is to find out which category the item is in and if it is in a category that does not ship to a country it will display a warning message and blank out the 'confirm purchase' button.

Regards, Rin

# Answer
> 1 votes
Yes, you can access it like this:

```
ee()->store_cart->contents();

```

There are also many extension hooks you can use if you want to validate the cart when it is updated.

---
Tags: expresso-store, categories, php, checkout
---


# Question
Title: Fieldpack 2.1 (P&T) EE2.6.1 and Safecracker Dropdown Not Working
I've just upgraded a site to EE2.6 with P&T Fieldpack 2.1

all of my safecracker dropdowns are now giving {option\_name} instead of my proper Options. My dropdown template code is using the following

{options:myfieldname} {option\_name} {/options:myfieldname}

This code output correctly with EE2.5.5 and P&T Dropdown 1

Can anyone help out with the correct Dropdown syntax or a working solution?

# Answer
> 5 votes
The `{options:field_name}` tag pair is actually a Safecracker tag, which only works with Field Pack 1.x out of the box. You can add Field Pack 2.x support by opening up system/expressionengine/config/config.php and adding these lines:

```
$config['safecracker_option_fields'][] = 'fieldpack_checkboxes';
$config['safecracker_option_fields'][] = 'fieldpack_radio_buttons';
$config['safecracker_option_fields'][] = 'fieldpack_dropdown';
$config['safecracker_option_fields'][] = 'fieldpack_multiselect';
$config['safecracker_option_fields'][] = 'fieldpack_pill';

```

---
Tags: ee2, safecracker, pixelandtonic, field-pack
---


title: Wygwam 3 and tables

text:
# Question
Title: Wygwam 3 and tables
I just upgraded to Wygwam 3 and I noticed whenever I cut and paste table tags within the source code field the tables get stripped out and replaced with `<p>` tags. Inserting other code within the source option works fine.

Has anyone noticed this?

# Answer
> 2 votes
As of Wygwam 3.1 you can turn off the "Restrict allowed HTML?" setting.

This was a feature to prevent people from adding unwanted HTML to their content fields.

---
Tags: wygwam
---


title: Unlimited Private Messages

text:
# Question
Title: Unlimited Private Messages
I see in the Member Groups Preferences(Member -\> Member Groups -\> Edit Group) that there is an option for "‘Maximum Number of Private Messages a user can store".

If I set it to 0, will this make this unlimited? If not, how do I make it unlimited?

# Answer
> 1 votes
Setting to 0 makes it unlimited.

Thanks to @Bhashkar for the answer

http://ellislab.com/forums/viewthread/237065/

---
Tags: messages
---


title: P&T Assets - How to show no results?

text:
# Question
Title: P&T Assets - How to show no results?
i was playing around with Assets 2.1.4 and i was wondering if there is any way of checking for no results.

My code:

```
{my_assets_field limit="30" offset="80"}
    <li><a href="{url}" alt="{alt_text}">{filename}</a></li>
{/my_assets_field}

```

Example of what i have in mind:

```
{my_assets_field limit="30" offset="80"}
    {if no_results} the end{/if}
    <li><a href="{url}" alt="{alt_text}">{filename}</a></li>
{/my_assets_field}

```

I'm doing a ajax call to this template and i need to know when i reach the end.

Thanx

# Answer
> 1 votes
I use:

```
{if my_assets_field}
{my_assets_field limit="30" offset="80"}
    <li><a href="{url}" alt="{alt_text}">{filename}</a></li>
{/my_assets_field}
{if:else}
the end
{/if}

```

But I don't know if this solution works for what you need with your ajax call.

---
Tags: assets, conditionals, module, no-results
---


# Question
Title: Listing channel entries by parent and siblings
I have a channel called fruit. There is a custom field called 'parent' of type 'relationship' in this channel. The relationship is set to channel fruit.

When I edit my entries in this channel, I can set the field called parent to any of my other entries.

Example entries...

* Orange
* Banana
* Apple
* Pear (parent is Grape)
* Grape
* Lemon (parent is Banana)
* Strawberry (parent is Apple)
* Kiwi (parent is Grape)
* Mango (parent is Apple)

Based on the above, with my setting of some entries to be parents of other entries, a list would appear as...

* Apple
    + Strawberry
    + Mango
* Banana
    + Lemon
* Grape
    + Pear
    + Kiwi
* Orange

Now I want to setup an ordered list to display this relationship **dynamically** so that the generated code results in...

```
<ul>
  <li>Apple
    <ul>
      <li>Strawberry</li>
      <li>Mango</li>
    </ul>
  </li>
  <li>Banana
    <ul>
      <li>Lemon</li>
    </ul>
  </li>
  <li>Grape
    <ul>
      <li>Pear</li>
      <li> Kiwi</li>
    </ul>
  </li>
  <li>Orange</li>
</ul>

```

I have been reading about the new way EE handles parent-child-sibling relationships in the Docs. But I am having problems coding the above.

Cheers

# Answer
> 1 votes
Not tested, but this *should* work. We're checking to see if each fruit has parents, and if it *doesn't*, then we display it (and any child fruits). It would be helpful if the fieldtype had something like Playa's `:total_parents` and `:total_children` tags, but it doesn't (which is one of the many reasons I still use Playa).

```
<ul>
{if '{parents field="child_fruit"}{title}{/parents}' == ''}
    <li>
        {title}
        {child_fruit}
        {if child_fruit:count == "1"}<ul>{/if}
            <li>{title}</li>
        {if child_fruit:count == child_fruit:count:total_results}</ul>{/if}
        {/child_fruit}
    </li>
{/if}
</ul>

```

---
Tags: relationships, navigation, related-entries, reverse-related-entries, list
---


# Question
Title: After ee update custom links doesn't work anymore
the title described it. After the ee update i wasn't able to click on my custom links in the ee main bar anymore. It throw me always out of my login session. I had to re-add each of my custom links to get it working.

**UPDATE:** I updated from 4.3.3 to 4.4.5. The behaviour was the same in an older update i did before. I added the links always via your +Add button and after an update, these links always fail. I think it's because a session or id is saved also inside the links. For example here is one of my old ones...

```
http://url.de/backend/index.php?S=56ddd7c4744a94b131bcd8f0bdb6f61965476ed5&D=cp&C=addons_modules&M=show_module_cp&module=zenbu

```

I always login via /system/ or in this example via /backend/ instead of admin.php, because there were always some issues in the past, but i can't remember by now.

Is there any other solution for this?

Thanks

Peter

# Answer
> 1 votes
I think it's because the sessions are handled differently in the most recent versions of EE.

I fixed it on a couple of sites of mine just by recreating the links. If you're still having issues then I'd suggest removing the session hash from the URL.

So http://url.de/backend/index.php?S=56ddd7c4744a94b131bcd8f0bdb6f61965476ed5&D=cp&C=addons\_modules&M=show\_module\_cp&module=zenbu

Would become http://url.de/backend/index.php?cp&C=addons\_modules&M=show\_module\_cp&module=zenbu

---
Tags: navigation
---


title: Matrix fields & flexslider

text:
# Question
Title: Matrix fields & flexslider
I'm using the flexslider to create a carousel of pictures and use channel entries to populate the list items (images) that the flexslider uses to create the carousel.

Now I want to add a link to a pdf on al those list items that I have in a matrix field in the channel and that works also but only for the first list item.

Anybody nows why this is?

```
<div class="flexslider">
    <ul class="slides">
        {exp:channel:entries channel="lr_press"}
            {if press_slider_switch != ""}
            {press_artikel}
            <li><a href="{press_document}" targat="_blank"><img src="{press_beeld}" alt="{title}" /></a></li>
            {/press_artikel}
            {/if}
        {/exp:channel:entries}
    </ul>
</div>

```

# Answer
> 0 votes
I suggestion - but I would recommend having the markup for the slider inside your entries loop - that way if no results are returned, absolutely no slider markup winds up in the page template. So like this:

```
{exp:channel:entries channel="lr_press"}
    {if count == "1"}
    <div class="flexslider">
        <ul class="slides">
    {/if}

    {exp:switchee variable="{press_slider_switch}" parse="inward"}
        {case value="on"}
             markup for ON items (so your matrix field, I believe)
        {/case}
        {case value="off"}
             markup for OFF items
        {/case}
    {/exp:switchee}

    {if count == total_results}
        </ul>
    </div>
    {/if}
{/exp:channel:entries}

```

With regard to what's going on for each list item - if you describe in a bit more detail what "press\_slider\_switch" is - as a conditional wrapped around your list items, it can certainly have a big impact on what's generated for your slider - then I might be abel to assist further.

EDIT: Added switchee example to the markup above. Also - one thing you might consider is using Entry Type add-on in place of switch. It has the same effect, really, except that it would allow you to hide/show your matrix field only for the switch values for which it is relevant - more for user-friendliness for the editor than anything - not much different in terms of the data or templating.

---
Tags: matrix, channel
---


# Question
Title: Can I (a) rename sticky to something like member, or recreate sticky functionality with a channel field?
I want a checkbox called members and when a lodging is searched for, I want members to display first and the rest to be alphabetized underneath. I know I can do this via the sticky function, but the wording of it is confusing to the client. Is there a plugin that will let me rename it or a method to do what I want to do?

Currently, using low search, if I order it ascending, which i need for alphabetization, my members are added to the bottom of the list, but if I go descending then everything is reverse alphabetized.

```
{exp:low_search:results
    query="{segment_3}"
    limit="10"
    paginate="bottom"
    dynamic="no"
    orderby="lodging_swita_member|title"
    sort="asc"
}

```

# Answer
This is a good reason to separate your data fetching from your data output using Stash. The parse order can get tricky, but this should work... It uses the P&T checkbox-group fieldtype to tick an entry as being a 'member':

```
{!--  ============================================
STASH INTO A SINGLE LIST
================================================== --}

{exp:stash:set_list
    name="results"
    parse_tags="yes"
    parse_conditionals="yes"
}
    {exp:low_search:results
        query="{segment_3}"
        limit="10"
        paginate="bottom"
        dynamic="no"
        orderby="title"
        sort="asc"
    }
        {if {cf_options:selected option="is-member"}}
            {stash:is-member}yep{/stash:is-member}
        {if:else}
            {stash:is-member}nope{/stash:is-member}
        {/if}
        {stash:the-title}{title}{/stash:the-title}
        {stash:the-url}{permalink}{/stash:the-url}
        {stash:the-summary}{cf_summary}{/stash:the-summary}
    {/exp:low_search:results}
{/exp:stash:set_list}

{!--  ============================================
START OUTPUT
================================================== --}

<ol>
{exp:stash:get_list name="results" match="#^yep$#" against="is-member"}
    <li>
        <a href="{the-url}">
            <h3>{the-title}</h3>
            <p>{the-summary}</p>
        </a>
    </li>
{/exp:stash:get_list}

{exp:stash:get_list name="results" match="#^nope$#" against="is-member"}
    <li>
        <a href="{the-url}">
            <h3>{the-title}</h3>
            <p>{the-summary}</p>
        </a>
    </li>
{/exp:stash:get_list}
</ol>

```

If you want to make it DRY-er you could use a snippet for the markup inside the two get\_list sections.
> 1 votes

# Answer
I agree - sticky is a pain. Yes, you can do it that way with a distinct custom field, though that's not how I would recommend approaching it - because without an add-on like Zenbu, you wouldn't be able to see that custom field from the main list edit screen - one of the few advantages of the sticky field is that it is present on the main list edit screen. But so is status. As of version 2.5.4, status is available for use in orderby. And while the label of "status" isn't ideal, since you can create a custom status of "member" and use status in your orderby param, maintaining your ability to group your members together at the top of the list, and still have alphabetization within each grouping.

Hope that helps.
> 1 votes

---
Tags: channel-entries, low-search, sort, orderby
---


title: Categories show only childrem

text:
# Question
Title: Categories show only childrem
is there a trick to only showing ONLY the children of a certain category?

```
{exp:gwcode_catmenu show="5" cat_id="5"}
<a href="{path='catmenu-demo/example1/{complete_path}'}"{cat_name}</a>
{/exp:gwcode_catmenu}

```

Trying to only show the children of cat 5, all parent categories are showing as well as the children of 5

```
-Bestseller
-New
-Featured
-Hunting (id 5)
----Accessories
----Calls
----Cameras
----Decoys
----Bags/Cases
----Face Paint / Scent Elimination
----Knives
----Deer Scents
----Range Finders / GPS
----Videos
-Fishing
-Archery
-Shooting
-Clothing
-Footwear

```

# Answer
Add the cat\_id="" parameter. This will show child categories for that category ID.
> 1 votes

---
Tags: categories, gwcode-categories, children
---


# Question
Title: How to quickly grab an entry's category (and child categories)
EE experts --

I must be missing something. It seems that the only way to grab the categories for an entry is via a sub-query, using GWcode, for instance. Categories are not readily available like they would be for custom fields or {title}.

This is a big pain for a few reasons. Take a site, like the site I am developing for a client -- a craigslist spin-off. Every entry has a category (Events, Free, etc). Each entry also has a Location category. Seattle (child), Washington (parent category).

Now, whenever I list entries from search results, etc, I have to use a pliugin (EE's favorite answer) to list the category and location of the entry.

This completely destroys performance. So I talk to EE support, they say my code looks good, try caching. Fine. Caching is a reasonable answer. It works well enough for this, but not always. Anytime, anywhere I need to list entries in a custom query (for the current\_user, for example) I get slammed by this bottleneck.

Maybe my question is about caching? Can anyone here speak to the larger issue? This is likely my last project in EE because of this issue. Is a design flaw in my structure? Surely I'm not alone on this?

# Answer
Doesn't the {categories} tag pair work with search results?

You can restrict the categories by group, or exclude some categories if you don't want them to show up. I use gwcode in some situations, but most of the time this tag pair takes care of things.

Check the docs here: http://ellislab.com/expressionengine/user-guide/modules/channel/channel\_entries.html#variable-pairs

Hope this helps.
> 1 votes

---
Tags: categories, caching, speed
---


# Question
Title: After moving EE to a new server front-end hangs and never loads
Moving EE between QA servers and experiencing an issue. The CP loads right up without issue. Can go straight to the home page as well (which is not managed with EE). However, when going to the `blog` channel (currently the only content we have managed with EE) the page gets stuck loading and never displays any content or errors. The loader in Safari's address bar just stop at about 10% and never loads.

Suggestions on places to look for issues? I've double/triple checked all paths and everything looks correct.

# Answer
> 1 votes
If you go to `(domain_name)/index.php` does the page load? If this works I would suggest looking at your .htaccess file (supposing your server runs Apache), making sure it was copied correctly and nothing needs to be changed.

UPDATE: Since you say your page does finally load but after a crazy number of seconds, I recommend you try the following steps to troubleshoot your issue.

1. Install EE Debug Toolbar;
2. In the control panel, go to Admin\>System Administration\>Output and Debugging and turn on "Display Template Debugging?";
3. Reload your front end page (while still logged in to the control panel as super admin);
4. Use EE Debug Toolbar to identify any pain-points. The toolbar will show you the total template rendering time in the fifth box, and query execution time in the last box. Clicking on either will give you more detail.

EE Debug Toolbar's GitHub readme page gives you a high level idea of what the toolbar looks like and how it works.

Try these steps, see if it doesn't point out anything obvious to you, and if you have more symptoms but no answers, update your question so we can troubleshoot further. Best of luck!

# Answer
> 0 votes
Did you change all the server paths? Assuming they differed between the servers.

---
Tags: server-migration, loading-time
---


title: E-greeting card functionality with EE?

text:
# Question
Title: E-greeting card functionality with EE?
I'd like to recreate an "e-greeting card" functionality using EE, and I'm wondering if this could be done with the core functionality of EE, or if it would require custom programming.

The functionality is as follows.

1. User clicks on an image they like for the "front" of their e-card, and is then presented with a form with 5 fields: "From" name, "From" email, "To" name, "To" email, and "message"
2. After filling form and clicking "send", system generates the following:

* A URL where this card now lives. The URL allows you to see the card's "front" and "back". The front is an image that the user selected. The back displays info the user entered--email, message, etc
    * An email to the recipient with another URL link where the receiver can see it
    * If the receiver clicks on the link, the sender also gets an email confirming the card was read

Any thoughts? Thanks!

# Answer
So you've got a image and a form to capture the content.

* You'll need to overlay the form text on the image: CE Image can help here
* A custom URL generator (like Solspace's Shortcut; there are others in Devot-ee)
* Solspace's Freeform can capture the form data, including the recipient address for forwarding
* Mail notification can be done with a hidden form on the display page, triggered by something like Adam Kahn's Send Email or Mike Rog's Email from Template
> 1 votes

---
Tags: ee2
---


title: Problem with “Export entries as CSV”

text:
# Question
Title: Problem with “Export entries as CSV”
I got a problem with “Export entries as CSV” Few months ago, this one was working well. When I click it, I can get/download an excel file which contains all the entries. Few days ago, I still could download excel file but it did not contains anything. Now, I can download excel file but it shows something like ‘your storage is full’.

I think the database which stores the entries is full. But I asked the host guy and he said the database on my plan is unlimited. So my question is:

Is there an option to control the limitation for storage of database in expression engine (control panel) ?

# Answer
> 1 votes
It could be that your hosting accounts' file storage is full? Have you tired clearing ./system/expressionengine/cache/ ?

---
Tags: solspace-freeform, entries, export
---


title: Playa - Next / Previous Sibling

text:
# Question
Title: Playa - Next / Previous Sibling
Is there a way in Playa, or by hacking Playa, to select the previous or next sibling to the current entry? I can't find anything in the docs.

Ideally, something like this (assuming we use the existing P&T tag)

```
{exp:playa:siblings entry_id="5"}

   {previous}
        <a href="{path=template/{url_title}}">< Previous</a>
   {/previous}

   {next}
        <a href="{path=template/{url_title}}">Next ></a>
   {/next}

{/exp:playa:siblings}

```

Or as it's own tag:

```
{exp:playa:prev_sibling entry_id="5"}
        <a href="{path=template/{url_title}}">Previous ></a>
{/exp:playa:prev_sibling}

{exp:playa:next_sibling entry_id="5"}
        <a href="{path=template/{url_title}}">Next ></a>
{/exp:playa:next_sibling}

```

Any ideas?

# Answer
This add-on may be worth a try:

http://devot-ee.com/add-ons/advanced-prev-next-entry

Version 1.2.0 added a tiny bit of Playa support. I'm not sure it will suit your needs or not though, take a look just the same; if you want.
> 1 votes

# Answer
Late reply, but I suspect the best way to do this may be to pass sibling id's using {exp:playa:sibling\_ids} ( http://docs.pixelandtonic.com/playa/templating/module/sibling\_ids.html ) to the native EE next / previous entry tags - {exp:channel:next\_entry} and {exp:channel:prev\_entry} ( http://ellislab.com/expressionengine/user-guide/modules/channel/entry\_linking.html ).
> 1 votes

---
Tags: playa, pixelandtonic, next-prev
---


title: Showing all forms

text:
# Question
Title: Showing all forms
I need to show all forms on one page dynamically.

I'm doing this:

```
{exp:freeform:form form_name="one-of-my-forms"}
{freeform:all_form_fields}
    <label>{freeform:field_label}</label>
    {freeform:field_output}
{/freeform:all_form_fields}
<p>{freeform:submit}</p>
{/exp:freeform:form}

```

But as you can see, I've specified a form\_name.

How do I get ALL forms without knowing how many there are..?

# Answer
The Freeform info tag pair, when used without a form\_name or form\_id param, outputs a list of the available forms. You may be able to use this loop to allow you to pull each form one after the other - with stash, you could stash the list of form IDs and then use them to output each form with its respective ID. Simplified view below:

```
{exp:stash:set_list name="freeform_ids" parse_tags="yes"}
    {exp:freeform:form_info}
        {stash:the_form_id}{freeform:form_id}{/stash:the_form_id}
    {/exp:freeform:form_info}
{/exp:stash:set_list}

```

And then later in the parse order:

```
{exp:stash:get_list name="freeform_ids"}
    {exp:freeform:form form_id="{the_form_id}"}
        {freeform:all_form_fields}
            <label>{freeform:field_label}</label>
            {freeform:field_output}
        {/freeform:all_form_fields}
        <p>{freeform:submit}</p>
    {/exp:freeform:form}
{/exp:stash:get_list}

```

That would output a "list" of your forms for each stashed form ID.
> 0 votes

---
Tags: forms, solspace-freeform, solspace
---


title: Check Expresso Store SKU and redirect

text:
# Question
Title: Check Expresso Store SKU and redirect
Folks:

I've got a complicated setup where I can't use the standard Store shipping options. Instead, shipping options need to be stored as price modifiers. The only SKU that will be generated for a product is for these shipping options and they can only select one. For example, if they select Canada, the SKU is can. If they select France, the SKU is France.

Now, for Canada, tax needs to be applied so users have to go through an extra step. I would like to evaluate if the SKU is can. If yes, they are redirected to a new page where they select their province (taxes vary by province).

For the life of me, I can't seem to get the eval working. The SKU is clearly there and changes if I change the country. I can even trace the SKU as can or france or whatever. But the if statement doesn't actually do anything. The code:

```
{if {sku}==can}
    {redirect="store/step_1a"}
{/if}

{if {sku}!=can}
    {redirect="store/step_2"}
{/if}

```

This is just one variation. I've tried with quotes and without. I've used NSM Transplant (http://ee-garage.com/nsm-transplant) to isolate the SKU and use the results from that. Still no go.

Any assistance would be appreciated.

# Answer
> 1 votes
Definitely needs to look like this:

```
SKU is {sku}.

{if "{sku}" == "can"}
    {redirect="store/step_1a"}
{/if}

{if "{sku}" != "can"}
    {redirect="store/step_2"}
{/if}

```

If this isn't working and {sku} is displaying correctly in the above code, then you have a parsing issue, whereby the conditionals are being parsed before the {sku}. In that case, please provide the surrounding code to see how you're outputting the {sku}.

---
Tags: expresso-store
---


title: Can't get past login screen

text:
# Question
Title: Can't get past login screen
I have an EE site on 2.5.2 that just reloads the login screen whenever I click login. This is happening for all users and user groups, and in multiple browsers.

EngineHosting suggested I edit the config file to add:

$config\[‘admin\_session\_type’\] = “c”;

This did not solve, unfortunately. Any thoughts?

Many thanks.

# Answer
Try adding the following and change the cookie prefix:

```
$config['cookie_domain'] = "";
$config['cookie_path'] = "";
$config['cookie_prefix'] = "";
$config['admin_session_type'] = "s";
$config['user_session_type'] = "c";
$config['require_ip_for_login'] = "n";
$config['require_ip_for_posting'] = "n";
$config['secure_forms'] = "n";

```
> 6 votes

---
Tags: control-panel, login
---


# Question
Title: replace_tag() receiving NULL for field data
I am creating my own custom field type, and my replace\_tag function is as follows:

```
function replace_tag($data, $params = array(), $tagdata = FALSE) {

    return $data; // NULL

}

```

The problem, as noted in the code, is that `$data` has no value. I have verified that the channel entry i'm display is correct, that field's data is properly stored in the database, and that if I manually set a value for `$data` inside the `replace_tag()` function, it prints to the template just fine.

Any suggestions as to what could be going wrong?

Thanks!

P.S. I started a thread here but never got responses. Trying this instead.

# Answer
As pointed out by Rob Sanchez, my pre\_process function wasn't returning field data.

If you have the pre\_process function in your fieldtype class file but it doesn't return the $data parameter that it accepts, nothing will get passed to the replace\_tag() function.

(**Edit**: clarity)
> 1 votes

---
Tags: fieldtype
---


title: Safecracker with JSON and MX Notify

text:
# Question
Title: Safecracker with JSON and MX Notify
I am having a bit of a issue when it comes to using MXNotify module and submitting a form with safecracker.

What's happening is if all fields are correct, it will save the post, and send the email, but it breaks my javascript submit, as it does a 302 redirect, and doesn't respond with the JSON my submit function is expecting. Therefore I can't use ajax to show the success. Are there any ways to still get my custom email sent on updating this channel, and still get a JSON response on success?

If this helps:

> {exp:safecracker channel="deal\_registration" return="deal-registration" error\_handling="inline" json="yes" include\_jquery="no" class="registration-form" safecracker\_head="no"}

The URL is site.com/deal-registration and it posts back to it self to show the AJAX responses.

# Answer
I'm not all that familiar with MX Notify, but I can't imagine why it's impacting the response given.

You might try using Objective HTML's Postmaster instead. Being a commercial add-on it'll offer better support should you have any problems with it.
> 1 votes

---
Tags: safecracker, notification, json
---


# Question
Title: Ordering CartThrob products by price when some have options
I'm working on a small CartThrob site at the moment. The site uses 'points' rather than real currency.

Products are stored in the "products" channel which contains a custom field for the points value of each product. There is also an options field to handle sizes/colours etc.

I have elected to use the points field by default but if a product has options then the points field is left at 0 and the price for each option entered in the options field - I find this easier for the client to understand than have them entering price differences for options.

Now, I need to order the products by price from lowest to highest. This is simple enough where there are no options but is it possible to include those products with option pricing in this ordering?

I'm using the obvious entries tag;

```
{exp:channel:entries channel="products" dynamic="no" orderby="price" sort="asc"}
... product stuff ...
{/exp:channel:entries}

```

It would be lovely if I could do something like;

```
{exp:channel:entries channel="products" dynamic="no" orderby="price|options:price" sort="asc"}
... product stuff ...
{/exp:channel:entries}

```

I'm hoping I can weave the option products into this somehow without having to resort to setting a "base price" on each one and have the client enter price diffrences for each option.

Is there a way to do this?

# Answer
> 1 votes
Here are some suggestions:

1. Bite the bullet and use the pricing how CT intended. Have a base price field and use modifiers.
2. Keep the base price at 0, and use modifiers to show the total prices, like you want. But add a 'sorting price' or 'minimum' price purely for the purposes of ordering by price in your templates.

If you decide to go with option 1, you can show the total prices rather than +20 by using the arithmetic tag.

```
{exp:channel:entries channel="products" orderby="base_price"}
  <h1>{title}</h1>
  <h2>Options</h2>
  {product_options}
    <h3>{option_name}</h3>
    <p><b>Price:</b> {exp:cartthrob:arithmetic operator="+" num1="{base_price}" num2="{price}"}</p>
  {/product_options}
{/exp:channel:entries}

```

# Answer
> 1 votes
If you only have a small amount of products, and you're not relying on the channel:entries pagination, you might be able to do it with stash. This is intended as psuedo-code and just a starting point (I forget the exact tags for getting item option prices in CT, for instance).

```
{exp:stash:set_list name="my_products" parse_tags="yes" parse_conditionals="yes"}
    {exp:channel:entries channel="products"}
        {stash:item_title}{title}{/stash:item_title}
        {stash:item_summary}{summary}{/stash:item_summary}
        {stash:item_price}{if price:numeric}{price}{if:else}{your_item_options_field}{price:numeric}{/your_item_options_field}{/if}{/stash:item_price}
    {/exp:channel:entries}
{/exp:stash:set_list}

```

You will probably need to fiddle around with parse order stuff to get that price stash working properly. Maybe add more parse\_depth to the stash tag.

Then you'd do a list with stash:get\_list

```
{exp:stash:get_list name="my_products" orderby="item_price"}
    <li>{item_title} - {item_price}</li>
{/exp:stash:get_list}

```

Check the stash wiki for more on set\_list and get\_list https://github.com/croxton/Stash/wiki

---
Tags: cartthrob, entries, sort
---


# Question
Title: How can I remove ICQ, Yahoo, MSN, Birthday fields from member profile admin in the Controlpanel?
Is there a way to remove the silly fields in the member profile administration of the control panel?

If not possible to remove them, is it possible to move them to the bottom so they appear after any custom member fields?

I'm specifically talking about the following fields;

* AOL
* IM
* ICQ
* Yahoo IM
* MSN IM \<- this doesn't even exist anymore does it?

and ideally I'd like to also remove;

* Birthday
* Location
* Occupation
* Interests
* Bio

Why these aren't an option in the config is something I have never understood. Or, if we want that stuff, just add them as custom member fields.

# Answer
I've just knocked up a quick accessory that does a similar thing to what Matt suggested.
> 6 votes

# Answer
I would add JavaScript to the control panel - perhaps using http://devot-ee.com/add-ons/cp-css-js

Then the following JS as required (jQuery already included in the CP)

```
$('label[for=aol_im],#other-selectors').parents('tr').remove();

```

You might also have to sort the table row classes (odd/even) but that will remove the fields from users view.
> 5 votes

# Answer
or you can use this addon http://devot-ee.com/add-ons/disable-default-memberfields

You can select what fields and for who is visible or not.
> 1 votes

# Answer
Since they are text fields probably, how about use phpMyAdmin to change their labels? Keep the fields short code the same, but just change the label so they appear on the front end as: Location Occupation Interests That leaves 2 unwanted ones. Rename their labels 'Pinterest' or another popular social media site.

For Bio, make a custom field of text area and for Birthday, make a custom field of date.

That lets you keep things pretty 'stock'.

You'll just need to remember that you assign the field ICQ to whatever you rename it.
> 0 votes

---
Tags: member-details
---


title: Assets File Upload issue

text:
# Question
Title: Assets File Upload issue
I have been having issues with the assets plugin in our new server and am having a hard time trying to debug.

When using ee file manager I get the below error. ee: 2.6.1, assets: 2.1.3

```
A Database Error Occurred
Error Number: 1364

Field 'date' doesn't have a default value

INSERT INTO `exp_assets_files` (`file_name`, `source_type`, `source_id`, `filedir_id`, `folder_id`, `kind`) VALUES ('5551725767_38cb459f19_b.jpg', 'ee', NULL, '2', '1', 'image')

Filename: C:\www-customers\websitename\wwwrootV2\system\codeigniter\system\database\DB_driver.php

```

When uploading via assets the progress bar fades away and I receive and 200 response of

```
{"error":"There was an error uploading your file: Assets could not complete the requested operation."}

```

Paths and permissions are all (supposed to be) set up correctly. Any ideas?

Cheers

# Answer
After a bit of debugging, I found that the date field in the exp\_assets\_files table was set to not allow NULL and also did not have a default value. Checking the box to allow NULL and setting a defauly value of 0 fixed the problem and now images can be uploaded.
> 1 votes

---
Tags: ee2, assets
---


# Question
Title: Conditional to check if a user has chosen a modifer - Exp:resso Store
Is there a conditional to check if a modifier has been chosen? I am trying to create a notification to inform the user the need to choose a modifier before trying to add the product to their cart.

# Answer
> 2 votes
I don't know if there is a variable you can use in a conditional.

But this would be easy to accomplish with jQuery. When the Add To Cart button is clicked, first check to see if a modifier is selected... if one isn't selected you can Alert your message so show an error on the page as needed.

# Answer
> 0 votes
Not sure if this will help. I'm using something similar to grab the value of a selected modifier. It checks for a modifier value. While I haven't tested it, it should return whatever message you want if no modifier\_value is found.

```
{exp:store:checkout}
{items}
{exp:channel:entries entry_id="{entry_id}"}
  {modifiers}
    {if "{modifier_value}" == ""}
    Message or code that you want the user to see.
    {/if}
  {/modifiers}
{/exp:channel:entries}
{/items}
{/exp:store:checkout}

```

Hope that helps.

---
Tags: expresso-store
---


# Question
Title: Where are EE's native Snippets saved, locationwise?
I just moved a site to another server and *duh!* forgot to copy over the Snippets manually. Don't ask.

I have a full backup though, ftp as well as sql. Now I am wondering where the native EE Snippets are being stored. I searched through all files and directories I could think of but I am unable to find any trace.

Also I couldn't really find anything in the sql dump.

Anybody know where they are being stored for sure?

Thanks and Cheers!

# Answer
> 4 votes
They're stored in the `exp_snippets` database table.

---
Tags: ee2, snippets
---


# Question
Title: How do I prevent users from entering HTML tags in a safecracker form?
I'm working on an EE powered website which also serves data to a mobile app. I'm trying to make a safecracker form, but one of the fields cannot have HTML code in it or the app breaks. How do I stop people from entering HTML? Here's the field's line in the safecracker form:

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

```

At the moment I think I need to use htmlspecialchars, but I have no idea how to implement it into safecracker. I'm also assuming that it might be easier to apply htmlspecialchars to the output, but unfortunately I do not have access to the apps source code.

# Answer
> 2 votes
I think, you need to look into that channel preferences under "Channel Posting Preferences". You can see "Default HTML formatting in channel entries" and set it to "Convert HTML into character entities".

I hope, it would work for you.

---
Tags: safecracker, php, forms, validation
---


# Question
Title: Freeform - adding an option to my form edit page
I need any form I create to belong to a parent category. The categories can be hard coded, but I need to know where/how to save that selection and how to show it on edit form page.

I've added the select box to edit\_form.html and it's showing, but how to save that data I'm not sure about. In the SQL there's a 'settings' field, can I save custom data like this, there?

I can create a new column sure, but I'd like to avoid hacking the established structure if I can... Thoughts?

# Answer
If I am understanding correctly your question, I would suggest you to create a new form field (from FreeForm module area in CP) and store category value with that.

On the entries listing of any Form, you can see button "Edit Field Layout" and you can include that category field into "Shown Fields".

**Note**: You should have FreeForm v4.0+ for above.
> 1 votes

---
Tags: forms, solspace-freeform
---


# Question
Title: File Field Class in a custom Add-on - Javascript click event not attaching
I'm using the Entry Widgets Add-on and as part of that I'm trying to create a new widget for it which contains a File FieldType. So I'm using the File Field Class which comes with EE to accomplish that, and it's outputting all the right html markup, but what it's not doing is adding the Javascript click event to the `Add File` link.

As I understand it so far, this is not happening because each widget is loaded into the page using AJAX and so is loaded after all of the File Browser javascript is executed on DOM Ready.

I guess what I'm after is a straightforward way to either rerun the javascript so the events get added to my newly injected fields, or just recreate the click event itself. Or alternatively, if anyone know of a standalone way of getting the standard CP File browser working in my widget.

# Answer
After much research it would seem the way to do it in my case is to manually call the `add_trigger` method on the `ee_filebrowser` JQuery object which exists in page.

So basically, I just added the following to my Widget template. When the Widget is loaded this JQuery is immediately executed.

```
<script type="text/javascript">
    $.ee_filebrowser.add_trigger(".choose_file", function (file) {

       // This is basically a callback method which is called after
       // you select a file in the File Manager modal window. The parameter
       // 'file' is an object representing the file you selected, which
       // has various properties pre-populated such as file_id, file_name etc.

       console.log(file); //Use Firebug in Firefox or similar to see all values.

       // Here you can then manually populate the hidden fields provided
       // by the File Field Class.
    });
</script>

```
> 2 votes

---
Tags: control-panel, add-on-development, file-uploads, jquery, entry-widgets
---


# Question
Title: Matrix - Fatal error: Class 'EE_Fieldtype' not found
really strange one, this.

I have a simple channel with one matrix field, which contains a single fieldtype of 'date'. It works in the control panel OK, but if I try to run the tag pair on the front end I get:

Fatal error: Class 'EE\_Fieldtype' not found in /path/to/\_system/expressionengine/third\_party/matrix/ft.matrix.php on line 14

This is EE v2.6.1 - Build Date: 20130506, and Matrix 2.5.5 or 2.5.6. But I have both Matrix and EE working OK on other projects at these versions so I'm stumped.

Anyone have any suggestions better than my "start again" one?

Thanks, Andy.

# Answer
> 3 votes
I found the problem - I had custom fields disabled in my entries tag (d'oh!)!!

This seems to cause the aforementioned problem if you try to parse matrix tags.

# Answer
> 1 votes
It sounds like the date issue with Matrix 2.5.5. Try upgrading to 2.5.6.

http://docs.pixelandtonic.com/matrix/changelog.html

> Fixed the Date celltype for EE 2.6.
>
> Fixed a bug where an illegal date string could crash EE.

There was also a problem with the installer.

---
Tags: matrix
---


# Question
Title: Display Description in Nested exp:file:entries Tag
Here is my template simplified for brevity

```
{exp:structure:entries channel="iconGroup" limit="1" sort="asc" paginate="bottom"}

    <h1>{title}</h1>
    <div class="icon-grid">
    {exp:file:entries directory_id="{file_upload_id}" dynamic="no" disable="categories" orderby="date"}
         <span>{filename}</span>
         <span class="extra-desc">{description}</span>
 {/exp:file:entries}
     </div>
{/exp:structure:entries}

```

The issue i am having is that the description does not show up when it is nested in the entries template. If i move it out of that it shows fine. Is there a way i can make it show up?

Alternatively The main reason i need it nested is to get the file\_upload\_id from the channel above. Maybe there is a way to get that single entry?

Thanks!

# Answer
> 1 votes
You should never to nest exp:channel:entries, but, in this case, you have a fair reason.

Let's use an embed!

```
{exp:structure:entries channel="iconGroup" limit="1" sort="asc" paginate="bottom" disable="categories|member_data|member_data|pagination"}
    <h1>{title}</h1>
    <div class="icon-grid">
    {embed="includes/.files-and-descriptions" id_of_directory="{file_upload_id}"}
     </div>
{/exp:structure:entries}

```

Then, on embed:

```
{exp:file:entries directory_id="{embed:id_of_directory}" dynamic="no" disable="categories|member_data|member_data|pagination" orderby="date"}
     <span>{filename}</span>
     <span class="extra-desc">{description}</span>
{/exp:file:entries}

```

If this embed is used just once per page, I suggest you to enable the template cache of both files.

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


# Question
Title: Wygwam switches double and single quotes
I am trying to implement Video JS (http://www.videojs.com) in my EE site. When adding the required code snippet in my Wygwam field:

```
<video id="bhv_ontruiming" class="video-js vjs-default-skin" controls preload="auto" width="700" height="396" poster="https://intranet.abvakabofnv.nl/uploads/videos/bhv_ontruiming.png" data-setup="{'example_option':true}">
</video>

```

... and switching to source mode and back, Wygwam takes

```
data-setup='{"example_option":true}'

```

and forces the outer quotes to double quotes and the inner single quotes to &qout;

```
data-setup="{"example_option":true}

```

... thereby disabling the functionality of the player.

Does anyone have any idea as to how to prevent this from happening?

Wygwam 3.1.1

# Answer
Your first code snippet shows the double quotes on the outside, so Wygwam is not actually touching those at all. It's just converting the single quotes to entities.

I'm not able to reproduce that with the latest version of Wygwam, but you might try going into Add-Ons \> Modules \> Wygwam \> \[your config name\], and adding the ‘entities’ advanced setting to “No”.
> 1 votes

# Answer
WYGWAM will strip that by default now. You'll need to alter the allowed content rules like this https://github.com/ckeditor/ckeditor-docs/tree/master/guides/dev/configuration/advanced\_content\_filter/allowed\_content\_rules
> 0 votes

---
Tags: wygwam
---


# Question
Title: File and Image Upload in a Wygwam field in a Safecracker Form
I was trying to find confirmation about whether the Browse Server button in the Image and File Upload functionality in Wygwam could be used in Safecracker. Currently the windows pop open fine, but the Browse Server button is not visible.

The only reference I could find was http://ellislab.com/forums/viewthread/223476/ which suggested switching to Ckfinder for the File Manager, which I tried and then wasn't able to see the Browse Server button on the frontend or the backend.

I get an error Uncaught TypeError: Cannot read property 'length' of null that seems unrelated, because it occurs regardless of whether the Browse Server button appears or not.

Thanks in advance for any help!

# Answer
> 0 votes
Even if you have Wygwam configured to use EE’s file browser, it will fall back on CKFinder within Safecracker, since the EE file browser doesn’t work there.

The only issue is that CKFinder is only able to work with a single upload directory. So you have to go into Add-Ons \> Modules \> Wygwam \> \[your config name\] and tell it which upload directory to use.

---
Tags: safecracker, wygwam, pixelandtonic, file-uploads, image
---


# Question
Title: Sending freeform submissions to multiple recipients
We need to send to three email addresses when a particular select option is selected. I've tried setting the value of that field (called recipient\_email) to foo@bar.com,baz@bar.com and setting recipients=yes and recipient\_limit=3 on the form, but the form just comes through to the default admin notification email.

Any suggestions? This in on EE 2.6.1 and Freeform 4.0.12.

Here's a cut down version of the template code:

```
{exp:freeform:form
collection="General Contact Form"
return="{embed:return}/category/submitted"
form:id="form-general-contact"
form:class="validate no-print"
required="first_name|surname|email|recipient_email|user_message"
recipients="yes"
recipient_limit="3"
}

<fieldset>

    <div class="fr">
        <label for="sel-general-type">Enquiry Type <span class="required">*</span></label>
        <div class="wrapper-select">
            <select id="sel-general-type" name="recipient_email">
                <option value="foo@bar.com,baz@bar.com">Foo</option>
                <option value="bar@foo.com">Bar</option>
            </select>
        </div>
    </div>

```

# Answer
The `recipient_email` field accepts **encoded recipient email values** (see an example here), using the `{freeform:recipient_value}` variable in the field's `name=""` attribute along with a set list of recipients using `recipient1=""`, `recipient2=""`, etc parameters.

If you want your field's value="" to be an regular, *non-encoded* email address (as you have it above), use `recipient_email_user` field (documentation).

To send to multiple recipients, use `name="recipient_email[]"` or `name="recipient_email_user[]"` for your field. Please note the brackets `[]`.

**You cannot have more than one email address as a field's value=""**.

**In your case, however,** you are using a select field, which cannot accept multiple values. Either change the field to checkboxes or a multi-select field, eg.

```
<input type="checkbox" name="recipient_email_user[]" value="email1@example.com" /> Recipient 1<br />
<input type="checkbox" name="recipient_email_user[]" value="email2@example.com" /> Recipient 2<br />
<input type="checkbox" name="recipient_email_user[]" value="email3@example.com" /> Recipient 3<br />

```

...or use javascript/jQuery to populate hidden `recipient_email_user[]` fields when a select field option is selected.
> 6 votes

---
Tags: solspace-freeform, solspace
---


# Question
Title: ExpressionEngine mail form with attachments: how do it?
What is the best way to do it a mail form in expressionengine with a file attachment? The objective is to construct a resumé sender mail form, where the user fill some fields and attach a PDF or DOC file.

I dont want to store this in the site, just attach and send in a e-mail recipient.

What solution to use? Code examples?

# Answer
Have you tried using Freeform from Solspace? There's a paid and free version, both of which should take care of your needs. I use Freeform all the time for a resume upload and email type of form.

EDIT: There are some good code examples in the Freeform Docs (at the bottom of the page).
> 4 votes

---
Tags: attachment
---


# Question
Title: Error Number: 1064, ExpressionEngine 1.7.3 Chrome Bug
I am getting the following error in Chrome for my site:

MySQL ERROR:

Error Number: 1064

Description: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'd code on line 341'' at line 1

Query: SELECT cat\_name FROM exp\_categories WHERE cat\_id ='Notice: Undefined variable: catID in /www/eh17535/public\_html/cp/core/core.functions.php(672) : eval()'d code on line 341'

I am only getting this in Chrome, IE and firefox work fine.

Can anyone help me?

Thanks, Allison

# Answer
> 2 votes
By definition, a server-side error (like the MySQL error you describe) cannot be happening in one browser but not another. So my guess is that you're simply viewing the specific page on which it is happening with Chrome, and viewing a *different* page in Firefox and IE.

(Or, another possibility - you're logged-in in Chrome, but not the others, and the error is triggered by code that is only running for logged-in users.)

My guess - you have a custom add-on or PHP in a specific template that's running a query which triggers the error. Search your templates for `$catID` to find the culprit.

---
Tags: error, ee1, debugging
---


# Question
Title: Only display certain checkout fields if there's a product in the cart from a certain channel
I've got different types of products (in different channels) in a CartThrob store. Is it possible to add a conditional within the Checkout Form tag to enable certain checkout fields to only appear if there's a product from a certain channel in the cart? If so, how would I go about doing this?

I've been looking at the Checkout Form tag and the Cart Items Info tag, but there doesn't appear to be anything here to test for what I'm looking for (please correct me if I'm wrong!). I also looked at the Is In Cart tag, but this only seems to work for adding one entry ID at a time, not looping through lots of entry\_id's in a channel (which rules out adding all the entries in this particular channel, though that might have been impractical anyway).

There is a Cart Entry ID's tag, but I can't figure out how to use this in a conditional that would output a single true/false result (for use in a conditional) if one of the pipe-delimited entry ID's belonged to a certain channel. Thanks for any advice on this.

# Answer
> 1 votes
You can probably get this done with stash. This is off the top of my head so please refer to the Stash documentation.

```
{exp:stash:set name="is_engravable" parse_tags="yes" parse_conditionals="yes" default="0"}{exp:cartthrob:cart_items_info}{if channel_name == "engravable_products"}1{/if}{/exp:cartthrob:cart_items_info}{/exp:stash:set}

{exp:stash:parse process="end"}
  {exp:cartthrob:checkout_form}
  {if {exp:stash:not_empty name="is_engravable"}}
  <label>Engraving</label>
  <input type="text" name="order_engraving">
  {/if}
  {/exp:cartthrob:checkout_form}
{/exp:stash:parse}

```

---
Tags: cartthrob, conditionals, ecommerce
---


# Question
Title: Playa field within a Matrix field - not displaying results
I'm trying to get information from a Playa field within a Matrix field, and nothing is showing. It's a very simple task, and I can't see where I've made a mistake:

```
{model}<!--Matrix field-->
<div class="row details">
<div class="large-6 columns">
<img src="{model_image}" title="{model_title}" alt="{model_title}">
</div>
<div class="large-6 columns">
<p>{if "{model_production}"=="Yes"}In production.{if:else}Out of production.{/if}</p>
{if model_link}
<p>Best source for this model:<br>
<a href="{model_link}" title="{model_link}" target="_blank">{link_title}</a></p>{/if}
{if model_painter}<!--Playa field-->
<p>Example painted by {model_painter}{title}{/model_painter}</p>
{/if}
</div>
</div>
{/model}

```

Any ideas? Thanks in advance.

# Answer
> 1 votes
One thing you could do is eliminate the conditional around the Playa field - like the entries loop, Playa won't output anything if no results are found. So you can do something like this instead:

```
{model_painter}
    <p>{if count == "1"}Example painted by{/if} {title}</p>
{/model_painter}

```

This may not have any bearing on why you're not seeing a result from your playa field, but it would simplify your loop just slightly.

Could there be a custom status at play that would be causing the playa field in the matrix to fail to return an entry for you?

# Answer
> 1 votes
Thanks for your replies. The solution was to use {exp:playa:children field="model\_painter" status="not closed"}

The channel I'm pulling data from is a Zoo Visitor members channel, and it requires the status="not closed" parameter.

---
Tags: matrix, playa
---


# Question
Title: Ajax submit errors contain html formatting
SO I'm using Solsapce's User for usersto edit their profile and have discovered something I'm not sure how to describe or fix.

I have a normal edit profile with a few fields, I have declared certain fields to be required, the syntax is identical to SAFE forms required="fielda|fieldb" etc.

When the form is submitted with all things filled in correctly, the ajax does its thing nicely, if one of the required fields is missing content, then I cannot get it to show anything meaningful.

```
 $('.user-edit').ajaxForm({
     target: '#confirmation',
     dataType: 'json',
     success: function(result) {
         $("#confirmation").html("<div class='success'>" +result.content+"</div>");
         $("#confirmation").hide();
         $("#confirmation").fadeIn(500);
     },

    error: function(jqxhr) {
        $("#confirmation").html("<div class='alert'>" +jqxhr.responseText+"</div>");
        //$("#confirmation").html("<div class='alert'>" +jqxhr.error+"</div>"); //Gives strange Javascript error (see comment below)
        $("#confirmation").hide();
        $("#confirmation").fadeIn(500);
     }
 });

```

Here's the kicker, Firebug shows this is the error response

```
{"error":"<p>The following fields are required: <ul><li>Birthday<\/li><\/ul><\/p>"}

```

This is whats displayed on the page, it includes the "error" and brackets and everything!

```
<div class="alert">{"error":"<p>The following fields are required: </p><ul><li>Birthday<\/li><\/ul><\/p>"}</li></ul></div>

```

On a successful post, this is the Firebug response and as I'm targeting "result.message" it displays fine:

```
{"success":true,"heading":"Successful Submission!","message":"Your profile has been successfully updated","content":"Your profile has been successfully updated"}

```

I've tried all manner of variations to get this ajax error displaying only the error content and am now doubtful that it ever will. Of course I could be a huge dumbass and missed something :)

# Answer
> 0 votes
For my future self and others trying to work ajax into EE, when editing your profile via front end (I'm using Solspace User with Malsup Ajax Form) but also applies when using PM (Messaging Module)

IF everything is filled in EE returns a proper Ajax/JSON reply yet if required fields are empty then EE returns a 200 success message with a plain text error. This is the reply if required field iss missing:

```
Error: Message must contain at least one recipient.

```

You have to break apart the message, like this

```
$('#compose').ajaxForm({
    target: '#confirmation',
    dataType: 'text',
        success: function(result) {
        //Fuckin EE, even when no fields filled in, returns "success", gotta break it up
        var data = result.split(":"); // The magic !!
        //console.log(data[0]);
        if (data[0] == 'Error'){//Use the first part of the split
            $("#confirmation").html("<div class='alert'><p>Ah c'mon man, "+data[1]+"</p></div>");
            $("#confirmation").hide();
            $("#confirmation").fadeIn(500);
        }else{
        //In this case proper success needs redirect but you could do whatever
        document.location.href = '/inbox';
            //$("#confirmation").html("<div class='alert'>"+result+"</div>");
            //$("#confirmation").hide();
            //$("#confirmation").fadeIn(500);
        }
        }
});

```

So when EE replies back with plain text, it can be useful. Using the exact same ajax behaviour above, when dealing with HTML formatted response like in my original question, use this to convert it into a JSON response

```
error: function(event) {
var data = eval("(" + event.responseText + ")");
$("#confirmation").html("<div class='alert'>"+data.error+"</div>");

```

I taught myself a lot trying to figure this out and hopefully this may help someone else :)

# Answer
> 0 votes
Looks like it's outputting the JSON object as a string because you've not specified the specific content to display. If you look at the one that's working, you're getting back

```
{ "success":true,
  "heading":"Successful Submission!",
  "message":"Your profile has been successfully updated",
  "content":"Your profile has been successfully updated"
}

```

and you're calling it with

```
$("#confirmation").html("<div class='success'>" +result.content+"</div>");

```

(i.e. you're specifying you want the *content* part of the object). The error you're getting back seems to be OK, but is a JSON object, not an HTML entity, i.e.

```
{"error":"<p>The following fields are required: </p><ul><li>Birthday<\/li><\/ul><\/p>"}

```

So you probably need to just reference it:

```
$("#confirmation").html("<div class='alert'>" +jqxhr.error+"</div>");

```

---
Tags: error, ajax, solspace-user
---


# Question
Title: Low Events: How can I compare formatted start_date and end_date in conditionals?
I've just started using Low Events after realizing the hard way why I need it. I'm attempting to format a nice string when the range happens within the same month; instead of `August 14, 2013 - August 16, 2013`, I'd like to display `August 14-16, 2013`.

I've attempted to compare formatted output of the month and year only, like this...

```
 {if '{event_dates:start_date format="%F%Y"}' == '{event_dates:end_date format="%F%Y"}'}
      {event_dates:start_date format="%F %j"}-{event_dates:end_date format="%j, %Y"}
 {if:else}
      {event_dates:start_date format="%F %j, %Y"} - {event_dates:end_date format="%F %j, %Y"}
 {/if}

```

...yet instead of the expected output EE just complains that it choked on the conditional:

```
 Parse error: syntax error, unexpected T_STRING in /var/www/vhosts/foo.com/httpdocs/system/expressionengine/libraries/Functions.php(683) : eval()'d code on line 56

```

Using `parse="inward"` had no effect, and I've isolated that first `{if` conditional as the problem. Is there any way to achieve the formatting I'd like without relying on an embedded template?

I also tried swapping the single and double quotes as Robson suggested, but that had no effect.

This is EE 2.5.5 and Low Events 1.1.4, and swapping `{exp:channel:entries}` for `{exp:low_events:entries}` makes no difference.

Here's the entire (simplified) template for context:

```
 {exp:channel:entries channel="events" limit="1" url_title="{segment_2}"}
 {embed="parts/.header" page_title="{title}"}

 <div id="content">
    <h3>{if '{event_dates:all_day}' == 'y'}
            {if '{event_dates:one_day}' == 'y'}
                {event_dates:start_date format="%F %j, %Y"}
            {if:else}
                {if '{event_date:start_date format="%F%Y"}' == '{event_date:end_date format="%F%Y"}'}
                    {event_dates:start_date format="%F %j"}-{event_dates:end_date format="%j, %Y"}
                {if:else}
                    {event_dates:start_date format="%F %j, %Y"} - {event_dates:end_date format="%F %j, %Y"}
                {/if}
            {/if}
        {if:elseif '{event_dates:one_day}' == 'y'}
            {event_dates:start_date format="%F %j, %Y"} - {event_dates:start_time format="%g:%i%a"}-{event_dates:end_time format="%g:%i%a"}
        {if:else}
            {event_dates:start_date format="%F %d, %Y"} - {event_dates:start_time format="%g:%i%a"} to {event_dates:end_date format="%F %d, %Y"} - {event_dates:end_time format="%g:%i%a"}
        {/if}
        {if event_location}
        <br/>{event_location}
        {/if}
    </h3>

    <hr/>

    {event_description}

    {if event_rsvp_link}
        <div class="rsvp"><a href="{exp:extract_url}{event_rsvp_link}{/exp:extract_url}">RSVP Now »</a></div>
    {/if}

 </div>

 {if no_results}{redirect="404"}{/if}{/exp:channel:entries}
 {embed="parts/.footer"}

```

# Answer
To be on the safe side, I'd check for numerical values only, like 201308. Something like this:

```
{if {event_dates:start_date format="%Y%m"} == {event_dates:end_date format="%Y%m"}}
  same month
{if:else}
  not same month
{/if}

```

When debugging the advanced conditionals, try to remove them and add them one at a time to see which actual one is causing the trouble.
> 4 votes

# Answer
I *guess* you should to use `exp:low_events:entries` instead of `exp:channel:entries`.
> 0 votes

---
Tags: conditionals, parse-order, low-events
---


# Question
Title: Low Variables, Playa, GWCode Categories, Entry IDs, and Categories
I need the list of category names, but only the categories that have been tagged in entries that are related (a Playa relationship) to another entry (I know, it's getting down to snow-fortress Inception levels).

Here's my Low Variable (an early-parsed textarea variable), called "lv\_region\_entry\_ids":

```
{exp:channel:entries url_title="{segment_3}"}{exp:playa:parent_ids}{/exp:channel:entries}

```

And here's the place I'm trying to use it:

```
{exp:gwcode_categories entry_id="{lv_region_entry_ids}"} (some code) {/exp:gwcode_categories}

```

That doesn't work, and I've read in a few places that when dealing with LV and Playa you have to use the pair tag instead of the the global variable syntax. But that's where I'm drawing a blank on how to do that.

# Answer
The code that ends up in the template with your current setup is this:

```
{exp:gwcode_categories entry_id="{exp:channel:entries url_title="{segment_3}"}{exp:playa:parent_ids}{/exp:channel:entries}"}
  (some code)
{/exp:gwcode_categories}

```

Can you see the problem now? You're using *two* tags as input for another tag's parameter value. On top of that, the double quotes are clashing; the value for entry\_id actually is `{exp:channel:entries url_title=` instead of the whole tag.

You can *try* using single quotes for either the gwcode\_categories tag or channel:entries tag *and* adding `parse="inward"` to the gwcode\_categories tag to try and parse the parameter value. If that doesn't work, use embeds or perhaps Stash, like Stephen suggested.
> 1 votes

# Answer
What happens if you move your `lv_region_entry_ids` code into your template wrapped in a stash:set pair, like this?

```
{exp:stash:set name="region_entry_ids" parse_tags="yes"}
  {exp:channel:entries url_title="{segment_3}" dynamic="no" disable="pagination|member_data|categories}{exp:playa:parent_ids}{/exp:channel:entries}
{/exp:stash:set}

```

Then, in the same template call/get the value like this:

```
{exp:gwcode_categories entry_id="{stash:region_entry_ids}"}
  (some code)
{/exp:gwcode_categories}

```
> 0 votes

---
Tags: playa, categories, low-variables, gwcode-categories, entryid
---


# Question
Title: When to use Low Variables and when to use Stash
I just started using Low Variables. I just bought Mustash to use with Stash. It is unclear to me as a newbie certain functionality and what best practices are. Which type of snippets would go in LV and which snippets in Stash

# Answer
Stash and Low Variables are complementary.

### Low Variables

Essentially a replacement for native snippets and global variables. Provides a control panel interface for managing variables. Variables may be considered content - text values, matrix data, default images - or code, such as a tag that outputs your primary navigation or contains your footer markup.

Variables groups can be used to allow some variables to be managed by your client (e.g. the content type variables) and others to be managed by you, the developer (e.g. the code variables).

### Stash

The most basic use of Stash is to save the output of tags - or the tags themselves - at runtime (when a template is parsed). You can then re-use the fragment of saved data somewhere else in your template(s).

Stash can be used to change the parse order of your tags such that fragments of data can be passed from tag to tag in the order you desire.

Stash embeds can be used as a powerful replacement for ExpressionEngine embeds.

Stash caching can be used to save your fragments of data to the database. The tags that generated the data then do not need to run again, so subsequent views of your template use less resources.

Stash can be used to implement various advanced template design patterns:

### Mustash

Mustash allows you to manage **cached** Stash variables in the control panel and set up cache-breaking rules such that the cache is refreshed when content is edited in the control panel. You can choose which sections of Mustash will be accessible to you or your clients; for example, you may wish for your client to be able to clear the cache but not have access to the rules section.

You do not need Mustash in order to use Stash, but if your are using caching then it will make things much easier to manage for both you and your client.
> 13 votes

# Answer
I think you misunderstood. Stash is a sort of replacement functionality for EE's built in snippets (yes oversimplifying it a bit, but that's what it boils down to), as in that it's meant for developers, where Low Variables is a way for clients to manage "global content" (such as settings, contact information etc). They work perfectly fine together.
> 1 votes

---
Tags: stash, low-variables
---


title: Relationships - Filtering Child Entries

text:
# Question
Title: Relationships - Filtering Child Entries
I’ve started trying to figure out how relationships work and I have two channels (parentChannel and childChannel).

My data looks like this:

* parentChannel - title - “Item Name”
* childChannel - title - “2013 Item Name” , “2012 Item Name”, etc, etc

Within one of my templates, I would like to show some childChannel data, but I want to filter it to only the newest entry - in this case the 2013 entry.

How would I accomplish this? Should I be “filtering” my childChannel data by some other means than the title itself, such as a category?

All help is appreciated.

# Answer
I ended up solving this issue with the following code:

```
{channel_relationship orderby="title" sort="desc" limit="1"}

```

I create a relationship field between the parentChannel and childChannel called channel\_relationship. Since the child fields all start with a year and I wanted to only display information from the newest year, I sorted all of the relationship entries by title, descending.
> 0 votes

# Answer
I can think of two ways of do this:

1. to turn the parentChannel into a category group;
2. to create a category or a field to save the year of the item name on childChannel;

To avoid duplicated data, I prefer the number 1.
> 0 votes

---
Tags: relationships
---


# Question
Title: Setting up channel for handling "editions"
I am trying to figure out the best way to structure my data. I am building a site that is for rating items (generic term), but there is a new edition of the item every year. For this example, let's say that it is magazine editions.

The user would be able to search magazines and get a list returned back. Let's say that the search results say National Geographic, Sports Illustrated, etc.

If they click on Sports Illustrated, they would go to a single page for sports illustrated, but within that page, they would be able to rate the content that they found in the January edition, as well as the February, March, etc. etc.

My understanding of ratings plugins is that they would actually be rating an entry like Sports Illustrated - January 2013, etc, etc.

What is the best way to set this up. I have done a basic website on EE, but nothing this complex involving ratings, members and all of that.

All input is greatly appreciated.

# Answer
To solve this issue, I ended up creating two channels:

1) Magazine 2) Edition

and a relationship field between the two.

So for the example data, Magazine channel contains entries for National Geographic, Sports Illustrated, etc. Edition channel contains 2013 National Geographic, 2012 National Geographic, etc, etc.
> 1 votes

# Answer
I'm sorry about the delay. I just found your question on the list of unanswered questions.

My suggestion is to create a category\_group for all magazines. Every magazine will be one category:

* National Geographic
* Sports Illustrated

You will use them for group the editions. Each individual edition go into one category of the group.
> 0 votes

---
Tags: ee2, channel-entries, channel, solspace-rating
---


title: EE Debug Toolbar Installation Crash

text:
# Question
Title: EE Debug Toolbar Installation Crash
I hate to complain about a freebie add-on - EE Debug Toolbar from mitra62 - but unfortunately installing EE Debug Toolbar has just caused me major problems.

The good news is that my site is still up.

The bad news is that I can't login as a superadmin at all.

The story is:

My EE site uses the latest version of EE and of MSM.

I just downloaded version 1.0 (RC1) of EE Debug Toolbar from Devot-ee.com

I followed the instructions on GitHub (just before it's current DDOS attack) including turning on the EE debugging reporting. I uploaded all the files that came with the download in the usual sections.

I went to Extensions and activated EE Debug. There was a list of things to activate, I believe I started with the first one on the list because it seemed the most general. I'm sorry but this is all I can recall about this step.

I got this error message:

Fatal error: Class 'XMLWriter' not found in /var/www/html/system/expressionengine/third\_party/ee\_debug\_toolbar/libraries/xml\_writer.php on line 35

My superadmin access to the site stalled there.

I went back to GitHub to look for help.

GitHub is experiencing a DD0S attack and is down.

I tried to log onto my super admin account from another browser and got the error message.

I got impatient and deleted all the EE Debug addons from the system and themes folder.

Now I just get a white screen when I try to log on to my superadmin account.

How do I get back in as superadmin now?

Thanks for any help you can provide.

Jeanne

# Answer
> 0 votes
It seems like there may be files missing from your upload. I would try reuploading the add-on to make sure all files were included. The error seems to be pointing to a missing file within the add-on's package directory.

In the meantime to get you back into the control panel, you can go into your database, find the `exp_extensions` table, find the EE Debug Toolbar record and set the value of the `enabled` field to `n`. This will disable the extension and should prevent it from interrupting your access to the control panel.

---
Tags: add-on
---


# Question
Title: Solspace importer how to tell it which channel to import to?
I'm trying to set up an import profile with with Solspace Importer to upload CSV files with channel entries but I don't see any way of telling it which channel I want to import to.

Am I missing something fundamental here?

Thanks, Alex

# Answer
> 1 votes
Per the documentation, the channel should appear as the first field in the create new import profile screen.

---
Tags: solspace, solspace-importer
---


# Question
Title: Fieldtype runs validate() multiple times?
I'm trying to create a custom fieldtype that's `display_field()` function produces a collection of `<input>` boxes. The problem I am having is that the `validate()` function in my ft.x\_fieldtype.php file is getting run each time for each `<input>` it seems.

Can anyone see a way around this?

# Answer
> 1 votes
One solution I came up with is to set an instance variable such as `$has_already_validated` to prevent further validation. It seems to work as there is only one instance created at least. Here's an example:

```
class My_fieldtype_ft extends EE_Fieldtype {
    private $has_already_validated = FALSE;

    function validate($data)
    {
         if ($this->has_already_validated) return TRUE;
         $this->has_already_validated = TRUE;

         // your validation code
    }
}

```

---
Tags: add-on-development, fieldtype
---


# Question
Title: Exclude Calendars (Solspace) from displaying?
I have a MSM site with Solspace Calendar installed. For ease of use on the clients side, they'd like to manage all calendars from one side of the admin which is pretty easy but I'm running into a problem with trying to exclude certain calendars from showing up on one site.

For site A, I'd like to show all calendars EXCEPT specified ones.

For site B, I'd like to ONLY show the specified calendars. This is easy:

```
calendar_name="classes|events"

```

So, for site A, I should be able to do this:

```
calendar_name="NOT classes|events"

```

But it doesn't seem to be working. It hides all my calendars and seems to break the tag.

Any ideas or suggestions would be great. Thanks!

# Answer
> 0 votes
Unfortunately as of this writing (latest Calendar version: 1.8.4), using "not" in `calendar_name="not calendar1|calendar2"` isn't available.

However, the `calendar_id=""` parameter should let you exclude calendars. Eg.

```
calendar_id="not 1|5"

```

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


title: include url title in live look template

text:
# Question
Title: include url title in live look template
I'm trying to use the live look feature in expression engine to preview entries, but it doesn't pass the URL title to the preview template. Am I doing something wrong or is this just not allowed? I can't imagine preview templates would be of much use without this.

# Answer
> 1 votes
In the "Live Look" url title isn't being pass with the preview template. Instead of url title, entry id is passed. you can see the entry id as last segment.

# Answer
> 0 votes
I solved this by spinning out two entry loops in the same template - one for `url_title` and one for `entry_id`. I used croxton's Switchee to select the appropriate loop based on regular expression in the segment.

Alternately, you could set up a separate live look template for the channel. But then you'll need to maintain two templates.

---
Tags: url-title, livelook
---


# Question
Title: git , bitbucket and multi environment (subdomain > same server)
So, this is my actual workflow:

* With my IDE (Webstorm or Aptana, I'm on windows) I create a project and I synchronize remotely via (s)ftp
* I then create a git repository and push it on bitbucket
* Everytime i upgrade the project in local , it syncs with the production version on the server. I then commit and push the changes
* therefore, my actual environment is local \> production

I would like to switch to multiple environments (local \> development \> production), where local is my pc and development/production are on the same server (dev in a subdomain), using ee master config

I read a bit and I found two solutions:

### 1) git/bitbucket + ftp + deployhq

In practice: local version synchronized remotely (dev.mysite.com pointing to a subfolder), then push in the repository on bitbucket and finally deployed into production via deployhq

pro: maybe the simplest solution

cons: deployhq or beanstalk are payments services (free version of deployhq has 1 repository and limited deploy)

### 2) git and ssh installed on the server

I copy these steps from another discussion:

> 1. do a git init in production server (is this safe?)
> 2. clone the repo from production to staging server
> 3. developers clone the repo from the staging to their local machine
> 4. push files to the staging server after finish changing
> 5. when staging is ready, push everything to the production

Are these steps correct? I'm not very familiar with git, so can you give me an example of the commands to use? I would use this solution. Also, can I still use bitbucket?

Are there better solutions? Thanks in advance

# Answer
Here's how I'm deploying the majority of sites http://digitalevangelist.net/blog/git-deployments

I do have a paid DeployHQ account as well but that's generally for larger projects deploying to multiple environments with emails going to stakeholders when there's been a deployment.
> 3 votes

---
Tags: focus-lab-master-config, git, workflow
---


title: Setting Up Sub Domains

text:
# Question
Title: Setting Up Sub Domains
What is the best directory structure to adopt when setting up a website based on this url structure:

www.example.com - home page subdomain1.example.com subdomain2.example.com subdomain3.example.com

I am told this is difficult to setup with expressionengine out of the box and needs some fancy .htaccess code to rewrite urls e.t.c. If i didn't want to go that route, what are my options?

is this easier if each subdomain had its own ee install? Do i need to use some sort of CNAME mapping? ideally, I'd like all sub pages under each subdomain to correctly show the url structure i.e "subdomain1.example.com/page1" vs "www.example.com/subdomain/page1"

Thx

# Answer
> 5 votes
Looks like you need Multiple Site Manager.

But, if all your subdomains are part of the same website, there's a technique I use on multiple language websites that can help you.

You have two possible setups.

On the first one, your directories need to follow this structure:

* /system
* /domain.com
* /domain.com/images
* /domain.com/themes
* /domain.com/index.php
* /domain.com/admin.php
* /sub.domain.com
* /subdomain.com/index.php
* /sub2.domain.com
* /sub2.domain.com/index.php

Each index.php has its own settings about the url of the website.

The second and my favorite option is to set all domains to use the same folder on server and add a conditional on system/expressionengine/config.php to set all the variables you need. For example, you can have a specific default category\_group or channel for every domain.

```
global $assign_to_config;

if(!isset($assign_to_config['global_vars']))
$assign_to_config['global_vars'] = array();

// set the site_url to the current domain being accessed
$assign_to_config['site_url']   = 'http://'.$_SERVER['HTTP_HOST'];

// different settings and variables for every domain
if ($_SERVER['HTTP_HOST'] == 'www.domain.com' || $_SERVER['HTTP_HOST'] == 'domain.com')
{
    $assign_to_config['xml_lang']   = 'en';
    $assign_to_config['language']   = 'en';
    $assign_to_config['global_vars']['cv_cat_group'] = 1;
    $assign_to_config['global_vars']['cv_channel'] = 'main_domain';
    [...]
}
else
{
    $assign_to_config['xml_lang'] = 'pt';
    $assign_to_config['language'] = 'pt';
    $assign_to_config['global_vars']['cv_cat_group'] = 2;
    $assign_to_config['global_vars']['cv_channel'] = 'subdomain';
    [...]
}

```

You can access this custom config variables right on templates: `{cv_cat_group}` and `{cv_channel}`. They are early parsed, so you can use them inside your modules variables pairs:

```
{exp:channel:entries channel="{cv_channel}" [...]}
  [...]
{/exp:channel:entries}

```

As I said, this technique works really well for me.

If you can't use the same directory to all sites, use the setup I suggested on option 1.

# Answer
> 0 votes
If your sites are simple in how they use EE templates, you can use a CNAME to map your subdomains to your main domain, and then use some simple redirect rules to route requests to the correct EE templates.

So, say your main site is: www.example.com and you map two subdomains, sub1.example.com and sub2.example.com as CNAMEs. Then, in EE, say you have corresponding template groups:

1. site (the default, for the www.example.com site)
2. sub1 (for your sub1.example.com site)
3. sub2 (for your sub2.example.com site)

Then, in your .htaccess, you could use these kinds of redirects:

```
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^sub1\.example\.com$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !^/index\.php/sub1/.*$ [NC]
RewriteRule ^(.*)$ /index.php?/sub1/$1 [L]

RewriteCond %{HTTP_HOST} ^sub2\.example\.com$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !^/index\.php/sub2/.*$ [NC]
RewriteRule ^(.*)$ /index.php?/sub2/$1 [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]

```

(note that those redirects assume your Apache is using FCGI. If it's using mod\_php, you don't need the ? in the RewriteRules -- e.g.,

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

```

)

So, with the above, a request to www.example.com would map to the default EE template, site/index. A request to sub1.example.com would map to the sub1/index. And a request to sub2.example.com would map to sub2/index.

The more complicated the sites, generally, the more complicated the structure of your EE templates. And, I don't think this approach scales very well, e.g., not having distinct 404 errors for different sites and other possible complications with URLs for the subdomains.

But, if the subdomain sites are, say, just 1-page landing pages, I think this approach works well enough.

---
Tags: ee2, subdomain
---


title: Help with Pagination displayed in line

text:
# Question
Title: Help with Pagination displayed in line
I'm getting a strange issue when trying to display pagination inline. It appears that when their is no pagination to display, the {paginate} will echo out:

```
pagination_marker

```

I'm trying to display pagination in a json output format, this is what my entry tag looks like:

```
[
    {
        "category": {exp:query sql="SELECT cat_name FROM exp_categories WHERE
cat_url_title = '{segment_4}'"}{exp:jsonencodetagpair}{cat_name}{/exp:jsonencodetagpair}{no_results}{redirect="404"}{/no_results}{/exp:query},
        "reviews": [{exp:channel:entries channel="reviews" category_url_title="{segment_4}" paginate="inline" status="open" limit="5" orderby="date" sort="desc" backspace="0" disable="categories|category_fields|member_data"}
            {
                "id": {entry_id},
                "snippet":{exp:jsonencodetagpair}{review_snippet}{/exp:jsonencodetagpair},
                "slug": "deeplink/{entry_id}",
                "firstName": {exp:jsonencodetagpair}{review_first_name}{/exp:jsonencodetagpair},
                "lastName": {exp:jsonencodetagpair}{review_last_name}{/exp:jsonencodetagpair},
                "image": "{if '{review_reviewer_photo}' != ""}{global:site_url}{review_reviewer_photo}{/if}",
                "date":{exp:jsonencodetagpair}{entry_date format='%Y-%m-%dT%H:%i:%sZ'}{/exp:jsonencodetagpair}{if count != total_results}

            },{if:else}

            }
        ],
        "pagination": [{paginate}
            {
                "previous": {exp:jsonencodetagpair}{if previous_page}{auto_path}{/if}{/exp:jsonencodetagpair},
                "next": {exp:jsonencodetagpair}{if next_page}{auto_path}{/if}{/exp:jsonencodetagpair}
            }{/paginate}
        ]{/if}{no_results}],"pagination":[]{/no_results}{/exp:channel:entries}
    }
]

```

Now, since it has to be in a json format, I don't want my pagination to be within the array of reviews. This works perfectly when their are multiple pages to be displayed, but when their is only 1 or 2 reviews and no pagination needed, pagination\_marker is then displayed.

Here is what the json looks like when it's working correctly:

```
[
    {
        "category": "Cosmetic Dentistry",
        "reviews": [
            {
                "id": 886,
                "snippet": "",
                "slug": "deeplink/886",
                "firstName": "test",
                "lastName": "test",
                "image": "",
                "date": "2013-07-31T12:37:00Z"
            },
            {
                "id": 883,
                "snippet": "",
                "slug": "deeplink/883",
                "firstName": "",
                "lastName": "",
                "image": "",
                "date": "2013-07-31T12:25:00Z"
            },
            {
                "id": 882,
                "snippet": "",
                "slug": "deeplink/882",
                "firstName": "James",
                "lastName": "Lukensow",
                "image": "",
                "date": "2013-07-31T12:22:00Z"
            },
            {
                "id": 881,
                "snippet": "",
                "slug": "deeplink/881",
                "firstName": "James",
                "lastName": "",
                "image": "",
                "date": "2013-07-31T12:19:00Z"
            },
            {
                "id": 880,
                "snippet": "",
                "slug": "deeplink/880",
                "firstName": "",
                "lastName": "",
                "image": "",
                "date": "2013-07-31T12:18:00Z"
            }
        ],
        "pagination": [
            {
                "previous": "",
                "next": "http://local.cds.test.com/v1/reviews/category/cosmetic-dentistry/P5"
            }
        ]
    }
]

```

This is what it looks like when it does not work:

```
[
    {
        "category": "Dentures",
        "reviews": [
            {
                "id": 879,
                "snippet": "",
                "slug": "deeplink/879",
                "firstName": "",
                "lastName": "",
                "image": "",
                "date": "2013-07-31T12:16:00Z"
            }
        ],
        "pagination": [
            {
                pagination_marker
            }
        ]
    }
]

```

# Answer
The pagination link generator is pretty whacky, because the parser grabs the code in your template and then may move it, depending on whether you have paginate set to bottom or top.

This is probably an example of the EE parser not working in a strictly top-to-bottom manner, and catching us off-guard since we want the parser to follow the sequence of the code.

So, as an easy step, trying adding paginate="bottom" to your exp:channel\_entries tag.

If that doesn't solve it, try taking the pagination code block all the way outside of the conditional {if count != total\_results}. I can't think of exactly how that'd work in the JSON, but maybe this can work.

If those approaches don't work, then you need to think about having the pagination go into a placeholder variable that you can then put in the right place later. You might need PHP to do this, or one of the "jumper" add-ons like NSM Transplant might do the trick.

These examples of How to Use Stash for Pagination and Capturing Pagination might be helpful, too.

Also, the EE parser sometimes is not happy with lots of curly brackets and quotes on the page. I think this may have something to do with why you're seeing the pagination\_marker placeholder rather than some other mess.
> 1 votes

---
Tags: pagination
---


# Question
Title: Is there a way to only show sticky entries?
Currently using Playa on a site to allow the client to pick what news entries show up on the homepage as they don't always want to show the newest entry, they want to show the most important. But it's a small nag to have them create a news post then have to open another "Home" entry to drag and drop news items. I was thinking it might be easier for them to set news articles as Sticky when they are creating them, then only display the sticky entries on the homepage. if I just set sticky="yes" this would show sticky entries on top, but might not show all sticky entries if the limit=3 and 4 sticky entries are set. Thanks for any ideas!

# Answer
> 2 votes
I've done that sort of thing using a status and limiting the items displayed on the home page to just those with that status. And you can, as of 2.5.4, order by status, putting them up first if you so choose, mirroring sticky functionality, on your inside page.

# Answer
> 1 votes
You can use a {if sticky == 'y'} content {/if} conditional in your entries loop to do this.

# Answer
> 1 votes
If you want to "push" entries to the home page based on data in the entry, I'd recommend that you use either a special "home page" category or a new field. Then you can use the exp:channel:entries tag limited by either a specific category\_id or a search term, respectively.

The special category option is nice because you can filter by category in the control panel. So, it's easy then to find the current home page entries, for editing (e.g., for removing them from the home page category).

Using a special status for the entries is pretty similar to using a special category. I don't like to use special statuses for this because I try to limit my use of statuses only close and open, and have them mean only "off" and "on" (since EE makes them mean that, by default).

With the way you're currently using Playa, (I assume) you're "pulling" entries into the home page entry. Another good way to pull entries into a template is with Low Reorder using its own Entries Tag. It has a handy drag-n-drop interface in the control panel.

---
Tags: entries
---


# Question
Title: 404 redirects and google analytics question
I read this article and setup my single entry pages with the 404 redirect conditional. I also setup the 404 page in the CP and set Strict URL's to YES. When I try and go to a broken link I do get redirected to the 404 page, but it still has the broken URL in the browser. I have analytics installed on the 404 template but I'm wondering how this will show up in Google Analytics. I want to be able to see what URL people are visiting and getting the 404. Any help? Thanks!

# Answer
> 2 votes
For SEO purposes, I don't think it's a good idea to return a 301 redirect when you want to return a 404 error.

When you do {redirect="404"} then EE serves the 404 template with a proper HTTP 404 status response.

When you do {redirect="404/index"} then EE responds with a HTTP 301 status redirect header.

Google Analytics and Webmaster Tools track when a URL responds with a 404 error, so that shouldn't be a problem

# Answer
> 1 votes
On our EE site, we are doing any forced redirects with this code:

```
{redirect="sorry/index"}

```

The URL changes accordingling to the 404 Error Page.

---
Tags: redirects, 404, analytics
---


title: Alternate way to specify Pagination

text:
# Question
Title: Alternate way to specify Pagination
I am using an add-on that that outputs a list of messages.

As is the same with the other native ExpressionEngine tags, it is dependent on the pagination value on the URL to determine the offset.

The problem lies in a specific use case where if no "P" value is set in the URL, I want the add-on to get the "10 latest messages". Since 'P' value is not available, I don't know if the "10 latest message" is possible to get.

I was thinking if there is a way to set the "P" value when page is just starting to load.

Is there a way to do this? If not, any suggested alternatives to this issue?

# Answer
> 2 votes
Is the list of messages sorted, with the "10 latest messages" first (sort on date, descending), or last (sort on date, ascending)?

If the "10 latest messages" are first, they should be on the first page of results--which would be the URL with no P, or with P0.

In any case, if you know the offset--say you want messages 90-100, the channel entries tag Offset parameter lets you do that. E.g.,

```
offset="90" limit="10"

```

---
Tags: pagination
---


# Question
Title: Set up of conditional redirect in htaccess
I've asked a question over at Stackoverflow thinking that it wasn't really EE related

https://stackoverflow.com/questions/18229829/set-up-of-conditional-redirect-in-htaccess

But now I'm not so sure that the rules I'm using to remove index.php aren't having an effect.

Any help appreciated.

# Answer
This is what I eventually went with;

```
# Rewrite for new language based urls
# This is to try and get all current pages going to /en/(old url) with a 301 redirect
RewriteCond $1 !\.(gif|jpe?g|png|ico|js)$ [NC]
RewriteCond %{REQUEST_URI} !^/(index\.php|en)(/.*)?$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /en/$1 [R=301,L]

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

```

I'm sure that could be refined a fair bit as there is some duplication but it works so I'm happy with it for now as it is a temporary requirement.
> 2 votes

---
Tags: htaccess, .htaccess
---