# Question
Title: My template files are not in system > expressionengine > templates. How can I figure out where they are?
My template files are not in system \> expressionengine \> templates. There's only a single index.html file in that folder.

I visited Design ‣ Templates ‣ Global Preferences. Basepath to Template File Directory is set to a single slash.

How can I figure out where they are?

# Answer
> 2 votes
The templates are saved on database, by default.

If you want to save them as files, you need to enable this feature on Design \> Templates \> Global Preferences \> Save Templates as Files. Their default location is the folder of your website and "system/expressionengine/templates", if you don't changed the name of the system folder. You can change the directory where they are saved on Design \> Templates \> Global Preferences \> Basepath to template directoy. You need to fill this field with the full server path.

If you already have templates on database, you can edit them on Design \> Template Manager \> Template Group \> Template name. You'll find a check box "Save template as file".

The template as files and on database can be synchronized on Design › Templates › Synchronize Templates.

Some developers synchronize the templates, disable the feature of saving the files and delete them before launch the website.

You can read about saving your templates as files on documentation.

---
Tags: templates
---


# Question
Title: Check playa:child_ids against entry_id || Execute a Matric Column only if XYZ in the first
I have a Matrix field as a Low-Variable. It contains two columns, each Playa-Fields.

First Playa-Field: All my sites Pages from my "Page"-Channel. Second Playa-Field: Every Sidebar-Block from my "Sidebar"-Channel.

I want to control all my Sidebars from one place with this structure. It allows me to create Sidebar-Groups through rows and even re-use Sidebar-Groups for two sites.

The problem: How can I check my {entry\_id} (of the Page) against the {entry\_id} of the first playa-field to check if I should execute this sidebar row?

I want something like below, but obviously it doesn't work. Who knows a work-around?

```
{exp:low_variables:parse var="lv_sidebar_pages" var_prefix="matrix"}

        {if {matrix:cell_pages:child_ids} CONTAINS {embed:page_id}}
                    {matrix:cell_sidebars}
                    {!-- Sidebar-Code --}
                    {/matrix:cell_sidebars}
        {/if}
{/exp:low_variables:parse}

```

I also thought about a possibility to check normally in the first Playa-Field and then skip aka. break this loop of the Matrix-Field:

```
    {exp:low_variables:parse var="lv_sidebar_pages" var_prefix="matrix"}

        {matrix:cell_pages}
            {if {embed:page_id} != {entry_id}}
                BREAK THIS MATRIX LOOP.. and jump to the next row..
            {/if}
        {matrix:cell_pages}

        {matrix:cell_sidebars}
            ..so this code isn't executed
        {/matrix:cell_sidebars}
{/exp:low_variables:parse}

```

Thanks for the help.

# Answer
> 1 votes
You can limit your Matrix field to only show rows that include the current page’s entry\_id using Matrix’s `search` param like so:

```
search:cell_pages="[{entry_id}]"

```

Just in case you might have accidentally added the same page to multiple Matrix rows, it’s probably worth throwing a `limit="1"` in there too.

So to throw it all together:

```
{exp:low_variables:parse var="lv_sidebar_pages"
                         var_prefix="matrix"
                         search:cell_pages="[{entry_id}]"
                         limit="1"}

    {matrix:cell_sidebars}
        {!-- Sidebar-Code --}
    {/matrix:cell_sidebars}

{/exp:low_variables:parse}

```

Depending on what else is going on in your template, the `var_prefix` probably isn’t necessary, but it doesn’t hurt so I left it in.

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


title: Email class suddenly fails

text:
# Question
Title: Email class suddenly fails
My client is reporting that starting a few days ago, emails are not being sent to admin and customer on a completed transaction. This site has been running with no issues for nearly a year. Notifications are handled through CartThrob, which I believe uses the standard EE mail class.

I haven't made ANY changes. I did a quick test to test out the email class by sticking this in a template (from EE docs): (emails are real in my template, fake here)

```
      $from = "me@mydomain.com";
      $recipient="me@gmail.com";
      $email_subject = 'testing at 2:25 on CPC';
      $email_msg = "here's the test from debra";
      ee()->load->library('email');
      ee()->load->helper('text');
      ee()->email->wordwrap = true;
      ee()->email->mailtype = 'text';
      ee()->email->from($from);
      ee()->email->to($recipient);
      ee()->email->subject($email_subject);
      ee()->email->message(entities_to_ascii($email_msg));
      ee()->email->send(FALSE);
      echo ee()->email->print_debugger(array('headers'));
      //ee()->email->Send();

```

Which should send the mail and show me the headers. Instead I get a blank page. I should be seeing PHP errors, if any. If I turn on the debug for EVERYONE, not just super-admin (which I am) I see:

Fatal error: Call to undefined function ee() in /www/mydir/public\_html/mysys/expressionengine/libraries/Functions.php(680) : eval()'d code on line 6.

In Functions.php, that is pointing to this:

`// --------------------------------------------------------------------`

````
/**
 * eval()
 *
 * Evaluates a string as PHP
 *
 * @access  public
 * @param   string
 * @return  mixed
 */
function evaluate($str)
{
    return eval('?'.'>'.$str.'<?php ');
}

// --------------------------------------------------------------------

````

(Yes, I have php tags around the code in my template. Yes, I have PHP enabled in my template.) It's just not loading the email function from the library.

I thought EE might have been mysteriously corrupted somehow, so I upgraded to the next version from the one we had, so we are now 2.53. No issues with the upgrade, but still failing to call email class.

I can send email through the Communicate module. I've put in a support ticket with our host to see if it's something server-related. I tried this exact same template on another site I have at the same host, and it works perfectly.

Anyone seen anything like this or have any ideas? It's a complete mystery to me!

# Answer
> 1 votes
Just wondering are you using SMTP and Gmail? If so I ‘m having a sending problem since 7/19 just posted here

mike

---
Tags: email, php-errors
---


title: SMTP Gmail not working

text:
# Question
Title: SMTP Gmail not working
Around mid day 7/19 my emails stopped sending. Found out today that my Gmail account created just for the server was disabled. After a few hoops was able to get the Gmail account working again. But EE 2.6.1 still is not sending.

Could Gmail change some settings?

I was using tls://smtp.gmail.com:465 and port 587 to get EE to use a gmail account.

But at this point I think Gmail changed or is no longer allowing this to work.

Anyone have any insight?

thanks Mike

# Answer
> 1 votes
Looks like i just needed to give it some time after I reactivated the gmail account.

---
Tags: email, smtp
---


# Question
Title: How to tell if template is being accessed by mobile?
In the templates, is there a way to know what type of devices is accessing the site? I need to make certain decisions based on that (e.g. what kind of images to push). An "is\_mobile" or "is\_tablet" check would be ideal.

# Answer
To extend Robson's answer, I've just been implementing this myself in the past few hours!:

MX Mobile Detect and on Devotee

I could simply detect which device it is (e.g. ipad, iPhone, blackberry, etc), but that's too specific for my needs. I just want to detect the different sizes of device so I can drop smaller images...

So, in addition to my JS libraries I have this tag:

```
{if "{exp:mobile_detect:device}" != "not_mobile"}{exp:mobile_detect:screen_detect}{/if}

```

This basically drops the JS cookie to detect what type of device and gets height, width, etc, but only if the device is a mobile (includes tablets) - hence the conditional.

I then have custom sizes which can be accessed with the variable `{responsive}` and return the value I've set.

Here I'm using CE\_Image to deliver different sized images from the server:

```
{if "{responsive}" == "small"}
     {exp:ce_img:single src="{image}" alt="{alt-text}" width="420" bg_color="FFF" allow_scale_larger="yes" quality="80" save_type="jpg add_dims="no"}
{if:else}
     {exp:ce_img:single src="{image}" alt="{alt-text}" width="938" bg_color="FFF" allow_scale_larger="yes" quality="80" save_type="jpg add_dims="no"}
{/if}

```
> 5 votes

# Answer
The only way of do this is using addons.

There's a lot of them on Devotee. This looks a good bet, but I never used any of them.

Maybe it's better to use some front-end technique for this.
> 3 votes

# Answer
Have you employed any sort of 3rd party statistics/traffic tracking like Google Analytics or StatCounter etc.? You can drill down and do reports for a lot info like that. Or if you are comfortable, you can review your server logs.

Edit \> Sorry, not sure if you were asking how to SEE the break down of devices accessing your site, or how to just deliver custom views based on device type (like with media queries etc.).
> -1 votes

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


# Question
Title: What EE_Table.php file is Testee add-on referring to?
I've just copied the Testee files into the appropriate places in my EE installation. When I try to install the module from the control panel it complains that it can't find the file `system/expressionengine/libraries/EE_Table.php`. This file does not exist in that directory of my installation, what is it? Is it from an older / newer version of EE? (I am running 2.1.3).

# Answer
> 1 votes
I would guess this file appeared later on. I had a quick look at a 2.1.0 install on bitbucket.org (not mine, just a random one I found) and that file doesn't seem to exist. Whereas I've check a couple of installs of my own and it is present in 2.5.3 and 2.6.1.

Could you upgrade your install? Or maybe you could get it touch with the Addon owner and see what's going on.

---
Tags: module, table-class
---


# Question
Title: Ratings Delete function using zoo:visitors
I'm trying to use the delete function in Solspace's Ratings addon:

It's passing the correct `rating_id`, but what seems to be happening is that since I'm using Zoo Visitor, it doesn't seem to be recognising me as the author of the item I'm trying to delete (or something like that)?

How can I turn off the function that checks this?

# Answer
Disregard -- I found how to do this, was clearly written in the documentation I just didn't read. Thanks.
> 1 votes

---
Tags: ee2, add-on
---


title: Matrix bug with Channel Entries API

text:
# Question
Title: Matrix bug with Channel Entries API
Running ExpressionEngine 2.6.1 and Matrix 2.5.5

If I import/update multiple entries at once using the channel entries API, all the matrix rows inside exp\_matrix\_data have the same entry\_id applied as the first entry that was inserted/updated.

After digging through, it's stemming from the \_save method inside ft.matrix.php, the conditional in line 2376

```
if (empty($this->entry_id))
{
    $this->entry_id = $this->settings['entry_id'];
}

```

On subsequent requests, $this-\>entry\_id is not empty, so $this-\>entry\_id contains the previous entry\_id.

I've resolved for now by updating the above code to:

```
if (!empty($this->settings['entry_id']))
{
    $this->entry_id = $this->settings['entry_id'];
}

```

That seems to have fixed the issue.

# Answer
This appears to be fixed in Matrix 2.5.6.
> 1 votes

---
Tags: matrix
---


# Question
Title: Given a relationship id, get the entry_id of related entries
I have a safecracker form for a channel which has a gender field.

The gender field is a relationship field that points to a gender channel.

Since I have the gender relationship id available to me via the {gender} tag in the safecracker form, how do I get the entry id of the gender channel row using it?

I am using EE 2.5.5

# Answer
> 1 votes
First, you could just use `{field:gender}`, which will give you your Gender menu with the existing selection pre-selected.

But to answer your question, here's the query you would use (in 2.5.5 or lower - things change in 2.6+):

```
{exp:query sql="SELECT rel_child_id FROM exp_relationships WHERE rel_id = {gender}"}
     {rel_child_id}
{/exp:query}

```

---
Tags: relationships
---


title: Matrix developer log note

text:
# Question
Title: Matrix developer log note
Using Matrix v2.5.6 under EE v2.6.1 I'm getting the following message pop-up in the Developer Log:

```
Deprecated function set_human_time() called in system/expressionengine/third_party/matrix/celltypes/date.php on line 92.
Deprecated since 2.6. Use Localize::human_time instead.

```

Not sure what the quick fix is for this?

# Answer
Don't worry about these deprecated function notices - I'm sure P&T are aware of it, and will remedy it in a future release, before EllisLab removes the deprecated from their codebase.

These particular changes (to the Localize class) are irritating for developers to fix while maintaining compatibility with EE 2.5.5 and lower - especially since they are for the most part simply re-named functions.

If you want to fix your local copy, simply do a find and replace on the Matrix codebase, changing `set_human_time` to `human_time`.
> 1 votes

---
Tags: matrix, pixelandtonic
---


title: Permalinks going to 404

text:
# Question
Title: Permalinks going to 404
I have a link from my home page:

```
<h1><a href="{title_permalink='projects/view'}">{title}</a></h1>

```

I have the template setup in my folder -\> http://cl.ly/QMlL

I can't understand why it isn't working.

# Answer
It was an .htaccess issue. Nick didn't know that a .htaccess file is need to remove the index.php from the URLs.
> 1 votes

---
Tags: templates
---


# Question
Title: Cancelling member deletion in member_delete hook handler
I am trying to implement some codein the `member_delete` hook in EE. But for testing purposes, I just want the hook to trigger but don't go ahead with the actual delete.

Is there a way to do this? In some other form related extension hooks, I only need to set the error variables to be able to cancel submit. I am not sure if the same can be said of `member_delete`

# Answer
> 1 votes
Sure - just make sure you return `NULL` or an empty array at the end of your method. (The hook expects an array of `member_id`s to be sent back.)

---
Tags: hook, delete
---


# Question
Title: PHP errors after upgrading to Playa 4.4.4
I'm getting the following error a number of times on the Edit Entry page in the Control Panel after upgrading to Playa 4.4.4 on EE 2.5.5:

```
A PHP Error was encountered
Severity: Notice
Message: Array to string conversion
Filename: playa/helper.php
Line Number: 179

```

The front end seems to be ok.

PHP version is 5.2.17.

# Answer
Fixed in 4.4.5, but passing along from P&T Support for 4.4.4:

Replace offending line in third\_party/playa/helper.php with:

```
if (!is_array($category) && (strlen($category) > 4 && (strtolower(substr($category, 0, 4)) == 'not ') || (strtolower(substr($category, 0, 4)) == 'not_')))

```
> 1 votes

---
Tags: playa
---


# Question
Title: Channel Entries API / Open API round or square brackets inconsistencies when accessing variables
I'm having a bit of trouble getting Open API to work with EE in conjunction with the Channel Entries API. It seems to be a similar problem to this question:

https://expressionengine.stackexchange.com/questions/10933/open-api-500-internal-server-error

So pulling data with GET is fine, but POSTing data returns 500 errors.

The trouble seems to stem from using square brackets or round brackets to access session data. Open API uses the following format:

```
$this->EE->session->userdata['group_id']

```

Whereas EE in the channel entries API uses this format with the round brackets:

```
$this->EE->session->userdata('group_id')

```

I went through and edited all references with round brackets in /libraries/api/Api\_channel\_entries to the square brackets and that fixed the issue with Open API. I was able to GET and POST just fine.

But it messed up everything else with publishing entries via the EE control panel or with Safecracker.

Does anyone have any insight into the difference between accessing data in these 2 ways and how it might be affecting things? I'm not sure whether its an EE problem or PHP issue.

I'm running a local install of EE 2.5.2 with PHP 5.3.15 and I've also tried a fresh install of 2.6.1 and had the same issue.

# Answer
> 1 votes
I don't know how to fix your issues exactly, but I can help you with the EE logic in question.

If you look at the following file:

```
system/expressionengine/libraries/Session.php

```

You will notice that `userdata` is a public property *and* method. If you access the property, you get an editable associative array, whereas the `userdata()` method just returns a specific key from that array. If you look at the method itself, you will see it's actually just referencing the property.

```
/**
 * Fetch a session item
 *
 * @param   string      Userdata item to return
 * @param   default     value returned if the key isn't set
 * @return  mixed       $default on failure, item on success
 */
public function userdata($which, $default = FALSE)
{
    return ( ! isset($this->userdata[$which])) ? $default : $this->userdata[$which];
}

```

---
Tags: add-on, open-api
---


# Question
Title: Process plugins/modules tags inside another module
I'm working on a module function where it will take the tagdata and send it through email. The tagdata can contain anything from simple strings to plugin or module tags.

I can't seems to find the clean solution without hacking the undocumented methods and probably unsupported and unstable and causing so many other problems.

```
template_file.html
{exp:my_module:send_mail}
  This is just an example with
  {exp:another_module:do_something_cool}
    some other cool stuffs
  {/exp:another_module:do_something_cool}.

  {global_variables} are working fine with the parse_global() function
{/exp:my_module:send_mail}

```

The code above will just send the whole `$tagdata` as it is without processing the `{exp}` tag inside. How do I process that `{exp}` tag before I send it through email?

# Answer
> 3 votes
Man, take a look at the function \_parse\_sub\_template used on stash.

Mark Croxton, the developer of stash, cloned the tagdata and parsed it.

```
// clone the template object
$TMPL2 = $this->EE->TMPL;
unset($this->EE->TMPL);

// parse variables
$TMPL2->tagdata = $this->_parse_template_vars($TMPL2->tagdata);

// parse simple conditionals
$TMPL2->tagdata = $TMPL2->parse_simple_segment_conditionals($TMPL2->tagdata);
$TMPL2->tagdata = $TMPL2->simple_conditionals($TMPL2->tagdata, $this->EE->config->_global_vars);
// Remove any EE comments that might have been exposed before parsing tags
if (strpos($TMPL2->tagdata, '{!--') !== FALSE)
{
    $TMPL2->tagdata = preg_replace("/\{!--.*?--\}/s", '', $TMPL2->tagdata);
}
// parse tags, but check that there really are unparsed tags in the current shell
if (strpos($TMPL2->tagdata, LD.'exp:') !== FALSE)
{
    // parse tags
    $this->EE->TMPL = new EE_Template();
    $this->EE->TMPL->start_microtime = $TMPL2->start_microtime;
    $this->EE->TMPL->template = $TMPL2->tagdata;
    $this->EE->TMPL->tag_data   = array();
    $this->EE->TMPL->var_single = array();
    $this->EE->TMPL->var_cond   = array();
    $this->EE->TMPL->var_pair   = array();
    $this->EE->TMPL->plugins = $TMPL2->plugins;
    $this->EE->TMPL->modules = $TMPL2->modules;
    $this->EE->TMPL->module_data = $TMPL2->module_data;
    $this->EE->TMPL->parse_tags();
    $this->EE->TMPL->process_tags();
    $this->EE->TMPL->loop_count = 0;

    $TMPL2->tagdata = $this->EE->TMPL->template;
    $TMPL2->log = array_merge($TMPL2->log, $this->EE->TMPL->log);
}

$this->EE->TMPL = $TMPL2;
unset($TMPL2);

// record if PHP is enabled for this template
$parse_php = $this->EE->TMPL->parse_php;

// parse advanced conditionals
$this->EE->TMPL->tagdata = $this->EE->TMPL->advanced_conditionals($this->EE->TMPL->tagdata);

// restore original parse_php flag for this template
$this->EE->TMPL->parse_php = $parse_php;

```

Please, improve this answer if you find more useful info.

---
Tags: templates, module, parsing
---


title: Wrapping a query in a logic statement

text:
# Question
Title: Wrapping a query in a logic statement
I didn't think this would give me any trouble, but it is. I just want to run a query depending on the URL segments.

I have this now:

```
        {if segment_3 != ''}
            {exp:query sql="SELECT a.cat_id, a.parent_id, b.cat_name FROM exp_categories a, exp_categories b WHERE a.cat_url_title = '{segment_3}' AND b.cat_url_title = '{segment_2}'"}
        {if:else}
            {exp:query sql="SELECT cat_id, parent_id FROM exp_categories WHERE cat_url_title = '{segment_2}'"}
        {/if}
            ...
        {/exp:query}

```

But every time I wrap it in the IF statement, I get nothing...

# Answer
This happens because of the "else". If you use else, the conditional became advanced and it will be parsed after the modules.

Try this:

```
{if segment_3 != ''}
   {exp:query sql="SELECT a.cat_id, a.parent_id, b.cat_name FROM exp_categories a, exp_categories b WHERE a.cat_url_title = '{segment_3}' AND b.cat_url_title = '{segment_2}'"}
{/if}
{if segment_3 ==''}
    {exp:query sql="SELECT cat_id, parent_id FROM exp_categories WHERE cat_url_title = '{segment_2}'"}
{/if}
        ...
{/exp:query}

```
> 5 votes

---
Tags: ee2, query, ifelse
---


# Question
Title: Error using freeform with MSM - not working on main site
I have a three sites that are joined with MSM in EE 1.7.1. Currently, I am working to put in a better contact form for the three sites. On the two sub sites, www.watermarkcc.com/events/contact and www.sunnybrookcc.com/events/contact, the form works fine. I can modify it freely and it submits the inputs correctly. On the third site, www.stonewatercc.com/events/contact\_testing, which is the main site, I get these PHP errors when I submit the form

```
Notice: Trying to get property of non-object in /home/stone/public_html/admin/core/core.functions.php on line 2659

Notice: Trying to get property of non-object in /home/stone/public_html/admin/core/core.functions.php on line 2659

Notice: Trying to get property of non-object in /home/stone/public_html/admin/core/core.functions.php on line 2659

Notice: Trying to get property of non-object in /home/stone/public_html/admin/core/core.functions.php on line 2659

Warning: Cannot modify header information - headers already sent by (output started at /home/stone/public_html/admin/core/core.functions.php:2659) in /home/stone/public_html/admin/core/core.functions.php on line 325

```

Before, I was also getting that the second parameter in the array\_merge wasn't an array, and I added "(array)" to both parameters to get rid of that warning, but that leaves me with the warnings above.

Line 2659 in the file is:

```
$vars = array_merge((array)$vars, (array)$TMPL->embed_vars);

```

Line 325 in the file is:

```
switch($PREFS->ini('redirect_method'))
{
    case 'refresh' : header("Refresh: 0;url=$location");
    break;
    default        : header("Location: $location"); //line 325
    break;
}

```

Anyone have any suggestions? I am using the exact same code for all three forms so I am very confused why one isn't working.

Here's the opening tag of the form:

```
{exp:freeform:form form_name="sunnybrook_contact" notify="info@sunnybrookcc.com" template="custom_contact_sb" required="name|email"  return="events"}

```

# Answer
> 1 votes
Apparently, this was only a problem on one browser on my computer. In that browser, it decided that I was logged into the site as the super admin and it was having trouble letting me do anything more advanced that simply looking at the sites.

---
Tags: multi-site-manager, ee1, solspace-freeform
---


# Question
Title: button element not working for empty_cart
Having some trouble getting the empty\_cart form element to work as a `<button>` element.

For example this works:

```
{exp:store:checkout next="store/checkout/1"}
  ...
  <input type="submit" name="empty_cart" value="Empty Cart" />
{/exp:store}

```

However using a button element instead of an input will not:

```
{exp:store:checkout next="store/checkout/1"}
  ...
  <button type="submit" name="empty_cart">Empty Cart</button>
{/exp:store:checkout}

```

The other inputs such as "update\_cart" work fine as button elements. Is this a bug or am I just missing something?

The reason I want to use button elements is for styling purposes and I have to add an icon in the button using the CSS framework the project uses.

# Answer
> 3 votes
I think the problem is submitted data. A button (of submit type) will submit a form, but it won't pass any value as POST and Store requires that to confirm what you want to do.

Try:

```
<button type="submit" name="empty_cart" value="Empty Cart">Empty Cart</button>

```

Now it has a value, it'll be submitted with the form data and Store can read it.

---
Tags: expresso-store
---


# Question
Title: Expresso - Store : How to create a "Notify me when product is available" when product is out of stock
Is there a plugin or method to create a "Notify me when product is available" when a product is out of stock? I will like to let the CMS send an email to users who opt in to the notification whenever the project stock is replenished.

Regards, Rin

# Answer
> 1 votes
There is nothing in Store directly that would allow you to send an email based upon the stock changing. I would recommend you use a conditional in your template similar to

```
{if total_stock == 0}
 // Signup form to collect
 // users email address
 // goes here
{/if}

```

Depending on which approach you use for collecting the users email address you can send an email to them letting them know that the item is back in stock. Some things you will need to think about is unsubscribing users from the list after the email is sent or do you want to leave them in the list unless they unsubscribe.

To automate the process of sending out an email you could write an extension based upon one of the extension hooks. I would probably say the store\_inventory\_datatable would fit your needs.

---
Tags: expresso-store, module, email, out-of-stock
---


title: Fieldtype replace_tag() not firing

text:
# Question
Title: Fieldtype replace_tag() not firing
I have a custom field type that I've developed that I'm having a problem with.

If I do something like `{field return="http://mysite.com/group/template/entry-url/thanks"}` everything parses fine.

I'm using structure on the site too and if I use `{field return="{structure:page:url}thanks"}` that also works.

But if I try to use a global variable inside like `{field return="{current_url}/thanks"}`, the replace\_tag() method does not get called and I get an output like `{field return="http://mysite.com/group/template/entry-url/thanks"}`

Even using an embed didn't work, the code below outputs the same as the example above

embed code

```
{embed="group/.field" entry_id="{entry_id}" return="{current_url}/thanks"}

```

In field.html

```
{exp:channel:entries
    disable="categories|pagination|member_data"
    entry_id="{embed:entry_id}"
}
    {field return="{embed:return}"}
{/exp:channel:entries}

```

---

I'm assuming this is some weird parse order issue, but I have no idea why it would happen. Is there a way to change when a field is parsed, or some other way to make this work?

# Answer
> 1 votes
This is due to an issue with the EE API (it simply doesn't support nested variables within the FT tag parameters). The reason structure works is those tags are parsed early so by the time the channel entries loop run, the variables are parsed and therefor the FT tag parses correctly.

You need to use the following syntax to pass variables that are parsed later. Note, there are definitely other ways to work around this limitation, but this is the easiest fix if you don't need to use the tagdata for anything else.

```
{field}
    {embed:return}
{/field}

```

# Answer
> 0 votes
Try using `$this->EE->TMPL->parse_globals($tagdata)` in your fieldtype code

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


# Question
Title: Dynamic dropdown/select values and Validation issues
I am using the Freeform 4.0.12 along with ExpressionEngine v2.6.1 for forms in one of my projects and I have a situation where I need to display drop down values dynamically - based on what value was chosen in the previous dropdown.

Similar to a country/province dropdown - Eg. If I choose USA - then my province dropdown is filled with places from the USA, but if I choose India, then the provice dropdwon is filled with places in India.

Any idea how I can incorporate something like this?

Also, i am having an issue with the validation of the select fields. I am supposed to make them required. I tried using the inline errors and making the fields required. for example {freeform:field:country} - when I put this in, if I don't choose any option, by default the first value is chosen, if I manually enter all the values, then the validation works in the sense that the form is not submitted, but it doesnt display the field required error.

I could really use some help in there areas.

# Answer
Ok I managed to solve the dynamic dropdown values using some php/jquery and ajax, but I still have issues with the validation of the dropdown values. Can someone help me on that one?
> 1 votes

# Answer
I think, you are using "FreeForm Pro" and having "Select" field type for the country. And you are listing the countries within "Field Options" of field settings.

You should select "Value/Label List" from "List type" and for the first option put label like "-- Select Country --" with empty value. Now your country validation would work fine as the first/default country option will be submitted empty.

Share your further findings.
> 1 votes

---
Tags: solspace-freeform
---


title: Using categories in my php variable?

text:
# Question
Title: Using categories in my php variable?
How do I get the if statement below, to return TRUE and therefore return my string "Africa is in this array"? Note: template is set to parse on INPUT (I cant use output for this template)

```
 <?php
    $entryregion="{categories show_group='4' backspace='2'}{category_name}, {/categories}";
    $entryregionArr=(explode(',',$entryregion));
    print_r($entryregionArr);
    echo "<br />" ;
    if (in_array('Africa', $entryregionArr)) {
        echo "Africa is in this array";

    }
    ?>

```

the above `print_r($entryregionArr);` prints an array that looks like this. `Array ( [0] => Africa [1] => South Africa [1] => Durban [1] => )` I *think* I want it to look more like this `Array ( [0] => Africa [1] => South Africa [2] => Durban )` where Durban is in the 2nd key and the last key id deleted, but I am not sure why or how to do this. I have tried `parse='inward'` in the category tag. I had a recent suggestion through this site to use the explode() function and I am grateful because it has shown me that this is where my error is. Well, one step at a time. Any suggestions would be appreciated.

# Answer
> 1 votes
It's my personal advice not to mix up the EE tags with PHP code. There may cause issue because of "PHP Parsing Stage" sometime.

In your case, you can use PHP code like:

**EDITED:**

```
$this->EE =& get_instance();
    $res = $this->EE->db->select('cat_name')->where('group_id', 4)->get('categories')->result_array();
    foreach ($res as $r)
    {
        $entryregionArr[] = $r['cat_name'];
    }

    if (in_array('Africa', $entryregionArr)) {
        echo "Africa is in this array";
    }

```

I hope, it would help you.

---
Tags: categories, php, parse
---


# Question
Title: How to test for the entry_id of a related entry?
I need to do a check like this:

```
{if:elseif {related_entries id="privacy"}{entry_id}{/related_entries} == 48}

```

However, the template errors out when there is no related entry. How do I do this test properly?

# Answer
After the parsing of the related entry, if there's no related entry, your conditional will became this:

```
{if:elseif == 48}

```

As you can see, this doesn't make any sense. So, add quotation marks:

```
{if:elseif "{related_entries id='privacy'}{entry_id}{/related_entries}" == 48}

```

After the parsing of the related entry, if there's no related entry, your conditional you became this:

```
{if:elseif "" == 48}

```

And it'll work fine.
> 2 votes

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


# Question
Title: Product to Retailers (one to many) in ExpressionEngine
I have to build a website using the popular Expression Engine CMS.

I have managed to get my head around how channels and channel fields work. The problem I now have is that when an admin user adds a new product I would like for them to be able to select a retailer and then add a unique url for that retailer for the product.

Is this something that can be achieved using the Expression Engine CMS.

I had a look at Playa but I am unsure if this is what I need for this?

Many Thanks!

# Answer
> 1 votes
So the retailer has their own page, or the "unique url" lists all products by that retailer?

Playa is for linking entries, 1 entry to many. using it to link 1 to 1 is a bit overkill.

Based on the information provided, I say you want to use Categories. So that when creating a product, you assign it a category (and the categories are the retailers).

If the retailers have their own pages and not just used to group products, then you could just associate an entry in the retailers channel to the relevant category.

So "Joe Blogs Outlet" manufactures "Widgets".

Widgets is assigned the category "Joe Blogs Outlet" Going to /products/joe-blogs-outlet lists all the products from that retailer (this can be done a variety of ways, one of the easiest is to capture it in template group "products" and use the index template, then use Low Seg2Cat to identify the category in one of URL segments

The retailer category could have additional basic fields assigned to it to display details about the retailer in this instance.

But if you wanted the retailer to have their own "proper" page and EE entry instead of storing information in the Category fields, you could have another channel called "retailers", create an entry called "Joe Blogs Outlet" and assign it the same retailer category as the product, then you'll be able to link the product to the retailer and both will have their own entry.

Alternatively use EE relationships.

# Answer
> 0 votes
Ask yourself this:

(1) is a product likely to have a relationship with only one retailer, or multiple? (2) are custom category fields going to be enough to display what needs to be presented about each retailer?

If the answer to (1) is multiple, Playa will be your best bet (I've used it before even when there is only a one to one relationship because its filtering options are considerably better than a regular relationship field and the client has an easier time understanding it). And if (2) is no, channel entries are definitely the way to go, whether with Playa or a standard relationship field. Channel entries will give you longer term flexibility in what you present about the retailer(s), since you could add any number of amazing custom fields to deliver great information on the front end thanks to the extensibility of the fieldtypes from the community.

---
Tags: php
---


# Question
Title: The uploaded file exceeds the maximum allowed size in your PHP configuration file
Hi can you help? im going to upload some mp3 but doesnt work that problem can you help in EE2, where can find the solution ?thank you

# Answer
You might be best contacting your ISP to check with them what the maximum allowed file upload size is. You should also be able to check via the PHP info screen 'within' EE2 by navigating to:

Tools \> Utilities \> PHP Info

Then search for "upload\_max\_filesize" - if the figure there is lower than the file size of your MP3 then you will need to raise the maximum file size allowed by the server - again this is something your ISP should be able to help you with. :)
> 1 votes

# Answer
Per the error message:

> The uploaded file exceeds the maximum allowed size in your PHP configuration file

So you need to increase the maximum upload size in your PHP configuration file. If you don't have access to this, ask your web host.
> 0 votes

---
Tags: ee2
---


# Question
Title: Adding trailing slashes and redirecting to www in .htaccess
I'm using the following code in my .htaccess in order to redirect to the www version of the website and also to add a trailing slash by default. It all seems to work, but I wondered is this the most efficient way of doing it. I'm no expert on this side of things, so I've bolted this lot together from the official EE docs and a couple of separate articles I found on the subject.

```
RewriteEngine On

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

RewriteCond %{REQUEST_METHOD} !=POST
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+[^/])$ /$1/ [R=301,L]

RewriteCond $1 !^(admin|assets|uploads|favicon\.ico|robots\.txt|index\.php) [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]

AddHandler php5-script .php

```

Should I (if possible) combine the rules? At the minute you can end up with two 301 redirects if you go to the non www version of the website without the trailing slash.

My motivation for making these changes is to improve the general SEO of the site, so any tips are most welcome.

# Answer
Here's a gist I've made that you can comment/uncomment out the bits you need. To date I haven't found the need to combine rules and I haven't found many examples that actually do combine rules. I'd love to see them if find some though.

Lastly, I normally move the AddHandler stuff up in the .htaccess and keep the rewrite stuff below it.
> 2 votes

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


# Question
Title: City / State Combination Verifier? (Exp:resso Store)
Any ideas on implementing a city/state combination check before order submission? Client has a few orders with cities and zip codes that don't exist in the state they submitted. Example: Atlanta, NY, 30346.

My first step was to ensure that all fields were clearly labeled and conspicuous.

Unfortunately an order came in last week with a city/state mismatch. It may have something to do with my client's userbase.

Any ideas? Pretty sure it will involve an extension using the store\_order\_submit\_start hook and a rather large database, but that's all I have right now.

Appreciate any help.

Thanks, Bobby

# Answer
You would need to either write an extension as you have suggested or there are some javascript libraries available too. In the past I have used am API called Ziptastic which requires that the user enters their zip code then it will find the matching city/state/country for the particular address. The times that I have used it the only required shipping requirements were in the US so I can not speak for how it works for international shipping but it is a start instead of trying to manage your own DB of addresses.
> 3 votes

---
Tags: expresso-store
---


# Question
Title: How can I tell EE to ignore certain directories?
We're slowly introducing sections of our site into EE. First is the blog, then other sections will follow. As a result I need to place EE in the web root, but I also need to leave existing directories alone and allow access.

There are numerous people that touch the files in this web root and I don't want for them to have to add new directory names to the `.htaccess` file every time they add new directories. People will inevitably forget they have to do this and seek support.

Is there a seamless way to have EE automagically recognize when we need to load static content from a directory vs. a channel entry?

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

```

Reference

Basically if the request is not a folder or not a file, then add index.php and let EE control it, otherwise it'll be served by whatever is in the relevant path.

Ensure none of your other htaccess entries conflict with this though and that the "other" files in those folders don't try to rewrite back to the EE root.
> 5 votes

---
Tags: channel-entries, htaccess, static
---


title: get_files() in 2.6 version

text:
# Question
Title: get_files() in 2.6 version
I am new to expression engine and following the tutorial on creating a module here: http://ellislab.com/expressionengine/user-guide/development/module\_tutorial.html

issue is, there is that

> tools\_model::get\_files()

is no longer valid in EE 2.6. How do I get the files list in the 2.6 version?

Thanks, Bharath

# Answer
Looks like you lucked out: Changelog

But it's still in use throughout EE code (for example):

```
ee()->load->library('addons');
$fts = ee()->addons->get_files('fieldtypes');

```

Defined in /system/expressionengine/libaries/Addons.php (line 50 v1.6.1)

...or perhaps the other one in /system/expressionengine/models/file\_model.php

```
ee()->load->model('file_model');
$files = ee()->file_model->get_files($dir['id'], $params);

```

But not being in the documentation or formally available to developers can mean that Ellis Labs can change it in the future and therefore render your module broken, so I appreciate you're following the tutorial (which obviously needs updating) I wouldn't use the above function in a commercial environment.

Unless, like the tutorial, they've just not updated the documentation to refer to the function...
> 0 votes

---
Tags: module
---


# Question
Title: Where in the database do I find channel_short_name
I'm trying to write a custom SQL query like this:

```
{exp:query sql="
    SELECT channel_short_name
    FROM what_table_is_it_in
    WHERE entry_id = '{embed:entry_id}'"
}
{channel_short_name}
{/exp:query}

```

It's inside an embed template with an entry\_id passed in as {embed:entry\_id}. I just need it to output the channel short name for that channel of that entry.

What database table is this in? I can't find it!

I'm trying to replicate the example at the very bottom of this page: http://www.solspace.com/docs/rating/entries/ except I want to get channel\_short\_name instead of entry title.

# Answer
> 1 votes
Channel titles are stored in the (exp\_)channels table in the channel\_name column, so you'll have to do a join to get the information you need.

```
{exp:query sql="SELECT c.channel_name as channel_shortname FROM exp_channels as c LEFT JOIN exp_channel_titles as ct on c.channel_id = ct.channel_id WHERE ct.entry_id = '14'"}
    {channel_shortname}
{/exp:query}

```

In this case, I would use a regular channel entries loop instead of a query loop. I don't think it would produce much more queries if you disable everything.

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

```

---
Tags: query, sql
---


# Question
Title: Condition to display content if an entry has a relationship with another defined entry
I want to set a condition in a channel:entries loop whereby a chunk of content is displayed if the entry has a particular relationship with another particular entry. In other words, I want to say: "IF this entry has a relationship with entry 1, show X. IF this entry has a relationship with entry 2, show Y"...

How would I achieve that?

# Answer
> 1 votes
Maybe I'm missing your meaning, but this should work:

```
{relationship_field}
    {if relationship_field:entry_id == "1"}
        // Show X
    {/if}
    {if relationship_field:entry_id == "2"}
        // Show Y
    {/if}
{/relationship_field}

```

Note that this only accounts for parent-child relationships made within the entry you're currently viewing. To do the same for child-parent relationships, you'd need to do something similar with the parents tag.

---
Tags: channel-entries, relationships
---


# Question
Title: Trouble with Relationship content displaying
Following a recent upgrade to EE 2.6.1 I am having trouble with relationship navigation content showing up correctly here. The content in question is the right sidebar where is says: Sub Navigation.

Here is the code:

```
<!-- Subnavs -->
                        <div class="box">
                            <h2>Sub Navigation</h2>
                            <ul class="nav">
                                {exp:channel:entries channel="customer_services" orderby="entry_date" dynamic="off" sort="asc"}
                                {if parent_page=="0"}
                                    <li>
                                        <a href="{title_permalink=customer-services}" title="{title}">{title}</a>
                                        {reverse_related_entries weblog="customer_services"}
                                            {if count==1}<ul>{/if}
                                            <li><a href="{title_permalink=customer-services}" title="{title}">{title}</a></li>
                                            {if count==total_results}</ul>{/if}
                                        {/reverse_related_entries}
                                    </li>
                                {/if}
                                {/exp:channel:entries}
                            </ul>
                        </div>

```

I would appreciate any guidance for getting this to display correctly.

Thanks!

# Answer
Relationships were completely rewritten in EE 2.6, so your reverse\_related\_entries will no longer work unfortunately.

See http://ellislab.com/expressionengine/user-guide/modules/channel/relationships.html#tag-reference for updated documentation.

However the updater should have replaced your existing relationship tags with their equivalents.
> 1 votes

# Answer
Instead of `reverse_reated_entries`, use the `parents` tag in 2.6. (Also, you're using `weblog` when you should be using `channel`).

```
{parents channel="customer_services" field="relationship_field_name"}
    {if parents:count == "1"}<ul>{/if}
    <li><a href="{parents:title_permalink="customer-services/index"}" title="{parents:title}">{parents:title}</a></li>
    {if parents:count == parents:total_results}</ul>{/if}
{/parents}

```
> 1 votes

---
Tags: relationships
---


# Question
Title: Access tags/variables in email notifications
I am looking at Design -\> Message Pages -\> Email Notifications templates.

It seems to me that the variables available in the templates are very limited.

Is there a way to introduce more variables or even tags in the template?

I wanted to use a custom field in a channel to be the sender name instead of `{sender_name}`. Ditto for `{receiver_name}`

# Answer
> 1 votes
EE System templates are extremely poor and basic. Your best bet is a third-party add-on:

Libraree

Custom System Messages (I'm pretty sure allows you to customise the email templates)

Also consider MX Notify Control

# Answer
> 0 votes
Try `[sender_name]` and/or `[receiver_name]`.

# Answer
> 0 votes
I would checkout Postmaster. https://objectivehtml.com/postmaster

It's by far the most advanced and capable notification add-on for EE with API's to do just about anything. It supports 7 different email services, and allows you to take control over system emails and so much more.

Currently, you can't edit these templates within Postmaster, but it does with any add-on hook (especially with some knowledge of PHP), so it's possible to make any variable (from any hook) available within a template. There are number of hooks included out of the box.

To customize the templates it's really just a matter of override the exp\_specialty\_templates records with your own content.

---
Tags: email
---


# Question
Title: Is there a shortcut/variable tag for an Assets field’s ‘parent’ entry title?
I have an Assets field in a Matrix field. When I'm inside the Assets field's loop, is there a shortcut tag to output the 'parent' entry's Title field (1.1 in the hierarchy below)?

1. Entry
    1. Title
    2. Matrix field
        1. Assets field

Or do I have to use an embed?

I ask because I recall Pixel & Tonic used to document all kinds of variable tags for Playa such as `{parent:title}`, that still work but are now *undocumented*.

I've tried a few such ideas in my Assets loop to see if I could get lucky but no joy so far.

# Answer
> 4 votes
Doh! The answer is to use the *documented* `var_prefix` parameter so I can then reference the entry's `{title}` field as normal :$

That Brandon fella has thought of (nearly) everything :)

---
Tags: matrix, assets, pixelandtonic
---


# Question
Title: Parse order and/or single/double quote issue with Calendar events and Google Map Info Window
I am utilizing a combination of Solspace 'Calendar', 'Playa', and 'Google Maps for ExpressionEngine'. I'm having a strange issue where the dates aren't showing up correctly in my infowindows on the Google Map, but they show up fine using the same code outside of the infowindow.

So, I have a 'Location' channel, and an 'Event' channel. The Event channel is associated with the Calendar module, and uses a Playa single relationship field to relate it to a Location.

I am adding markers to the map for every 'Location', and for each marker, I'm populating the infowindow with the Location details. this includes using the Playa:Parents method to show all of the events that are at that location.

I copied the code from the Solspace Calendar demo template for a single event to show the event date, because it had all the conditionals all worked out to deal with single day or multi-day events well.

My problem is that in the infowindow, it's only showing the 'From' date, and not the 'To' part of the date string. It shows it correctly when I output it outside of the map, though. Here is the code that is outputting the date information.

```
    {exp:calendar:events}
    <b>From:</b> {event_first_date format="%F %j, %Y at %g:%i%a"}
    {if event_never_ends}
        (never ends)
    {if:else}
        {if "{event_first_date format='%Y%m%d%g%i%a'}" != "{event_last_date format='%Y%m%d%g%i%a'}"} <b>to:</b>
            {if "{event_first_date format="%Y%m%d"}" != "{event_last_date format="%Y%m%d"}"}
                {event_last_date format="%l, %F %j, %Y at %g:%i%a"}
            {if:else}
                {event_last_date format="%g:%i%a"}
            {/if}
        {/if}
    {/if}
    <a href="{path=find-music/event/{url_title}}">{title}</a>
{/exp:calendar:events}

```

But this is how it outputs, in the infowindow, and outside of the map.

(crap, I don't have enough 'reputation' to post the image here, but it's here: http://paleosun.com/misc/stackexchange-map-calendar-question.jpg)

Notice, the section below the map has the "to" date. Same code is used to output it.

I have determined that something is going wrong with the quotes in the event date formatting tags. The `{if "{event_first_date format='%Y%m%d%g%i%a'}" != "{event_last_date format='%Y%m%d%g%i%a'}"}` part is never resolving to 'true' like it should. In fact, If I just try to output `{event_first_date format='%Y%m%d%g%i%a'}` in the infowindow part, nothing show up. However, if I use double quotes and output `{event_first_date format="%Y%m%d%g%i%a"}` it DOES work. The problem is, I cannot use that fix in the conditional, because double quotes are already being used around the output of that tag...

Any ideas why? Or what I can do as a work-around?

Here is all of my relevant template code:

```
{exp:gmap:init
    id="mainmap"
    class="gmap"
    style="height:600px;width:100%; border: 1px solid green;"
    center="United States"
    zoom="4"
}

<div id="location-container">
    {exp:channel:entries
        channel="location"
        disable="member_data|pagination|category_fields"
        limit="9999"
        }

        {if loc_show_on_map == 'yes'}

            {exp:gmap:marker
                id="mainmap"
                latitude="{loc_latitude}"
                longitude="{loc_longitude}"
                geocode="false"
                clustering="true"
                infobox="true"
                show_one_window="true"
                class="ui-infobox-dark ui-infobox"
                offsetY="-45"
                offsetX="15"
                icon="{categories limit='1'}{category_image}{/categories}"
                }

                <div style="width: 400px;" class="clearfix">
                    <h3><a href="{path=find-music/location/{url_title}}">{title}</a></h3>

                    <ul>
                        {categories}
                            <li>{category_name}</li>
                        {/categories}
                    </ul>

                    {if loc_image}<img src="{loc_image}" alt="{title} image" width="200" class="right" />{/if}
                    {loc_contact_first_name} {loc_contact_last_name}<br />
                    {loc_street_address} {if loc_address_details}{loc_address_details}{/if}<br />
                    {loc_city_town}, {loc_state} {loc_zip_code}<br />

                    <ul>
                    {exp:playa:parents channel="calendar_events"}
                        <li>
                            {exp:calendar:events}
                                <b>From:</b> {event_first_date format="%F %j, %Y at %g:%i%a"}

                        <br />From:{event_first_date format='%Y%m%d%g%i%a'}
                        <br />To: {event_last_date format='%Y%m%d%g%i%a'}!
                        Yes
                                {if event_never_ends}
                                    (never ends)
                                {if:else}
                                    {if "{event_first_date format='%Y%m%d%g%i%a'}" != "{event_last_date format='%Y%m%d%g%i%a'}"} <b>to:</b>
                                        {if "{event_first_date format="%Y%m%d"}" != "{event_last_date format="%Y%m%d"}"}
                                            {event_last_date format="%l, %F %j, %Y at %g:%i%a"}
                                        {if:else}
                                            {event_last_date format="%g:%i%a"}
                                        {/if}
                                    {/if}
                                {/if}
                                <a href="{path=find-music/event/{url_title}}">{title}</a>
                            {/exp:calendar:events}
                        </li>
                    {/exp:playa:parents}
                    </ul>
                </div>

            {/exp:gmap:marker}

            {!--
                custom javascript to add attributes to the markers
                for location type and music styles, so we can filter
                based on that
            --}
            <script type="text/javascript">
                if(typeof newMarker!='undefined'){
                    newMarker.entry_id = {entry_id};
                    newMarker.music_styles = [];
                    {exp:playa:children field="loc_music_styles"}
                        newMarker.music_styles.push({entry_id});
                    {/exp:playa:children}

                    newMarker.location_types = [];
                    {categories}
                        newMarker.location_types.push({category_id});
                    {/categories}
                }
            </script>
        {/if}

        <div id="location-{entry_id}"  class="location-entry clearfix">
            <h3><a href="{path=find-music/location/{url_title}}">{title}</a></h3>
            {if loc_image}<img src="{loc_image}" alt="{title} image" width="200" class="right" />{/if}
            {loc_contact_first_name} {loc_contact_last_name}<br />
            {loc_street_address} {if loc_address_details}{loc_address_details}{/if}<br />
            {loc_city_town}, {loc_state} {loc_zip_code}<br />

            <ul>
            {exp:playa:parents channel="calendar_events"}
                <li>
                    {exp:calendar:events}
                        <b>From:</b> {event_first_date format="%F %j, %Y at %g:%i%a"}
                        {if event_never_ends}
                            (never ends)
                        {if:else}
                            {if "{event_first_date format='%Y%m%d%g%i%a'}" != "{event_last_date format='%Y%m%d%g%i%a'}"} <b>to:</b>
                                {if "{event_first_date format="%Y%m%d"}" != "{event_last_date format="%Y%m%d"}"}
                                    {event_last_date format="%l, %F %j, %Y at %g:%i%a"}
                                {if:else}
                                    {event_last_date format="%g:%i%a"}
                                {/if}
                            {/if}
                        {/if}
                        <a href="{path=find-music/event/{url_title}}">{title}</a>
                    {/exp:calendar:events}
                </li>
            {/exp:playa:parents}
            </ul>
            <hr />
        </div>
    {/exp:channel:entries}
</div> <!-- /#location-container -->

```

# Answer
I am not sure of a workaround, but that is definitely a parse order issue. Given this is a very unique scenario, it would be rather difficult to duplicate without getting access to your EE install.

Email support@objectivehtml.com and I can try to help you find a workaround. I am not sure who this support requests belongs to, me (Objective HTML), P&T, or Solspace but I can try to help you. :)
> 1 votes

# Answer
I never used GoogleMpas for EECMS, but let's try something.

I already had some problems to solve because of nested `exp:channel:entries` and `exp:channel:events`.

So, let's first move them to an embed, but trying to reduce the number of times the modules are parsed and improve the performance.

```
{embed="events/.mapmarkers" event_ids="{exp:playa:parents channel='calendar_events' backspace='1'}{entry_id}|{/exp:playa:parents}"}

```

The default format of the variables of `exp:channel:events` is already YYYYMMDD. So you don't need to format some of your conditionals.

```
{if "{event_first_date}" != "{event_last_date}"}

```

Other conditionals, can have the double and single quotation marks replaced and the '%a' can be removed if you use '%H'.

```
{if '{event_first_date format="%Y%m%d%H%i"}' != '{event_last_date format="%Y%m%d%H%i"}' }

```

Your embed will look like this:

```
{if embed:event_ids !== ""}
    <ul>
    {exp:calendar:events parse="inward" event_id="{embed:event_ids}"}
        <li>
        <b>From:</b> {event_first_date format="%F %j, %Y at %g:%i%a"}

        <br />From:{event_first_date format='%Y%m%d%g%i%a'}
        <br />To: {event_last_date format='%Y%m%d%g%i%a'}!
        Yes
            {if event_never_ends}
                (never ends)
            {if:else}
                {if '{event_first_date format="%Y%m%d%H%i"}' != '{event_last_date format="%Y%m%d%H%i"}' } <b>to:</b>
                    {if "{event_first_date}" != "{event_last_date}"}
                        {event_last_date format="%l, %F %j, %Y at %g:%i%a"}
                    {if:else}
                        {event_last_date format="%g:%i%a"}
                    {/if}
                {/if}
            {/if}
            <a href="{path=find-music/event/{url_title}}">{title}</a>
        </li>
    {/exp:calendar:events}
    </ul>
{/if}

```

Because you're calling this twice on your template, I strongly suggest you to use stash to save the content of the embed.
> 0 votes

---
Tags: playa, parse-order, google-maps-for-ee, calendar
---


title: Low Seg2Cat Not showing all entries

text:
# Question
Title: Low Seg2Cat Not showing all entries
I am using Low Seg2Cat here and there are three entries with the Renewable Energy category. However, only one of them is displaying.

Here is the code I am using:

```
{exp:channel:entries channel="what_we_do" category="{segment_3_category_id}" }
                            <div class="project">
                                    <div class="thumbnail">
                                        <img src="{project_thumbnail}" alt="{title}" >
                                    </div>
                                    <h3><a href="/what-we-do/project/{url_title}">{title}</a></h3>
                                    <p>{project_summary} <a href="/what-we-do/project/{url_title}">More...</a></p>
                            </div>
{/exp:channel:entries}

```

I can't see what I might be missing here. Please advise.

Thanks!

# Answer
> 4 votes
does it work if you set dynamic="no"?

---
Tags: low-seg2cat
---


# Question
Title: Related Entries broken after upgrade to 2.6
I just upgraded to 2.6 and everything seemed to go ok until i found a piece of the template code on the site.

```
{related_entries id="task_lead"}{/related_entries}

```

Now when i go to the template code it shows:

```
{related_entries id="task_lead"}{staff_name}{/related_entries}

```

notice the {staff\_name} variable, which i think is kind of weird

# Answer
> 0 votes
I had the same problem and had to convert the {related\_entries} tag to the new relationships format:

From:

```
{related_entries id="task_lead"}{/related_entries}

```

To:

```
{task_lead}{task_lead:title}{/task_lead}

```

Or for a URL:

```
{task_lead}<a href="url/{task_lead:url_title}">{task_lead:title}</a>{/task_lead}

```

Ellis labs claim that the templates will be automatically updated to the new format, but this didn't work for us.

# Answer
> 0 votes
EE has released 2.6.1 which resolves this bug.

---
Tags: upgrade, related-entries
---


title: Saving JSON to member field?

text:
# Question
Title: Saving JSON to member field?
Has anyone saved JSON in a custom member field? I have a big array I'd like to tie to member registration. I'm using the User module to register. Thoughts?

# Answer
That was exactly what I needed to do, just didn't think about it at the end of the day. Building the JS object onClick of the button, then filling a textarea prior to submit. Thanks for the point in the right direction.
> 1 votes

# Answer
What we did was wrote a, extension and handle the hook that updated the entry and added it there.

This was for BrilliantRetail and we needed to add JSON to a field for each product when being added to the cart.
> 0 votes

# Answer
I just did this, and although my situation was pretty unique, hopefully it still helps.

In my situation, I needed to add lots of data from a template, and I wanted to use `Freemember` to easily save it as a custom field. Here were the steps:

1. Created a simple "dummy" html `form` with all the necessary inputs, independent of Freemember, with no form action or onClick event (just a `form` tag, inputs, and a submit button).
2. Created a separate (hidden) `form` with one hidden field that's set up via Freemember's `{exp:freemember:update_profile ...}` tag. This field is set to submit to my custom member field, and has an empty `value` attribute. This is what actually gets submitted.
3. When the dummy form is submitted, I used jQuery's amazing `.serializeArray()` method to collect all the dummy form data into a nice js object, and then a really simple json-jquery plugin to turn that into a proper `JSON` string.
4. Once I have my json string from all the form fields, I use it to populate my Freemember form's hidden `input` tag, and trigger it's submission.

Keep in mind, for most cases this is a sloppy approach. Building a proper extension / module and implementing solid validation is likely the way to go. For someone like me who's way quicker in JS than EE Extension Development, this was a nice workaround. At the very least, hopefully this approach brings other methods to light =).

Best of luck!
> 0 votes

---
Tags: add-on, solspace-user
---


title: Access segments in hooks

text:
# Question
Title: Access segments in hooks
Is it possible to access segment or page information in the hooks?

Each hook has different parameters so I can't rely on those to get segment information.

# Answer
> 2 votes
You should look into "URI Class"

---
Tags: segments, hook
---


# Question
Title: Extension Development : Redirect on error
I'm developing an extension that uses the `member_update_end` hook. This extension requires communicating with a 3rd party API, which I can't guarantee will always be active.

As a side note, the hook will be called when a specific custom member field is updated, which I do in my templates via `Freemember`.

Should this 3rd party API fail to respond with the output I want, how can I present (or redirect to?) an error message/template to the user? Is there an EE method (or best practice) for such things while inside an extension, that makes sure it won't interrupt anything else that needs to happen (like other hooks that may be set, etc.)?

Thanks in advance.

# Answer
In the hooked function you can return the error message which will be displayed as "User Message".

Like:

```
function function_name($member_id, $data)
{
$errors = array();
#####
Data processing with API

Put all the errors into the array $errors

#####

if( count ($errors) > 0 )
return $this->EE->output->show_user_error('general', $errors);
}

```

I hope, it would help you.
> 1 votes

---
Tags: add-on, extension, redirects, hook
---


# Question
Title: Search on Assets (pixel & tonic) Meta Data
Hi I need help with searching assets image data via the front end of my site. I have a single entry for a page with an assets field powered gallery on it.

The multiple images for the gallery are added via an assets field and pulled into my template with an assets tag pair e.g.

{page-gallery} content {/page-gallery}

Is it possible to do a search on assets meta for the content within the tag pair ?

My goal is to create a simple image library that can searched on assets meta content.

e.g. {page-gallery:title}

Is this possible ?

# Answer
Assets has field tag parameters that correspond with each of its metadata fields (see http://docs.pixelandtonic.com/assets/templating/field.html).

If you pass your ‘title’ search input as POST data on the page, you can fetch that value and pass it into Assets’ `title` param using the GET/POST Parameters add-on like so:

```
{page-gallery title="{exp:parameters post='asset_title'}"}
    ...
{/page-gallery}

```
> 1 votes

---
Tags: assets
---


# Question
Title: overrides in config.php site_url and templatefiles
I have two questions for you:

1. changing the settings for the site\_url with `$config['site_url'] = "http://domain/";` in config.php works as expected in some places. But the paths in the channel preferences are still not affected by this override. Shouldn they be?
2. How do I, in the config.php, define the the path to directory where the the templatefiles are stored?

/yours truly

# Answer
1) I think, you need to update the paths in channel preference as it wouldn't be effected with Site URL.

2) You need to set `$config['tmpl_file_basepath'] = '';` to specify the directory where templates will be stored as file.

You can see all config variables from: http://devot-ee.com/ee-config-vars
> 2 votes

---
Tags: config, config-overrides
---


title: Low variables and wyvern

text:
# Question
Title: Low variables and wyvern
I have created a low variable that uses wyvern for a section of the page, although i cannot get the wyvern content to display at all.

My code to call in the variable is :

{exp:low\_variables:pair var="gv-online-training"} {gv-online-training} {/exp:low\_variables:pair}

What am i doing wrong anyone?

# Answer
> 1 votes
I don't think the tag pair is what you are looking for. Try the single tag:

```
{exp:low_variables:single var="gv-online-training"}

```

Or alternatively, just:

```
{gv-online-training}

```

---
Tags: low-variables
---


# Question
Title: EE code in WYGWAM being wrapped in a paragraph tag
I'm using MX-Jumper to replace EE style code in a WYGWAM field with images. The WYGWAM content will look something like this:

```
{image_1}

Climb leg rub face on everything give attitude nap all day for under the bed. Chase mice attack feet but rub face on everything hopped up on goofballs.

```

Using MX-Jumper I'm replacing `{image_1}` with images from a Matrix field. Thing is when putting `{image_1}` in the WYGWAM field it’s getting wrapped in a `<p></p>` tag.

Is there any way to strip or even disallow a `<p></p>` tag around these shortcodes?

# Answer
> 1 votes
That likely comes down to how you are placing the shortcode into the Wygwam field - the

tags are likely wrapped around {image\_1} before any replacement is done. Have you tried this:

```
{image_1}Climb leg rub face on everything give attitude nap all day for under the bed. Chase mice attack feet but rub face on everything hopped up on goofballs.

```

That may still not be exactly what you are looking for though, since it would place the image within the

tgs of the paragraph. But you should still be able to use your CSS to compensate though, applying your desired styling to the combination of p tag followed by img tag - particularly if you surround the wygwam field with something to allow you to target is specifically. Then you wouldn't necessarily need to remove it in the code, just remove its impact visually.

---
Tags: wygwam, richtext, shortcode, mx-jumper
---


# Question
Title: advice on displaying a business directory / member list
I have a site with a list of members and each member is listed in a business directory. I am using solspace user to handle my members and display their location on a map.

THe issue I have run into is that some members have more than one location so I need to come up with a method to allow them to add a second location. (and sometimes 3 or 4 additional locations)

What are my options? add many new member fields or build a new channel to handle additional stores?

I laready have hundreds of members with their info already in there, so changing the members with a single store is not really an option. I only need to add on the option of additional stores.

I am using this bit of code in a map widget:

```
{exp:user:users sort="asc" limit="100" group_id="5" search:shipping_region="NB" search:retailer_type="not Pending|Web"}
    {if longitude}
     {
        "properties": {
            "tags": [],
            "phone": "{shipping_phone}",
            "classifiers": ['a'],
            "address": "{shipping_address1}",
            "name": "{shipping_name}",
            "province": "{shipping_region}",
            "owner": "welocally",
            "postcode": "",
            "city": "{shipping_address3}",
            "country": "{shipping_country}",
            "website": "{website}"
        },
        "type": "Place",
        "geometry": {
            "type": "Point",
            "coordinates": [ {longitude},{latitude} ]
        }
    },
    {/if}

```

{/exp:user:users}

# Answer
Couldn't you just add a matrix field for "other locations" to allow the user to define their other locations as needed, leaving your existing member location field intact (basically turning it into their "primary" location)?
> 1 votes

---
Tags: channel, solspace-user
---


# Question
Title: Membrr - Credit Card Number not required?
I have a billing form for plans/subscriptions that are not free.

However, when trying to submit the form with empty credit card number, it processes the form as valid and subscribes the user.

Is this the default behaviour? If not, are there options to prevent this? Or do I need to implement my own hook for it?

# Answer
> 2 votes
I think its related with some gateways doesn't requiere CC info recollected before the actual payment (usually for offsite payments). What gateway are you using? Also check help.electricfunction.com I remember seeing very similar question already

# Answer
> 2 votes
Davor is right, it looks like this question is very similar. It notes a bug and an update to eWay and Stripe payment gateway code for Membrr.

That said, you might also consider using some client side form validation to avoid the form being submitted at all without the CC# field being validated. On our site we use the jQuery validation plug-in. If you want to see it in action on our site you can see it here

---
Tags: membrr
---


title: Does Assets support categories?

text:
# Question
Title: Does Assets support categories?
I'm looking to create a file repository of PDFs.

One way I was thinking to do this is to just use the native file manager with categories to sort the content. But I would prefer to use Assets, but I can't find anywhere mentioning if it supports categories or not?

# Answer
> 1 votes
If you need to organize it at the back end, you can do this very easily using folders in assets. So that is not strictly a category, but might fill the purpose.

For the front end it's super fast as well. You can insert a complete folder in a field in one go.

The only thing might be that it will not automatically update files that are added in the back end, you would need to add these in the field.

PS; you can order the items at will, by dragging them around in the field.

---
Tags: assets
---


# Question
Title: Multiple product categories non ecommerce site
Hi what would be a good starting point for building the following functionality with EE:

Level 1: Main product categories - page listing all main categories

Level 2: Selecting a main category takes user to list of sub categories within the main category

Level 3: Selecting subcategory takes user to a list of products within the subcategory.

Level 4: Product page

Importantly products would need to feature in several categories which would be easily selected in the admin panel by my client.

Would an addon like Matrix help with this?

# Answer
I can't see one single reason for an add-on other than Low Seg2Cat on this.

The default category management of EECMS can handle this pretty well.
> 0 votes

---
Tags: ee2, matrix, categories
---


# Question
Title: {status} not available as variable in Solspace Rating:Entries?
Is {status} not an available variable in Rating:Entries?

It's a parameter but it doesn't seem to be available as a variable - I've tried using it in a conditional and it doesn't work.

Solspace, any comment? Any workaround?

I'm creating a page to show a logged in member's ratings but I want to show closed ratings and well as open ratings and display an extra "Pending approval" message on closed ratings only. Need status as a variable to do this.

# Answer
Assuming you're using the latest versions of ExpressionEngine (2.6.x) and Rating (3.2.x), you can display the status of the rating submission by using the {rating\_status} variable within the {exp:rating:entries} tag.

This was not documented for some reason, so I will be documenting it now. :)
> 1 votes

---
Tags: solspace, solspace-rating
---


# Question
Title: Using the new Relationships field for a conference site
I'm working with a client that uses EE to promote its annual conferences. Although I haven't used it yet, the Relationship field in EE 2.6.x seems like it would be perfect for what I have in mind, but I am hoping to get some advice on how to best set it up.

Each conference has a number of presentations, each of which has one or more presenters. I'm thinking the relationships would be organized like so:

* Conferences
    + Presentations
        - Presenters

Assuming that each of these are the names of my channels, how should I create the relationships between them? One relationship that links them all? One for Conferences and Presentations and another for Presentations and Presenters?

Any pointers on how to set this up would be greatly appreciated--thank you!

# Answer
> 1 votes
Seems to me like everything could be controlled from the middle of the relationship.

Inside your presentations channel field group, you would have a conferences relationship field linked to the conferences channel. And also in that field group, you would have a relationship field to your presenters channel. This leaves your conferences as the parent, which is what you would want since they would change with the least frequency. That's how I've done it before myself, anyway, and it worked well.

---
Tags: relationships
---


title: conditional returns result, but doesn't

text:
# Question
Title: conditional returns result, but doesn't
EE 2.5.3 MSM 2.1.4

9 site MSM install where this code is on site 9 calling content from site 1. All content is pulled correctly except this field.

I have the following conditional which is returning the html inside the conditional correctly.

```
{if press-image}
<p class="press-image">

    {!--
    <img src="{press-image}" alt=" " height="120" width="160" class="pretty-box"/>
    --}

    {exp:ce_img:single src="{press-image}" height="120" width="160" class="pretty-box"}
</p>
{/if}

```

However, the source for the image is returning blank. This happens regardless of whether I'm using CE Image or not. I've also tried placing {press-image} by itself in the template and it returns nothing.

I'm not sure why the conditional would work but not output the field that is checking. Any ideas on why this would be happening?

**\******UPDATE******\******

More code as per lisa's request in the comments

```
{exp:channel:entries channel="press" site="default_site" disable="member_data|category_fields" category_group_id="2" limit="5" paginate="bottom"}
<article>
    <!-- Blog Post -->
    <section class="blog-post">
        <!-- Blog Post Title -->

        {if press-image}
        <p class="press-image">

            {!--
            <img src="{press-image}" alt=" " height="120" width="160" class="pretty-box"/>
            --}

            {exp:ce_img:single src="{press-image}" height="120" width="160" class="pretty-box"}
        </p>
        {/if}

        <header>
            <h3><a href="/media/{url_title}">{title}</a></h3>
        </header>

more code here
</article>
{/exp:channel:entries}

```

Also tried the following in the middle of the channel:entries tag but not in a conditional and it output nothing.

```
{press-image}{path}/{filename}.{extension}{/press-image}

```

**\*****UPDATE 2******\*****\****/ Have now created a new test template that contains only the following code - problem persists.

```
<div id="blog">
    <!-- Begin Blog Post -->
    {exp:channel:entries channel="press" site="default_site" disable="member_data|category_fields" category_group_id="2" limit="5" paginate="bottom"}
    <article>
        <!-- Blog Post -->
        <section class="blog-post">
            <!-- Blog Post Title -->

            <p class="press-image">
            press

                <img src="{press-image}" alt=" " height="120" width="160" class="pretty-box"/>

                {exp:ce_img:single src="{press-image}" height="120" width="160" class="pretty-box"}

                {press-image}{path}/{filename}.{extension}{/press-image}

            image
            </p>

            <header>
                <h3><a href="/media/{url_title}">{title}</a></h3>
            </header>
            <!-- Blog Post Date -->
            <div class="date">{entry_date format="%M  %d%S %Y"} <br /><a href="/media/{url_title}" style="font-size:110%;">Read More…</a></div>

        </section>
    </article>
    {/exp:channel:entries}
<div>

```

Below is the source code on the front end of the site.

```
<section class="blog-post">
            <!-- Blog Post Title -->

            <p class="press-image">
            press

                <img src="" height="120" width="160" class="pretty-box">

            image
            </p>

            <header>
                <h3><a href="/media/some-url-title">Entry Title Here</a></h3>
            </header>
            <!-- Blog Post Date -->
            <div class="date">Jun  30th 2013 <br><a href="/media/some-url-title" style="font-size:110%;">Read More…</a></div>

        </section>

```

**\*****UPDATE 3******\*******

I have now put the following code on both the site1 site and the site that is causing trouble. In site1 the image url is output, in the trouble site nothing is output

```
{if logged_in}
    a{press-image}b
{/if}

```

# Answer
Ok, so this is kind of cool and baffling. I'll just write through the troubleshooting I did. Check out the template additions. I couldn't get the variable to output either, so I tried throwing in some searches since search: is supposed to work with the MSM now

So the first channel entries tag pulls the entry but will not pull the variable out. Crazy. The second entries tag won't pull anything since press-image has stuff.

I threw in some conditionals with very obvious "answers" - and it does output the content for when the variable isn't empty - but it won't output your actual content. See this:

```
 {if press-image != ""}PRESS IMAGE IS NOT EMPTY DARNIT!{/if}
{if press-image == ""}PRESS IMAGE IS EMPTY Y'GOOFY GAL{/if}

```

Output this:

> PRESS IMAGE IS NOT EMPTY DARNIT!

The only thing I can think of here, since press-article works, is some conflict between the MSM and the File Manager - since this is a file field. I searched and found this bug:

https://support.ellislab.com/bugs/detail/17510

but that says it's fixed. I'm not sure in what version it was fixed, so you might try those code mods they recommend?

My template test code:

```
    {exp:channel:entries search:press-image="not IS_EMPTY" channel="press" site="default_site" disable="member_data|category_fields" limit="5" paginate="bottom"}
<h1>title: {title}, id: {entry_id},  channel short name: {channel_short_name}</h1>

    a{press-image}b
{if press-image != ""}PRESS IMAGE IS NOT EMPTY DARNIT!{/if}
{if press-image == ""}PRESS IMAGE IS EMPTY Y'GOOFY GAL{/if}

{/exp:channel:entries}

<hr />

{exp:channel:entries search:press-image="IS_EMPTY" channel="press" site="default_site" disable="member_data|category_fields" limit="5" paginate="bottom"}
<h1>title: {title}, id: {entry_id},  channel short name: {channel_short_name}</h1>

    a{press-image}b

{/exp:channel:entries}

```
> 2 votes

---
Tags: conditionals, multi-site-manager
---


title: Use same channel field across channels

text:
# Question
Title: Use same channel field across channels
I am trying to setup meta tags for my site specifically for Facebook sharing.

I have 4 different channels and I want to ideally use the same channel field for each of them so I can efficiently publish the "description" tag without complex {if} statements.

What is the best way to achieve this?

If I can't use the same channel field can I use something along the lines of {{channel\_short\_name}\_summary}?

Any help appreciated.

N

```
{exp:channel:entries channel="projects|case_studies|articles|about" url_title="{segment_3}" status="open" disable="categories|category-fields|member-data|pagination"}
{exp:channel_images:images entry_id="{entry_id}" cover_only="yes"}

<meta property="og:title" content="{title}"/>
<meta property="og:image" content="{image:url:small}"/>
<meta property="og:site_name" content="mysite.com"/>
<meta property="og:description" content="{{channel_short_name}_summary}"/>
{/exp:channel_images:images}
{/exp:channel:entries}

```

# Answer
I try to always prefix custom fields with the channel name like so:

* projects\_fieldname
* case\_studies\_fieldname
* articles\_fieldname
* about\_fieldname

Swap out "fieldname" for the actual custom field name of course.

Aside: I often start with the channel, then custom field type, then name. For example about\_textarea\_summary. There is a character limit so sometimes you have to be smart about abbreviation.

Then if you want to go the variable variable route you could make use of the channel short name variable like you described.

```
<meta property="og:description" content="{{channel_short_name}_summary}"/>

```

In your case you'd of course have 4 different custom fields named like:

* projects\_summary
* case\_studies\_summary
* articles\_summary
* about\_summary

This method of course is going to run up against Parse Order as those variables are parsed during stage 5 as is the channel entries tags and there is no way of knowing which will come first.

This is why using something like Stash nowadays is so great. You can also use segment variables because those are parsed earlier.

For example if you used the same naming conventions for your channel custom fields as I described above and you have your channel short names set as the first segment of the url you could do the following:

```
<meta property="og:description" content="{{segment_1}_summary}"/>

```

One thing to note is in the case of your case\_studies channel you might want to go with case-studies\_summary for the custom field name if your URLs use dashes over underscores.
> 5 votes

# Answer
If all you need is one field per channel, you could possibly use the oft-overlooked Channel Description field.
> 2 votes

# Answer
Ok I am not expert but basically I do this sort of thing like this...basically a router embeds a model which embeds a view (layout). You don't necessarily need the router bit...but the model and view approach is really really great and avoids all sorts of parse order conundrums.

**Router**

I have a single router template as my index.html in each template group. This dissects the URL and then stash:embeds a model. Occasionally, above this, I have some stash sets to pull, for example, lists of categories I may use in the routing below. E.g.:

(top)

```

!-- Get the textures and the brands--}
{exp:stash:set parse_tags="yes" trim="yes" debug="yes"}
    {stash:textures}{exp:gwcode_categories cat_id="9" depth="3" style="linear" backspace="1"}{cat_url_title}|{/exp:gwcode_categories}{/stash:textures}
    {stash:brands}{exp:gwcode_categories cat_id="10" depth="3" style="linear" backspace="1"}{cat_url_title}|{/exp:gwcode_categories}{/stash:brands}
{/exp:stash:set}
{!-- Join those together --}
{exp:stash:set parse_tags="yes" trim="yes" debug="yes"}
    {stash:sub_cats}{stash:brands}|{stash:textures}{/stash:sub_cats}
{/exp:stash:set}

```

And then (just part of it)

(below the top, the actual url routing)

{exp:stash:parse parse_vars="yes" parse_depth="3"}
    {exp:switchee variable="{segment_2}" parse="inward" debug="yes"}
        {!-- PAPERS MAIN INDEX --}
        {case value=""}
            {stash:embed:inkjet:model_index}
        {/case}

```
    {!-- PAPERS --}
    {case value="paper"}
        {switchee variable="{segment_3}" parse="inward" debug="yes"}
            {!-- PAPER INDEX -> REDIRECT TO GENERAL INDEX --}
            {case value=""}
                {stash:embed:inkjet:model_index_paper}
            {/case}
            {!-- SEARCHING BY BRAND OR SURFACE--}
            {case value="{stash:sub_cats}"}
                {stash:embed:inkjet:model_index_paper_brand_or_surface}
            {/case}
            {!-- PAPER ENTRY --}
            {case default="yes"}
                {stash:embed:inkjet:model_product_paper}
            {/case}
        {/switchee}
    {/case}   {!-- seg2 = "paper" --}

```

'...etc

This model is basically a channel entries wrapped around a bunch of stash:sets. Indeed, it may also pull categories data or whatever. The beauty of it is you just pull all the data as stash set it as variable, you don't need to worry about parse or page order at all really.

**MODEL**

stash:embed:layouts:layout_product_options_inkjet_paper}

{exp:channel:entries
    channel="product_inkjet_paper"
    disable="{lv_disable_default}"
    limit="1"
    url_title="{segment_3}"
    require_entry="yes"
    dynamic="no"}

```
{exp:stash:set name='page_title'}{title}{/exp:stash:set}
{exp:stash:set name='page_h1'}{title}{/exp:stash:set}

{!-- BASIC PRODUCT & CHANNEL FIELDS --}
{sc_set_basic_entry_fields}
{exp:stash:set debug="yes"}
    {stash:product_unavailable}{cf_paper_unavailable}{/stash:product_unavailable}
    {stash:one_line_description}{cf_printer_one_line_descrip}{/stash:one_line_description}
    {stash:is_description}{cf_paper_is_descrip}{/stash:is_description}
    {stash:manufacturer_description}{cf_paper_manufacturers_descrip}{/stash:manufacturer_description}
{/exp:stash:set}

```

{!-- CATEGORY FIELDS --}
    {exp:gwcode_categories entry_id="{entry_id}" excl_cat_id="10" excl_cat_id_children="yes" last_only="yes" style="linear" parse="inward"}
       {exp:stash:set debug="yes"}

            {stash:cat_url_title}{cat_url_title}{/stash:cat_url_title}
            {stash:cat_name}{cat_name}{/stash:cat_name}
            {stash:cat_id}{cat_id}{/stash:cat_id}
            {stash:cat_title}{cat_title}{/stash:cat_title}
        {/exp:stash:set}
    {/exp:gwcode_categories}

{sc\_set\_basic\_entry\_fields} - this is an early parsed low variable that just contains basic stash:sets of entry\_id, channel\_short\_name etc.

The model embeds the layout, which is where we put this all together. I break mine up into modular little chunks, each stored as an early parse low variable (a snippet)

**VIEW**

    {lv_global_htmlhead}

{lv_global_navigation}

```
{lv_page_header}

{!-- THE MAIN PAGE FIELDS --}
{exp:stash:parse parse_tags="yes"}

    {sc_product_brand_range_links}
    {sc_product_images}
    {sc_product_availability_and_notes}
    {sc_product_add_to_cart_variations}

    ...etc

{/exp:stash:parse}

<div id="page_footer">
    {lv_global_footer}
</div>

{lv_space}

```

(Not this is not a fully finished example and I have cut various things for brevity).

Each sc\_whatever is something very simple, and a self contained block, like:

```

    {exp:ce_img:pair src="{stash:master_image_url}" max="175" crop="no" allow_scale_larger="no" parse="inward"}

    {/exp:ce_img:pair}

```

So, and finally **here's the point** \- the only thing that varies really, for each of your channels, is the model. It pulls from the different channels using their fieldnames, whatever they are, but it stashes the data **into the same named stash variables** \- so that you only need one layout template to deal with the data coming from different channels. (You can take it a step further and do template inheritance as well - https://github.com/croxton/Stash/wiki/Template-inheritance \- although I haven't implemented that yet myself).

You can see an alternate and better described version of this at http://pixelfear.com/blog/stash-workflow

Hope this helps! Obviously this is a non-trivial amount of complexity to solve this particular issue...but I am using it for a lot more than this of course. And conce you're on top of it - separating data retrieval from display in EE - I think it would be hard to go back to another approach as this so deftly avoids a whole host of issues and brings performance gains to boot...
> 1 votes

# Answer
Unfortunately you pretty much need to have the "same" field for each channel.

Prefixing the field names with channel short name is clever, or you could just output all of the variables in your loop. Nasty, but gets the job done, as any field name you call that doesn't exist, is simply ignored.

```
<meta property="og:description" content="{projects_summary}{case_studies_summary}{articles_summary}{about_summary}"/>

```
> 0 votes

# Answer
+1 for Stash for this (and almost everything!).

You can pull from all the channels usign whatever filed names you have used, and stash the data into stash variables the same names, and then inject these into re-usable template chunks. It's great!

Not only does it solve this annoying issue with fieldnames, it neatly gets around a whole host of parse order crap at the same time. Once you get it, it makes development a LOT more DRY and indeed simply easier.
> 0 votes

---
Tags: channel-entries, fields
---


# Question
Title: How can I strip <p> tags from entry content, but only if it's wrapped around a <figure>?
On occasion a `<figure>` tag will make it through WYGWAM with a `<p>` wrapped around it which breaks my layout (and is incorrect formatting anyway). Can I remove just the `<p>` tags that appear around specific elements? If so, how?

# Answer
You can use the add-on Find and Replace Plus. http://devot-ee.com/add-ons/find-and-replace-plus

This should work for you.

```
{exp:replace_plus}
  {replace_area find="<p><figure>" replace="<figure>"}
  {replace_area find="</figure></p>" replace="</figure>"}
    text you want processed
  {/replace_area}
  {/replace_area}
{/exp:replace_plus}

```
> 2 votes

---
Tags: wygwam, content, strip-html
---


# Question
Title: How do I use DB SELECT to return only CHOSEN categories in a specific group while in an entries tag?
I am working in a channel entries tag. I want to return an array of category names that are selected in the entry, if they are in group\_id 4. This is what I have so far... however, it is returning **all** my categories in group\_id 4 not just the ones selected in that entry.

```
$this->EE =& get_instance();
$res = $this->EE->db->select('cat_name')->where('group_id', 4)->get('categories')->result_array();
    foreach ($res as $r)
    {
        $entryregionArr[] = $r['cat_name'];
    }
    if (in_array($_GET['region'], $entryregionArr)) {
        echo "Africa is in this array";
    }

   print_r($res);

```

I am then going to see if my $\_Get value is in the array. Right now with all the categories in group\_id 4 returning, Africa is always in the array. so it returns everytime.

# Answer
You need to have JOIN statement for it. Like:

```
$this->EE =& get_instance();
$entry_id = '[FETCH ENTRY ID]';
$res = $this->EE->db->select('c.cat_name')
                ->from('categories c')
                ->join('category_posts cp', 'cp.cat_id = c.cat_id')
                ->join('channel_titles ct', 'c.entry_id = cp.entry_id')
                ->where('c.group_id', 4)
                ->where('ct.entry_id', $entry_id)
                ->result_array();

```

I hope, it would help you.
> 1 votes

---
Tags: categories, query
---


title: Set Custom Field Prefix With Stash

text:
# Question
Title: Set Custom Field Prefix With Stash
I have multiple channels with different field groups, but several duplicate fields. For example:

**Channels:**

* products\_bikes
* products\_skateboards
* products\_trikes

**Fields:**

* bikes\_summary
* skateboards\_summary
* trikes\_summary

I use the same detail template to output info for all of the channels, but with the duplicate fields, I have to repeat the "summary" field 3 times:

```
{exp:channel:entries
    channel='products_bikes|products_skateboards|products_trikes'
}
    <h1>{title}</h1>

    {bikes_summary}
    {skateboards_summary}
    {trikes_summary}

{/exp:channel:entries}

```

And this isn't the only field that's repeated. So that can get pretty hairy, especially if I need to check if a field is empty or not, or if I want to add another product type in the future.

So ideally I'd be able to set a channel prefix, and use it in a single field tag:

```
{{channel_prefix}_summary}

```

I can't use the `channel_short_name` because it doesn't match up, so I figured Stash might be able to do it. I tried:

```
{exp:stash:channel_prefix}
    {if channel_short_name == 'products_bikes'}
        bikes
    {/if}
    {if channel_short_name == 'products_skateboards'}
        skateboards
    {/if}
    {if channel_short_name == 'products_trikes'}
        trikes
    {/if}
{/exp:stash:channel_prefix}

{{exp:stash:channel_prefix}_summary}

```

But that output the text "{bikes\_summary}" rather than parsed the field tag. I figure parse order has to do with it, but I'm not sure how to fix it - or if it's possible.

Thanks for any help!

# Answer
> 3 votes
The first thing I would ask is do you really need a fieldgroup for each product channel? Multiple channels can share the same fieldgroup and you can use publish layouts to hide the fields that are not relevant to a particular product. Using the same fieldgroup will also force you to generalise the fields you use which can be a good thing for rationalising your data structure.

If not then you could adopt the following approach. It does requires that you use a consistent naming scheme for your fields, e.g. channel\_fieldname:

```
{!-- make a list of your channel prefixes --}
{exp:stash:set_list name="channels"}
    {stash:channel}products_bikes{/stash:channel}
    {stash:channel}products_skateboards{/stash:channel}
    {stash:channel}products_trikes{/stash:channel}
{/exp:stash:set_list}

{!-- make a list of your common field suffixes --}
{exp:stash:set_list name="fields"}
    {stash:field}summary{/stash:field}
    {stash:field}another_field{/stash:field}
{/exp:stash:set_list}

{!-- map channels and fields to generate tag pairs --}
{exp:stash:set name="mapped_fields" parse_tags="yes" parse_depth="2" type="snippet"}
   {exp:stash:get_list name="fields"}
      {stash:{field}}
         {exp:stash:get_list:nested name="channels"}
            {{channel}_{field}}
         {/exp:stash:get_list:nested}
      {/stash:{field}}
   {/exp:stash:get_list}
{/exp:stash:set}

{!-- capture the data --}
{exp:stash:set parse_tags="yes" type="snippet"}
   {exp:channel:entries
      channel='{exp:stash:get_list name="channels" backspace="1"}{channel}|{/exp:stash:get_list}'
      parse="inward"
   }

   {mapped_fields}

  {/exp:channel:entries}
{/exp:stash:set}

{!-- example of using the data in your view template (Stash embed or EE embed) --}
{if summary}{summary}{/if}

{!-- example of using the data in the *same* template you capture the data --}
{if summary}{exp:stash:get name="summary" type="snippet"}{/if}

```

To make this even more robust, you could list the channels automatically using a plugin like Get Channels.

```
{exp:stash:set_list name="channels" parse_tags="yes"}
    {exp:getchannels}
       {stash:channel}{channel_name}{/stash:channel}
    {/exp:getchannels}
{/exp:stash:set_list}

```

# Answer
> 0 votes
Stash doesn't work for this because their tow instances are parsed on the same parsing stage. So, when you call `stash:channel_prefix` its value isn't available yet.

Your better option is to remove the "products\_" prefix from the short names of the channels.

# Answer
> 0 votes
I think basically if you wrap the second part in a `{exp:stash:parse parse_vars="yes" parse_depth="2"}` \- it will be like the categories bit in my router basically.

https://expressionengine.stackexchange.com/a/12231/1532

---
Tags: stash, custom-fields, parse-order, dry
---