title: Redirect user based on country

text:
# Question
Title: Redirect user based on country
I was wondering if it's possible to work out if it is a user's first visit to the site and then redirect them to another site based on their country of origin (perhaps through GeoIP), but if they come back to the uK site then just show them the UK site.

Perhaps storing the first time visit check in a session?

So as an example, if it's someone's first visit to the .co.uk site and they are in Germany, then redirect them to the .de site.

However, if they visit the .co.uk site again - then we can tell their intent is to see the UK site and we let them view it until the session expires.

# Answer
> 1 votes
You could set a cookie for their initial visit containing their original country. Then you could set a session using the same method.

Cookies have a longer lifetime and won't get erased after the user leaves the site. This allows you to pull their country after they return. Setting the session variable holds their country site data for their current visit.

Then in your code (php but expression engine plugins could do some of this) do something like this in your page header

```
//test to see if the session has already been set
if (isset($_SESSION['country'])) {
   //redirect to http://test.$_SESSION['country'] if they are not already on that page;
} else {

//if it hasn't, test to see if the cookie is set
   if (!isset($_COOKIE['country'])) {
     //if not, get that information
     setcookie("country", //however you get your country);
   }

//Then start the new session and set country to the cookie
   session_start();
   $_SESSION['country'] = $_COOKIE['country'];

   //then redirect based off of the session variable
}

```

There are several plugins that might save you from having to write this in php, like Session Variables, Cookies, IPGeo

With these, I am sure you can recreate that code following the same logic

---
Tags: sessions
---


# Question
Title: Assets not displaying correctly after moving server
We moved a completely running website to a new server. The whole migration worked out well. The domain name, server settings, paths, MySQL stayed identical.

However all uploaded images and assets created subfolders are not visible anymore in Assets. They're still available in the database and are also shown on the front end. Folder rights are OK.

After indexing assets again I'm getting the following message:

# Answer
Firstly, Assets disallows files and folders that begin with a dot or an underscore, as the convention is to user either of those prefixes for hidden files and folders.

Another thing to look out for is the Upload File Preferences - if you migrated between servers, are you sure that the physical server path to the Upload Filedirs remained the same as it is in the preferences?
> 2 votes

# Answer
It looks like you just need to re-index but Assets is being a little cautious in checking that you want to delete the old references it has stored and replace with new ones. An re-index should stop Assets asking. I'm sure Andris or Lisa will be able to help out directly however if you're a little uneasy about removing old references (understandable).
> 0 votes

---
Tags: assets
---


# Question
Title: htaccess, https, MSM, and Expresso Store
I'm running EE multi-site manager (MSM).

1. My default site's domain (say, www.default.com) is where the /themes folder is housed.
2. So, for my second site (say, www.site-two.com), all of the EE and third-party theme files (js, css, etc) are being pull from www.default.com/themes/\*
3. Site two is secure, using https (via .htaccess), since it's running Expresso's Store and requires SSL. Default site is not https.

**My problem is that the requests to the EE and third-party theme files (from the default site) are not completing because they're being requested as https://www.default.com/themes/* instead of http://...**

Here's my current .htaccess mod\_rewrite section

```
RewriteEngine On

## -- force www -- ##
RewriteCond %{HTTP_HOST} ^site-two\.com$ [NC]
RewriteRule ^(.*)$ http://www.site-two.com/$1 [R=301,L]

## -- force https -- ##
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^www\.site-two\.com$  [NC]
RewriteRule .* https://www.site-two.com/%1%2  [R=301,L]

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

```

I've tried endless .htaccess variations with no success. I don't even know if I'm wanting is possible. I'd like to avoid making www.default.com secured (more money), if possible.

NEW INFO PER ADRIAN'S FIRST ANSWER: Using Focus Lab's master config set up, I have this for the production config, which is why it at least pulling from the default site.

```
$env_config['default_url']      = 'http://www.default.com';
$env_config['theme_folder_url']     = $env_config['default_url'] . '/themes/';

```

Any help is greatly appreciated.

EDIT: Problem is this auto-generated script from the exp:store:checkout tag. See the `script.src`

```
if (!ExpressoStore.scriptElement) {
                var script = ExpressoStore.scriptElement = document.createElement("script");
                script.type = "text/javascript"; script.async = true;
                script.src = "//www.default.com/themes/third_party/store/store.js";
                (document.getElementsByTagName("head")[0] || document.getElementsByTagName("body")[0]).appendChild(script);
            }

```

# Answer
This isn't really an issue with your htaccess. You need to look at using a simple EE config bootstrap file such as this one to automatically set `$config['theme_folder_url']` as either HTTP or HTTPS depending on whether the current request is served over HTTPS.

In the most basic form, you could probably just add this to your `config.php` file:

```
if (empty($_SERVER['HTTPS']) || strtolower($_SERVER['HTTPS']) == 'off') {
    $config['theme_folder_url'] = 'http://www.example.com/themes';
} else {
    $config['theme_folder_url'] = 'https://www.example.com/themes';
}

```
> 4 votes

# Answer
That's because your .htaccess file is forcing them over a secure connection. Stepping backwards for a second do you really need ALL areas of the site to be run over a secure connection? Generally you only want the checkout and the account section to be sure as it involves sensitive form submissions. The rest of the site isn't really necessary.

So with that in mind how about changing your .htaccess file so that you only specify the URL segments you wish to protect:

```
# Redirect to HTTPS if not using HTTPS
RewriteEngine On
RewriteCond %{HTTPS} !=on
# Specify URL segments to ensure a secure connection
RewriteCond $1 ^(member|account|checkout|system) [NC]
# Rewrite requests to above segments over HTTPS
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

```

So now instead of EVERY request being sent over HTTPS it will only send the segments you specify and should solve the problem.
> 1 votes

---
Tags: expresso-store, multi-site-manager, htaccess, ssl
---


title: empty thumbnails

text:
# Question
Title: empty thumbnails
I've just installed assets 205 on EE 255 and am having a strange issue. the regular file manager works fine but the assets view shows blank boxes for all of the images. It has file names, sizes, and dimensions, but no other attributes and no previews. File manager and uploads work fine without Assets, and assets is uploading images but only displaying blank boxes. when I switch back to the regular file manager, the images are fine. any ideas?

# Answer
Ah I've had this before also! Could be a difference in your ControlPanel URL in General Configuration and the URL you are actually logged in with (ie www.site.com/system/ or site.com/system). Doesnt Assets 2 use the EE native thumbnail-creation? Are you uploading in subfolders with Assets?
> 1 votes

# Answer
I've just had a similar issue which, given the necessary permissions, Andris solved for me by adding an **assets\_site\_url** config variable to config.php to point at my EE web root index.php. (Thanks, Andris!)

I'm guessing this was necessary because my system is renamed and above web root (don't think it was a permissions issue).

Andris, feel free to add to this :)

**Post edit**: seems my issue was to do with the lack of a DirectoryIndex directive coupled with the rewrite rule for removing index.php in my .htaccess, and the consequent failure of Assets ajax. In other words, a properly configured DirectoryIndex directive negates the need for the config variable.

Hope this may help someone.
> 1 votes

# Answer
this sounds like your system/expressionengine/cache folder is not writable - Assets uses that folder for the thumbnails, as that gives us a chance of creating whatever sizes we need.

Let me know if that was it!

Cheers, Andris
> 0 votes

---
Tags: assets, pixelandtonic, file-manager
---


# Question
Title: Expresso Store: Insert a final confirmation screen AFTER payment interface
Our client has requested that we add a final confirmation screen in checkout process that appears after the payment screen. This would seem a pretty simple addition, but having tried unsuccessfully to add one I found this in the Expresso Store docs.

'To give the user a choice between payment methods, you can either use the payment\_method="" parameter, or **submit a payment\_method field on the last page of your checkout**.'

Which suggests that payment HAS to occur on the last page of checkout wether or not the 'next' parameter is set on the store tag.

Has anyone managed to get a final screen working? If its not possible it would certainly be a useful option in future versions.

Cheers!

# Answer
> 5 votes
Store doesn't support adding a final confirmation page AFTER you have already taken payment. As soon as payment is successful, the order is complete (that is why payment must be on the last page of your checkout).

You won't be able to support this without significantly modifying the checkout codde, and besides, only a few gateways would support it (the payment gateway would need to support authorize/capture, otherwise we would need to store the credit card details in the database which is a big no-no).

Instead of this, normally you use the final page of the checkout as a "confirmation", where you display the order details, and add a credit card form/paypal button which indicates the customer wants to proceed with the order.

# Answer
> 3 votes
I'm not sure you really need a final confirmation screen AFTER payment because this is what the order confirmation page is for once you're returned to the site after paying for your goods.

I provide an order summary page after the user has entered in the order details and before they make the payment as that is the time you want to display it to give them a final chance to review the order items, totals, shipping, and details before making the payment. I do this by just making an extra page and using the Next attribute along with regular Store tags to sum it all up. The button on that page is the Submit button to make the payment.

Is this what you're after? I just can't see any reason why you'd need one after this page and before the order confirmation page after payment. Both of those cover all bases. If you're having trouble with the code to put that together then feel free to submit that here and I can edit it to show you how I handle it.

---
Tags: expresso-store, checkout
---


# Question
Title: Category group ordering within categories tab
Does anyone know if it's possible to change the order category groups appear within the categories tab when publishing/editing an entry?

Mine are coming back in neither ID order nor alphabetical order!

# Answer
> 1 votes
There seems to be no way to do this out of the box, but the Category Field addon makes it possible (and is an excellent addon for categories generally!).

# Answer
> 1 votes
Go to to **Admin \> Channel Administration \> Categories** drop down, then click on **Add/Edit Categories** and choose Alphabetical or Custom sorting. Based on what you said, you probably have custom sorting enabled.

You can also do the custom sort within the actual categories tab like I mention below or do it in the Admin Categories area.

In the Categories tab on the edit/publish entry page, click the **Edit Categories** link underneath the actual categories. The categories have a custom sort order based on that.

There are arrows to move them up or down.

Is that what you were looking for?

---
Tags: categories
---


# Question
Title: Capturing post processed template into PHP variable
Is there a way to capture in PHP a post processed version of an embed?

I have a footer embed template. There are 2 rendered states for the footer, user logged in and not. What I would like to do is cache the rendered version of the footer so that it does not need to be reprocessed on every page. The only time that EE processing needs to be done to rerender the template is when the user changes their login state.

I cannot create 2 footers and then do template caching them through EE because the footer contains information unique to each user so the caching needs to be done on per session basis and controlled through PHP.

So what I would like to do is capture the rendered state of the footer into a PHP variable and then store it into memcache. Is this possible?

# Answer
I can't answer your question specifically but here is an alternative that might work...

Take a look at the CE Cache modules and specifically their **Partial Caching option using the {exp:ce\_cache:escape} tag**. The modules offers a memcache driver option.

```
{exp:ce_cache:escape}
    <p>{if logged_in}Hello {username}{if:else}Please log in{/if}</p>
{/exp:ce_cache:escape}

```

You can also use the Static driver (which is very fast) and have it only enabled for logged out users with the `$config\['ce_cache_fragment_logged_in_only'\] = 'yes';` config setting.
> 1 votes

---
Tags: templates, php
---


# Question
Title: Migrating EE to fresh install changed file upload directory ID - Now what?
I am rebuilding a current site from scratch and I've rebuilt the file upload directories and migrated all of the previous uploads over but now, the path variable in my links references the upload directory ID of my previous installation. Before, it was...

```
{filedir_8}

```

and now, it's...

```
{filedir_2}

```

I am using WYGWAM v.2.7 and EE v.2.5.5. I am using CKFinder for the upload manager.

Any recommendations to correcting this? I know I could develop some sort of SQL query, but I am hoping there is another way.

Thanks for your help!

# Answer
> 2 votes
The simplest thing to do would be to go into your new database and manually change the IDs of your upload directories in `exp_upload_prefs` to match your old site. Use phpMyAdmin to do this if it's installed on your server.

(This is assuming, of course, that you haven't made a bunch of new associations with the new directory ID since migrating.)

**UPDATE:** Alternately, you can do a find and replace on each Wygwam field via SQL:

```
UPDATE exp_channel_data SET field_id_XX = REPLACE(field_id_XX,'filedir_8','filedir_2');

```

Do this for each Wygwam field, replacing `field_id_XX` with the actual `id` for that field.

---
Tags: wygwam
---


title: Sort categories by amount of entries

text:
# Question
Title: Sort categories by amount of entries
When using `{exp:channel:categories}` to list categories, is it possible to sort the list by the number of entries each category has associated with it?

# Answer
> 1 votes
I'd make use of GWcode Categories which is an excellent free addon where you can simple do something like this:

```
{exp:gwcode_categories entry_count="yes" orderby="entry_count" sort="desc"}

    {cat_name} ({entry_count})

{/exp:gwcode_categories}

```

Where in this example I'm ordering by the entry count (descending) and also outputting the entry count if desired.

# Answer
> 0 votes
You can try this sql with Query module:

```
{exp:query sql="SELECT count(exp_category_posts.entry_id) AS total_entries, exp_categories.cat_id, exp_categories.cat_name, exp_categories.cat_url_title
FROM exp_category_posts
LEFT JOIN exp_categories ON exp_categories.cat_id=exp_category_posts.cat_id
WHERE exp_categories.group_id=1
GROUP BY cat_id
ORDER BY count(entry_id) DESC"}

Total Number of entries = {total_entries}, Category ID = {cat_id}, Category Name = {cat_name}, Category URL Title = {cat_url_title}
<br /> <br />

{/exp:query}

```

You need to update the category group id in WHERE condition (group\_id=1) and ORDER BY either DESC or ASC.

With the above query, you can get other info like total number entries in a particular category, category name, category id and category url title.

I hope, it would help you.

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


# Question
Title: Entry ID Returned From Plug-In Not Working in Channel Entries Tag
I've written a custom plugin which I call repeatedly (via a channel:entries tag) to store a list of entries in an array. (BTW, you have to set up a separate singleton class to do that, as the plug-in object gets re-instantiated from scratch every time it's called from the template.) So the plug-in has two functions: one to store the entry ID's (parse\_home\_seq), and one to return the entry we're currently looking for (get\_hero), which is dictated by the value of a cookie.

I've logged extensively in the plug-in, so I know that it's returning the right ID. And yet, the second channel:entries tag always returns the same entry (while the get\_hero function cycles through the entries on successive page requests). I've been banging my head against this wall all day. Here's the code:

```
{!-- Determine which products to use for hero --}
{exp:channel:entries channel="products" status="wide" orderby="homepage_seq_no" sort="asc"}
    {exp:ah_proc:parse_home_seq seq="{homepage_seq_no}" id="{entry_id}"}
{/exp:channel:entries}

{exp:stash:parse process="end"}
{exp:ah_proc:get_hero no_update="1"}:: {!-- for logging --}
{exp:channel:entries channel="products" entry_id="{exp:ah_proc:get_hero}" status="wide" limit="1" parse="inward"}
    {entry_id}  {!-- for logging --}
    <h1>{title}</h1>
{/exp:channel:entries}
{/exp:stash:parse}

```

Any help appreciated. Thank you.

# Answer
(1) you can use the session class to store your private data in an array or object :-) http://ellislab.com/expressionengine/user-guide/development/usage/session.html#cache-array

(2) What i'ld do is wrap the whole second channel entries tag within `{exp:ah_proc:get_hero}` and have a simple tag `{ah_proc_get_hero}` which you can just be search and replaced for the chan:entries to use.

```
// first chan:entries tag

// second
{exp:ah_proc:get_hero parse="inward"}
  {exp:channel:entries channel="products"
    entry_id="{ah_proc_get_hero}" status="wide"
    limit="1"
  }
    {entry_id} <h1>{title}</h1>
  {/exp:channel:entries}
{/exp:ah_proc:get_hero}

```
> 1 votes

---
Tags: channel-entries, plugin, parse-order
---


# Question
Title: Generating static map based on custom field data EE GMaps
Trying to create a static map dynamically in a channel entries loop with the lat/long field data. I'm thinking that the text fields are parsed after the `{exp:gmap:static_map center="{retailers_latitude},{retailers_longitude}"}` \- any solution for this? Swapping parse order doesn't do anything.

# Answer
> 2 votes
You may have to encase those variables in quotes like:

```
{exp:gmap:static_map center="{retailers_latitude},{retailers_logitude}"}

```

---
Tags: add-on, google-maps-for-ee
---


# Question
Title: Clients in singapore on Singtel cannot login and sometimes cannot access site
This is my issue: http://ellislab.com/forums/viewthread/205006/P18

> users in singapore are having an issue when posting content in various and random channels and other places in the control panel.
>
> This goes for updating a post and publishing a new one. What happens is the user can navigate to the publish/edit screen fine, and change content, but when they click on submit, it boots them back to the CP home screen, and the form does not save the data to the channel.
>
> No one else is having this problem around the world.
>
> I suspect this is related to the IP address in the session so I did a code search for IP checking on form submits and couldnt find anything, but I may not have looked correctly.

This is my current security settings (not ideal but made some improvement to logins)

http://d.pr/i/b8Iz

# Answer
This probably isn't the answer your looking for, but your mention of Singapore and then reading the conversation thread at Ellis Lab, my first thought was you're hitting some internet restriction, either by the ISP, but more likely by the country.

In Singapore the government via the **Media Development Authority (MDA)** bans, blocks, and otherwise monitors access to any website. It's possibly random, in that one ExpressionEngine site got banned for objectionable content— anything from humor to art to politics to religion or sexuality, and they created a profile ban that hits almost **all** ExpressionEngine sites.

It sounds like you guys have gone through a number of test with your clients, but I recommend one more: **test with a VPN in place**.

We deal with a client that travels back and forth to China and we've set them up with **PandaPow**. This has worked well, so far. Now, I can't say if PandaPow will work well for Singapore, but they do work hard to keep there servers off of various banned list, so they may.

You should also look at this article called: **Best VPN for Singapore** at Start VPN. We've never tried any of the VPNs listed in the article, but the focus is directly on avoiding Singapore restrictions (which can be hard, since they don't publish them and frequently deny that they are in place).

Start with a simple test. With PandaPow you can have one of your client's download the software, pay for a single month's membership, install the software, test to see if VPN is working, then test logging in to the Control Panel. They can try using a US or Europe based IP server.

If this works, then you know it's the ban that's effecting access and can decide to proceed from there.

You can also try other options as well, if you don't want to test the VPN immediately. I'd look at:

1. **Change Control Panel Access** from `system folder` to renamed `admin.php` file. The idea here is that if the MDA is blocking they maybe blocking one access protocol, but not another.
2. **Check Blacklist** make sure there aren't in bans on Singapore IP addresses or generic domains, like Singtel servers. Make sure you check `.htaccess` as well. It sounds crazy, but we once discovered a ban that blocked most of Russia (which we were fine with, except for 2 addresses, that we needed to have access).
3. **Signup for a Content Delivery Network (CDN)**. This one is probably the least likely to work. Not because it couldn't work in theory, services like **CloudFlare** have CDN servers around the world, including Singapore. There DNS management may bypass Singapore government filters. But the reason why it's less likely to work, is ExpressionEngine's control panel javascripts don't work well under CloudFlare's speed enhancers (RocketScript), so generally a CloudFlare set-up excludes the Control Panel from CloudFlare protection and speed services. But just the overall DNS switch may work, so it can be tried.

I think the VPN is probably the top method, but I'd look at changing from `system folder` access to renamed `admin.php` access to the control panel as well, if you haven't yet.
> 8 votes

# Answer
I'm not sure whether it has been fixed or not, but there used to be a bug in EE where sessions were tied to a particular IP address (which I mentioned in that thread you linked to).

In many parts of Asia, the ISPs run a transparent proxy which can cause your http requests to appear to come from multiple IPs (the first page will come from one IP, the second from a totally different IP). You can verify if this is happening by opening up a few different "what is my IP address" type websites and compare the results (don't just refresh one, compare different sites). I've also run into this problem accessing EE over 3G mobile broadband connections in Australia, NZ, and Europe. I'm not sure how common this is in the rest of the world.

If you aren't running the latest version of EE, I'd recommend updating and see whether they've fixed it recently. Otherwise, I'd recommend either hacking the EE code to remove the totally pointless IP address check, or just bug EllisLab about it and try to get a fix (probably email the individual developers to get a response).

**UPDATE:** I just checked the source of the latest version of EE. Commenting out the following line 76 of `system/expressionengine/core/EE_Security.php` should fix your problem submitting forms at least:

```
$total = $EE->db->where('hash', $xid)
    // ->where('ip_address', $EE->input->ip_address())
    ->where('date > UNIX_TIMESTAMP()-7200')
    ->from('security_hashes')
    ->count_all_results();

```
> 0 votes

---
Tags: control-panel, sessions
---


title: Assets2 subfolders have gone missing

text:
# Question
Title: Assets2 subfolders have gone missing
A recent import using Solspace importer where I just wanted to update a standard file field (NOT an asset field) has had the unfortunate side effect that in my assets file manager and assets fields all subfolders have gone missing. When I try to recreate a subfolder I get an alert telling me the folder already exists, but it's not visible in the asset file manager. All the data that's in the entry form is still correct but when trying to upload a file all subfolders have gone missing as well as in the assets file manager. Any suggestions on how to get these back?

# Answer
> 1 votes
I can confirm a similar issue here

In our case updating Assets to 2.1 made subfolders disappear. However database was intact. Hence the error when trying to recreate same folders.

Solution was to

1. Create a dummy folder
2. Move all disappeared files/folders into the dummy folder
3. Update indexes & delete references
4. Rename dummy folder with the old folder name
5. Update indexes & delete references again

Hope this helps

---
Tags: pixelandtonic, assets
---


title: category_heading and GWcode Categories

text:
# Question
Title: category_heading and GWcode Categories
I don't seem to be able to use ExpressionEngine's native `{exp:channel:category_heading}` feature in combination with GWcode Categories.

I would like to display a simple category results page which displays all entries within a particular category, with the category name at the top as a page header. There will also be a list of all the categories in the sidebar (which I'm using GWcode for).

My code, simplified:

```
<!--Page heading-->
{exp:channel:category_heading}
    <h2>{category_name}</h2>
{/exp:channel:category_heading}

<!--List of all the categories-->
<ul class="tags">
    {exp:gwcode_categories channel="project|miscellany" entry_count="yes" orderby="entry_count|cat_name" sort="desc" style="linear"}
    <li>{cat_name}</li>
    {/exp:gwcode_categories}
</ul>

<!--Results of selected category-->
{exp:channel:entries channel="project"}
    <img src="{project_thumbnail}" />
    <h2>{title}</h2>
{/exp:channel:entries}

```

The only bit that doesn't work is the page heading. Does anyone know why this might be?

Thanks.

# Answer
That's one of the limitations of native category handling in EE. You can grab it with some PHP but even easier is to use Low Seg2Cat which is to remedy this type of case.

You can simple use `{segment_n_category_name}` to output the category name from the segment in the URL where it is displayed. So if you have a URL such as:

mysite.com/products/category

You can then output the category heading with:

```
<h2>{segment_2_category_name}</h2>

```

It is certainly very useful when working within the limitations of the native EE category handling.

**EDIT:** Updated to show an alternative method using the Query Module.

```
{exp:query sql="SELECT cat_name FROM exp_categories WHERE cat_url_title = '{segment_3}'"}
    {exp:channel:category_heading}

        <h2>{category_name}</h2>

    {/exp:channel:category_heading}
{/exp:query}

```

Something like that should work if you didn't want to use Seg2Cat specifically. Just be sure to swap out `{segment_3}` with whatever segment variable contains your category URL title.
> 1 votes

---
Tags: channel-entries, categories, gwcode-categories, bestpractice
---


# Question
Title: Why are PHP and Stash variables not set as expected within EE conditionals?
I boiled my problem down to this template code on a template with "Allow PHP" set to "YES" and "PHP Parsing Stage" set to "Output":

```
{if 1 == 1}
  First block
  <?php echo '1 == 1 is true'; ?>
  <?php $test = 'hello'; ?>
{if:else}
  Second block
  <?php echo '1 == 1 is false'; ?>
  <?php $test = 'goodbye'; ?>
{/if}
<?php echo $test; ?>

```

The output is:

> First block
> 1 == 1 is true
> goodbye

But I would expect the output to be:

> First block
> 1 == 1 is true
> hello

I don't understand how the `1 == 1 is true` line could get echoed while the variable `$test` gets set to "goodbye". It seems like my PHP variable assignments statements all get executed whether or not the conditional block they are in should get executed or not.

## Update

This is apparently still a problem even when I eliminate the PHP from the template:

```
{if 1 == 1}
  1 == 1 is true
  {exp:stash:set name="test"}hello{/exp:stash:set}
{if:else}
  1 == 1 is false
  {exp:stash:set name="test"}goodbye{/exp:stash:set}
{/if}
{exp:stash:test}

```

The output is:

> 1 == 1 is true
> goodbye

# Answer
> 3 votes
That's Parse Order. Advanced conditionals, like the one in your example, are parsed **after** PHP is parsed. In fact, it doesn't even matter if PHP is set on Output or Input. So, think of this step by step. First, your PHP is executed, echoing both `1 == 1 is true` *and* `1 == 1 is false`. And the var `$test` is first set to `hello`, then to `goodbye`, after which the latter is echoed out.

Then the advanced conditional is parsed, hiding the first block. But the setting and echoing of `$test` has already been done, hence `goodbye` remains as is.

'Tis the nature of EE's Parse Order Beast.

# Answer
> 1 votes
Following on from @Low's answer and your comment, it doesn't mean that you can't still use PHP successfully in templates. You just need to be mindful of the parse order when mixing PHP with EE tags.

For instance in your example if you used PHP for the full if statement then it would work as it would all be parsed at the same time from top to bottom.

Alternatively use something like Stash to set variables and then call them later in your template in among regular EE tags. You'll then be on par with the parse order again.

You can see a couple of examples of mixing PHP with EE tags on both input and output here.

As a good rule of thumb though try to keep PHP use in your templates down as much as possible for security...and sanity in regards to parse order. ;)

# Answer
> 1 votes
You can easily resolve parse issues like these with Switchee or Ifelse. These addons will completely remove any non-matching conditions before they are parsed. Here's how you'd fix the code sample from your post:

```
{exp:ifelse parse="inward"}
    {if 1 == 1}
        1 == 1 is true
        {exp:stash:set name="test"}hello{/exp:stash:set}
    {if:else}
        1 == 1 is false
        {exp:stash:set name="test"}goodbye{/exp:stash:set}
    {/if}
    {exp:stash:test}
{/exp:ifelse}

```

This template will output `1 == 1 is true hello` as expected.

The `parse="inward"` parameter is key - it tells EE to parse the outer tag (the IfElse plugin) before processing the inner ones (the stash:set calls). See the EE docs for further info.

---
Tags: stash, conditionals, php, variable
---


# Question
Title: Embedded variables conditional - Assets 2 Issue or parse order?
I am having an issue with an embedded template. I embed the template passing a "type" variable. Then, in the embed file it displays the content based on which "type" was specified. This all works, but either the parse order or Assets is causing hundreds of extra assets sql queries and ignores **simple** "type" conditional. It looks like EE parse order states that embedded variables are parsed early, so I am not sure why I am getting output from within other conditionals? If I comment out my Assets 2 code it cuts out most (if not all) the extraneous requests. (from ~500 to a normal 100ish at the moment).

Below is the embedded template. If I uncomment the cottage\_photos fields my display is correct but they ALL get parsed across the board regardless of "type" conditional or Assets 2 limit param. I am new to Stack Exchange, so sorry if the code formatting is incorrect.

*UPDATE* As I keep testing, I really think its Assets and not parse order. When I comment out all the custom assets fields (cottage\_photos below) all the issues are resolved. So, the question is why are the assets fields ignoring parse order and limit param?

```
{!-- GRID VIEW -----------------------------------------------------------------}
{if "{embed:type}" == "grid"}

{exp:channel:entries channel="cottage-rentals"
    dynamic="no"
    status="open"
    paginate="bottom"
    limit="12"
    orderby="title"
    sort="asc"
    disable="categories|member_data"
    }

    {sn_pagination}

    {if count == 1}
        <ul id="cottage-grid" class="large-block-grid-4 small-block-grid-1">
    {/if}

    <li>
        <div class="cottage">
            <a href="{path='/accommodations/cottage-rentals/cottage'}/{entry_id}" class="leadin" title="Click here to view {title}">
                {!--exp:ce_img:single src="{cottage_photos limit="1"}{url}{/cottage_photos}" crop="yes" width="225" height="200" allow_scale_larger="yes"--}
                <strong class="title">{title}</strong>
            </a>
            <a href="#" title="Check availability (popup)"><i class="icon-calendar"></i> Check Availability</a><br>
            <a href="{path='/accommodations/cottage-rentals/cottage'}/{entry_id}" title="View details for rental {title}"><i class="icon-zoom-in"></i> View Details</a><br>
            <i class="icon-user"></i> {cottage_capacity}<br>
            <i class="icon-home"></i> {cottage_bedroom_count}<br>
        </div>
    </li>

    {if count == total_results}</ul>{/if}

{/exp:channel:entries}

{/if}

{!-- LIST VIEW -----------------------------------------------------------------}
{if "{embed:type}" == "list"}
{exp:channel:entries channel="cottage-rentals"
    dynamic="no"
    status="open"
    paginate="bottom"
    limit="25"
    orderby="title"
    sort="asc"
    disable="categories|member_data"
    }
    {sn_pagination}

    {if count == 1}
        <!-- Sortable table props: see http://www.datatables.net/ -->
        <table cellpadding="0" cellspacing="0" id="cottage-list-view">
            <thead>
                <tr>
                    <th>Gallery</th>
                    <th>Title</th>
                    <th>Capacity</th>
                    <th>Bedrooms</th>
                    <th>Preview</th>
                    <th>Details</th>
                </tr>
            </thead>
            <tbody>
    {/if}

    <tr>
        <td>
            {!--cottage_photos limit="1"}
                <a href="{url}" data-rel="{entry_id}" class="preview-modal">{exp:ce_img:single src="{url}" crop="yes" width="70" height="50" allow_scale_larger="yes" class="th"}</a>
            {/cottage_photos--}
        </td>
        <td><a href="{path='accommodations/cottage-rentals/cottage'}/{entry_id}"><strong>{title}</strong></a></td>
        <td>{cottage_capacity}</td>
        <td>{cottage_bedroom_count}</td>
        <td><a href="#" data-rel="{entry_id}" class="button preview-modal"><i class="icon-info-sign icon-large"></i>  Preview</a></td>
        <td><a href="{path='accommodations/cottage-rentals/cottage'}/{entry_id}" class="button"><i class="icon-zoom-in icon-large"></i>  View Details</a></td>
    </tr>

    {if count == total_results}</tbody></table>{/if}

{/exp:channel:entries}
{/if}

{!-- COTTAGE DETAIL VIEW ---------------------------------------------------------}
{if "{embed:type}" == "detail"}

{exp:channel:entries channel="cottage-rentals"
    dynamic="no"
    status="open"
    paginate="bottom"
    limit="1"
    orderby="title"
    sort="asc"
    disable="categories|member_data|pagination"
    {if embed:cottage_id}entry_id="{embed:cottage_id}" {/if}
    }

    <p><a href="{path='accommodations/cottage-rentals'}"><i class="icon-chevron-left icon-small"></i> more cottage rentals</a></p>
    <div class="row">

        <div class="large-4 columns">
            {!-- PHOTO GALLERY --}
            <div id="cottage-photos">
                {!--cottage_photos limit="21"}
                    {if count == '1'}
                        <a href="{url}" rel="group1" title="{desc}"><img src="{url}" width="100%" alt="{desc}" /></a>
                        <ul class="small-block-grid-4 large-block-grid-4">
                    {/if}

                    {if count > '1'}
                        <li>
                            <a href="{url}" rel="group1" class="cottage-thumb" title="{desc}">
                                {exp:ce_img:single src="{url}" crop="yes" width="160" height="122" allow_scale_larger="yes"}
                            </a>
                        </li>
                        {if count == total_results}
                            </ul>
                        {/if}

                    {/if}
                {/cottage_photos--}
            </div>
        </div>

        <div class="large-8 columns">

            <div class="row">
                <div class="large-7 columns">
                    <h3>{title}</h3>
                    {cottage_description}
                    <h4 class="orange">Features</h4>
                    {cottage_features}
                    <h4 class="orange">Rooms Description</h4>
                    {cottage_rooms_description}
                </div>

                <div class="large-5 columns">
                    <div class="cottage-info-box">
                        <p><strong>Bedrooms:</strong> {cottage_bedroom_count}<br />
                        <strong>Capacity:</strong> {cottage_capacity}</p>
                    </div>
                    <h4 class="orange">Rental Rates</h4>
                    {cottage_rental_rates}
                </div>
            </div>

            {!-- MAP --}
            {if cottage_display_map == "Yes"}
                {if cottage_map_geocoded != ""}
                    <div style="clear:both; padding-top:10px;">
                        <h4>Location</h4>
                        {exp:gmap:init id="map" scrollwheel="false" style="width:100%;height:265px" latitude="{cottage_map_latitude}" longitude="{cottage_map_longitude}" map_type="google.maps.MapTypeId.ROADMAP"}
                        {exp:gmap:marker id="map" latitude="{cottage_map_latitude}" longitude="{cottage_map_longitude}" zoom="{cottage_map_zoom}" geocode="false"}{/exp:gmap:marker}
                    </div>
                {/if}
            {/if}

            {!-- AVAILABILITY --}
            {if cottage_rms_id != ""}
                <div style="clear:both; padding-top:28px;">
                    <h4>Availability</h4>
                    <div id="cottage-availability">
                        <iframe scrolling="no" src="http://rms5.resortplanet.com/1459/calendar.php?unit={cottage_rms_id}" style="border-style:hidden; width:100%; height:770px;"></iframe>
                    </div>
                </div>
            {/if}

        </div>
    </div>

    {if no_results}
        <h3>Lakeside Chautauqua Cottage Listings</h3>
        <p>Requested Cottage is no longer available or could not be found. Click here to return to <a href='{path="accommodations/cottage-rentals"}'>cottage rentals</a>
    {/if}
{/exp:channel:entries}

{/if}

```

# Answer
Two things: you're quoting your embed variables in your conditionals, which actually makes them advanced conditionals. So first, instead of this:

```
{if "{embed:type}" == "list"}

```

Try this:

```
{if embed:type == "list"}

```

But second, and more importantly - just use Switchee. It is great at avoiding these parse order/performance issues.

```
{exp:switchee variable="{embed:type}" parse="inward"} {!-- < added end quote --}
    {case value="grid"}
        .. do your loop
    {/case}
    {case value="list"}
        .. do your loop
    {/case}
{/exp:switchee}

```
> 2 votes

---
Tags: conditionals, parse-order, assets
---


title: Show total channel entries with matrix

text:
# Question
Title: Show total channel entries with matrix
I am looking to show the total number of channel entries which do not have and empty matrix field.

For example I have entries which have a matrix field with customer information. I would like, if possible, to show all the channel entries which have no customer information added.

Any advice appreciated.

Thanks Ben

# Answer
One way is to use the **search:field\_name** parameter on your Channel Entries tag. You can use it like...

```
search:your_matrix_field="not IS_EMPTY"

```

...and it will only return entries that actually have content in your Matrix field.

---

Alternatively, Adrian Macneil just released a nifty plugin called **Channel Query** that is perfect for this. It works just like the Channel Entries tag but allows you to specify a custom query to get just the entry\_ids you need. So in this case you'd select entries where your Matrix field is not empty.

This will loop over all the entries that have Matrix data:

```
{exp:channel_query sql="SELECT entry_id FROM exp_channel_data WHERE field_id_22 != '' AND channel_id = '12'"}
    {title}<br>
{/exp:channel_query}

```

Substitute the field\_id for your Matrix field's id and channel\_id for your particular Channel.

---

**If instead you want only the total results** you can just use the Query module:

```
{exp:query sql=
    "SELECT COUNT(exp_channel_data.entry_id) AS total
    FROM exp_channel_data
    JOIN exp_channel_titles
    ON exp_channel_titles.entry_id = exp_channel_data.entry_id
    WHERE field_id_22 != ''
    AND status = 'open'
    AND exp_channel_data.channel_id = '12'"
}
    {total}
{/exp:query}

```

For either of these queries you can change to showing/counting only entries that *do not* have any Matrix data by altering the `field_id_X != ''` to `field_id_X = ''`
> 3 votes

---
Tags: matrix
---


# Question
Title: Getting a custom fieldtype working in Matrix
I've recently updated EE to 2.5.5 and Matrix to 2.5.3, but now one of out in-house addons is broken. The addon is a custom fieldtype designed to be included in a Matrix field, but this now causes the publish page to turn blank. This is the only scenario in which this occurs; Matrix plays nicely with everything else, and our addon doesn't break anything when not included in a Matrix field.

I've tested this with a locally hosted version of EE 2.5.3, and got a PHP error rather than a blank page:

A PHP Error was encountered

Severity: Notice

Message: Undefined property: Content\_publish::$tools\_model

Filename: custom\_fieldtype/ft.custom\_fieldtype.php

Line Number: 271

Fatal error: Call to a member function get\_upload\_preferences() on a non-object in C:\Program Files\EasyPHP-12.1\www\EE\system\expressionengine\third\_party\custom\_fieldtype\ft.custom\_fieldtype.php on line 271

Anyone know what's going on here?

# Answer
> 1 votes
It seems that Tool Model isn't being loaded before calling its property. Try by putting this line of code above the line number 271:

```
$this->EE->load->model('tools_model');

```

---
Tags: matrix
---


# Question
Title: Nested conditional is not displaying content
I have a .sidebar template which is in a template shared by a few inner pages of the site. It pulls in the channel based on a preload tag on the page it is embedded in.

I have a conditional set to display certain content based on what page it's on, however no content is being displayed.

Here is the full sidebar code I have right now:

```
<aside>
<h2 class="sidebar-title"><a class="up" href="#">About</a></h2>
<div class="expand">
    {exp:channel:entries channel="{embed:chan}" limit="1" category="{embed:cat}"}
    {if sidebar_title != "" AND sidebar_description != ""}
    <section class="sidebar-description">
        <h2>{sidebar_title}</h2>
        <p>{sidebar_description}</p>
    </section>
    <hr />
    {/if}
    {embed="_includes/.sidebar-posts"}
    <hr />
    <section>
        {if segment_1 == "blog"}
        <h2>Follow me</h2>
        <p>{follow_me_blurb}</p>
        <ul>
            <li><p><a href="#">Facebook</a></p></li>
                            <li><p><a href="#">Instagram</a></p></li>
                            <li><p><a href="#">Twitter</a></p></li>
                            <li><p><a href="#">Pinterest</a></p></li>
        </ul>
        {/if}
        {if segment_1 != "blog"}
            {if bring_content != ""}
            <h2>Bring</h2>
            <p>{bring_content}</p>
            {/if}
            {if tip_content != ""}
            <h2>Tips</h2>
            <p>{tip_content}</p>
            {/if}
        {/if}
    </section>
    <section class="sidebar-links">
        <a href="#" class="small"><strong>Blog</strong></a>
        <a href="#" class="large">Shop »</a>
        <a href="#" class="large">« Discover</a>
        <a href="#" class="small"><strong>Follow</strong></a>
    </section>
    {/exp:channel:entries}
</div>

```

On my main page, I embed the sidebar, and set preload at the top of my template:

```
{preload_replace:chan="inner_page_details"}
{preload_replace:cat="7"}

```

\_edit: I discovered this issue happened because it wasn't reading the channel preload\_replace included in the main templates. I had to hard-code the channel in, but am unable to discover a solution for the categories\_

# Answer
> 0 votes
Apparently it wasn't completely an issue with the nested conditional. After tweaking that I was able to display plain html inside it. The issue was that the {preload\_replace} for my channel in the main templates wasn't being used to replace the channel in my sidebar template. I had to hardcode the channel name into the sidebar. I will have to find some solution to get the category {preload\_replace} to work as well.

I am marking this topic answered, since the title no longer applies to this issue. Thanks for the help guys!

# Answer
> 1 votes
I'm assuming that when you say sections other than `/blog` are not displaying content that you also mean that sections which are `/blog` ***are*** displaying content(?).

If this is the case then it may very well be the `{if:else}` causing the problem so try this:

```
{if segment_1 == "blog"}
    ...
{/if}

{if segment_1 != "blog"}
    NOT blog section
    other nested conditionals here
{/if}

```

Let me know if that helps in getting something to display for sections other than `/blog/`.

# Answer
> 0 votes
Looking at the documentation:

http://ellislab.com/expressionengine/user-guide/templates/globals/conditionals.html

The first user comment mentions enclosing your variables in quotes, so maybe you should try:

```
{if "{bring_content}" != ""}
   <h2>Bring</h2>
   <p>{bring_content}</p>
{/if}
{if "{tip_content}" != ""}
   <h2>Tips</h2>
   <p>{tip_content}</p>
{/if}

```

Conditionals can be fickle sometimes. The third comment in the documentation mentions that by adding the quotes around your tags, it parses it as an advanced conditional vs a simple conditional.

---
Tags: conditionals, fields, nesting
---


# Question
Title: Pull all {alternate_titles} fields for navigation menu, even if page is limit=1
I'm using a sidebar navigation, that is embedded on an intro page and subsequent single article pages. This is my embedded navigation:

```
<ul>
<li><a href="{path='spice_2011/kiritimati'}" class="active_left">Kiritimati</a></li>
{exp:channel:entries channel="spice_kiritimati" category="not 268" disable="member_data|pagination" sort="desc" orderby="date"}
<li><a href="{url_title_path='spice_2011/kiritimati_atlas'}" {alternate_title}</a></li>
{/exp:channel:entries}
</ul>

```

This is how the content is displayed on the intro page:

```
{exp:channel:entries channel="spice_kiritimati" category="268" disable="member_data|pagination" sort="desc" orderby="date"  }

```

All the titles of the articles show up in my embedded navigation on the intro page. Using the same embedded navigation, when I show pages that are limited to one article, using this code:

```
{exp:channel:entries channel="spice_kiritimati" disable="member_data|pagination" sort="desc" orderby="date" limit="1"  }

```

Only the one title, of the page you are on, shows up in the embedded navigation. Is there another way to handle how the embedded navigation is built, so that its not limited to the one article title, but shows all article titles, as on the intro page? I tried changing the limit=10 in the embedded navigation code, that didn't work. Neither did showing related categories, both tries were stabs in the dark.

I'm guessing I need to somehow grab all alternate titles in a channel, but can't figure out how to do it.

# Answer
> 1 votes
You need to add `dynamic="no"` to the `{exp:channel:entries}` tag.

By default, it is dynamic, meaning it will look at the URL for information about which channel entry to show.

If you turn dynamic off, it will just do what you tell it in the parameters.

---
Tags: ee2, channel-entries, categories, navigation
---


title: Redirect to outside server

text:
# Question
Title: Redirect to outside server
I am trying to redirect a template to an outside website in EE2, I have tried this:

```
    {redirect='http://other_website.com/whatever/12/'}

```

It puts the url of the host before the url I put there because it's expecting a template.

```
    http://myhost.com/http://other_website.com/whatever/12/

```

Is there any way to redirect it properly?

Thanks!

PS: In EE1, I have used:

```
    {exp:redirect_to location="http://www.yahoo.com"}

```

but it's not working now.

# Answer
> 1 votes
You might use RedirectURL EE2 Plugin for redirection in EE2.

# Answer
> 0 votes
You can use http://devot-ee.com/add-ons/redirectee This plugin will use the `header()` function from PHP

---
Tags: redirects
---


# Question
Title: Matrix, plus symbol in text input breaking in simple if conditional
I seem to be getting the same error as in this post, but in my case the problematic part of my condition is a plus symbol, which is pretty absurd!

```
{if '{caption}' != ''}data-caption="#caption-{row_id}"{/if}

```

In this case, if the caption includes a plus, it will result in:

```
Parse error: syntax error, unexpected T_STRING in /Users/danielhowells/Sites/Calvert/www.calvertadmin.com/web/content/expressionengine/libraries/Functions.php(683) : eval()'d code on line 28

```

It's a bit embarrassing explaining to my client that they can't use + in their captions. :-)

# Answer
> 1 votes
You could try low replace on the tag and turn the + into a word:

```
{if '{exp:low_replace find="+" replace="plus"}{caption}{/exp:low_replace}' != ''}

```

---
Tags: matrix
---


# Question
Title: Is it correct to put "{site_url}" inside a global variable?
As the title says, is it correct? Thanks

# Answer
> 3 votes
Global variables declared in Design \> Templates \> Global Variables cannot contain EE tags, PHP, or other variables inside them.

> User-defined global variables are not run through the template engine, so you cannot place EE Tags, PHP, or variables inside them.

If you need to place EE tags inside re-usable bits of code then you'll need to use Snippets: Design \> Templates \> Snippets. They're parsed at a very early stage of template rendering so can contain dynamic variables.

---
Tags: global-variables
---


title: wygwam upload assets set keyword

text:
# Question
Title: wygwam upload assets set keyword
Izzit possible to input keyword right on the wygwam uploader. Now when I right click it only show "view file" I wish there is a way that I can have "edit" so our editor can input some keywords for that particular image they upload for their article.

# Answer
Kevin - I am sorry that I missed this! Unfortunately this is not currently possible, you'd need to edit the Metadata from an Assets field or the Assets CP.
> 0 votes

---
Tags: assets, wygwam
---


# Question
Title: Wanting to return individual variables for different "types" in the Google Map json object
Using the GMaps geocoder field and using the parse parameter on the template to return the data stored in it.

Is there a way to access just each address componoent individually? For instance, I want to return the zipcode only.

`{types}` does not appear to be a loop. I also tried `{types:var}` and no dice.

https://objectivehtml.com/google-maps/fieldtype#parse

This is what the JSON object looks like from Google Maps API: https://developers.google.com/maps/documentation/geocoding/#JSON

```
{retailers_geolocation parse="markers"}

    {markers}

        {marker:address_components}

            {short_name}

        {/marker:address_components}

    {/markers}

{/retailers_geolocation}

```

# Answer
This is coming in 3.3, but it's not 100% ready for release. The main issue is that each locality has different address components and meanings. So my current example is US based (because that's where I am).

The API will look something like:

```
{your_field:address_component type="zipcode"}
{your_field:address_component type="city"}
{your_field:address_component type="address"}
{your_field:address_component type="state"}

```

There are config variables so you can define your own locality, but of course there are no docs for this yet and has not been very well tested (outside of me). There is no ETA on this, but I know 3.3 will not be in the next several weeks or month. It's several months out. I you want the beta preview to use without docs I am happy to send it to you. Email support@objectivehtml.com
> 2 votes

---
Tags: add-on, google-maps-for-ee
---


# Question
Title: Playa "no entries for this related channel"
I'm using a Playa field within Matrix to specify related entries, in EE 2.5.5

If I set the "Channels" selection to -Any- everything works as expected and the entries to select from are displayed when you go to edit a content item.

If I change the "Channels" selection to any specific Channel, it displays "No entries for this related channel" when there are Open entries.

The themes folder URL is given with the full URL, and I have tried disabling the .htaccess as suggested at http://pixelandtonic.com/playa/docs/troubleshooting

# Answer
> 1 votes
what Playa version is this? 4.4 release introduced some bugs which will be fixed in a 4.4.1 release probably today, so this might be that.

---
Tags: playa
---


# Question
Title: Expresso Store - How to use the checkout tag without any items in the cart?
I would like to use the {exp:store:checkout} tag to amend a members details such as order\_email, shipping\_country etc on an account page. Members fields are all setup being mapped to the correct place.

However, when viewing the account page (using the checkout tag) it will only show the member fields for editing when there is something in the shopping cart. I want to be able to show these details when there is nothing in the cart.

It must be possible, any ideas please?

Thanks.

# Answer
You cannot use the Store checkout tag to alter member profile fields. For that, you should use Freemember or another member management plugin.

The checkout tag will automatically load any mapped member fields, and save them when the customer submits an order, but you cannot use it to update member fields without placing an order.
> 1 votes

# Answer
Store doesn't deal with member details outside of the checkout. For that you'd need to use the default Member module with custom profile fields or take advantage of Freemember (also made by Exp:resso so the integration should be good). FreeMember mainly just provides an easier way to deal with member profiles by releasing them from the shackles of default Member Profile Templates.

Going one better a specialist member addon such as Zoo Visitor or Profile:Edit can be very useful if you really want to take control of Members and profiles in more detail, bringing those entries into regular Channels. Zoo Visitor may have a little better integration with Store and I've successfully used it in combination with Store to profile a member management in the past.

The good thing is that there is a tight integration between Store and Zoo Visitor so you can register new members in the checkout and have them added to your Members Channel. The other big bonus is that it brings member management into regular EE channels so you can work with regular templates and template tags.
> 2 votes

---
Tags: expresso-store, checkout
---


# Question
Title: Three different statuses - sort each status differently
I have a three different statuses displaying within one main channel entries wrapper. I would like the first status to be ordered randomly, and the other two statuses will be sorted alphabetically by title. The code below obviously does not work, but it conveys what we are looking for. Can anyone help with this?

```
{exp:channel:entries status="1|2|3" channel="listing" limit="15"}
{if status == "1" orderby="random"}
   Entries here
{if:elseif status == "2" orderby="title" sort="asc"}
   Entries here
{if:else orderby="title" sort="asc"}
   Entries here
{/exp:channel:entries}

```

# Answer
> 2 votes
If you don't mind using Stash, you could achieve it that way.

The idea is that you output all the channel entries once, and not worry about the order.
You 'stash' the appropriate fields inside a list, where you will retrieve it later.

```
{exp:stash:set_list name="my_listing" parse_tags="yes"}
  {exp:channel:entries status="1|2|3" ...}
    {stash:the_title}{title}{/stash:the_title}
    {stash:the_status}{status}{/stash:the_status}
  {/exp:channel:entries}
{/exp:stash:set_list}

```

Then later in your template, you would retrieve them in the appropriate order.

```
<ul>

{exp:stash:get_list name="my_listing" match="#1#" against="the_status" orderby="random"}
  <li>{title}</li>
{/exp:stash:get_list}

{exp:stash:get_list name="my_listing" match="#2#" against="the_status" orderby="the_title" sort="asc"}
  <li>{title}</li>
{/exp:stash:get_list}

{exp:stash:get_list name="my_listing" match="#3#" against="the_status" orderby="the_title" sort="asc"}
  <li>{title}</li>
{/exp:stash:get_list}

</ul>

```

The `match` and `against` parameters allow you to retrieve a filtered version of your listing. (`match` is a regular expression)

(I've prepended the stash variables with `the_` so you don't confuse them with the channel entries variables. They could be whatever you want.)

# Answer
> 2 votes
You could use Stash by Mark Croxton to accomplish that without multiple channel entries loops. Here is the kind of code I would use with the dev branch of Stash.

```
{exp:stash:set_list name="mylistname" parse_tags="yes"}
    {exp:channel:entries status="1|2|3" channel="listing" orderby="random" dynamic="no" limit="15"}
        {stash:st_title}{title}{/stash:st_title}
        {stash:st_status}{status}{/stash:st_status}
    {/exp:channel:entries}
{/exp:stash:set_list}

{!-- get status 1 entries randomly ordered --}
{exp:stash:get_list name="mylistname" match="#^1$#" against="st_status"}
    {st_title}
{/exp:stash:get_list}

{!-- get status 2 entries ordered by title asc --}
{exp:stash:get_list name="mylistname" match="#^2$#" against="st_status" orderby="st_title" sort="asc"}
    {st_title}
{/exp:stash:get_list}

{!-- get status 3 entries ordered by title asc --}
{exp:stash:get_list name="mylistname" match="#^3$#" against="st_status" orderby="st_title" sort="asc"}
    {st_title}
{/exp:stash:get_list}

```

That way you just use one channel entries loop to get all your entries in random order and build a stash list, then use multiple stash get\_list to filter and order that list the way you want.

Hope it helps

**EDIT see comment below.**

You want a paginated list of all your 10000 entries, ordered by status (all entries from status one, then all from status 2, etc.) ... but you also want the entries from status 1 to be ordered randomly and the other two ordered by title.

*(partial) solution 1: native tags*

You can orderby status and then by title using native tags.

```
{exp:channel:entries status="1|2|3" channel="listing" orderby="status|title" sort="asc|asc" dynamic="no" limit="15"}
    {title}
{/exp:channel:entries}

```

The remaining problem is ordering the status 1 entries randomly.

*Solution 2: custom plugin*

You could also look at extending the channel:entries module. Here is an article detailing the process. Obviously you will need to adapt it to your needs.

---
Tags: status, orderby, sort
---


# Question
Title: Freemember update_profile with member photo?
I'm using freemember to update a member's profile, which is working great. However I now need to add member photo into the mix but I cannot figure out how to get this to work in that photos are not being uploaded. Are the any examples of an update form with member photo?

# Answer
> 1 votes
Member profile pictures and avatars are not supported yet officially by Freemember, but there is an open pull request which adds support for this and needs some beta testers.

You can grab a copy of Freemember with upload support directly here, and add any feedback or comments to the GitHub pull request.

I'll update this answer once this feature is released officially.

---
Tags: freemember
---


# Question
Title: returnURL is invalid expresso:store paypal_express
I am having a problem but with express:store on expressionengine and paypal\_express. I have inputed all the details but I was receiving a 'Security header is not valid" I deleted the payment method and re-created it but I am now getting another error 'returnURL is invalid' I have remove the .htaccess thinking this may interfere with it but I am at the end of my teather here. Any help or advice would be greatly appreciated.

# Answer
When you see the PayPal error:

> Security header is not valid

This generally means you have PayPal set to "Test Mode", but you are using a live account, or vice versa. PayPal test mode is only for when you have a PayPal developer account (which is a completely separate login/password, you cannot use it with a regular account).
> 1 votes

---
Tags: expresso-store
---


title: sort="asc" Breaks "count" Conditional

text:
# Question
Title: sort="asc" Breaks "count" Conditional
This is super weird. I have this channel entries loop:

```
{exp:channel:entries
  channel='resources_webinars'
  dynamic='no'
  limit='5'
  disable='categores|member_data|pagination'
  orderby='webinars_date'
  sort='asc'
  search:webinars_featured='=not_featured'
}
  {if webinars_date > current_time}

    {if count == 1}
      <div class="heading clearfix">
        <h3>Upcoming Webinars</h3>
      </div><!--/.heading-->

      <ul class="items webinars resetlist">
    {/if}

    <li class="clearfix">
      <article>
        <a href="{webinars_registration}" class="preview">
          <figure>
            {exp:ce_img:single
              src='{webinars_thumb}'
              width='210'
              height='100'
              crop='yes'
              allow_scale_larger='yes'
              alt='{title} preview'
            }
          </figure>
        </a>
        <div class="text clearfix">
          <header>
            <h4><a href="{webinars_registration}">{title}</a></h4>
            <p class="sml"><strong>{webinars_date format='%F %j, %Y'}</strong> / {webinars_date format='%g:%i%A'}</p>
          </header>
          <p>{webinars_summary}</p>
          <footer>
            <a href="{webinars_registration}" class="btn-ui action">Register</a>
          </footer>
        </div><!--/.text-->
      </article>
    </li>

    {if count == total_results}
      </ul>

      {if count == 5}
        <p class="learn-more clearfix"><a href="{path='resources/webinars/upcoming'}">View All Upcoming Webinars »</a></p>
      {/if}
    {/if}
  {/if}
{/exp:channel:entries}

```

It basically shows all non-featured upcoming webinars, sorted by a custom date field. What's weird is that adding `sort="asc"` causes the `{if count}` conditionals at the top and bottom not to work, so the opening and closing `<ul>` tags aren't output.

What's even weirder is that if I put `sort="desc"`, everything works fine.

Anybody ever seen anything like this before?

EE 2.5.5

# Answer
Count is an absolute entry count, so your earlier conditional of {if webinars\_date \> current\_time} may be returning entries that the loop considers "1" but your conditional, run AFTER the returned counted entries, excludes it. In order to use count, you'd need to narrow the entries loop with a query or a parameter to exclude entries that you don't want returned, or move the {if count == "1"} conditional outside of that wrapping conditional so it fires no matter what.
> 4 votes

# Answer
Are you sure it's not your {if webinars\_date \> current\_time} conditional that is skipping entries?
> 3 votes

---
Tags: channel-entries
---


title: Email not unique?

text:
# Question
Title: Email not unique?
Is there a way to remove the validation for unique email addresses.

I got a customer with a lot of members that must be imported into EE. But a lot of members doesn\`t have a email address and a lot of duplicated email addresses are present.

# Answer
> 1 votes
The simplest thing to do would be to create a fake email address for each member. The easiest way I can think of to do this would be via a small PHP script (might even be possible in Excel) that iterates a counter and inserts "user\*n\*@fakemail.com" into the relevant "slots" of your data source. Then import that into ExpressionEngine.

# Answer
> 0 votes
I don't think, EE provides such a feature as email is mandatory field for member registration but it can be achieved by hack into EE's library file .

If you look within /system/expressionengine/libraries/Validate.php around line number 365 there is a function validate\_email().

Within this function, you can comment the code which is checking for duplicate and empty email which are within the if conditions:

```
if ($this->email == '')
{
......
}

if ( ! valid_email($this->email))
{
.....
}

if ($type == 'new')
{
....
....
}

```

Its your preference if you would like to use hack because applying this hack duplicate and empty email will not be checked for all member registration process.

# Answer
> 0 votes
You could try importing members directly into your database. After fiddling around with Laisvunas' Social Sign On add-on it turns out that an e-mail being unique isn't really necessary. You'll have to keep *something* unique, however, at least their username. You'll also have to bear this stuff in mind in regards to how members might be logging in... this eliminates their email address as a means of logging in as it is no longer unique.

The tricky part with this is then updating other tables (see below) to match the member's new `member_id` (in other words you wouldn't be able to just do an import, it would have to be scripted in part at least).

A quick google for required fields/tables for importing members directly into your EE database (matches what I find in relative add-ons):

> I want to import my members. What is the minimum information that I need to populate in the database?
>
> * group\_id - the ID number for the member group this user belongs to
> * username
> * screen\_name - can be identical to the username
> * password - can be MD5 or SHA1
> * unique\_id - a random 32 character string, used for session cookies.
> * ip\_address
> * join\_date - Unix time stamp correlated to GMT time.
> * email
>
> There are two additional tables that must contain a row for each member, correlated with the member\_id of the member:
>
> * exp\_member\_data
> * exp\_member\_homepage

---
Tags: members, email, validation
---


# Question
Title: How can I add a Playa relationship via SafeCracker
I have the following scenario:

* 2 Channels: `events` and `users`
* `{user_id}` holds the `{entry_id}` to the currently logged in member since members are stored in a channel rather than using the native member module.
* In the event list, I have an "add to my events" safecracker form which should inject the currently logged in `{user_id}` into the Playa field (`cf_event_participants`) on the `events` entry currently being edited.

I can read and write to the correct entry and can set the definite playa selection using the hidden field method like so:

```
<input type="hidden" name="cf_event_participants[selections][]" value="{user_id}">

```

The problem I am having is that the above `cf_event_participants` field is a multi selection field and the effect of the above is that all existing relationships already stored in that field are cleared upon submitting the safecracker form and replaced only with the submitted logged in `{user_id}`.

Is there any way to just **add** a new relationship to the field without disturbing the existing ones already stored inside the `[selections]` array?

One more caveat: Because multiple users might be "saving" an event into their list simultaneously the following work around will *not* work as by the time the user submits this form, another user might have already added themselves into the `cf_event_participants[selections]` array.

```
// loop through existing values of the relationship field and store as hidden
// fields with the entry_id as value.
{cf_event_participants}
    <input type="hidden" name="cf_event_participants[selections][]" value="{entry_id}">
{/cf_event_participants}

// add new member
<input type="hidden" name="cf_event_participants[selections][]" value="{user_id}">

```

# Answer
(as requested by @GDMac - just copying my previous comments into a real answer here)...

Strangely enough I'm working on something very similar. This is not really a direct answer to your question, but I set this up using a combination of Matrix and ~~Playa~~ Matrix Relations: each event contains an attendee matrix, where the first column is a relationship to the users channel. In this way, each row represents a single attendee. I then have a simple custom add-on that adds/removes a matrix row when the logged-in member registers/de-registers for the event. (While an admin has full access to the matrix via safecracker).

---

I've tried to break out the relevant parts of my larger module here: gist.github.com/thisisjamessmith/9c01faeb65d11d641bb4 \- though if you're not familiar with php this could be a problem! Important points: This actually uses the Matrix Relations add-on instead of Playa: github.com/moresoda/ft.matrix\_relations.ee\_addon (this is a simpler way, since it just stores the related entry\_id). It also relies on the Profile:Edit add-on. Please get in touch if you need help with this.

Also, this gist requires you to supply the column id of your attendee field (to be found in exp\_matrix\_cols) and the field id of your attendee matrix (to be found in exp\_channel\_data).
> 2 votes

---
Tags: safecracker, playa, pixelandtonic
---


title: same category urls in category group

text:
# Question
Title: same category urls in category group
I need to create a categories with a parent/child structure as follows:

Category Parent 1

* Parks
* Accommodations
* Dining

Category Parent 2

* Parks
* Accommodations
* Dining

The child categories need to be the same for each parent but EE won't allow this.

Is there a way around this?

Thanks!

# Answer
> 1 votes
Since EE doesn't require the parent category to be in the URL in order to sort by category, your category URL titles can't be duplicates. The reason is, how would EE tell the difference between this URL for Category Parent 1:

`http://mysite.com/cities/category/parks`

And this URL for Category Parent 2:

`http://mysite.com/cities/category/parks`

As far as I'm aware, the only way to do this without hacking the core or using a custom field is to simply namespace each category:

* parent\_1
    + parent\_1\_parks
    + parent\_1\_accomodations
    + parent\_1\_dining
* parent\_2
    + parent\_2\_parks
    + parent\_2\_accomodations
    + parent\_2\_dining

Another option is to change how your categories are structured. So instead of duplicate categories, have separate category sub-groups:

* Cities

+ Portland
    + Seattle
* Features

+ Parks
    + Accomodations
    + Dining

Then the user picks the city, and the feature(s) to associate with the entry.

---
Tags: categories
---


# Question
Title: Is it possible to use EE, Structure and Playa to create multiple related listings and detail pages?
We have a single channel that holds all the information for one dataset, in our case, Producers.

We have multiple Event type channels, for each of the Events that our client holds every year.

We then add an entry which holds a relationship field to the Producer channel, so that we can show a list of Producers attending that particular Event.

This works fine, but can be labour intensive if for example 200 Producers attend an Event, as we would have to create 200 new entries in that particular Event type channel.

We thought Playa might make this a better admin process, as it allows you to multiple select relationships within one Playa field. Therefore, each Event type channel would have just one entry, that had a Playa field holding all the Producer relationships.

Trouble is, we can't get this to work with Structure, as Structure does not seem to recognise the individual relationships. The following code lists the Producers for an Event, but does not link through to the detail page as the {page\_uri} variable for each listing is empty (this is why we presume the relationship is not recognised):

```
{exp:structure:entries}

    {exp:playa:children field="producers" limit="5"}
        <p><a href="{page_uri}">{page_uri}</a></p>

    {/exp:playa:children}

{/exp:structure:entries}

```

Can Expression Engine, Structure and Playa work in this way, and if so, how do we correct the above template code?

# Answer
They can work happily together but it looks like you're confusing the benefits of Structure. Structure aims to provide the clients with more of a traditional page-based CMS structure presenting more of a one-to-one relationship with pages to URL's. In your case it sounds like you're working with '*Listings*' which are just Channel Entries so you don't really need to use Structure in your templates at all.

Secondly `{exp:structure:entries}` is not native to Structure. It looks like you're using the Structure Entries addon. Again, this isn't necessary from what you've described.

All you need to do use is the `{exp:channel:entries}` tag with a `{playa}` tags inside to output the relationships. So call out the entry based on the entry\_id and then output the Playa field of all the Producers who are attending the event. Something like:

```
{exp:channel:entries channel="events" dynamic="no"}

    {exp:playa:children field="producers" limit="5"}
        <p><a href="{page_uri}">{page_uri}</a></p>

    {/exp:playa:children}

{/exp:channel:entries}

```

Don't forget that if you're dealing with a Structure managed *Listing* then you'll need to add `dynamic="no"` to the Channel Entries tag.
> 1 votes

# Answer
For the votes up, the answer is not out of the box. Structure can only show a listing once. Use it on another Structure page and the detail page will go to the first page on which you used the listing.

That said, you can use Structure to serve a content page, select a template that shows the content on that page, and then also pulls in results from another channel. This approach only works by using Freebie to break your urls at a predetermined point. The listing view and the detail view are conditionally served in the template I mentioned, you test the URL using Freebie, if it has a segment after the specified break, you server a detail, if its empty, it's a listing.

Here's an example:

1. Set the Freebie break segments as 'producers' - freebie will look for this in urls, and will give you the functionality as specified on https://github.com/averyvery/Freebie.
2. Assign a Playa relationship field to the channel that serves the page one level higher than your producers listing page. In this example this is 'Festival One'. The playa field is called 'producers\_at\_festival'. This makes sense, as we are going to associate our producers that are appearing at Festival One here, in the landing page entry for that festival. We'll pull these relationships later, using the URL segment for this page.
3. Create a new Structure page called Producers (on the page tree list in Structure), and select the following template as the Structure Template (found in the Structure tab):

{if segment\_3 != "" AND freebie\_break\_1==""}

{exp:channel:entries channel="content\_page"}

# {title}

{content}

{/exp:channel:entries}

{exp:channel:entries channel="individual\_festival\_landing\_pages" dynamic="no" url\_title="{segment\_2}"}

{exp:playa:children field="producers\_at\_festival" disable="member\_data"}

### {title}

{/exp:playa:children}

{/exp:channel:entries}

{/if}

{if freebie\_4 !=""}

{exp:channel:entries channel="producers" dynamic="no" limit="1" url\_title="{freebie\_4}"}

{exp:channel:entries channel="producers"}

{exp:structure:breadcrumb inc\_home="no" inc\_separator="no" inc\_here="no" add\_last\_class="no"}

{if freebie\_break\_1}

Producers

{title}

{/if}

# {title}

{/exp:channel:entries}

{/if}

There's a few things to note, the above only works when the page is called Producers, you'll have to change that to whatever you need. Also, this is the third level down in the navigation, thats why we are checking {freebie\_3} for the listing, and {freebie\_4} for the detail, so my URL looks like:

Domain.com/festivals/festival-one/producers.

Also note that to show the detail page, we simply call the channel entry by using it's URL, this is the fourth URL segment , after 'producers'. We also use the second segment before 'producers' to pull our relationships.

Our page is in effect made up of:

Structure content page The page one level higher in the URL (that holds the producer relationships) The producer entry.

You can probably make this a bit more dynamic but hopefully it gives a good place to start in terms of logic.

IMPORTANT - there's code being stripped out above, here's an image of the Detail section of the code - Stackexchange - must do better :p
> 0 votes

---
Tags: playa, structure
---


title: Static Pages and Embed Tag

text:
# Question
Title: Static Pages and Embed Tag
I have come across this issue and I cannot figure out what I am doing wrong.

I have this code in an include file:

```
<!-- .site-title -->
          <hgroup>
          {exp:channel:entries channel="site_image" limit="1"}
            <h1 class="site-title"><a href="{site_url}" title="title here" rel="home"><img src="{site_image}" alt="{title}"></a></h1>
            {/exp:channel:entries}
            {if segment_1 == ""}{site_intro}{/if}
          </hgroup>
          <!-- .site-title -->

```

This all seems fine and works on all the pages of the site it is embedded into, except static pages created with the 'Pages Module'. On those pages I get this output from the browser:

```
<!-- .site-title -->
          <hgroup>

          </hgroup>
          <!-- .site-title -->

```

Nothing at all appears between the tag pair. Any help would be greatly appreciated.

# Answer
> 1 votes
Sounds like a classic dynamic="no" situation. Add this to your exp:channel:entries tag:

```
{exp:channel:entries channel="site_image" limit="1" dynamic="no"}

```

---
Tags: pages
---


# Question
Title: Require account activation with Cartthrob and Profile:edit issue
I have an EE 2.5.5 site. Using Cartthrob 2.2.9 with Profile:edit 1.0.9 as well.

During checkout I've set the `create_user="yes"` param which does in fact create a member upon checkout completion.

I have CT setup under the Members tab to use Profile:edit.

I receive an email asking to click a link to activate said account. This email is based on a message template "Member Account Activation Instructions" in EE itself which uses `{unwrap}{activation_url}{/unwrap}` to create the actual link

The link looks like: `http://mysite.com/?ACT=14&id=3YI1MYDJtG`

When I click this link I get an error as follows:

> Error Invalid activation request.

Note: I'm using custom system messages

In profile:edit I set "Require Member Account Activation?" to be "Self-activation via email".

There is this setting in Cartthrob under the Member tab:

I have this set to Auto Login so it pulls the data from the checkout form to the member creation fields (and then on to to P:E or vice versa I presume.)

Questions:

* Does Cartthrob automatically activate the user upon checkout with the above setting? And if so why is there an email still being sent out for activation? Would that be the cause of the error then? Is this a bug on the part of CT, P:E or EE maybe?
* Is there a setting which I'm missing in EE, CT, P:E or combination there of which I need to set to get the activation working properly?

Thanks!

# Answer
You'd want to use the cartthrob\_pre\_process hook. Your extension would look something like this:

```
public function cartthrob_pre_process()
{
  if ($this->EE->input->post('create_user') === 'yes')
  {
    $this->EE->config->set_item('req_mbr_activation', 'none');
  }
}

```
> 1 votes

---
Tags: ee2, cartthrob, profile-edit, activation
---


# Question
Title: Restrict Assets directory access per-user in Safecracker
Taking a look at Assets 2.0 docs I can see that with the {exp:assets:folders} tag we can determine the folder where the photos are uploaded in a simple file uploading field, my question is if the same can be done with the regular assets field, so that when the users click on the button to add files they can see only the pre-determined folder and its subfolders? If this is possible then what is the code? I've only used a simple {field:field\_name} to load Assets inside Safecracker so I'm not familiar with more complex solutions.

Thank you!

# Answer
> 1 votes
If you look at the field settings for your Assets field, you should see the option to restrict the available upload directories there.

# Answer
> 1 votes
I've got a deeper implementation of this, however as a basis you can hack Assets 2.1 to only show files uploaded by the logged in member when working with standard EE file sources.

First, add a 'member\_id' column to the assets\_files table:

```
ALTER TABLE  `exp_assets_files` ADD  `member_id` INT( 10 ) UNSIGNED NULL

```

Modify assets/sources/base\_source.php (line 605) to add the member\_id to the db table:

```
'file_name' => $filename,
'member_id' => $this->EE->session->userdata('member_id'), // Add 'member_id' to database
'kind' => Assets_helper::get_kind($filename)

```

Finally, modify assets/libraries/assets\_lib.php (line 712) to limit the display of files to the currently logged in member only:

Change this existing line:

```
$this->EE->db->where_in('exp_assets_files.folder_id', $full_folder_list);

```

To this:

```
$this->EE->db->where_in('exp_assets_files.folder_id', $full_folder_list)->where('member_id', $this->EE->session->userdata('member_id'));

```

---
Tags: safecracker, assets
---


# Question
Title: SafeCracker + Assets: Restrict file browser to display logged-in member's files only.
Is there a way to configure the Assets file browser in a SafeCracker form to only show assets for the currently logged-in member?

# Answer
> 2 votes
Assets 2.1 is easily hackable, here's what you can do to restrict the file browser to the currently logged-in member's (standard ExpressionEngine) assets only:

First, add a 'member\_id' column to the assets\_files table:

```
ALTER TABLE  `exp_assets_files` ADD  `member_id` INT( 10 ) UNSIGNED NULL

```

Modify assets/sources/base\_source.php (line 605) to add the member\_id to the db table:

```
'file_name' => $filename,
'member_id' => $this->EE->session->userdata('member_id'), // Add 'member_id' to database
'kind' => Assets_helper::get_kind($filename)

```

Finally, modify assets/libraries/assets\_lib.php (line 712) to limit the display of files to the currently logged in member only:

Change this existing line:

```
$this->EE->db->where_in('exp_assets_files.folder_id', $full_folder_list);

```

To this:

```
$this->EE->db->where_in('exp_assets_files.folder_id', $full_folder_list)->where('member_id', $this->EE->session->userdata('member_id'));

```

# Answer
> 1 votes
No, not yet, sorry Roger. We do have something planned for that, but I can't make any promises regarding ETA.

---
Tags: assets, safecracker, members, login
---


# Question
Title: Is there a way to display "last edit date" when viewing entries in the admin panel?
I am trying to find a way to view the last edit date of entries while in the control panel. I haven't found an EE2 plug-in or module, and have no idea of any other way to do it. Does anyone have any ideas?

I basically need to make sure I am not overriding any database info a user has entered when I import a new database from the staging site with changes.

# Answer
**Zenbu** will let you filter entries by `edit_date` (similar to the Edit page in ExpressionEngine, see screenshot below).

If you don't want to use an add-on you could run a MySQL query to check the `edit_date` in `exp_channel_titles`. Something like:

```
SELECT entry_id, title, DATE_FORMAT(edit_date, '%m-%d-%Y-%k:%i') AS updated
FROM exp_channel_titles
ORDER BY edit_date DESC LIMIT 50

```

This above just returns a list of entries along with the edit date, with the most recently edited entry listed first. You can easily run this query in the EE Control Panel using the Database Query Form, or with an application like Sequel Pro or Navicat.

---

Note that there will likely be other data besides the edit date entry data you'd want to check before you import a copy of the staging database (changes in categories, members, and comments for example). But if you know for sure that the only data changing on your staging site is entries then you should be good just checking `edit_date`.
> 21 votes

# Answer
If you want to do it yourself without installing anything or using SQL, this code in a template will display the most recent 5 entries and when they were edited:

```
{exp:channel:entries limit="5" orderby="edit_date" sort="desc" dynamic="no"}
    {edit_date format="%Y %m %d - %g:%i:%s"}: {title} ({relative_date})
{/exp:channel:entries}

```

The `{relative_date}` tag is kind of cool and also gratuitous here :)
> 6 votes

# Answer
If you don't care about the created date at all, you could conceivably write an extension which runs every time an entry is saved, and syncs the created date with the edit date.

That would avoid hacking the core, and would show the date you need in the control panel. It does mean you will forever lose the created date though.
> 0 votes

---
Tags: control-panel, channel-entries, date
---


# Question
Title: Filtering Playa entries in the drop panes loads site index template
When I start typing to filter entries in the Playa drop pane my list of entries is being replaced by my homepage template. There are no javascript errors. What could cause this?

I'm using Playa 4.3.3 on EE 2.5.5.

Edit: As suggested by Jérôme below, removing this from my .htaccess fixes the issue:

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

```

How can I deal with this?

# Answer
Removing the index.php shouldn't be an issue, but you can try adding to /system/expressionengine/config/config.php:

```
$config['assets_site_url'] = "/index.php";

```

It may also be worth trying:

```
$config['assets_cp_path'] = "./";

```

those should get you moving forward with your .htaccess in place. Please let me know how it goes.
> 0 votes

# Answer
Another somewhat ridiculous way to cause this problem, is to do some HTML prototyping in a file called index.html and keep that in your EE set up, therein confusing the Playa because things aren’t being properly routed through index.php

Yes, I am ashamed to admit that’s what caused this for me.
> 1 votes

---
Tags: playa
---


# Question
Title: How to get file upload paths that use Windows UNC format working
Anyone ever got images on an EE site working on a Windows server that uses UNC paths, e.g. //server/folder/?

I'm using imgSizer to resize images but am getting errors like:

> imgsizer.Error: /wwwroot/uploads/img/image.jpg image is not readable or does not exist

Support for the server says that it seems that EE is trying to serve images from a path with a single / at the front instead of the //

# Answer
Can you force C:\path\to/webroot/folder instead? I have that in use on a Win server with EE. You might also change from Imgsizer to CE Image - when I did that I was able to remove the base\_path type parameters from my plugin calls.
> 1 votes

# Answer
The imgSizer plugin uses remove\_double\_slashes() function of Functions library to remove the double slashes to a single slash. So it will not work either with "base\_path" or "src" parameters of imgSizer.

You can try "ED Imageresizer" by having "ed\_server\_path" config variable like:

```
$config['ed_server_path'] = '//server/folder/';

```

It would work.
> 0 votes

# Answer
Following on from Chad Crowell's answer: I would say that the easiest way to fix this -- assuming you're connecting to a single UNC server -- would be to map the UNC path to a drive letter. This is really easy, in Windows -- just open an Explorer window and go to Tools -\> Map Network Drive. Enter \server\images in the obvious box, and pick a drive letter in the other obvious box. If the server uses different credentials than the Windows login, then check the "Use different credentials" box. Then click "OK". (If you've checked 'use different credentials', it will prompt you for those after you've clicked OK; there will be an option to save them.

Then you can reference the paths from Imagesizer as, say, Q:\media (maps to \server\images\media) or Q:\stuff (maps to \server\images\stuff).

Failing that, use CE Image. :)
> 0 votes

# Answer
For:

```
/wwwroot/uploads/img/image.jpg

```

try:

```
\wwwroot/uploads/img/image.jpg

```
> 0 votes

---
Tags: server, windows
---


# Question
Title: How to return the right {site_short_name} in a Channel Entries Tag when using MSM
I'm using MSM to manage a number of sites, but on one of them I need to list ALL news items across ALL sites (which is easy!) ... however I need to identify which site each item has come from by either site\_id or site\_short\_name, etc.

So... I'm looking for:

```
{exp:channel:entries channel="news" site="siteA|siteB|siteC"}
{count}. {title} - {site_short_name}<br />
{/exp:channel:entries}

```

To result in:

```
1. My great title - siteB<br />
2. Another great title - siteA<br />
3. Yet another great title - siteC<br />

```

Unfortunately, the {site\_short\_name} is only coming back with the site\_short\_name of the site I am actually on. For example if the above code is on Site A, it comes back with the results:

```
1. My great title - siteA<br />
2. Another great title - siteA<br />
3. Yet another great title - siteA<br />

```

Anyone able to help?

Cheers.

# Answer
I think, it would be better to create to global variables within the index.php files of each site. In the index.php of each site you can have the code like:

```
$assign_to_config['global_vars'] = array('site_1_short_name' => '[short name of site 1]',  'site_2_short_name' => '[short name of site 2]');

```

**Please note**: You need to put this global variables assignments array above the last line of code i.e above the line of code:

```
require_once BASEPATH.'core/CodeIgniter'.EXT;

```

within index.php

The global variables {site\_1\_short\_name} and {site\_2\_short\_name} can be used anywhere within the templates.

**Updated**:

I don't think above would work.

The small SQL can be used with Query module:

```
{exp:query sql="SELECT exp_sites.site_name AS SiteShortName FROM exp_sites, exp_channel_titles
WHERE exp_sites.site_id=exp_channel_titles.site_id AND exp_channel_titles.entry_id='{entry_id}'"}

{SiteShortName}

{/exp:query}

```
> 1 votes

# Answer
Try to use {entry\_site\_id}

http://ellislab.com/expressionengine/user-guide/modules/channel/channel\_entries.html#entry-site-id

And this Query module:

```
{exp:query sql="SELECT site_name FROM exp_sites WHERE site_id='{entry_site_id}'"}
    {site_name}
{/exp:query}

```

---

This add-on can help too: Blog Info

http://devot-ee.com/add-ons/blog-info
> 1 votes

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


title: Error - Playa’s var_prefix parameter

text:
# Question
Title: Error - Playa’s var_prefix parameter
I'm having trouble getting this error resolved:

> .... is using the deprecated {child:url\_title} tag. Please use Playa’s var\_prefix parameter instead

This is my code:

```
{exp:playa:parents field="artist-relationship-playa" orderby="artworks-order" sort="asc"}
        {if "{show-on-website}" == "y"}
            <a href="{site_url}artists/{child:url_title}/{url_title}">{embed="artists/_artist-artworks-embed" entry_id="{entry_id}"}</a>
        {/if}
{/exp:playa:parents}

```

This code is inside a **channel** tag pair.

What should I change about this code to make is work?

# Answer
> 2 votes
Ah, I get how it works now. This is the code that got it to work:

```
{exp:playa:parents field="artist-relationship-playa" orderby="artworks-order" sort="asc" var_prefix="artworks"}
      {if "{artworks:show-on-website}" == "y"}
         <a href="{site_url}artists/{url_title}/{artworks:url_title}">...</a>
      {/if}
{/exp:playa:parents}

```

Just so that others want to know how it works. When using var\_prefix, all variables inside that playa tag pair are rendered as if they where not. Only if you prefix your variable with your var\_prefix value, will it be rendered as it would previously... get it :)

---
Tags: playa
---


# Question
Title: How can I collect order delivery date/time in Store?
Any ideas on how I could collect order delivery date/time in Store.

Best wishes Lee

# Answer
> 0 votes
You just need to create a custom order field and then output that in the checkout process.

Store \> Settings \> Order Fields. Pick an available field and give it a name ('Delivery Date' for instance).

Then output this as normal in the checkout. You can use it in combination with jQuery UI Datepicker to provide a date selection widget and set the correct formatting automatically. Or if you need the time included in the same field as well then I look to use jQuery DateTimePicker. You have lots of control here when it comes to date and time selection.

That combination works very well and can be pulled through into the Store order confirmation emails too.

---
Tags: expresso-store
---


# Question
Title: Expresso Store not sending billing details to PayPal Express
I am using Expresso Store with PayPal Express checkout. When the user goes through the Store checkout they enter their billing details and once they are taken to the PayPal guest checkout the billing detail fields are blank apart from (first) name, telephone and email. So the user has to enter their address details again.

Is there a way to get these fields automatically populated?

I've also noticed it's possible to enter billing details in PayPal that are different from those entered in Store, and the order in store shows the Store entered details rather than the PayPal details. (not sure if this is an issue or not).

I'm currently doing this on a MAMP install so i don't know if that is an issue, but it seems strange that email, name and phone are being passed through ok.

using store 1.6.1 and EE 2.4.0, with no easy way to upgrade.

Another question, I thought Paypal express had a mode where you would enter your card, shipping and billing details on the PayPal site and not on your site's checkout. Does Store support that, I can't seem to find any information on how to set that up.

Thanks

# Answer
Are you sure you're using the correct Store tags when collecting the Billing details on your site? You need to be using:

```
{field:billing_name}
{field:billing_address1}
{field:billing_address2}
{field:billing_address3}
{field:billing_country}
{field:billing_postcode}

```

etc...

Are you using these fields in your checkout?

Also, double-check that you have entered in all your Paypal Express Checkout details correctly in the Payment Gateway part of Store:

> PayPal Express Checkout requires an API Username, Password, and Signature. These are different from your PayPal account details. You can obtain your API details by logging in to your PayPal account, and clicking Profile \> My Selling Tools \> API Access \> Request/View API Credentials \> Request API Signature.

Does this all check out?
> 2 votes

---
Tags: expresso-store, paypal, paypal-express-checkout
---


# Question
Title: Country Code Not Being Saved in Orders Channel
I'm trying to get the country code for for an order to be saved in the orders channel. Currently, I have a step in the checkout process which uses the {exp:cartthrob:save\_customer\_info\_form} tags to collect the customer's shipping info. Most of this information is somehow, in a way I don't understand, getting saved for each order (in the orders channel). That's exactly what I want but unfortunately the country code is not being saved with the rest of the address. How would the country code typically be saved to the orders channel and is there anything that I should check to see why it hasn't?

# Answer
> 0 votes
Are you sure you have mapped this field to the correct field in your orders channel?

```
Cartthrob > Orders > Order data fields > Shipping country code

```

Also, how are you capturing the country code in your template files? Can you provide a sample of your code? Are you using a text input field like this(?):

```
<input type="text" name="country_code" value="{customer_country_code}" />

```

---
Tags: cartthrob
---