# Question
Title: Alternative channel:entries Depending on First Result Set
I have two channels: products and promos. I need to display either one or the other on my homepage. If I find a promo, I display that one and not the the product. If I don't find a promo, I display the product.

I have Stash installed. I'm thinking I try for the promo. If I find it, I set a Stash variable called promo\_found to TRUE; otherwise its FALSE. Then I can test for promo\_found == FALSE, and do the products channel:entries call.

Would this work? (I don't have much/any experience with Stash.) Is there a better pattern to use?

Thanks for your help.

# Answer
If you don't want to use Stash, you could just do it with `no_results` and an embed.

Homepage template:

```
{exp:channel:entries channel="promos" ...}
  {if no_results}
    {embed="product"}
  {/if}

  <div id="promo">
     ...
     {promo_content}
     ...
  </div>
{/exp:channel:entries}

```

Product embed template:

```
{exp:channel:entries channel="products" ...}
  <div id="product">
    ...
    {product_content}
    ...
  </div>
{/exp:channel:entries}

```
> 1 votes

---
Tags: channel-entries, stash
---


# Question
Title: ExpressionEngine {exp:channel:categories}, categories from multiple category groups ordered together
Is it possible to create a single alphabetically ordered list containing categories from *multiple* category groups?

Here is the code I am using:

```
<ul>
    {exp:channel:categories category_group="1|2"}
         <li>{category_name}</li>
    {/exp:channel:categories}
</ul>

```

Unfortunately this separates the category groups, and I end up with a list such as this:

* book
* graphic identity
* poster
* website
* architecture
* art
* David Bowie
* ExpressionEngine
* zoos

You'll notice that it is actually two lists ordered alphabetically. I would like to merge these into one list somehow.

I would expect to be able to add something like `orderby=` as in the Channel Entries Tag:

```
<ul>
    {exp:channel:categories category_group="1|2" orderby="name"}
         <li>{category_name}</li>
    {/exp:channel:categories}
</ul>

```

But this does not work. Has anyone come across this before?

Many thanks in advance.

# Answer
> 1 votes
GWcode Categories may be more helpful to you.
You can do a whole lot more with categories than the native solution.

I would be very surprised if it couldn't do what you need.

**OR**
Use Stash.

Get *all* the categories you need, don't worry about the order.
Once they are stashed, they become one single list.

```
{exp:stash:set_list name="categories" parse_tags="yes"}
  {exp:channel:categories category_group="1|2"}
    {stash:name}{category_name}{/stash:name}
  {/exp:channel:categories}
{/exp:stash:set_list}

```

Then just output them all in the order you need.

```
<ul>
{exp:stash:get_list name="categories" orderby="name"}
  <li>{name}</li>
{/exp:stash:get_list}
</ul>

```

---
Tags: channel-entries, categories
---


title: Creating entries from csv & XML feeds

text:
# Question
Title: Creating entries from csv & XML feeds
This is something I have had no experience with whatsoever, so I am hoping that someone can tell me whether it is possible or not.

I have a site up and running, and I am looking at starting a section for people to find holiday properties.

The information of these properties can be accessed via an XML feed of the details and a separate csv of the prices and photos.

The data is presented like so in the XML..

```
<tcreated>2013-04-09 22:30:26</tcreated>
<cweblink>http://www.linhere</cweblink>
<nid>55</nid>
<nremoteid>0</nremoteid>
<tupdated>2013-04-09</tupdated>
<cpropname>Brazengate Family Cottage, Long Ashes, Threshfield, Yorkshire Dales (Ref 55)</cpropname>
<ccountry>England</ccountry>
<carea>Yorkshire Dales</carea>
<csubarea>Yorkshire Dales - Wharfedale</csubarea>
<short_name>Brazengate</short_name>
<cvillagename>LONG ASHES, THRESHFIELD</cvillagename>
<nlatitude>54.0789359001</nlatitude>
<nlongitude>-2.0351578974</nlongitude>
<cpriceinfo>All prices are inclusive of the booking fee.<BR><BR>Winter Short Breaks (WSB) are available at many properties in the "Winter" period - subject to availability. Extra nights are charged pro rata of the weekly rental.<BR><BR>Off Season Breaks (OSB) are available at many properties in parts of the "Low" and "Mid" periods - subject to availability. The price for a 3 night break is either 75% of the normal weekly rental or, if it is higher, the quoted Winter Short Break price. Extra nights are charged pro rata of the weekly rental. OSBs can be booked within a calendar month of the start date of the holiday.<BR><BR>"Last Minute Breaks" (LMB) are available at most properties throughout the "LOW", "MID", "HIGH", "PEAK", "XMAS" and "NEW YEAR" periods. The price for a 3 night break is either 65% of the normal weekly rental or, if it is higher, the quoted Winter Short Break price. Extra nights are charged pro rata of the weekly rental. LMBs can be booked within one week of the start date of the holiday. </cpriceinfo>
<nminprice>310</nminprice>
<nmaxprice>575</nmaxprice>
<nbedrooms>2</nbedrooms>
<lkettle>1</lkettle>
<lparkingspace>1</lparkingspace>
<lsmoking>0</lsmoking>
<nsinglebeds>0</nsinglebeds>
<ndoublebeds>1</ndoublebeds>
<ntwinbeds>1</ntwinbeds>
<nbunkbeds>0</nbunkbeds>
<nfamilybeds>0</nfamilybeds>
<nmaxsleeps>4</nmaxsleeps>
<cproppostcode>BD23 5PN</cproppostcode>
</cottage>

```

Now I've seen that there is an add-on called Datagrab, and I am assuming this will be handle this kind of import?

I can see how I can map most of those fields, so that shouldn't be a problem. Where I am a bit unsure is that the images for each entry are stored as urls in a separate csv feed that looks like this...

```
nid,cURL,tUpdated,nPosition
10006,http://sc_13279413350143_10006_01.jpg,2012-01-30,2

```

Now will it be possible to pull those images in the entries that are created via the initial XML import? It would need to match the "nid" custom field (I create) to hold the "nid" value from the XML and match it with the "nid" in the csv image import. Also it would need to order them as per the nPosition value.

I'm hoping this is possible, because there's around 2000 entries that need to be created, and I really do not fancy doing so by hand!

Thanks!

# Answer
> 1 votes
Yes, you just run your initial import to get your properties entries into the system, storing the `nid` as a custom field.

Then run a *second* import with the option to update existing entries using `nid` to map the image data to the correct existing entry.

Datagrab will work and is a great add-on. Solspace Importer is also very nice.

---
Tags: import, datagrab, xml, csv
---


# Question
Title: simple search results not including body content
I am using the simple search by Expression Engine and the searches are fine, but they are just returning title results and not searching the body content. I have the excerpt search in the channel properties set to the right channel field in the channel preferences, but I am not sure if there is anything else I need to do. Below is my search code and my search results code.

**SEARCH CODE**

```
{exp:search:simple_form channel="blog|documents|static|overview|company|products|media|services|support|solutions" result_page="search/results"}
          <div class="icon"><img src="{site_url}assets/img/search.png" border="0"></div>
          <input type="text" name="keywords" id="keywords" placeholder="Search Site">
        {/exp:search:simple_form}

```

**SEARCH RESULTS CODE**

```
{exp:search:search_results switch="resultRowOne|resultRowTwo"}
            {if count == 1}<ul>{/if}
              <li>
                <strong><a href="{auto_path}">{title}</a></strong>
                <p>{auto_path}</p>
              </li>
            {if count > 0 && count == total_results}</ul>{/if}

        {/exp:search:search_results}

```

Thanks!

# Answer
> 0 votes
Just add `search_in="everywhere"` to your search form to search in the titles and entries.
The default is `titles`.

# Answer
> 0 votes
You have `{auto_path}` where your `{excerpt}` should be.

---
Tags: simple-search
---


# Question
Title: Wygwam and IE10, Enter key doesn't function in IE10
Just visited a client that has Wygwam v2.4.0.2 and EE 2.4.0. The Enter key wouldn't function in IE10. Worked fine in Chrome. Is this a known bug that was fixed in an updated version of Wygwam? Thanks!

# Answer
It appears to be a bug in CKEditor. If you can, try upgrading to the latest version of Wygwam (v2.7), which is using a slightly newer version of CKEditor that includes fixes for greater IE10 compatibility.
> 1 votes

---
Tags: wygwam
---


title: Sort Channel Entries By Matrix

text:
# Question
Title: Sort Channel Entries By Matrix
Is there a way to sort Channel Entries by a Matrix field?

How would this work if date was a Matrix field?

```
{exp:channel:entries orderby="date" sort="desc" limit="10"}
        <a href="{title_permalink='channel/comments'}">{title}</a><br>
{/exp:channel:entries}

```

# Answer
I heard back from ExpressionEngine support about this question - There is actually no way to do it from the entries tag. As Jean St-Amand said in the comments, you would need to have a custom query.
> 1 votes

---
Tags: matrix
---


# Question
Title: How do I add player parameters to a video using DevDemons Channel Videos
I know it's possible to add parameters to a youtube url and these will load different settings.

Like this parameter **?rel=0** indicates whether the player should show related videos when playback of the initial video ends. https://developers.google.com/youtube/player\_parameters#rel

If I add a video in DevDemon Channel Videos and pass the parameter **?rel=0** it doesn't show any result(the related videos still show up). Does anyone know how to pass the parameters the right way?

# Answer
> 4 votes
Channel Videos 3.1.0 introduced a Module Control Panel where you can control all of those available parameters from a central point.

There is no need to use template parameters.

# Answer
> 4 votes
I've analysed the source code of Channel Videos and saw that there was a template tag parameter available named **youtube:url\_params** that does add the parameters to the video but again added the questionmark at the end.

I rewrote/hacked the code to provide a solution that if there are parameters in the direct URL they will be placed correctly without question mark. And if there are parameters in the template tag **youtube:url\_params** they will be placed correctly with a question mark.

**File:** mod.channel\_videos.php

**Line** 203

```
//Added a fix for placing a questionmark after a direct link with params
$extra_params = $this->EE->TMPL->fetch_param('youtube:url_params', '');
$extra_params = !empty($extra_params) ? '?'.$extra_params : '' ;
$vars[$prefix.'web_url'] = 'http://www.youtube.com/watch?v=' . $vid->service_video_id;
$vars[$prefix.'embed_code'] = "<iframe width='{$embed_width}' height='{$embed_height}' src='http://www.youtube.com/embed/{$vid->service_video_id}{$extra_params}' frameborder='0' allowfullscreen></iframe>";

```

### Fix still needed...

> Note: The fix provided above doesn't solve the problem because it's based on the service\_video\_id that is extracted out off the URL in the get\_video() method. When I've completed the fix I'll update it.

---
Tags: video, channel-videos, devdemon
---


# Question
Title: Expresso Store: Using with Freemember to Save a user's shopping cart
I'm working with an ecommerce site powered via the Expresso Store module, and I'm using the Freemember plugin to handle store user accounts and to save billing information for use in the checkout pages. Everything seems to be working great, only when a user logs out and logs back in the cart is cleared every time. However, if you're signed out, add a product to the cart, then sign in, the product remains in the cart. Do I need to pass anything special into the `{exp:store:cart}` loop? Can someone give me a nudge in the right direction? Thanks!

+

EE v2.5.3 / Store v1.6.3 / Freemember v2.2.1

# Answer
In the Control Panel you can goto Store \> General \> then scroll down to the bottom and look for "Empty cart on member logout" and change that setting to No.
> 2 votes

---
Tags: expresso-store, freemember
---


title: Does a Members IP address get updated?

text:
# Question
Title: Does a Members IP address get updated?
The reason for this question is that I was running EE v2.3 which did not have ipv6 support. So users with those ip address where given the ip address of 0.0.0.0

I have now upgraded to EE v2.5 which has ipv6 support.

So I want to know are those members with ip addresses of 0.0.0.0 going to be able to use the site as a member now? Is their ip address going to be updated?

If not, what are my options? Would see strange if a users IP address is set once and never updated?

# Answer
> 1 votes
No, the IP Address won't be updated, generally speaking. If you are using a different membership module besides the one built in to ExpressionEngine, then maybe. But generally speaking, ExpressionEngine (EE) logs the IP Address the user was at when they created their account or when they are logged in, but it doesn't require the same IP Address.

I can or you can log-in from any ip\_address, unless you've put blockers in place to restrict to specific IPs. The control panel option for tracking ip\_addresses reads:

> **Require IP Address and User Agent for Login?** Prevents users from logging in unless their browser generates IP Address and User Agent data. This keeps hackers from logging in using direct socket connections.

As it states, it prevents `socket` use, and while it does log current IPs, it doesn't do member matching. At least not to my knowledge. Checking my Control Panel logs, I can see that I've logged in from at least 7 different ip\_address, though the IP Address on my account profile, remains my home ip\_address.

Now, if you are using Forums, this maybe different. We've never used EE Forums for clients, so I can't comment. But generally speaking, the `ip_address` is used for basic security, like you could ban a country or a block of IPs, that have been problematic.

So you should be fine, unless you have other restrictions by ip\_address in place.

---
Tags: members
---


# Question
Title: Expresso Store: Stock Control for Product Variations
Just wondering if there is scope to have stock control ability on product variations.

Useful for a scenario like mag wheels for cars:

Simmons Xtreme Chrome Mag (example model) \- 17" (3 available) \- 18" (2 available) \- 19" (7 available)

Cheers. =)

# Answer
> 2 votes
If you add a product and choose Variation you can choose to control stock for each variant. I have attached a screenshot of an example:

# Answer
> 1 votes
I'm assuming you're referring to displaying on the fronted, not creating in the backend? Store currently doesn't allow you to output the stock levels for modifier options. I've written a plugin that allows you to do just that for multiple modifiers and options, it's called Store Options and will be released on Devot-ee.com within the next couple of weeks, but if you want a copy of it prior to that drop me an email. peter@peteralewis.com

---
Tags: expresso-store, shopping-cart, out-of-stock
---


# Question
Title: Outputting tag pairs such as images/files with Stash
I'm getting into Stash and I wondered what the best way of handling tag pairs such as files/images?

My aim is to totally separate out the markup from the fetching of stuff from the database (exp:channel:entries tags etc). So far, this is how I'm currently handling it, and it works fine:

**Model end of things** (this would be within exp:channel:entries tag also with a load of other stuff).

```
{exp:stash:set_list name="main_image" parse_tags="yes"}
{my_image}
    {stash:url}{url}{/stash:url}
    {stash:height}{height}{/stash:height}
    {stash:width}{width}{/stash:width}
    {stash:title}{title}{/stash:title}
{/my_image}
{/exp:stash:set_list}

```

**Markup end of things**

```
{exp:stash:get_list name="main_image"}
<img src="{url}" height="{height}" width="{width}" alt="{title}" title="{title}" />
{/exp:stash:get_list}

```

What concerns me the most is I'm using a list even though there will only ever be one thing in it, as thus it makes me a bit uneasy.

Is there a better way of doing it? Like I said it definitely works, I just want to make sure I'm doing it right.

# Answer
> 1 votes
From a performance point of view I don't see anything wrong with that at all. It will still output your desired variables. The `set_list` tag pair ideally caters for an array of items (many) but it should be just as happy returning one.

You could just set them as regular stash:set variables but it shouldn't make any difference performance wise either way.

---
Tags: stash
---


# Question
Title: Assets not indexing under www but does without www
Assets isn't indexing and showing thumbnails or uploading if I'm logged in to CP with www…

I've read elsewhere that www.example.com and http://example.com are treated as separate domains but is there a simple solution? I have all paths in EE set without www. including the CP url and I'm not forcing either with .htaccess

I can remember to login without www. but cant expect my clients to remember.

# Answer
> 2 votes
I would always say to stick to one or the other, either www or no-www. You're correct in that they are treated as separate domains and you may see a hit in terms of SEO if you have duplicate content on two different domains. Ideally you should always pick one and stick to it and ensure it's adhered to by backing it up in the .htaccess file:

Rewrite "www.domain.com -\> domain.com"

```
<IfModule mod_rewrite.c>
  RewriteCond %{HTTPS} !=on
  RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
  RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
</IfModule>

```

This takes any requests for the www. domain and then forwards it on to the no-www domain giving it a 301 redirect (permanent move). This will ensure you and your clients don't accidentally use a both.

---
Tags: assets
---


# Question
Title: Passing ID’s from a query to Channel Entries
I'm using quite a complex query using exp:query to generate the member ID's of members who have certain data in a custom field.

I'm struggling on how to pass the generated ID's onto a channel entries tag.

I gather that I can't put a channel entries tag inside the query, it certainly didn't work correctly she. I tried, so should I be using php?

I've virtually zero knowledge with php, so does anyone have any suggestions on the correct way to pass a pipe delimited list of member ID's from a query?

Thanks.

# Answer
It occurred to me this would be a great idea for a plugin, since it's something most people have to do often when building even moderately complicated sites, and currently requires you to understand both MySQL `GROUP_CONCAT` and the intricacies of the EE parse order.

So without further ado, I present the Channel Query plugin. Use it like so:

```
{exp:channel_query sql="SELECT entry_id FROM exp_channel_titles"}
    <!-- normal channel entries tag data -->
{/exp:channel_query}

```

The `sql` parameter specifies the custom SQL query. Only SELECT statements can be used, INSERT, UPDATE and DELETE are not supported for security reasons.

All other parameters and variables are exactly the same as the standard EE Channel Entries Tag.

If an `orderby` parameter is specified, that will take precendence. Otherwise, entries will be displayed in the order returned by your SQL query.
> 2 votes

# Answer
`GROUP_CONCAT` is your friend. Instead of returning multiple rows of entry IDs, `GROUP_CONCAT` lets you return a single row containing a concatenated string of a single field, like `entry_id`, like in this example:

```
{exp:query sql="SELECT GROUP_CONCAT(DISTINCT entry_id SEPARATOR '|') AS entry_ids
                FROM exp_channel_titles WHERE channel_id = 1
                # ...and more where clauses here...
                GROUP BY entry_id"}

    {exp:channel:entries entry_id="{entry_ids}"}
        ...
    {/exp:channel:entries}

{/exp:query}

```

So, use `GROUP_CONCAT` and `SEPARATOR '|'` to generate the pipe-separated list of field values of any field you want.
> 4 votes

# Answer
An embed solves this problem. You didn't provide any code in your question so my code below is for demonstrating the concept only. You'll need to adjust for what you need.

In your main template add your query module code like this:

```
{embed="embeds/member" ids="{exp:query sql='SELECT member_id FROM exp_members'}{member_id}|{/exp:query}"}

```

In your embed you can call the IDs like this:

```
{exp:channel:entries channel="news" limit="10" author_id="{embed:ids}"}
    {title}
{/exp:channel:entries}

```
> 0 votes

---
Tags: channel-entries, php, query
---


title: Formatting a CSV using Channel Entries

text:
# Question
Title: Formatting a CSV using Channel Entries
I'm trying to export a CSV of my members using Solspace User.

It works fine, except that when I open the CSV in Excel, it actually shows the quotes around the values. I know that obviously my template has quotes around each value, but some addresses have commas in them - without the quotes, it throws off the CSV.

My template looks like this: (I've added whitespace for readability).

```
{exp:ifelse parse="inward"}
  {if group_id == 1 OR group_id == 6}

    {exp:http_header content_type="text/csv"}

    email, screen_name, address,
    {exp:user:users limit="100000"}
      "{email}", "{screen_name}", "{address}",
    {/exp:user:users}

  {if:else}
    {redirect="404"}
  {/if}
{/exp:ifelse}

```

Has anyone tried to do this sort of thing? Am I missing something obvious?

When opening in Excel, it looks like:

```
email             | screen_name  | address
------------------+--------------+------------------------
name@domain.com   | "John Smith" | "123 Street, Somewhere"

```

When using Finder's Quick Look, it looks just fine (no quotes).

I'm not sure if this is a general CSV issue, an issue with EE or an Excel thing.
Any help would be appreciated.

**Edit**
Actually, the first column doesn't show the quotes, but the rest do. Which I really don't understand.

# Answer
> 2 votes
Alex pointed me in the direction of using an HTML table to output the data, then serve it as an xls file instead.
While this technically doesn't answer the question of how to fix the CSV issue, it did help me solve the real problem I was having, which was the data being incorrect.

When using a lone `table` tag, everything shows up in Excel in Times New Roman with no borders. To get it to show up with default Excel styling, use the following markup:

```
{exp:ifelse parse="inward"}
{if group_id == 1 OR group_id == 6}

{exp:http_header content_type="application/vnd.ms-excel"}

<html>
<head>
  <meta http-equiv=Content-Type content="text/html; charset=macintosh">
  <meta name=ProgId content=Excel.Sheet>
</head>
<body>

  <table>
    <tr>
      <th>email</th>
      <th>etc...</th>
    </tr>
    {exp:user:users limit="100000"}
    <tr>
      <td>{email}</td>
      <td>etc...</td>
    </tr>
    {/exp:user:users}
  </table>

</body>
</html>

{if:else}
  {redirect="404"}
{/if}
{/exp:ifelse}

```

# Answer
> 1 votes
This is an Excel issue. If you open the file by double-clicking or dropping directly on Excel, you'll see delimiters. If you import the file, Excel will ask you to ID the delimiters and remove them.

# Answer
> 1 votes
I did something recently that may be of use in your cirumstance: LowReplace

Its use is fairly straight forward, I used it to output Freeform data to JSON but should work for you.

```
{exp:user:users limit="100000"}
{exp:low_replace find="QUOTE|NEWLINE" replace="\QUOTE|SPACE" multiple="yes"}
"{email}", "{screen_name}", "{address}",
{/exp:low_replace}
{/exp:user:users}

```

This isnt tested, you'll likely need to wrap each field in a Low Replace but might help !!

---
Tags: channel-entries, templates, solspace-user, csv
---


# Question
Title: How do you set up a language pack to take effect on system messages?
I'm currently finalizing the setup of a multi-lingual site and everything to this point has benefited from variables handling language-specific items, but I do have a Safecracker form in the site that automatically serves up general error messages when, for example, a field has been left blank when it's required. I have the french language pack installed, but I'm somehow missing how I enable it so that when the site is being accessed via the french URL that the error messages served back by the Safecracker form also appear in French.

In index.php, I have the following (mirrored for english as well):

UPDATED CONFIG INFO BELOW

```
case "french.domain.com":
    $assign_to_config['site_url'] = 'https://french.domain.com';
    $assign_to_config['language'] = 'french';
    $assign_to_config['global_vars'] = array(
        "user_language" => "fr",
        "user_locale" => "en_US.UTF-8",
        "user_locale_date_format" => "%b %e %Y",
        "user_locale_event_date_format" => "%b %e %Y",
        "swap_site_label" => "English",
        "swap_site_url" => "https://english.cps.ca",
        "country_code" => "fr",
);

```

I just need a bit of help sorting out this final step.

# Answer
> 1 votes
You may also need to add:

```
 $assign_to_config['deft_lang'] = 'french';

```

# Answer
> 0 votes
I think:

```
$assign_to_config['language'] = 'french';

```

would work. Where variable value will be the language folder name as for the "system/expressionengine/language/french" the language variable value will be 'french'

---
Tags: safecracker, multi-language
---


title: Delay on navigation // cache issue?

text:
# Question
Title: Delay on navigation // cache issue?
one of my customer told me that he was seeing a white page during site navigation. The white page he was talking about was just the browser empty pages; he sees it while navigating between the website pages, as apparently there is some kind of delay // or // cache problem with the browser. It isn't a big issue, and it's something that I can't relate to ExpressionEngine, but it's there, and I would like to fix it.

You can reproduce it navigating on the main menu, sometimes the browser just load the new page, sometimes there's a delay that returns the empty page for some seconds.

Do you have any clue? I've changed the busted css to absolute path and turned on cache for templates with no luck. This happens on all browser, it's like he's re-loading all the files.

Do you have any clue/hint?

thank you.

Here is the Site

# Answer
First step is to move all CSS and JS out of EE templates. You will see improved load times just from this... If you minimize and combine into less files, that will help even more.

The **http://visiosuite.org/index.php/javascript/plugins** file is consistently loading slowly which you should be able to see in your browser's Network tab...

As currently coded, your images, css and JS are still using an absolute link (www.domain.com/filename) instead of a root-relative link (/filesname) when loading.

I also suggest you move your main CSS file up near the top of the list if subsequent css files aren't overwriting styles in that main file. One larger minimized CSS files is better than 5 smaller files that are not minimized.

Additionally, you are loading Modernizer JS file in the header but if you aren't using it, I suggest removing it.

Also, change the "**Enable GZIP Output?**" setting in EE to "Yes".

If you have caching enabled in EE, it's not evident... The page loads here are ~ 5-6 seconds. You might want to spend money on the **CE Cache** module. The static driver will make the site amazingly fast.
> 1 votes

# Answer
I can't say for sure, Firefox seems to have little to no issue, Safari defiantly has signs of the issue.

One thing I did notice, are you using EE CSS templates ? It looks like it via the URL they're being called from.

This could be slowing things down, I'd remove them from the EE system, I'm yet to see any scenario where they are of any real benefit. Having them as traditional CSS files kept in a folder makes everything simpler.

You could also try some caching via htaccess to help speed things up as well.
> 0 votes

---
Tags: javascript, css, cache, browser
---


# Question
Title: Problem with empty, non-required Assets 2.1 field in a Matrix row
I upgraded to Assets 2.1 yesterday and am experiencing a problem when a non-required Assets 2.1 field in a Matrix row is empty. On a single-entry template **(limit=“1” and require\_entry=“yes” parameters in my exp:channel:entries tag)** this situation is causing the {if no\_results} conditional to be invoked. Selecting a file for the empty, non-required, Assets field and re-saving the entry fixes the problem.

Thanks in advance for your help.

Matrix 2.5.3 ExpressionEngine 2.5.2 Build 20120606

Here is template code that will trigger the issue:

```
{exp:channel:entries channel="videos" limit="1" status="open" disable="categories|category_fields|pagination|member_data" require_entry="yes"}{if no_results}{redirect="404"}{/if}<!doctype html>
<html lang="en">
<head>
<title>Page Title</title>
</head>
<body>

<h2>Videos</h2>

{sidebar_videos limit="1"}

<iframe src="//www.youtube.com/embed/{youtube_video_id}"></iframe>
<p>{youtube_caption}</p>

{/sidebar_videos}

<h3>All Videos</h3>

<ul id="videothumbs">

{sidebar_videos}

<li><a href="/features/videos/{entry_id}/{row_id}" title="{youtube_title}”>{youtube_thumbnail}<img src="{url}" alt="{alt_text}">{/youtube_thumbnail}</a></li>

{/sidebar_videos}

</ul>

</body>
</html>
{/exp:channel:entries}

```

`{sidebar_videos}` is my Matrix field, which is not required. `{youtube_thumbnail}` is the problem Assets field within the Matrix field. The other columns in the Matrix field are:

`{youtube_title}` (Text/required)

`{youtube_video_id}` (Text/required)

`{youtube_caption}` (Wygwam/required)

`{youtube_thumbnail}` (Assets/not required)

# Answer
Edit again! jauses - can you try changing line 1324 in ft.assets.php file from

```
if (! $data)

```

to

```
if (! $data && $this->var_id)

```

? That should fix this up for you.

Thank you!
> 1 votes

---
Tags: assets, matrix
---


title: Redirect user to site based on IP

text:
# Question
Title: Redirect user to site based on IP
I'm looking for advice on how to redirect a user to one of our country sites, based on their IP and wondered if anyone has done this with ExpressionEngine?

Additionally, I need to provide users with a way to circumvent this - similar to what happens with Google where you can click a link that can take you to the .com site if you don't wish to view the .co.uk site.

I have IP to Nation installed and updated, but unsure if this would be needed.

Thanks.

# Answer
Because of parse order, the ip\_to\_nation module just works on channel:entries or comments. The necessary {ip\_address} variable is a global variable, which means it is parsed after the variables of ip\_to\_nation.

You should use IPGeo add-on to get the visitor's location info based on IP address like:

```
{exp:ipgeo}

{if country == 'India'}

{exp:redirecturl url="http://examplesite.in"}

{/if}

{/exp:ipgeo}

```

You can see for the redirect, I used plugin http://devot-ee.com/add-ons/redirecturl-ee2-plugin as standard global variable {redirect} wouldn't work here.
> 1 votes

---
Tags: redirects
---


# Question
Title: How to get order to go 1, 2, 3, 4... rather than 1, 10, 11, 12, 2, 3, 4
I'm sure this is a simple one, but it's got me stumped so I'd appreciate your thoughts. Here goes...

* I'm displaying a selection of images
* The order of these images is controlled by using orderby="file\_index" & sort="asc" in the channel entries tag
* The file index field contains a number (i.e. 1, 2, 3 etc,), but is not changeable (i.e. we can't use two digit numbers for all images)
* The problem is that when there's more than ten images, they are being output as 1,10,11,12, 2, 3, 4... rather than 1, 2, 3, 4... In other words, the teens are being put before the 2

**Any ideas on how to make the images display in the correct order?**

Thanks in advance,

Tom

# Answer
You need to go to that custom field settings (Edit Field) and select "Field Content" as "Number".
> 2 votes

---
Tags: channel-entries, number-format, order-info
---


# Question
Title: How would one output a Assets File stored on Amazon S3, within a Query tag?
I have a Query tag to output Matrix data for various entries. One of the Matrix fields is an Assets field, which is linked to files stored on Amazon S3.

Within the Assets database, this fields data does not hold the full Amazon S3 path. This path seems to be stored within a JSON encoded array in the field Settings in exp\_assets\_sources.

So therefore I am stuck as to how to get the full S3 path within my Query to link to the Amazon file. Anyone know?

Thanks

# Answer
Answered my own question...

Enabling PHP and then using json\_decode of course:

```
{exp:query
    sql="SELECT
            md.*,
            ct.title AS title,
            ct.url_title AS url_title,
            af.file_id,
            aso.settings AS settings
        FROM exp_matrix_data md
        LEFT JOIN exp_channel_titles ct ON md.entry_id = ct.entry_id
        LEFT JOIN exp_assets_selections ass ON md.row_id = ass.row_id
        LEFT JOIN exp_assets_files af ON ass.file_id = af.file_id
        LEFT JOIN exp_assets_sources aso ON af.source_id = aso.source_id
        WHERE md.col_id_5 = 'xxxxxx'
}

<?php
$settings = json_decode('{settings}');
$url_prefix = $settings->url_prefix;
?>

<?php echo $url_prefix;?>

```
> 1 votes

---
Tags: assets, pixelandtonic, query
---


title: Understanding Stash Variables

text:
# Question
Title: Understanding Stash Variables
I'm using Stash 2.3.6 beta. Can somebody explain why this works:

```
{exp:stash:set name="var1"}no{/exp:stash:set}
{exp:stash:set name="var1"}yes{/exp:stash:set}
{exp:stash:get name="var1"}

```

Where I get "yes" as output.

But this does not:

```
{exp:stash:set name="var1"}no{/exp:stash:set}
{exp:channel:entries channel="promos" limit="1"}
    {exp:stash:set name="var1" replace="yes"}yes{/exp:stash:set}
{/exp:channel:entries}
{exp:stash:get name="var1"}

```

Where I get "no" as output, but expect "yes".

I'm guessing it has to do with the parse order, and that channel:entries happens after everything outside of it is parsed. I looked at the parse order docs (The Template Engine), and it looks like channel:entries are processed on step 15, module and plugin tags. Not sure where Stash gets processed.

But, speaking of which, I did try adding process="end" to the get. That got me a funky looking output: {357b280a38bad6479603b312799efcb0422985159}

Any help appreciated.

# Answer
Such seemingly random strings can be a symptom of the Stash extension not being activated. Worth a check.

Those strings are used by Stash as placeholders getting replaced by the stash extension. If the stash extension is not activated, they never get replaced.
> 2 votes

# Answer
Yes, this is a parse order thing, the get is parsed before the second set, since it is within a channel entries tag pair. But this should work:

```
{exp:stash:set name="var1"}no{/exp:stash:set}

{exp:channel:entries limit="1"}
  {exp:stash:set name="var1" replace="yes"}yes{/exp:stash:set}
{/exp:channel:entries}

{exp:stash:parse process="end"}
  {exp:stash:get name="var1"}
{/exp:stash:parse}

```

But in general, you won't get very far with setting and getting data within the same template. That's why the template partials approach sets data in the base template and then gets it in an embedded template.
> 0 votes

---
Tags: stash
---


# Question
Title: Performance of Matrix and P&T Field Pack add-ons
On every install I have P&T field pack and Matrix installed. blindly.

just recently I had to analyse a site's performance, and the only spike in load times I discovered was P&T add-ons.

```
(0.081127 / 20.43MB) Calling Extension Class/Method: Matrix_ext/channel_entries_tagdata
(0.251239 / 21.99MB) Calling Extension Class/Method: Pt_field_pack_ext/channel_entries_tagdata

```

it this always the case?

it uses 1.5 MB of memory and 0.17s...
this seams a lot?

is matrix using that much resources or is it the field\_pack? or am I not interpreting the numbers correctly...

cheers
stefan

# Answer
You didn't provide what the numbers were without Matrix or P&T Field Pack. But it also looks like you're posting the progression data. Generally speaking, calls to extensions and add-ons will jump the memory usage and progress time. But I wouldn't consider that a large jump, by any means.

A page using almost nothing can take up 8MB of memory to load. I've talked to a few ISPs and while they **WON'T** say what an average is, they will say, page/template loads under 24MB are fine, preferred even, since these days of growing web applications frequently use far more than that, and they're expecting to keep the server running smoothly, when the developer has created laborious code.

Here's a progression sample form one of the sites, we run. The jump when 'Assets' is called is almost 4MB memory.

```
(0.088663 / 13.76MB) -> Method Called: entries
(0.198751 / 17.92MB) Calling Extension Class/Method: Assets_ext/channel_entries_query_result
(0.244685 / 20.07MB) Calling Extension Class/Method: Favorites_ext/parse_favorites_date
(0.246708 / 20.11MB) Calling Extension Class/Method: Gmap_ext/channel_entries_tagdata
(0.248493 / 20.16MB) Calling Extension Class/Method: Matrix_ext/channel_entries_tagdata
(0.279621 / 20.40MB) Calling Extension Class/Method: Gmap_ext/channel_entries_tagdata_end
(0.279966 / 20.30MB) -> Data Returned
(0.280127 / 20.25MB) - End Tag Processing

```

But the finally details are, the page is processed in under `0.33 seconds` and uses less than `22MB Memory`. Plus it loads pretty darn fast. The page with specified data, loads in 0.7946 seconds, with around 42 queries, some items on the page are cached, total memory used is 22.4MB.

So it's very dependent. But generally speaking, no that's not bad.
> 3 votes

# Answer
There is a new(ish) version of P&T Field Pack -- available on Github. Download ZIP from Github

I saw this mentioned by Brandon on a P&T Get Satisfaction thread.

I just did the upgrade. The instructions (Docs are included with the Zip) tell you that if you are upgrading, first disable the P&T FieldPack extensions. Then install the latest in your expressionengine/third\_party folder.

Voilà! Your Template Debugging will no longer have lines like this in it:

```
Calling Extension Class/Method: Pt_field_pack_ext/channel_entries_tagdata

```
> 1 votes

# Answer
Yes, this is always the case when certain add-ons are installed. The amount of memory use will grow based on the amount of data returned by your Channel Entries call(s) with any add-on that uses the `channel_entries_tagdata` hook.

See also: Matrix\_ext/channel\_entries\_tagdata
> 0 votes

# Answer
Also don't forget that if you have a Playa field that is looking at channel(s) with a lot of entries, it may cause significant performance issues.

Try reducing the overall number of options/entries from the default "ALL" to a lesser number, starting with 1,000 and go lower if issues continue.
> 0 votes

---
Tags: matrix, performance, field-pack
---


# Question
Title: Is there a quick way to disable all plugins?
Installed a new module and now the site is insanely slow - stylesheets in the CP aren't loading even, 5-10 minute wait per page load. Is there any way to disable all the plugins at once? Deleting them from the third\_party folder didn't help.

# Answer
You can disable all **extensions** (which is the likely culprit, as a module doesn't have the power to inject anything into *all* of the control panel) by editing your **/system/expressionengine/config/config.php** file like so:

```
$config['allow_extensions'] = 'n';

```

This temporarily stops all extensions from loading, but does not actually uninstall them.

To *uninstall* any accessory, extension, or module, simply delete the appropriate row(s) from `exp_accessories`, `exp_extensions`, and `exp_modules` respectively.

You might want to turn on the Template Debugger first though, to try and find the culprit that way.
> 1 votes

---
Tags: ee2
---


# Question
Title: Copy Data from exp_channel_titles Based on entry_id
I'm trying to copy some channel data from the `exp_channel_titles` table into Better Workflow's `exp_ep_entry_drafts` table. I want to copy the data by matching the entry\_ids, which already exist in both tables. So the status for entry ID 42 in `exp_channel_titles` will go into the status column for entry ID 42 in `exp_ep_entry_drafts`.

I'm very much a MySQL n00b, but here's what I came up with:

```
INSERT INTO
  exp_ep_entry_drafts (
    status,
    url_title,
    expiration_date,
    entry_date
  )
SELECT
  titles.status,
  titles.url_title,
  titles.expiration_date,
  titles.entry_date
FROM
  exp_channel_titles titles
JOIN
  exp_ep_entry_drafts
ON
  titles.entry_id = exp_ep_entry_drafts.entry_id

```

When I run that in the EE query form, I get this error:

> Fatal error: Call to a member function num\_rows() on a non-object in /path/to/the/system/expressionengine/controllers/cp/tools\_data.php on line 482

# Answer
> 2 votes
I have no idea what the num\_rows() thing is about -- that's not an SQL error, it's an EE error that says it's having trouble running $this-\>EE-\>db-\>query -- but in any case, the query above has several issues. It's an INSERT, which means it inserts new rows; what it sounds like you want is to update existing rows, which uses a (wait for it!) UPDATE query. It also joins to the table you're INSERTing into, which generally isn't allowed, so it may be what's causing the EE error.

Try this:

```
UPDATE
    exp_ep_entry_drafts ed, exp_channel_titles t
SET
    ed.status = t.status,
    ed.url_title = t.url_title,
    ed.expiration_date = t.expiration_date,
    ed.entry_date = t.entry_date
WHERE
    ed.entry_id = t.entry_id

```

---
Tags: mysql
---


# Question
Title: Re-writing Playa tags to disable the Playa extension for better site performance
With the overall goal of reducing page load time (Memory, Execution Time in template debugging), how can I rework my Playa templates so as to “shut off” the Playa Extension?

Template debugging shows that I have 511 lines like so:

```
Calling Extension Class/Method: Playa_ext/channel_entries_tagdata

```

(The largest batch of them, 435 at a stretch, adds 3 seconds and 5MB to page execution time. And *of course* those 511 lines of calls appear on a section of the site that isn't using Playa. I've already gotten rid of similar calls for Matrix and P&T Field Packs by downloading the latest Field Pack off Github)

In this (old) P&T Support discussion thread, Brandon Kelly mentions that it's possible, by adding A Thing Or Two to your Playa tags, to disable the Playa extension. (I've done that with Matrix and, Field Pack, thanks to the latest version of them)

Brandon:

> You’d just have to remember to set entry\_id="{entry\_id}" on any Playa tags inside {exp:channel:entries}, as well as set the var\_prefix= param:

```
{exp:playa:children field="some_field" entry_id="{entry_id}" var_prefix="child"}
  {child:title}
  ...
{/exp:playa:children}

```

---

How do I apply that in this situation where I have a matrix tag pair and all that image replacement stuff going on?

```
{exp:channel:entries
    channel="thankyou"
    orderby="date"
    sort="desc"
    limit="1"
}
<h2>Thank you {title}</h2>
{thanks_body}

{!-- Playa Field tag pair: --}
{thanks_related_entries limit="8"}

<div class="related blurb">
{exp:lg_replace:haystack needles="{mtrx_images backspace="1"}image_{row_count}|{/mtrx_images}"}

<h4>
{if channel_id=="1"}<a href="/news/view/{url_title}">{/if}
{if channel_id=="4"}<a href="/articles/view/{url_title}">{/if}
{title}</a> </h4>

<p class="excerpt">
    {exp:eehive_hacksaw words="55" append="…"}
        {exp:smartdown} {summary} {body} {/exp:smartdown}
    {/exp:eehive_hacksaw}

{mtrx_images}
    {exp:lg_replace:replacement needle="image_{row_count}"}
        <a href="{img}" title="{img-caption}">{exp:ce_img:single src="{img}" width="70" alt="{img-caption}" class="left" title="{img-caption}"}</a>
    {/exp:lg_replace:replacement}
{/mtrx_images}
</p>
<p class="excerpt smallcaps">{if channel_id=="1"}<a href="/news/view/{url_title}">{/if}{if channel_id=="4"}<a href="/articles/view/{url_title}">{/if}» Read This</a></p>
{/exp:lg_replace:haystack}
</div>
{/thanks_related_entries}

```

Used in a similar manner in another location, I've wrapped the entire playa tags inside an if statement:

```
{if static_playa_related_posts}
    {static_playa_related_posts limit="15"}
     ...STUFF....
     {/static_playa_related_posts}
{/if}

```

# Answer
Here is what worked. Discussion follows below the code.

```
{exp:playa:children
    field="static_playa_related_posts"
    entry_id="{entry_id}"
    var_prefix="child"
    limit="8"
    }
<div class="related blurb">
{exp:lg_replace:haystack needles="{child:mtrx_images backspace="1"}image_{row_count}|{/child:mtrx_images}"}

<h4><a href="{child:comment_url_title_auto_path}">{child:title}</a> </h4>

<p class="excerpt">
    {exp:eehive_hacksaw words="55" append="…"}
        {exp:smartdown} {child:summary} {child:body} {/exp:smartdown}
    {/exp:eehive_hacksaw}

{child:mtrx_images}
    {exp:lg_replace:replacement needle="image_{row_count}"}
        <a href="{img}" title="{img-caption}">{exp:ce_img:single src="{img}" width="70" alt="{img-caption}" class="left" title="{img-caption}"}</a>
    {/exp:lg_replace:replacement}
{/child:mtrx_images}
</p>
<p class="excerpt smallcaps right"><a href="{child:comment_url_title_auto_path}">» Read This</a></p>

{/exp:lg_replace:haystack}
</div>

{/exp:playa:children}

```

The matrix field tag pair {mtrx\_images} {/mtrx\_images} both got the child: prefix in both places where they were used. {child:mtrx\_images} {/child:mtrx\_images}

The matrix field's contents did NOT have any prefix applied.

The {if channel\_id=="1"} set of statements did not survive this method, tho. Instead, I used {comment\_url\_title\_auto\_path} and gave it the prefix. {child:comment\_url\_title\_auto\_path}

Finally, for the example where everything was wrapped by a conditional, the IF used the name of the playa field, and the more detailed exp:playa:children markup went inside it:

```
{if static_playa_related_posts}

{exp:playa:children
    field="static_playa_related_posts"
    entry_id="{entry_id}"
    var_prefix="child"
    limit="15"
    }

.......

{/exp:playa:children}
{/if}

```

---

Then I uninstalled the Playa extension (but kept the Field Type and Module installed)

Memory usage on the original page:

*BEFORE* **28 MB** (30,207,216 bytes)
*AFTER* **19.5 MB** (20,432,320 bytes)
> 3 votes

---
Tags: templates, playa, performance, debugging
---


# Question
Title: Solspace Freeform Pro no field types available
I recently bought freeform PRO(version 4.0.11) and upgraded my freeform(version 4.0.8) using the Solspace update method.

When I navigate to the module page and select the tab **field types** the page shows the following message.

```
No field types available.
What, you deleted all of the default ones, too? O_o

```

It also throws some PHP error's.

```
A PHP Error was encountered
Severity: Warning
Message: glob() [function.glob]: Pattern exceeds the maximum allowed length of 260 characters
Filename: libraries/Freeform_fields.php
Line Number: 300

A PHP Error was encountered
Severity: Warning
Message: Invalid argument supplied for foreach()
Filename: libraries/Freeform_fields.php
Line Number: 302

```

When I open the freeform\_fields.php file from the libraries folder and navigate to line 300 I see the following piece of code.

```
    // -------------------------------------
    //  default fields
    // -------------------------------------

    $default_fields = glob(
        $this->default_path . 'freeform_ft.{' .
            implode(',', $this->data->defaults['default_fields']) . '}.php',
        GLOB_BRACE
    );

```

If I open the **default\_fields** folder it shows a lot of freeform\_ft\_FIELDTYPENAME.php files.

Whats wrong and how can I fix it without removing/uninstalling the whole module and install it again? I want to keep my submissions.

# Answer
You can run this query to build the fieldtypes table. (as always, make sure you have backups before doing anything like this!)

Another thing to try is to delete your FreeForm folders in third\_party and themes and upload them fresh. Often people try to just overwrite existing folders with the upgrade and strange things can happen. THis will not uninstall the module, so your data should be safe. It just makes sure the right files are in the right place.

```
DROP TABLE IF EXISTS `exp_freeform_fieldtypes`;
CREATE TABLE IF NOT EXISTS `exp_freeform_fieldtypes` (
  `fieldtype_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `fieldtype_name` varchar(250) DEFAULT NULL,
  `settings` text,
  `default_field` char(1) NOT NULL DEFAULT 'n',
  `version` varchar(12) DEFAULT NULL,
  PRIMARY KEY (`fieldtype_id`),
  KEY `fieldtype_name` (`fieldtype_name`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=15 ;

--
-- Dumping data for table `exp_freeform_fieldtypes`
--

INSERT INTO `exp_freeform_fieldtypes` (`fieldtype_id`, `fieldtype_name`, `settings`, `default_field`, `version`) VALUES
(1, 'checkbox', '[]', 'n', '4.0.0.b1'),
(2, 'checkbox_group', '[]', 'n', '4.0.0.b1'),
(3, 'country_select', '[]', 'n', '4.0.0.b1'),
(4, 'file_upload', '[]', 'n', '4.0.0.b1'),
(5, 'hidden', '[]', 'n', '4.0.0.b1'),
(6, 'mailinglist', '[]', 'n', '4.0.0.b1'),
(7, 'multiselect', '[]', 'n', '4.0.0.b1'),
(14, 'province_select', '[]', 'n', '4.0.10'),
(9, 'radio', '[]', 'n', '4.0.0.b1'),
(10, 'select', '[]', 'n', '4.0.0.b1'),
(11, 'state_select', '[]', 'n', '4.0.0.b1'),
(12, 'text', '[]', 'n', '4.0.0.b1'),
(13, 'textarea', '[]', 'n', '4.0.0.b1');

```
> 1 votes

# Answer
@Jim Wyse

Could you find out why the following piece of code doesn't work on my Windows machine? It also outputs an empty array. The vars $this-\>default\_path and $this-\>data-\>defaults\['default\_fields'\] are filled with data. Maybe it could be related to the **glob** method.

**File:** Freeform\_fields.php

**Line:** 296

```
    $default_fields = glob(
        $this->default_path . 'freeform_ft.{' .
            implode(',', $this->data->defaults['default_fields']) . '}.php',
        GLOB_BRACE
    );

```

I temporarly fixed it by creating the **$default\_fields** array and pushed the file paths in there with the **array\_push** method(not fully dnynamic like the code posted above).

```
    //Create an array
    $default_fields = array();

    //Foreach default field in default fields
    foreach($this->data->defaults['default_fields'] as $default_field)
    {
        //Push file path to default fields array
        array_push($default_fields, '../system/expressionengine/third_party/freeform/default_fields/freeform_ft.'.$default_field.'.php');
    }

```
> 0 votes

---
Tags: php, solspace-freeform, fieldtype, solspace
---


# Question
Title: Are prices for EE 1.x to EE 2.x upgrade & CartThrob upgrade still $49.95 & $149?
I'm helping a client quote an EE 1.x to 2.x upgrade and having trouble getting upgrading pricing from EE 1.x to 2.x. Before the site was changed my notes had the upgrade price as $49.95, is this still true?

Secondly, is the upgrade price for CartThrob for EE 1.x to 2.x still $149?

Nada on both sites, hope someone in here is in the know :)

# Answer
Close. The cost of an EE1 to EE2 upgrade is $50. (but what's 5 cents here and there ;)).

Sadly as far as I know there is no upgrade price anymore for Cartthrob from v1 to v2. CT2 has long been established and they've since brought out a slim lined version called Cartthrob Lite which just provides the basics. Unfortunately the cost of CT2 Pro has now gone up considerably to $300 and the support seems to now be absent in all areas so give it some careful consideration when quoting.
> 0 votes

---
Tags: cartthrob, ee1, ee2-upgrades
---


# Question
Title: {exp:playa:parents} returning value of {exp:channel:entries} that it's nested within
```
{exp:channel:entries}
    {exp:playa:parents}
        {title} returns title from the entry
    {/exp:playa:parents}
{/exp:channel:entries}

```

If I remove the `{exp:channel:entries}` tag pair, then the playa returns the correct data. However, I need info from the entry and then I want to loop through all the parents in another channel.

In this case, think of the entry as a product, and then return all the FAQs about that product. The relationship is made on the FAQ not the product.

# Answer
It sounds like, although it's not entirely clear how your relationship is defined, is that you're just coming at it from the wrong end of the relationship. If the entry is a ***product*** and the relationship is defined in this entry to FAQ pages then you need to be calling the ***children*** of this entry rather than the ***parent***.

> **Parent**: The entry that has the Playa field.
>
> **Child**: The entry that you selected in the Playa field.

Have you tried `{exp:playa:children}` instead of parent?
> 1 votes

---
Tags: add-on, playa, pixelandtonic
---


title: Chrome Back button issues

text:
# Question
Title: Chrome Back button issues
Whenever a user hits the back button in Google Chrome, if the previous page was password protected - it asks the user to login again even though they already are. Refreshing the page does display the protected content, but this is not a great experience.

Anyone else experiencing anything similar with the last couple Chrome releases?

# Answer
Are you talking about a member login area in the front-end templates or in the control panel? I'm using the latest version of Chrome and I don't have that problem with either.

It sounds like a session or cookie problem. In Admin \> Security & Privacy \> Security & Sessions, what do you have your Control Panel Session and User Session set to?

Try this:
> 1 votes

---
Tags: ee2
---


# Question
Title: Appending textarea fields with line breaks using Safecracker
Another perplexing "is probably an easy fix" question:

I have an EE site, and am using Safecracker to maintain a customer data channel. Each week, the customer receives a notice about an upcoming grocery delivery. When they do, they have the opportunity to submit a note about it – for example, "I don't want beets."

I have a another textarea field that collects all of these notes.

I was using a hidden Safecracker field to populate the textarea:

```
<input type="hidden" name="customer_bin_notes" id="customer_bin_notes" value="{customer_bin_notes}\n{customer_bin_recent_note}">

```

I can't get the line break to work. I also tried
and \l but those didn't work either.

I'm sure I'm overlooking something simple here.

Suggestions?

# Answer
Have you tried `<br />` instead of `\n`?
> 1 votes

---
Tags: safecracker
---


# Question
Title: How to update field-type table when a channel gets deleted?
I am trying to build a Expression engine field-type(add-on),where I will be storing the field-type data in a separate table(Ex:field\_type\_data).I am able to update the records of the table "field\_type\_data" whenever a entry or multiple entries gets deleted,through function delete($ids) in ft.fieldtypename.php which gets called whenever a entry is deleted and $ids is an array containing the ids of the entries that are deleted.

But I am not able to do the same when a channel itself is deleted by user.Because with the deletion of a channel all the entries related to that channel also gets deleted.

Can anyone help me please,how to and where I can know the list of entries related to the channel when it gets deleted.

Thanks in advance

# Answer
> 1 votes
hm... is no any special hooks for this in EE as I know. So possible solution is to create ext. on sessions\_end or sessions\_start and execute records cleanup in case if $\_GET = "channel\_delete" exist.

# Answer
> 1 votes
Yeah, this is a bit of a problem. I usually just ensure I always JOIN my custom table back to `exp_channel_titles` when I access data, so that if the entry has been deleted without my knowledge, it will not show up in the SQL query results.

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


# Question
Title: MSM site - cannot get addon site to use its own template
I have installed MSM and set up three sites, “live”, “beta” and “internal”. Edited the “live” site, created a default template group called “Live” and edited the index template in that group. Now I’m editing the “beta” site. I created a default template group there called “Beta” and edited the index template in that group. The problem is: when I go to the URL for the “beta” site, I still get shown the index template for the “live” site! How do I debug this problem?
I have tried changing uri\_protocol to PATH\_INFO in the live site’s config.php and it did not fix the problem.

# Answer
> 1 votes
As mentioned, it was the Apache virtual hosts setup that was wrong.

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


# Question
Title: How to get attempted url before access restriction?
this might be a simple fix, but it certainly doesn't seem to be.

I have built a EE-based web application, and as is part and parcel with web applications, users are required to log into the system.

With our application, users are often sent links like profile links, sort of like a social network works. However, at the moment, when users click on the links, they are required to login, and then they are brought to a generic template after logging in. I've tried using this http://devot-ee.com/add-ons/preevious but the value is coming up as blank regardless of how many times I try to use it.

Any ideas? Realistically, this is a massive deterrent for our users. If they are sent a link to a page, they need to log into the system, and then go back and click on the link in an email or via whatever other medium they were sent the link.

Any help or input would be massively appreciated. By the way, we are using standard access restrictions on this web app, which are set in the Template Manager. So if I try to go to domain.com/contacts, it will redirect me to domain.com/login and then once I login it will bring me to domain.com/home because that is our index page.

Cheers in advance, Conor

# Answer
> 1 votes
There are a few ways to do this, I find the easiest to be, to make the login page, available everywhere.

For example, we frequently have the login available from the Navigation Bar or one of those TopNav bars, say like Twitter. Generally, in either case, we use either CSS hide/display or an overlay window to display the login option. And have the login return them to the same page.

We've done this using Solspace's User, Authenticate, Zoo Visitor, and SafeCracker Registration. I'm certain any of the other add-ons for membership or registration will also allow you to do it as well.

Generally, speaking, if your login is available from **ANYWHERE**, then you don't really have to worry about re-directing the user back to where they came from. I like using FancyBox or another overlay script to provide the fields to enter in username and password, log them in, then drop them back onto the page.

Even without an add-on, you can set-up pages that require login access to display the login, when the user isn't logged in.

Using the built-in Member Login Form, see **Login Form Tag**. You can set-up something like:

```
 {exp:member:login_form return="{site_url}/{segment_1}/{segment_2}/{segment_3}"}

     <p>
          <label>Username</label><br>
          <input type="text" name="username" value="" maxlength="32" size="25">
     </p>
     <p>
          <label>Password</label><br>
          <input type="password" name="password" value="" maxlength="32" size="25">
     </p>
     {if auto_login}
          <p><input type="checkbox" name="auto_login" value="1"> Auto-login on future visits</p>
     {/if}

     <p><input type="checkbox" name="anon" value="1" checked="checked"> Show my name in the online users list</p>
     <p><input type="submit" name="submit" value="Submit"></p>
     <p><a href="{path='member/forgot_password'}">Forgot your password?</a></p>

 {/exp:member:login_form}

```

This form combined with the page logic like

```
{if logged in}
   {embed="include/mypage"}
{if:else}
   {embed="include/login}
{/if}

```

Should work.

# Answer
> 1 votes
Found a great solution this morning. We are now using stash to set values before pages are redirected and then to get the value on the login template. It is fairly similar to nonprofit\_tech's suggestion above, except this is all handled on a single page which is being set for all our redirects. So if a user has no access to a page, they are sent to the site's index. Then if they are logged out, set a stash variable, and redirect them to the login template.

```
{if logged_out}
    {exp:stash:set name="preLoginUrl" scope="user" save="yes"}{site_url}{segment_1}{if segment_2}/{segment_2}{/if}{if segment_3}/{segment_3}{/if}{/exp:stash:set}
    {redirect='login'}
{if:else}
    ...perform a bunch of routing here...
{/if}

```

Then on the login template (using a zoo visitor login form):

```
{exp:zoo_visitor:login_form error_handling="inline"}
                    <input type="hidden" name="RET" value="{exp:stash:get name="preLoginUrl" process="inline"}" />

                    {if "{error:login}" != ""}
                    <div class="content dashed-bottom error-holder">
                        <span class="tag danger">{error:login}</span>
                    </div>
                    {/if}
                    <div class="fieldset-holder cf">
                        <fieldset>
                            <label>Email</label>
                            <input type="text" name="username">
                        </fieldset>
                        <fieldset>
                            <label>Password</label>
                            <input name="password" type="password">
                        </fieldset>
                        <fieldset class="inline grid-33">
                            <label for="loginButton" class="button block primary"><i class="icon-key"></i><span>Sign In</span>
                                <input id="loginButton" class="hide-submit" type="submit" value="submit">
                            </label>
                        </fieldset>
                        <fieldset class="inline grid-66 text align-right">
                            <div><a href="{site_url}login/reset/" class="link">Forgot your password?</a></div>
                        </fieldset>
                    </div>
                    {/exp:zoo_visitor:login_form}

```

We tried everything from cookies to using php referrer headers and nothing worked apart from stash.

Hopefully this helps someone else out.

---
Tags: redirects, pages, restricted-area, redirection
---


# Question
Title: Grab logged_in user info in PHP template and assign variables
can you help me writing this lines of code for grab in a EE template the information about a logged\_in user, using php.

I'm using Vanilla Forum, and i want to use the JsConnect to pass the logged\_in user information to the Vanilla Log in. Here's the guide:

Implementing Vanilla jsConnect Single-Signon on your Site

I found that libraries to include in system

PHP jsConnect client library

And the code to include in my page template is this:

```
<?php
require_once dirname(__FILE__).'/functions.jsconnect.php';

// 1. Get your client ID and secret here. These must match those in your jsConnect settings.
$clientID = "1234";
$secret = "1234";

// 2. Grab the current user from your session management system or database here.
$signedIn = true; // this is just a placeholder

// YOUR CODE HERE.

// 3. Fill in the user information in a way that Vanilla can understand.
$user = array();

if ($signedIn) {
   // CHANGE THESE FOUR LINES.
   $user['uniqueid'] = '123';
   $user['name'] = 'John PHP';
   $user['email'] = 'john.php@anonymous.com';
   $user['photourl'] = '';
}

// 4. Generate the jsConnect string.

// This should be true unless you are testing.
// You can also use a hash name like md5, sha1 etc which must be the name as the connection settings in Vanilla.
$secure = true;
WriteJsConnect($user, $_GET, $clientID, $secret, $secure);

```

How can i call the logged\_in user info here

```
// 2. Grab the current user from your session management system or database here.
$signedIn = true; // this is just a placeholder

// YOUR CODE HERE.

```

with this

```
{if logged_in}
UniqueID={member_id}
Name={username}
Email={email}
PhotoUrl={photo_url}{photo_filename}
{/if}

```

And assign that the variables to pass to

```
// 3. Fill in the user information in a way that Vanilla can understand.
$user = array();

if ($signedIn) {
   // CHANGE THESE FOUR LINES.
   $user['uniqueid'] = '123';
   $user['name'] = 'John PHP';
   $user['email'] = 'john.php@anonymous.com';
   $user['photourl'] = '';
}

```

To generate a json file that vanilla JsConnect can read?

I think also

```
<?php
require_once dirname(__FILE__).'/functions.jsconnect.php';

```

return error in ExpressionEngine

Please somebody can tell me how can solve this.

Thank you in advance Alessio

# Answer
> 1 votes
If this is in a template you can just use: {member\_id} {username} {email}

If you want to use all php you can use the Session class: http://ellislab.com/expressionengine/user-guide/development/usage/session.html

```
$user['uniqueid'] = $this->EE->session->userdata('member_id');
$user['name'] = $this->EE->session->userdata('username');
$user['email'] = $this->EE->session->userdata('email');

```

You'd probably be better off writing an extension that takes care of this at login than in a template.

---
Tags: templates, php, forum
---


# Question
Title: Using a custom PHP variable in a channel entry start_on and stop_before
I am attempting to display entries from a specific channel 7 days before and 7 days after an entry\_date from another entry. I don't want to use a plugin because.

**Here's how I am getting / calculating the 7 days prior / 7 days after:**

```
{exp:channel:entries channel="pd_request_form" entry_id="{segment_2}"} <?php $php_7_days_before = date ("Y-m-d H:i", floor('{entry_date}' - 604800)); ?>{/exp:channel:entries}
{exp:channel:entries channel="pd_request_form" entry_id="{segment_2}"} <?php $php_7_days_after = date ("Y-m-d H:i", floor('{entry_date}' + 604800)); ?>{/exp:channel:entries}

```

**Here's what works:**

```
{exp:channel:entries channel="pd_request_form" dynamic="no" start_on="2013-01-10 00:00" stop_before="2013-01-24 00:00"}

    {title} - {entry_date}<br />

{/exp:channel:entries}

```

The dynamic="no" is there because the URL has an entry\_id in it. I see entries I would expect to see.

**Here's what also works:**

```
<?php echo $php_7_days_before; ?>
<?php echo $php_7_days_after; ?>

```

When I say it works I mean, it produces output that looks correct to me.

**But here is what isn't working:**

```
{exp:channel:entries channel="pd_request_form" dynamic="no" start_on="<?php echo $php_7_days_before; ?>" stop_before="<?php echo $php_7_days_after; ?>"}

    {title} - {entry_date}<br />

{/exp:channel:entries}

```

I think I'm missing something simple, but I'm not seeing it.

# Answer
> 2 votes
Your issue here is one of parse order. Changing to php on input won't help. Leave it on output.

I just tested this:

```
{exp:channel:entries channel="blog" limit="1"}
 <?php $php_7_days_before = date ("Y-m-d H:i", floor('{entry_date}' - 604800)); ?>
 {/exp:channel:entries}
 {embed="site/php_test" 7daysbefore="<?php echo $php_7_days_before; ?>" }

```

Then in your embedded template you can call start\_on="{embed:7daysbefore}"

# Answer
> 2 votes
Set PHP Parsing Stage to '*Input*' in your template file.

---
Tags: variable
---


# Question
Title: Need a query to display limited subset of categories based on custom category field value
I suspect there's a simple query to be able to do this but it's not something I've tried before. I'm trying to create a user-friendly way for a client to, from within the category edit screen, to indicate that a given category should or should not display within a drop down on the site. The general idea is that while they may have 20 categories, only 3-5 of them would be seen as "primary" and therefore should display in the dropdown menu at the top of the site.

So for user friendliness, I though adding a custom category field with a simple select list of no vs. yes would be the way to go. But the channel categories loop doesn't have a search parameter, so I suspect that I will need a query to loop through the categories in the given group and pull out only those with the custom category field of "display" with a value of "yes".

Can a query expert out there help me out?

# Answer
You can use this simple query with Query module:

```
{exp:query sql="SELECT exp_categories.cat_id, exp_categories.cat_name, exp_categories.cat_url_title FROM exp_categories
LEFT JOIN exp_category_field_data ON exp_category_field_data.cat_id=exp_categories.cat_id
WHERE exp_categories.group_id=2 AND exp_category_field_data.field_id_1='Yes'"}

<p>{cat_name} :: {cat_url_title} </p>

{/exp:query}

```

Please note the "field\_id\_1" within WHERE condition. You need to have id of field instead of '1' and field id can get from "Custom Category Fields" under "ID" column.

Hope, it would help you.
> 2 votes

# Answer
You could do it that way by setting a custom field if you wanted. I've done a similar thing recently and used GWcode Categories to simply call out that custom field:

```
{exp:gwcode_categories channel="my_channel" custom_fields="yes" cat_url_title="{segment_2}" style="linear" limit="5"}
    ...
    {my_custom_category_field}
    ...
{/exp:gwcode_categories}

```

You'll have complete control with GWcode categories to organise your categories as you choose and easy access to custom fields. You can also run conditional checks on them if they contain a yes/no value for displaying in the dropdown menu.
> 0 votes

---
Tags: categories, search, query
---


title: Running a query within a class method

text:
# Question
Title: Running a query within a class method
So i'm looking at http://ellislab.com/expressionengine/user-guide/development/usage/database.html

I've used

```
$query = $this->EE->db->query("SELECT channel_name FROM exp_channels");

```

many times, but never within a class. and using $this-\> causes issues. I'm no expert but how do i overcome this?

```
class Name
{
    public $variable;

    public function Something()
    {
         if($this->variable == "whatever")
           {
                //Run query to pull data based on $variable
                // This causes errors. I assume because $this is now something else.
                $this->EE->db->query("SELECT * FROM tablename WHERE...");
           }
    }
}

```

Message: Undefined property: Module::$EE

Message: Trying to get property of non-object

Fatal error: Call to a member function query() on a non-object

# Answer
> 2 votes
You first need to initialize global object like:

```
$this->EE =& get_instance();

```

---
Tags: php, query
---


title: Display Number of Active Members

text:
# Question
Title: Display Number of Active Members
I'd like to be able to display the number of "active" members on a site. Ideally this would be something like "number of members who have logged in in the past 30 days".

Barring that, I'd settle for the total number of combined members in a set of member groups, like: group\_1 + group\_3 + group\_5 = total number of members.

What do you think is the best way of going about this?

# Answer
> 4 votes
So both of the above should done done relatively easy with the query tool...

The SQL you'll need is :

```
SELECT count(*) as active_members from exp_members WHERE FROM_UNIXTIME(last_visit) > DATE_SUB(NOW(), INTERVAL 30 DAY);

```

The second one would just be :

```
SELECT count(*) as active_members from exp_members where group_id=1 OR group_id=3 OR group_id=5;

```

You'll simply be able to get the value using {active\_members} from within the Query module.

Hope this helps.

---
Tags: members, global-variables
---


# Question
Title: How to show entry modified date in CP entry listings?
With the Control Panel, is there a way to show an entries modified date within the entry listings rather than the creation date?

I believe it's possible with Zenbu but since that's all I would need it for purchasing that add-on would seem a little over the top.

# Answer
Zenbu is really awesome in my experience. But maybe if you just need to see the most recently edited entries this would help: http://devot-ee.com/add-ons/recent-entries
> 1 votes

---
Tags: control-panel
---


title: Incrementing Value in Cookie

text:
# Question
Title: Incrementing Value in Cookie
I've got Cookie Plus and Mo' Variables installed. I'm trying to set, get and increment a value in a cookie. Here's my test script:

```
{if "{exp:cookie_plus:get name="aa_seq"}" == ""}
{exp:cookie_plus:set name="aa_seq" value="1" seconds="0"}
Setting<br>
{/if}

Cookie: {exp:cookie_plus:get name="aa_seq"}<br>
{exp:cookie_plus:set name="aa_seq" value="<?php echo {exp:cookie_plus:get name="aa_seq"} + 1; ?>" seconds="0"}

```

I tried it with PHP on input and output, and they both FUBAR.

Would appreciate any pearls of wisdom. Thanks.

# Answer
I'm not sure about the first conditional.. but you could try this for the last line if you want to continue using the add-on. The original last line will fail because you've set it up to need to run cookie\_plus both before and after the php increment.

```
{!-- Set PHP to input --}

{if "{exp:cookie_plus:get name="aa_seq"}" == ""}
    {exp:cookie_plus:set name="aa_seq" value="1" seconds="0"}
    Setting<br>
{/if}

<?php
if(isset($_COOKIE['aa_seq']))
{
    $aa_seq_value = $_COOKIE['aa_seq'] + 1;
} else {
    echo "No cookie was found."
}
?>

Cookie: {exp:cookie_plus:get name="aa_seq"}<br>
{exp:cookie_plus:set name="aa_seq" value="<?php echo $aa_seq_value; ?>" seconds="0"}

```
> 1 votes

---
Tags: cookies
---


# Question
Title: Suggestion for add-on for date-triggered emails?
Thought someone might have a suggestion of an existing add-on or built in EE solution.

What the client needs is a way to trigger a specific 'reminder' email sent out. The date, time, and email template, would be set in fields on the individual members entry (using members as entries).

For example, an entry called "John" could be updated by the client to trigger a reminder email to go out in 30 days, which would only go to him.

# Answer
> 3 votes
Postmaster Add-Ons Email Solution will let you send emails exactly when you want.

---
Tags: ee2, email
---


# Question
Title: Error Number: 1364 on insert to exp_member_data
I am working with an add-on that does an insert into a custom member data field and I am getting the following kind of error:

```
A Database Error Occurred
Error Number: 1364

Field 'm_field_id_2' doesn't have a default value

```

My EE install is currently at 2.5.2 and it was upgraded from EE 1.6.9. In checking the `exp_member_data` table in database I can see that none of the custom field columns are set up with default values or allowed to be set to NULL. This includes even custom fields I set up after upgrading.

My questions are:

1. Is it default behaviour for EE to create new `exp_member_data` columns to not allow NULL and to have no default set? Seems like it shouldn't be.
2. Did something happen to my `exp_member_data` table in my upgrade so it is not set up correctly for EE2?
3. Am I safe to simply set the columns in the `exp_member_data` table to allow NULLS and set the default value to NULL?

# Answer
> 0 votes
I have this in my fresh EE 2.5.5 install

```
fiedl:m_field_id_1 type:varchar(100) NULL:YES Default:

```

You can probably safely adjust your columns

---
Tags: members, mysql, member-details
---


title: Different title for single pages

text:
# Question
Title: Different title for single pages
I'm trying to add a different title to inside pages of a specific channel. I have the logic down (I think), but am not quite sure how to determine if I'm getting served a single entry page:

```
<title>
{if embed:channel =='news'}
    {if [test for single page]}
        {embed:title}
    {if:else}
        News Index Page Title
    {/if}
{if:else}
    {embed:title}
{/if}
</title>

```

Is this possible?

# Answer
Just always pass `title` as an embed parameter in your template. So in **news/index**, you'd pass `title="News"`, and in **news/entry** you'd pass `title="{title}"`, or perhaps `title="{title} - News"`.

Then in your embed:

```
<title>{embed:title}</title>

```

In other words - perform the logic in your template, not in your embed.
> 2 votes

# Answer
If you're just looking for how to handle `title` and `sections` in the `<title>` tag, we use variations of this:

```
{exp:channel:entries channel="not forms" limit="1" show_future_entries="no" disable="categories|member_data|custom_fields|pagination|trackbacks"}

    <title>
        {if segment_2=="articles" AND title != ''}MySite - {title}
        {if:elseif segment_2 =="" AND segment_2 !="articles" AND segment_1 != ''}MySite - {exp:phpstringfun function="ucwords"}{exp:low_replace find="_" replace="SPACE"}{segment_1}{/exp:low_replace}{/exp:phpstringfun}
        {if:elseif segment_2 !="" AND segment_1 != ''}MySite - {exp:phpstringfun function="ucwords"}{exp:low_replace find="_" replace="SPACE"}{segment_1}{/exp:low_replace}{/exp:phpstringfun} :: {exp:phpstringfun function="ucwords"}{exp:low_replace find="_" replace="SPACE"}{segment_2}{/exp:low_replace}{/exp:phpstringfun}
        {if:else}
            MySite - {tagline}
        {/if}
    </title>

{/exp:channel:entries}

```

We set-up most sites, so that there is an `article` page that triggers the single post view. We may call it something other than article, but that's the primary trigger. The secondary triggers are for `section` pages, like News or About.

I've included our strip and format plugin use. You can use whatever you want, but we use PHPStringFun and Low Replace. This code is just in the header file for the site, and handles everything regarding `<title>` with little problem. It's our starter. We occasionally add a few lines with other checks.

Also we deliberately use the `not` in channel specification, so it processes everything, except a section never used on the front-end. We choose `forms` since we store all forms in a single area, then embed them where needed.
> 0 votes

---
Tags: channel, entry, title
---


title: Simple Quiz and Results in EE?

text:
# Question
Title: Simple Quiz and Results in EE?
I'd like to see what capabilities EE has for making a quiz with 10 questions, all of which have answers:

Not At All (0) Not Really (1) Undecided (2) Somewhat (3) Very Much (4)

If the sum of points (in parenthesis) exceeds 20, I want to display some custom message. I'd use Javascript, except I want to also store the results. Any recommendations on the best approach to this? Thank you.

# Answer
As mentioned you can use 4-EE Quiz Module ( http://devot-ee.com/add-ons/4-eequiz ) which has a built in point and scoring system already while allowing for the users selections to be saved.

Alternatively you could use something like Freeform which would allow you to create the questions as fields in Freeform so that the users selections could be stored in the EE DB. You could then use the Javascript that you were planning on using already to calculate the users total and show the messages based upon the users choices.
> 2 votes

# Answer
why not use this module. i've done a couple assesssments/quizzes with it: http://devot-ee.com/add-ons/4-eequiz
> 0 votes

---
Tags: ee2
---


title: Previous/Next Entries with custom URL

text:
# Question
Title: Previous/Next Entries with custom URL
I am building a site where the URLs of a blog entry look like:

```
/blog/2012/04/url_title

```

I am building out these urls by using `entry_date`. My links look like:

```
/blog/{entry_date format="%Y"}/{entry_date format="%m"}/{url_title}

```

The one thing I have not been able to figure out is how to use the Next/Previous Entries tags. Entry date values are not available in this tag pair so I have no way of grabbing the date values of the entry.

Any ideas?

# Answer
Thanks to both Bhashkar and Ian. I ended up using the Entry Linking plugin and CE:String like so:

```
{exp:entry_linking entry_id="{entry_id}" link="prev" channel="blog" status="open" mode="full" parse="inward"}
    <a href="/blog/{exp:ce_str:ing php}<?php echo date('Y/m', '{link_entry_date}'); ?>{/exp:ce_str:ing}/{link_url_title}">{link_title}</a>
{/exp:entry_linking}

```

The one drawback to the Entry Linking plugin is that you can't pass formatting to the entry\_date like: `{link_entry_date format="%Y/%m"}` but luckily I was able to use PHP to convert the date for my purpose.
> 1 votes

# Answer
Entry linking plugin would help you.
> 2 votes

# Answer
Nearby Entries will probably be your best bet as it includes the required parameters in your example: year, month, and url\_title.

By way of a similar example for /year/month/day/url\_title format:

```
<div class="nextprev nextprev-single">
    <div class="nav-previous">
        <span class="nextprev-arrow">‹</span>
        {exp:nearby_entries:prev this_urltitle="{segment_4}" this_channel="blog" debug="n" limit="1"}
        <a href="{path=/}<?php echo date("Y/m/d", "{nearby:entry_date}"); ?>/{nearby:url_title}">
            <span class="nextprev-post">Previous Post</span>
            <span class="nextprev-single-link-title">{nearby:title}</span>
        </a>
        {/exp:nearby_entries:prev}
    </div><!-- /.nav-previous -->
    <div class="nav-next">
        {exp:nearby_entries:next this_urltitle="{segment_4}" this_channel="blog" debug="n" limit="1"}
        <a href="{path=/}<?php echo date("Y/m/d", "{nearby:entry_date}"); ?>/{nearby:url_title}">
            <span class="nextprev-post">Next Post</span>
            <span class="nextprev-single-link-title">{nearby:title}</span>
        </a>
        {/exp:nearby_entries:next}
        <span class="nextprev-arrow">›</span>
    </div><!-- /.nav-next -->
</div><!-- /.nextprev -->

```

Just be sure to set PHP parsing to '*inward*' for your template.
> 1 votes

# Answer
I think the easiest method would be to use Advanced Prev Next Entry.

entry\_date vars are in fact available in this tag pair. I know because I just tested it for you :)

```
{exp:channel:entries channel="blog"}

    {exp:bbr_prevnext_entry current_url_title="{segment_4}" channel_name="blog" orderby="entry_date" sort="asc" cycle="yes"}

        <a class="prev" href="/blog/{entry_date format="%Y"}/{entry_date format="%m"}/{prev_url_title}/">Previous</a>
        <a class="next" href="/blog/{entry_date format="%Y"}/{entry_date format="%m"}/{next_url_title}/">Next</a>

    {/exp:bbr_prevnext_entry}

{/exp:channel:entries}

```

Use this and forget about having to mess with turning on PHP or using a second add-on ;)

Note: make sure your orderby and sort are set the same on your listing page as they are set in the bbr\_prevnext\_entry params (or rather vice versa) other wise things could appear out of order.

Bonus: APNE allows you to do a full circle with your entries via the cycle param. Not something that comes standard with core Next/Previous Entry Linking tags to my knowledge.
> 1 votes

---
Tags: next-prev
---


# Question
Title: Channel Entries Search Returning No Results
I have a routine that searches for an existing customer, based on their member email address. I'm passing the email address as an embed variable:

```
{embed="delivery/charter_customer_form" cust_email="{email}"}

```

The variable returns the address correctly. If I put `{embed:cust_email}` in the template, it displays the correct address.

However, when I plug it into the channel entry tag, I get no results, even I though I know for a fact that there is a match there:

```
{exp:channel:entries channel="customers" search:customer_email="{embed:cust_email}" dynamic="no" limit="1"}

```

Also, if I replace the variable with the hard-coded address, it returns the entry I'm looking for.

Am I overlooking something?

# Answer
This is due to ExpressionEngine parsing order in which user defined global variables are parsed at last. See here http://loweblog.com/downloads/ee-parse-order.pdf

To resolve this problem, you need to have small custom plugin which will return member's email. The plugin code would be like:

```
class Custom_plugin {
    public $return_data;
    function __construct(){
        $this->EE =& get_instance();
        $this->return_data = $this->EE->session->userdata('email');
    }
}

```

*I hope, you will put other plugin code yourself.*

Now you can have embed variable like:

```
{embed="delivery/charter_customer_form" cust_email="{emp:custom_plugin}"}

```
> 1 votes

# Answer
You might need parse="inward" on your channel entries tag.
> 0 votes

---
Tags: channel-entries, search, embeds
---


# Question
Title: Avoiding duplicate based on title in exp:channel:entries
I have a bunch of testimonials in a channel. Some have the exact same value in the title field.

My code looks like:

```
{exp:query
sql="
SELECT DISTINCT title
FROM exp_channel_titles
WHERE channel_id=19
ORDER BY RAND() LIMIT 3
"}

    {exp:channel:entries channel="testimonials" disable="categories|member_data|pagination"
    search:title="{the_title}" dynamic="no" limit="1"}

       {title}

     {/exp:channel:entries}

{/exp:query}

```

How can I insure I do not get more than one entry with the same title?

I can write a little SQL if needed.

Thx.

# Answer
> 1 votes
Updated query:

```
{exp:query sql="SELECT tmp.entry_id AS entryId
FROM (SELECT entry_id, title FROM exp_channel_titles WHERE channel_id='1' AND status='open' ORDER BY RAND()) tmp
GROUP BY tmp.title LIMIT 5"}
    {exp:channel:entries entry_id="{entryId}" disable="categories|member_data|custom_fields|pagination|trackbacks}
        <h3>{title}</h3>
    {/exp:channel:entries}
{/exp:query}

```

You need to pass correct channel\_id within WHERE clause.

You can see, I am applying the GROUP BY clause on random records so that query can group the entries based on random order otherwise each time query will return the top most record having duplicate Title.

I hope, it would be workable for you.

# Answer
> 1 votes
I believe Ian's response is the closest to what you need. I'd modify the query to:

```
{exp:query sql='SELECT DISTINCT title FROM exp_channel_titles WHERE channel_id='3' ORDER BY RAND() LIMIT 3'}

        {title}

{/exp:query}

```

I'm not certain why the `channel:entries` tag was introduced. It's not needed. Now there could be a debate about whether the items are truly random, since the DISTINCT statement is used. But they aren't forbidden from being used together.

So this should work. Make sure, the channel\_id matches the id from testimonials.

# Answer
> 0 votes
If you happen to already be using Stash, you can probably achieve this with the `set_list` and `get_list` methods in combination with the `unique="yes"` parameter.

If you're not already using Stash, then the query module approaches would be best.

---
Tags: channel-entries
---


title: {if:else if} & Matrix - Help!

text:
# Question
Title: {if:else if} & Matrix - Help!
I'm trying to add a conditional that checks if some Matrix fields are populated. If there's content, it'll enter the content within the Matrix fields. If not it'll default to another value. However, I'm not having any luck; the code at the moment reads as follows:

```
    {exp:channel:entries channel="{segment_1}"}
        {matrix_primary_tag_pair}
            {matrix_field_1}
        {if matrix_field_2}
            {matrix_field_2}
            {matrix_field_3}
        {if:elseif}
               {title}
        {/if}
        {/matrix_primary_tag_pair}
    {/exp:channel:entries}

```

As it is, either the {title} & {matrix\_field\_2} {matrix\_field\_2} appear, or none. Can anyone offer any suggestions? Thanks

# Answer
You should try changing your conditional to test if the content is not equal to "". Also this should not be an elseif, it should simply be and else statement

```
{exp:channel:entries channel="{segment_1}"}
   {matrix_primary_tag_pair}
     {matrix_field_1}
     {if matrix_field_2 != ""}
       {matrix_field_2}
       {matrix_field_3}
     {if:else}
       {title}
     {/if}
   {/matrix_primary_tag_pair}
{/exp:channel:entries}

```

Expression Engine evaluates "" as true coming from matrix.

Also the {if:elseif} needs a condition like:

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

```

http://ellislab.com/expressionengine/user-guide/templates/globals/conditionals.html#else-and-elseif

The {if:else} is more appropriate here though Hope this helps.
> 6 votes

---
Tags: matrix, conditionals, pixelandtonic
---


title: At import rule in style sheet

text:
# Question
Title: At import rule in style sheet
I have an at import rule in my main style sheet. @import url("base.css"); However its not importing the base.css. The base.css is in the same template group.

Any suggestion?

Jim Breen

# Answer
Just a guess but have you checked the url path? You should use a full path for the base.css file on the server like...

http://www.mysite.com/css/base.css

And since the css file is in a template group I would also suggest including the "index.php" part of the URL so that htaccess won't mess around with it.

* Bob.
> 1 votes

# Answer
I'm assuming from "the same template group" that both the main style sheet and base.css are both in your EE templates. Are you using the template group and template name in an EE tag in your import rule?

`@import url('{path=home/base}');`

or

`@import url('{stylesheet='channel/channel_css'}');`
> 1 votes

# Answer
I presume you've created a 'CSS' templates to run your CSS through? If you're using @import then I think you'll either need to use the full path to the other CSS file:

```
@import(/path/to/css);

```

Or you can use regular path variables using the template\_group/template pattern:

```
@import({path='template_group/template'});

```

As a general tip though using @import is best avoided if possible from a performance point of view. It will ad an extra roundtrip to your page loads and in IE it will see the imports load out of order which can cause issues. If you have multiple stylesheets you'll be better off using something like Minimee to minimise, combine, and compress your CSS files for much better performance.

You can also link to regular CSS files without needing to run through CSS specific templates.
> 0 votes

---
Tags: error
---


# Question
Title: Suggested method to watermark images on a case-by-case basis? (Matrix+CE Image or Channel Image)
I want to add watermarks to *some* images that I upload to an EE site.

I create images/illustrations and want to watermark those. It's helpful when the images come up in Google Image Search, both for branding, to make copying more difficult, and to come up with a good branding strategy for Pinterest usage of images.

However, I also use images for which watermarking is not suitable (CC attribution images, images from other sites that I use with permission).

Right now I use the Matrix file upload and do resizing using CE image and the image slug replacement method. I've theorized that I could add a switch in the Matrix field to watermark or not, and put CE image to work if the switch says yes.

However, I'm also thinking about re-architecting images using Channel Images instead. (call me crazy!)

1. For those of you who've worked with images using both CE Image and Channel Images, how would you conditionally apply watermarks using Channel Images?
2. Do you think I should stick to my current Matrix Image Replacement technique, or (once it's re-architected) would using Channel Images be easier to do in the long run?
3. Finally, is there some other method to accomplish watermarking on a case-by-case basis that I haven't mentioned here?

# Answer
Personally I wouldn't look to switch to a different method unless you have a particular need to. If I were given the same scenario I would go with the same method that you use and combine Matrix and CE Image to apply watermarks on an ad-hoc basis. That combination sounds like it should both work well and do everything that you need it to do. If it aint broke, don't fix it! ;)

I think the only benefit you may get to using Channel Images is the ability to upload multiple files at once rather than one per row but unless you have a *lot* of images per entry and this is really becoming a burden then I honestly think the extra work in changing things and the time in doing so wouldn't be worth the extra benefit.
> 2 votes

---
Tags: conditionals, image, ce-image, channel-images
---


title: Matrix error before and after upgrade

text:
# Question
Title: Matrix error before and after upgrade
I'm having an issue with Matrix where after upgrading from Matrix 2.4.3 to 2.5.3 I get this error on every page of the site regardless of the content on the page. Any ideas on how to fix this would be greatly appreciated.

```
Error Number: 1054

Unknown column 'is_draft' in 'where clause'

SELECT row_id, col_id_1, col_id_2, col_id_3 FROM exp_matrix_data WHERE field_id = 17 AND entry_id = 1048 AND is_draft = 0 ORDER BY row_order ASC LIMIT 1

Filename: third_party/matrix/ft.matrix.php

Line Number: 2808

```

Site specifications

* EE 2.5.3
* PHP Version 5.3.20
* SQL 5.0.77

Plugins

* Structure
* Matrix
* WYGWAM
* Playa
* Assets

# Answer
It sounds like Matrix may not have completed it's update routine. Did you go to Add-Ons → Fieldtypes → Matrix to trigger the update script?
> 12 votes

---
Tags: matrix
---


# Question
Title: Adding Page Titles and Meta Info to Home Page and Non Channal Entry Pages
What is the best way to add custom page titles and meta info to non entry pages like the home page or a landing page for a portfolio? I want to give users the ability to edit the page title and meta info on these types of pages via the CP. I set up embedded variables to do this for my entry pages which works great but need a solution for these no channel entry pages. Any advice would be appreciated.

# Answer
> 1 votes
One of the most popular ways is to use Low Variables. It's perfect for handling all the 'etc' information which doesn't fit into a channel but where the user needs to be able to edit it from the control panel. It's commercial but it has many uses and is a common install.

# Answer
> 1 votes
Digital Surgeons recently released an add-on to address this specific situation. Here's a snippet from their overview text:

> But unlike other SEO add-ons, you can manage SEO meta data on pages which are not entries.

I haven't used it myself, but it looks pretty nifty. Take a look: http://devot-ee.com/add-ons/surgeeo

# Answer
> 0 votes
I would suggest you to use the channel to manage the page title and meta info. This channel would contain the field for these. Also, you should have a field type "Template Select" http://devot-ee.com/add-ons/template-select within this channel. In this way, this channel would have following fields:

* Page Tile
* Description
* Keywords
* Select the template (Template Select) field type

You can have following code example within your non-entry template:

```
{if segment_1}
{exp:channel channel="page_seo" search:template="{segment_1}/{segment_2}"}
<title>{page_title}</title>
<meta name="description" content="{description}" />
<meta name="keywords" content="{keywords}" />
{/exp:channel}
{if:else}
<!-- To manage Home Page -->
{exp:channel channel="page_seo" search:template="home/index"}
<title>{page_title}</title>
<meta name="description" content="{description}" />
<meta name="keywords" content="{keywords}" />
{/exp:channel}
{/if}

```

---
Tags: seo
---


# Question
Title: Are custom member fields not functional in the registration form if the setting for "field visible in registration page" is set to "No"
I have a number of custom member fields setup to store "yes" or "no" settings. They are used for form inputs for checkbox fields. I don't want them visible on the standard Exp Eng profile pages or on the standard Exp Eng Registration page because that would be confusing to the user and they might enter incorrect values in the fields.

In the Exp Eng documentation there is this...

> Is this field visible in registration page?
>
> When set to “yes”, the field will be available in the public member registration form.

For these fields in question I have them set to "no" for the above setting. My question is, will the above setting also "deactivate" that custom field on a Registration page, even if I make the field available in the code of the form?

I have a custom registration page that I setup in a member profile template group that uses these input fields but after someone has submitted the form and completed the member signup none of the selections that use those fields come through.

From the point of view of the person signing up they are making selections to signup for email newsletters but after they are registered none of those subscriptions choices were saved.

There may be another issue with a javascript routine but that works fine on other pages.

# Answer
Correct, those fields will not be functional in your front-end registration forms either. You need to set them to "yes" for that setting.

If you're wanting to hide those fields from the user in their EE profile edit page, then set the previous option regarding making it available in the public profile to "no."
> 1 votes

---
Tags: forms, member-details, registration
---


title: remove embedded media

text:
# Question
Title: remove embedded media
Testing Wygwam 2.7 with a Youtube video uploaded via the Embed Media button, but the embed needs to be removed when an excerpt of the entry appears on the home page. Can this be done with Wygwam natively?

# Answer
> 1 votes
Sure thing. From the docs:

```
{wygwam_field text_only="yes"}

```

This will strip all other HTML as well, but for an excerpt that's probably desirable anyway.

---
Tags: wygwam
---