title: Store PayPal not working

text:
# Question
Title: Store PayPal not working
Latest EE and Latest Store.

I've setup PayPal Express in settings and have `{exp:store:checkout payment_method="paypal_express"}` on the final checkout page. I have the submit button as `<input type="submit" name="submit" value="Place Your Order">`. When I click the button nothing happens. I was expecting to be whisked over to PayPal. Any ideas what I've missed?

Thanks
Lee

# Answer
> 3 votes
As Justin mentioned in the comments, it sounds like there are some errors on your page which you haven't templated.

As a first step, always remove `error_handling="inline"` from your checkout tag, to see all the errors.

In the comments you mentioned it was missing the email address, so that sounds like the problem. All orders require an email address (that the order confirmation email is sent to), and at this stage it can't be automatically pulled from the customer's Paypal account, it must be collected before you redirect the customer for payment.

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


title: Deny Multiple Logins

text:
# Question
Title: Deny Multiple Logins
Is there any way to deny multiple user logins when using the same username & password?

So if a user is logged in, they can't login from another machine using the same login credentials.

Thanks for any help.

# Answer
Yes. Go to Admin -\> Security and Privacy -\> Security and Sessions and if you're using Sessions for the CP session type then you can select "no" for Allow Multiple Log-ins From a Single Account.
> 6 votes

# Answer
Yes you can. go to Admin \> Security & Privacy \> Security and Session Preferences and disable "Allow multiple logins from single account".
> 0 votes

---
Tags: config, login
---


# Question
Title: How do you "hide" sites from search engines during development?
I'm in the process of tweaking my base install and was wondering how you hide sites from search engines when deployed to a publicly accessible DEV or STAGING server?

I currently:

* Add a robot.txt file to disallow crawling (not sure how much that really helps though)
* Use global vars to hide GA code from all but PROD servers
* On occasion set the site to "offline" and force people to login

How do you do it? Do you simply keep the site "offline" and make the clients/stakeholders login? Or is there another fancy way of keeping the site "open" to those who know the URL but don't want to log in?

# Answer
> 16 votes
The best way to do this is to use a .htpasswd file to prevent anyone (including spiders) from seeing the site if they are not authorized. This is much better than a robots.txt file because unlike robots.txt - it cannot be ignored. If a spider doesn't have your password, they cannot view the content.

I typically like using a single, shared login for viewing the site. If all visitors to the site ask their browsers to remember the password, normally they will only need to enter it once.

Some hosts, such as DreamHost, will provide a method to automatically create a .htpasswd file for you. Otherwise, it's pretty easy to do manually.

First create or modify your .htaccess file in the root of your site to add authorization directives:

```
AuthType Basic
AuthUserFile /home/USERNAME/.htpasswd
AuthName "EE Staging Site"
require valid-user

```

We will create the .htpasswd file in a moment, which actually contains the credentials for the login. Whatever location you want to store this file in, you should enter above after the AuthUserFile directive. Lots of hosts have separate directories within your home directory for each site, so you may end up doing something like this:

```
AuthType Basic
AuthUserFile /home/USERNAME/example.com/.htpasswd
AuthName "EE Staging Site"
require valid-user

```

At any rate, once you've decided where to store the .htpasswd file and created the above .htaccess you need to then create the actual .htpasswd file. This is pretty easy:

```
/usr/bin/htpasswd -c /home/USERNAME/example.com/.htpasswd STAGINGUSER

```

Replace USERNAME with you actual username (and otherwise adjust the path as needed) STAGINGUSER use with a username you want visitors to have to enter, such as "staging":

```
/usr/bin/htpasswd -c /home/USERNAME/example.com/.htpasswd staging

```

In this example, we are creating a new username within the .htpasswd file named "staging". After running this line, it will prompt you for the actual password. Enter it, then enter the confirmation when prompted as well.

For Nginx, you can look into how to create the equivilant of a .htaccess file here and here.

The Nginx config file looks like this:

```
location  /  {
  auth_basic            "EE Staging Site";
  auth_basic_user_file  /home/USERNAME/example.com/.htpasswd;
}

```

The same instructions to create the .htpasswd file should apply, if you have Apache installed. If not, you can find alternative ways of creating the file at the second link.

# Answer
> 7 votes
I actually use the following along with Focus Lab's master config:

First I create php file called robots.php in root and I add the following to it:

```
<?php
header("Content-Type: text/plain");
require_once('../config/config.env.php');
echo "#".ENV_FULL." version of robots";
?>

<?php if(ENV != 'prod'): ?>
User-agent: *
Disallow: /
<?php endif; ?>

###
# Add unsafe robots here to keep away
###

```

Making sure I'm linking to the config.env.php so I can check if we are on production or not.

Then in my .htaccess fill I add this:

```
# Use Dynamic robots.txt file
# ------------------------------
RewriteRule robots\.txt /robots.php [L]

```

Which does our redirect when robots hit robots.txt which in turn gives them the contents of the robots.php file.

Note: if we aren't on production then we are giving them the following:

```
User-agent: *
Disallow: /

```

---
Tags: seo, development, staging-server
---


# Question
Title: CartThrob and CT Admin reporting email address
I'm using CT Admin with my Cartthrob store. Currently all my reports with CT Admin use the EE site's webmaster name and email address for the values. I would prefer to keep our agency as the webmaster email and have a setting somewhere (if possible) to use in the invoice/report pages.

Is this possible?

# Answer
> 2 votes
The latest update to CT Admin (1.5.1) has this capability. Just edit in the settings area.

---
Tags: add-on, cartthrob, email
---


# Question
Title: How can I create a category listing which has its own template?
**Use custom category listing template 'news/category':**

```
/site/news/category

```

**Use custom template to present “Legal Politics” 'news/category-legal-politics' entries:**

```
/site/news/category/politics/legal

```

I assume that I must create a custom template called "news/category" which then dynamically picks between:

* category-listing
* articles-in-category
* special-news-category

And I am also guessing that custom URL fragments will need to come into play to achieve this. But what I do not understand how to convert the URL into the category ID:

```
<!-- Template Group: news   Template: category -->
{exp:channel:entries channel="news" category="??{get-from-url}??"}
    <h1><a href="{path='news/index'}">{title}</a></h1>
    <div class="summary">{summary}</div>
{/exp:channel:entries}

```

Interestingly I find that the following URL works (almost) for regular category listing

```
/site/news/category/category/politics/legal

```

when using the following template:

```
{exp:channel:entries channel="news"}
    <h1><a href="{path='news/index'}">{title}</a></h1>
    <div class="summary">{summary}</div>
    <ul class="categories">
        {categories}
            <li>{category_name}</li>
        {/categories}
    </ul>
{/exp:channel:entries}

```

If I could somehow skip the second category slug in the URL then this would be half way there!

In WordPress this would be achieved by providing a custom template "category.php" and special categories "category-legal-politics.php" or "category-42.php". What would the equivalent be for EE?

# Answer
Why not use a single template for your news items with a conditional to check for the "/politics" or "/legal" URI segments? Your template would look something like this:

```
{!-- Category Index --}
{if !segment_3}
    Show overview of all content instead of simple listing...

{!-- Specific Category --}
{if:elseif segment_3 == "politics"}
    Specialised template for politics...

    {exp:channel:entries channel="news" category="3"} {!-- this assumes the "politics" category id is 3 --}
        <h1><a href="{path='news/index'}">{title}</a></h1>
        <div class="summary">{summary}</div>
    {/exp:channel:entries}

{!-- Default Category Listing --}
{if:else}
    Generic template for anything else...

    {exp:channel:entries channel="news" category="{segment_3_category_id}"}
        <h1><a href="{path='news/index'}">{title}</a></h1>
        <div class="summary">{summary}</div>
    {/exp:channel:entries}
{/if}

```
> 4 votes

---
Tags: ee2, templates, categories
---


# Question
Title: How can I create a custom template for a specific content item?
**Use regular news ‘news/index’ template:**

```
/site/news/regular-news

```

**Use special ‘news/special-story’ template:**

```
/site/news/special-story-which-needs-custom-template

```

# Answer
> 1 votes
Okay, the following seems to solve two problems:

1. It allows me to provide a different template for the category listing and for an individual news item.
2. Looking at the URL segment I can perform some custom template routing.

Here is my template "news/index":

```
{if segment_2 == 'category' || segment_2 == 'archives' || !segment_2}
    {embed="news/.listing"}
{if:elseif segment_2 == "special-story"}
    {embed="news/.special-story"}
{if:else}
    {embed="news/.single"}
{/if}

```

This has the undesirable effect of adding whitespace in front of the page DOCTYPE, but I cannot see an easier way to avoid this (any ideas welcome!)

# Answer
> 2 votes
I'm not completely clear on what you want to do here, but I'll give it a shot. I'm assuming you want to have your regular news with any url\_title show up using the index title, so `/site/news/regular1` and `/site/news/regular2` would both use the `site/index` template. I believe you can accomplish that much by default, you just need to make sure your template has the code in place to read the url title and pull the appropriate content.

The second one is a little unclear as to what you want to accomplish? Do you want to have a special template for each special story or one special template for all special stories?

A special template for each story: Just create the template with the appropriate name and make sure it has the code to read the right content, and away you should go.

A special template for all special stories: Look into the pages module for this, or you can have a toggle of some kind in your channel fields that the main template would look at and determine which design template to embed.

Let me know if this answers your question, or if it seems like I'm misunderstanding, please edit your question to clarify.

**Update:** Based on your clarifications I built a little proof of concept with one of my existing channels and a new template group called testa. Here are the two templates:

testa/index:

```
{if segment_2==""}<ul>{exp:channel:entries channel="announcements"}
<li>{url_title}</li>
{/exp:channel:entries}
{if:else}
{exp:channel:entries channel="announcements" url_title="{segment_2}"}<h1>{title}</h1}
{ann_en_body}
{/exp:channel:entries}
{/if}

```

and here is a brief sample of output from /testa/ (note I don't have the equivalent of your /site/ folder so in your case it would be segment\_3)

If I visit /testa/islamic\_finance\_report I get the title and English body of that page, until I add the islamic\_finance\_report template in the template group:

```
{exp:channel:entries channel="announcements" url_title="islamic_finance_report" limit="1"}
<h1>{ann_ja_title}</h1>
{ann_ja_body}
{/exp:channel:entries}

```

Now visiting that same url loads up the Japanese title and body for that page.

Hope that helps.

---
Tags: ee2, templates, url
---


title: Image cropping/sizing with CE Image

text:
# Question
Title: Image cropping/sizing with CE Image
I've got some images that are not square (portrait and landscape format), but I want them cropped square with CE Image.

I've tried various parameters from the documentation, but the results are stretched unnaturally. I'd prefer to have the image cropped to center and not scaled.

```
{exp:ce_img:single src="{image}" filter="grayscale" filename_suffix="-OFF" unique="none" class="fadein" max="192" crop="yes|center,center|0,0|no"}

```

# Answer
What Brett suggested above should work. Maybe you can try with the tag pair approach ? Again, very simple example you can build upon.

```
{exp:ce_img:pair src="{cf_news_img}" width="200" height="200" crop="yes|center,center"}<img src="{made}" alt="{title}" />{/exp:ce_img:pair}

```
> 2 votes

# Answer
This has always worked for me:

```
{exp:ce_img:single src="{url}" width="200" height="200" crop="yes|center,center" }

```

You can obviously add any additional paramaters (offset, filter, etc), but give this simple example a shot and try adjusting from there.
> 12 votes

---
Tags: add-on, ce-image, image, crop
---


# Question
Title: When using Google Maps for EE, why does my third map (out of 3) appear correctly while the others are static images?
Using Objective HTMLs "Google Maps for ExpressionEngine" plugin this query returns 3 records and it is giving me the first two maps as staic maps and third map as a live map:

```
{exp:channel:entries channel="events" orderby="events_start_date" sort="desc"}

<div class="map">
{exp:gmap:init id="map{entry_id}" class="google-maps" style="width:100%;height:380px" scrollwheel="false"}
                {exp:gmap:marker id="map{entry_id}" latitude="{events_map_latitude_field}" longitude="{events_map_longitude_field}" zoom="16"}
</div>

{/exp:channel:entries}

```

Why are all the maps not live maps with a marker on them?

The maps are also in a div that uses jquery show/hide and the real map only shows the first tile and the static maps (which should be real maps) don't even show. If the show/hide is disabled the maps render correctly (though the first two are static).

# Answer
> 6 votes
Take a look at the DOM, you will notice that the Google Maps library is included with each loop.

Use the `script_tag="false"` parameter.

https://objectivehtml.com/google-maps/documentation/tag/init#script\_tag

Try something to this effect:

```
{if count == 1}
    {exp:gmap:init id="map{entry_id}" class="google-maps" style="width:100%;height:380px" scrollwheel="false" latitude="{events_map_latitude_field}" longitude="{events_map_longitude_field}" zoom="16"}
{if:else}
    {exp:gmap:init id="map{entry_id}" class="google-maps" style="width:100%;height:380px" scrollwheel="false" latitude="{events_map_latitude_field}" longitude="{events_map_longitude_field}" zoom="16" script_tag="false"}
{/if}

```

---
Tags: ee2, google-maps, google-maps-for-ee
---


# Question
Title: Structure {page_url} variables still pointing to staging site after deploying to production
This question is also on StackOverflow. Sorry for repeating...

I've just moved an ExpressionEngine (v.2.5.3) stage site to the production server. The site uses Structure and Publisher add-ons.

Everything went well except that **all the hyperlinks using `{page_url}` are pointed to the stage site and not to the new site.**

I'm using **`{page_url}`** to call Structure entries.

However when I use `{path=""}` or `{url_title_path={segment_1}}` for instance the URLs are OK. It is only when using {page\_url} that they kept pointed to the stage site.

I tried `{page_uri}`, which works, but then the language prefixes from Publisher get lost.

I run REElocate add-on and then checked:

* Admin \> General Configuration \> URL to the root directory
* Main index.php file, for any overrides to site\_url
* Main config.php file for site\_url variable overrides
* I checked all the Basepath to Template File Directory, the base\_url, Also clean all caches,etc.

I went to check all the database SQL tables and: exp\_files and publisher\_log tables show staging paths not the new ones...

Any help would be very much appreciated.

# Answer
I used to have issues like this then I started using a DRY config.php file. I would strongly recommend doing the same. My first config.php file was based on the one from this NetTuts article, "Apply the DRY Principle to Build Websites With ExpressionEngine 2". If you set this up right you won't need to mess with REElocate anymore.

If you do use this approach and you still have problems, clear your cache and resave the entries. If the problem STILL persists then you might need to go into the SQL manually and fix the paths and hope they don't resurface.

**update** Now that I'm in the office and have a couple minutes I can share my default config file (the database.php file is the same as the one from the article).

The biggest change from the NetTuts article is the use of $\_SERVER\['HTTP\_HOST'\] instead of $\_SERVER\['SERVER\_ADDR'\] because I tend to setup the staging server as a subdomain on the clients production server. This is to ensure that PHP and MySQL setting issues are caught early on and relying on IP addresses is difficult at best when doing this. Plus it's more human readable so you know what the development, staging, and production servers are. I am also a single developer so I don't setup a local production server where multiple devs can sync their efforts. You can easily add one by duplicating one of the switch cases.

If you want to learn more about some of the other hidden config variables in this config file, or others you can add at your own discretion, I would recommend this page on devot-ee. Te EE docs cover some variables but this page documents previously undocumented one that can be very useful.

I should also note that this is by far the only DRY config.php setup around. Focus Lab LLC’s EE Master Config is a very competent setup for doing the same thing and it sits above the web root which makes it easier to find and edit. Another popular approach is NSM Config Bootstrap. To each their own. I decided to start with something basic and add to is while I learn more about what's really going on under the hood.

```
/* Environmental Variables
-------------------------------------------------------------------*/
switch ( $_SERVER['HTTP_HOST'] ) {

    // development
    case 'mysite.dev' :
    $db['expressionengine']['hostname'] = "";
    $db['expressionengine']['username'] = "";
    $db['expressionengine']['password'] = "";
    $db['expressionengine']['database'] = "";
    break;

    // staging
    // case 'staging.mysite.com' :
    // $db['expressionengine']['hostname'] = "";
    // $db['expressionengine']['username'] = "";
    // $db['expressionengine']['password'] = "";
    // $db['expressionengine']['database'] = "";
    // break;

    // live
    // case 'mysite.com' :
    // $db['expressionengine']['hostname'] = "";
    // $db['expressionengine']['username'] = "";
    // $db['expressionengine']['password'] = "";
    // $db['expressionengine']['database'] = "";
    // break;

}

/* Universal Variables
-------------------------------------------------------------------*/
$config['app_version'] = "253";
$config['license_number'] = "1111-2222-3333-4444";
$config['debug'] = "1";
$config['install_lock'] = "";
$config['system_folder'] = "system";
$config['admin_file'] = "admin.php";
$config['doc_url'] = "http://expressionengine.com/user_guide/";
$config['is_system_on'] = "y";
$config['cookie_prefix'] = "";
$config['site_name'] = "Default EE install";
$config['allow_extensions'] = "y";
$config['enable_db_caching'] = "y";
$config['debug'] = "1";
$config['daylight_savings'] = date('I') ? 'y' : 'n'; // Autodetect DST
$config['cp_session_ttl'] = 3600; // Keep admins logged in for one hour! (in seconds)

/* General Path Settings
-------------------------------------------------------------------*/
$config['site_index'] = "";
$config['site_url'] = "http://".$_SERVER['HTTP_HOST'];
$config['server_path'] = $_SERVER['DOCUMENT_ROOT'];
// $config['cp_url'] = $config['site_url']."/".$config['system_folder']; // use if keeping system within root
$config['cp_url'] = $config['site_url']."/".$config['admin_file']; // use if moving system one level above root

/* Universal database connection settings
-------------------------------------------------------------------*/
$active_group = 'expressionengine';
$active_record = TRUE;
$db['expressionengine']['dbdriver'] = "mysql";
$db['expressionengine']['dbprefix'] = "exp_";
$db['expressionengine']['pconnect'] = FALSE;
$db['expressionengine']['swap_pre'] = "exp_";
$db['expressionengine']['db_debug'] = FALSE;
$db['expressionengine']['cache_on'] = FALSE;
$db['expressionengine']['autoinit'] = FALSE;
$db['expressionengine']['char_set'] = "utf8";
$db['expressionengine']['dbcollat'] = "utf8_general_ci";
$db['expressionengine']['cachedir'] = $config['cp_url']."/expressionengine/cache/db_cache/";

/* Member directory paths and urls
-------------------------------------------------------------------*/
$config['avatar_url'] = $config['site_url']."/images/avatars/uploads/";
$config['avatar_path'] = $config['server_path']."/images/avatars/uploads/";
$config['photo_url'] = $config['site_url']."/images/member_photos/";
$config['photo_path'] = $config['server_path']."/images/member_photos/";
$config['sig_img_url'] = $config['site_url']."/images/signature_attachments/";
$config['sig_img_path'] = $config['server_path']."/images/signature_attachments/";
$config['prv_msg_upload_path'] = $config['server_path']."/images/pm_attachments/";

/* Misc directory paths and urls
-------------------------------------------------------------------*/
$config['theme_folder_url'] = $config['site_url']."/themes/";
$config['theme_folder_path'] = $config['server_path']."/themes/";

/* File directory paths and urls
-------------------------------------------------------------------*/
// $config['upload_preferences'] = array(
//     1 => array(
//         'name'        => 'name of directory',
//         'server_path' => $config['server_path']."/assets/path/to/directory/",
//         'url'         => $config['site_url']."/assets/path/to/directory"
//     )
// );

/* Templates Preferences
-------------------------------------------------------------------*/
// $config['save_tmpl_files'] = "y";
// $config['tmpl_file_basepath'] = $config['server_path']."/templates/";
$config['site_404'] = "404/index";
$config['strict_urls'] = "y";
$config['hidden_template_indicator'] = "_";
$config['autosave_interval_seconds'] = "99999";
$config['word_separator'] = "underscore";

// END EE config items

```
> 4 votes

# Answer
This sounds like a Structure problem ... Admin \> General and your paths are correct?
> 2 votes

# Answer
Do you still have e.g. MAMP running? Maybe there is something left in the local cache from your stage\_site
> 1 votes

# Answer
Have you tried resaving the entries?

Is it also a problem for newly created entries?

Otherwise you could do a mass find and replace on the database via Tools \> Data \> Search and Replace
> 1 votes

# Answer
I wouldn't swear to it but I seem to recall that `{page_url}` when used inside say a WYSIWYG editor will actually be rendered as the full-path on saving of the entry.

I believe that's why I now never use anything else but relative URL's for content.

Also as James asked, does it happen on new entries also ?
> 1 votes

---
Tags: structure, url, server-migration
---


title: Low Search Returning All Results

text:
# Question
Title: Low Search Returning All Results
Being new to EE I have only used Low Search once before and it was a very basic keyword search. This time it is a search with parameters. Unfortunately, it is return all entries in the channel I'm searching.

Following is my setup - where am I going wrong?

Channel name: events Collection label: Event Collection name: events

Field Weights: Title 3
Event Start Date 3
Event End Date 3
Course Name 2 Event Description 2 Event Location Map 1

Trying to search the following 'events' channel fields:

Play Dates {events\_start\_date} {events\_end\_date}

Venue {events\_course\_name}

Location {events\_map\_formatted\_address}

Event Name {title}

Event Type {events\_type}

```
{exp:low_search:form collection="events" search_mode="all" result_page="events-and-offers/search" form_class="form-horizontal"}
    <div class="left-form">
        <h5>Search by</h5>

        <div class="control-group">
          <label class="control-label" for="inputDates">Play Dates</label>
          <div class="controls">
            <input type="text" id="txtFromDate" name="range:events_date" placeholder="start date" class="datepicker span placeholder">
            <input type="text" id="txtToDate" name="range:events_date" placeholder="end date" class="datepicker span placeholder">
          </div>
        </div>

        <div class="control-group">
          <label class="control-label" for="venue">Venue</label>
          <div class="controls">
            <input type="text" id="venue" name="events_course_name[]" placeholder="venue" class="span placeholder">
          </div>
        </div>

        <div class="control-group">
          <label class="control-label" for="location">Location</label>
          <div class="controls">
            <input type="text" id="location" name="events_map_formatted_address[]" placeholder="postocde" class="span placeholder">
          </div>
        </div>

        <div class="control-group">
          <label class="control-label" for="event-name">Event Name</label>
          <div class="controls">
            <input type="text" id="event-name" name="title[]" placeholder="event name" class="span placeholder">
          </div>
        </div>
    </div>

    <div class="right-form">
        <h5>I am interested in</h5>
        <label class="checkbox">
          <input type="checkbox" name="events_type[]" value="special-events">
          <i class="ss-icon ss-standard ss-star"></i> Special Events </label>
        <label class="checkbox">
          <input type="checkbox" name="events_type[]" value="offers">
          <i class="ss-icon ss-standard ss-dollarsign"></i> Offers </label>
        <button type="submit" class="btn btn-normal btn-success"><i class="ss-icon ss-symbolicons-block">search</i> SUBMIT SEARCH</button>
   </div>
{/exp:low_search:form}

```

Results page (keeping it basic for testing):

```
{exp:low_search:results query="{segment_3}" limit="10"}
  {if count ==  1}<ol>{/if}
    <li><a href="{comment_url_title_auto_path}">{title}</a></li>
  {if count == total_results}</ol>{/if}
  {if no_results}No search results{/if}
{/exp:low_search:results}

```

# Answer
Okay, this may take a while, but first, read my Low Search Primer. Now you know searching is simply filtering entries by keyword. Low Search uses its collections and their indexes for high quality keyword filtering. In a Low Search form, you can use an input field with `name="keywords"` to trigger filtering by keywords.

## Keyword filtering

The Keywords filter searches Collections and the index they create, which is a single field that contains all the custom fields you've added weight to, combined. Therefore, you're not searching *just* the title or a custom field specifically; you're searching through an entry as though it is a single searchable field.

You *can* be creative with the collections, of course. For example, you could create another collection where you only add weight to the title of a channel, and call it (in your case) 'Event Titles'. When choosing which collection to search in, you can give the user the option to search only 'Event Titles' or 'Events'.

Note that you should only give weight to fields that have meaningful text for keyword searches. A date or a drop-down with 'yes' and 'no' do not make sense for keyword searches.

## Native filtering

The `channel:entries` tag natively provides filters as well, as parameters. For example: `status`, `category` or `search:my_custom_field`. Each of these parameters can be used as input fields or selects in the Low Search form as well, using `name="status"`, `name="category"` and `name="search:my_custom_field"`, and so on.

Now, as you know, most parameters can take multiple values. If you want to do that in the form, you can use a multiple select field or checkboxes. For example, you could use the `channel:categories` tag to generate a checkbox list of categories. However, if you name those `name="category"`, like I stated above, it will only return **the last one checked/selected**. That's just how forms work. To send a list (array) of categories, add square brackets to the name: `name="category[]"`. Now **all** checked/selected items will be posted, and Low Search will convert those to a pipe-separated list and place that in the `category` parameter of the `channel:entries` tag.

The same principle applies to **all** native parameters. You can even make sure Low Search converts those values to an &-separated list for **inclusive** parameters, by setting the `require_all` parameter to the Form tag. For example, `require_all="category"` will generate a parameter like `category="1&2&3"`.

## Ranges

In addition to the Keywords filter, Low Search also lets you filter by Ranges. In your case, you're filtering by date range.

It works similarly to EE's native `search:my_custom_field` parameter, but uses `range:my_custom_field` instead. This means you can use an input field like `name="range:my_custom_field"` as well.

To get the **from** and **to** values, you can separate the parameter value with a pipe, for example: `range:my_custom_field="1|10"`, which translates to "my custom field should be between 1 and 10".

You can also *split this into 2 fields* like this: `range-from:my_custom_field="1" range-to:my_custom_field="10"`. Again, the same principle applies to using this in input fields: `name="range-from:my_custom_field"` and `name="range-to:my_custom_field"`. See where this is going?

## In conclusion

With what I've tried to explain above, you should already notice the tweaks you need to make in your example code.

* Don't add weight to your start and end date fields. It won't hurt, but it won't do anything.
* You're using `name="range:events_date"` for both the dates, which is wrong on 2 accounts. You're probably looking for events that **start** in the given range, so this would make more sense: `name="range-from:events_start_date"` and `name="range-to:events_start_date"`
* You want to search for the custom fields venue and location specifically. You could, but only using EE's native search parameter, so: `name="search:events_course_name"` and `name="search:events_map_formatted_address"`. Also note I'm not using \[\], because the fields are a *single value*.
* You want to search for a *title* specifically. This can't be done with EE's native search parameter, but *can* be done with Low Search's extended Field Search filter, using `search:title=""`.
* The checkboxes do need the square brackets, since they both apply to the same field, but again, they're not keywords, so you should use `name="search:events_type[]"` to trigger the filter. You should also add `require_all="search:events_type"` to the form tag, so if both checkboxes are ticked, you only get results for A **and** B, not A **or** B.

Turned out to be quite an essay, but I hope this helps you grasp the concept of Low Search better.
> 27 votes

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


title: Dealing with 100+ categories

text:
# Question
Title: Dealing with 100+ categories
I need a 'location\_channel' with location entries.
These entries should have 3 multi-select boxes containing different categories.

**Select #1 - Location Type**

* Education
    + Academies
    + Auditoria
    + ...
* Religion
    + Chapels
    + Temples
    + ...
* ...

**Select #2 - Location Style**

* Medieval
* Gothic
* ...

**Select #3 - Location Era**

* 10th Century
* 11th Century
* ...

I tried to do this with native EE categories, but it seems it's not possible to add multiple 'categories'-fields. And it wouldn't be easily selectable when you have 100+ categories.

Also looked at Playa, but it handles entries not categories.

**So my question is:**
What is the best way/practice to handle this case?
Am I overlooking something to do this with native categories?
Should I make use of a category\_channel & add the 'categories' as channel\_entries?
Or should I use 'Tags' instead?

**Keep in mind:**

* easily manageable by the admin
* only the admin can add/remove categories
* on the front we need a 'search/filter' that can handle these categories

# Answer
> 6 votes
> but it seems it's not possible to add multiple 'categories'-fields.

I'm not sure I'm reading that right though, you can add multiple category groups.

If you go to Admin \> Channel Administration \> Channels \> Edit Group Assignments

Where "Edit Group Assignments" being the link to where you can assign category groups, statuses and a channel field group to a certain channel.

You can then select multiple category groups by ctrl/cmd clicking multiple category groups at once and updating.

You also mentioned multi-select boxes and I remember there being an add-on which would setup the native category "tree" into multi-selects though, for the life of me I can't remember what it was called and if it was for EE1 or EE2.

There are a few category field types which may come in handy:

As far as using one of the Tag add-ons I'm not sure you can get tags within tags if that makes sense. So from your example:

* Location Type
    + Education
        - Academies

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


title: Member Import Alternative

text:
# Question
Title: Member Import Alternative
I know you can import members by using the built in import function, but that uses XML. Who keeps their data in XML...?
There's the CSV to XML converter, but its hardly client-friendly.

Are there any alternative methods to import members?

A client of mine takes down member details manually at their store, and they want to upload them in bulk on a semi-regular basis.
Ideally I'd like the client to just have to upload a CSV (in a format we can define).

# Answer
> 4 votes
I've been working on a module to import members from CSV files. You can download it here:

https://bitbucket.org/ajweaver/ajw\_import\_members

If you are familiar with DataGrab it is very similar so you define the data source, map data fields to member fields and then run the import. You can also save imports and re-run them again later.

It is working fine on the handful of sites that are using it, but consider it "beta" software for now and take a backup before you try using it!

# Answer
> 6 votes
I suggest moving the member info over to channel entries with a third party add-on like Profile:Edit or Zoo Visitor. This opens member data and gives you a ton of power and flexibility you normally get with channel entries and custom fields. You could then use DataGrab to setup and configure a member import to automatically load a .csv file from a given url and re-run that import weekly or however often as needed.

---
Tags: members, import, xml, csv
---


# Question
Title: Using switchee to redirect to 404 if no category exists
I'm interested in redirecting to a 404 if no category exists at the URL, for example if category xyz doesn't exist at; mydomain.tld/shop/category/xyz

I'm using Switchee and a case value for category as follows;

```
{exp:switchee variable="{segment_2}" parse="inward"}
    {case value="category"}
        {!-- Redirect to 404 if no category exists here --}
    {/case}
{/exp:switchee}

```

Wondering if anyone knows how to do a redirect here if a matching category is not found?

Thanks.

# Answer
Get Low Seg2Cat, make sure the Set All Segments setting is set to Yes, and then use something like this:

```
{if segment_2 == 'category' AND segment_3_category_id == ''}
  {redirect="404"}
{/if}

```

...or the Switchee equivalent.
> 7 votes

# Answer
I didn't have time to write this out before you chose Low's answer though, I will add it just the same for future reference:

```
{exp:switchee variable="{segment_2}/{segment_3}" parse="inward"}
    {case value="#^category/\S+$#"}
        your code....
    {/case}
    {case default="yes"}
        {redirect="404"}
    {/case}
{/exp:switchee}

```

This assumes you will always have something in segment 3 or else go 404
> 2 votes

---
Tags: categories, redirects
---


# Question
Title: Freemember: Redirect user to previous page after login
Is it possible to redirect the user to the previous page after login, without needing to use PHP?

Note: I'm not using the default login, i'm using the Freemember add-on.

# Answer
**UPDATE:** As you're using FreeMember you can take advantage of its built-in `PREVIOUS_URL` constant:

```
{exp:freemember:login return="PREVIOUS_URL"}

```

As detailed in the FreeMember login form docs on GitHub.

If you were using the built in `login_form` tag instead, I'd suggest you use something like the Current URL extension (EE2 version linked) use the incredibly useful Mo'Variables, to achieve the same effect:

```
{exp:member:login_form return="{current_url}"}

```

This works as you can pass a full URL as the return parameter to the `login_form` tag. That way you're good for any URL structure you might have in your site.
> 6 votes

# Answer
This should work:

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

```

Maybe you will need to add segment if you have more than 3.
> 3 votes

# Answer
There's also this excellent add-on by Objective HTML that adds redirect on login and logout: Authenticate
> 3 votes

---
Tags: login, redirects, freemember
---


title: File Uploads with Special Characters

text:
# Question
Title: File Uploads with Special Characters
I just updated a site from 2.1.3 to 2.5.3 and I'm having some trouble with old file uploads.

**First Problem**
EE now seems to URL Encode the file URL which causes some issues with Image Sizer since it tries to use the encoded path.

Is there a way to get the unencoded path or do I need to modify Image Sizer or use a different plugin?

**Second problem**
Some of the old files had an & (ampersand) or other invalid characters in their name. After the upgrade when I did a sync on the upload directories it seems to have stripped those characters from the file names on the filesystem, but not from the actual File Upload Fields. Now I have to re-chose the files that got renamed and I get a PHP error (see below) when editing the entries.

```
A PHP Error was encountered
Severity: Notice
Message: Undefined index: filename
Filename: libraries/File_field.php
Line Number: 77

```

Is there a query I can run on all the upload fields, or anything else I can do to fix this?

Here's some examples of the files being renamed.
The name from the live server is on the left and the name from the dev server where I ran the upgrade is on the right.

MP900409379\[1\].jpg --\> MP9004093791.jpg
004\_LB-Cottages F&F.PDF --\> 004\_LB-Cottages FF.PDF

# Answer
> 4 votes
Did you check your channel's Posting Preferences? (Admin \> Channels \> Channel Prefs) Could "Automatically turn URLs and email addresses into links?" be turned on? This has caught me a few times in the past...

While ugly, you could otherwise wrap the output with URL Decode tags. This fall under the heading of "quick and damned-dirty" tho.

# Answer
> 1 votes
Just a quick note, ImgSizer is no longer being updated, you may want to look at CE Image over on Devotee. The author is very quick to answer questions, you may want to ask him if his add-on will have the same issue.

---
Tags: file-uploads, upgrade, uploads
---


# Question
Title: Checkbox field, displaying li with different classes
Nice to see a Stack site for EE. Used S Overflow many times in past, and has always been much help.

Anyhow, heres my first question...

I have a site that lists dog walks. I have a checkbox field for the walks channel. Users submit walks via a safecracker form, and the checkbox field is used for users to select certain features present at the walk.

At the moment I display the field on the single entry view page, using the following...

```
<strong class="heading">Walk Features:</strong>
                <ul>
                  {walk_features}
                    <li>
                      <span>{item}</span>
                      <a href="{site_url}walk_location_features" target="_blank">Find out more</a>
                    </li>
                  {/walk_features}
                </ul>

```

This produces me a simple list on front end. Now I want to spice up that list slightly, by having a different icon/image & description for each option (contained within the checkbox field.)

So I need to output (HTML) something like:

```
<ul class="features">
<li class="option1">
    <h3>Option 1</h3>
    <p>A short description of option one</p>
</li>
<li class="option2">
    <h3>Option 2</h3>
    <p>A short description of option two</p>
</li>
etc

```

I'm just not quite sure on how to get to that from my checkbox field. I have had P&T checkbox field & Low Options suggested, however I am still unclear as to how I can get it from the current field.

I have over 130 entries which use this field, and was hoping that I could output it directly from the existing field. I could add a new field if necessary, and go through transferring the data, but I obviously would like t avoid that if possible! Any help greatly appreciated! :)

# Answer
I suggest switching the field over to P&T Checkboxes or Radio Button (if you only want them to select one option). In the settings I would specify an option value separately from it's label:

```
option_one : Option 1
option_two : Option 2
option_three : Option 3

```

Then in your template use the option value as the class name:

```
<ul>
  {walk_features}
    <li class="{option}">
      <span>{option_name}</span>
      <a href="{site_url}walk_location_features" target="_blank">Find out more</a>
    </li>
  {/walk_features}
</ul>

```

Since you have 130 entries already, I suggest using a SQL query to find/replace all the entries with the new values. Be sure to backup your DB before doing this.

```
UPDATE
exp_channel_data
SET field_id_X = replace(field_id_X,'Option 1','option_one');

```

**UPDATE** To add a short description instead of a link:

```
<ul>
  {walk_features}
    <li class="{option}">
      <span>{option_name}</span>

      {if "{option}" == "option_one"}
        short description about Option 1
      {/if}

      {if "{option}" == "option_two"}
        short description about Option 2
      {/if}
      ...

    </li>
  {/walk_features}
</ul>

```
> 4 votes

---
Tags: ee2, list
---


# Question
Title: Deleting members / Changing Author of multiple entries
I used zoo member/safecracker to allow registered members submit 1 entry (application form) a few months back. I now need to open this form back up for submissions again. I need to save the original submissions in the database but need to remove the registered members so they can submit again.

I believe that the author of the entries needs to be changed before the members are deleted.

Does anyone know of a plug-in to change the author of multiple entries (1000 aprox) or what syntax to use for the database query.

# Answer
Your SQL query would look something like this:

```
UPDATE exp_channel_titles SET author_id = XX WHERE entry_id IN(34,278,45,91, [...]);

```

You'll want to run a Recount Statistics afterwards as well.

(If there was something common to all of these entries, you could possibly incorporate more into the query that would prevent you from having to have a comma-delimited list of all the entry\_ids hard-coded.)
> 7 votes

---
Tags: database, safecracker, plugin
---


# Question
Title: Disabling Postmaster from sending emails using a config.php override
Is it possible to disable Postmaster from sending emails using a config.php override? I've got a development version of a site and it'd be good if I could disable the emails from sending when I'm triggering the parcels during testing. Thanks.

# Answer
Currently these features are not available in Postmaster. v1.2 is almost finished, but it wouldn't be a problem to add the following in the form a config override in the next version:

* Config var to disable all emails from being sent
* Config var to enable debugging (testing why emails are sent/not sent)
* Config var to disable all error messages (for production sites)

I use the Master Config bootstrap with multiple environment, so you can guarantee it will work for stuff like that too.

Email support\[at\]objectivehtml.com to get a copy of the latest beta once it's available. (A valid license is required for beta access.)
> 1 votes

# Answer
If you're using the webserver email option for Postmaster, why don't you just override the smtp settings based on your environment.

```
$config['mail_protocol']    = 'smtp';
$config['smtp_server']      = '127.0.0.1';
$config['smtp_username']    = 'example';
$config['smtp_password']    = 'example';

```

If you're unfamiliar with multi-environment config setups, this is a good one:

https://github.com/focuslabllc/ee-master-config
> 2 votes

---
Tags: add-on, config, email, postmaster, config-overrides
---


# Question
Title: Two channel entries loops on one page, both with pagination
I am having some issues with pagination.

I have two channel entries loops on one template, both of which have pagination enabled.

One of the loops works fine but the second one, I guess is conflicting.

For example.. the second loop is duplicating the pagination segments in the url

domain.com/P1/P2 etc..

(I am also using this from Aaron Bushnell)

Is it even possible to work them independently on one template? Thanks!!

# Answer
> 3 votes
Try wrapping each channel entries and each pagination in a conditional. If the pagination layout is identical for each channel entry section then you can throw it in a snippet. It might look something like this:

```
{if segment_2 == "pancakes"}
{exp:channel:entries channel="pancakes"}
    {title}
    {sn-pagination}
{/exp:channel:entries}

{if:elseif segment_2 == "waffles"}
{exp:channel:entries channel="waffles"}
    {title}
    {sn-pagination}
{/exp:channel:entries}
{/if}

```

# Answer
> 3 votes
I would do the same as Stuart McCoy, but performance wise it's better to use switchee instead of the native advanced conditionals.

```
{exp:switchee variable = "{segment_2}" parse="inward"}

{case value="pancakes"}
    {exp:channel:entries channel="pancakes" dynamic="off"}
      {title}
      {sn-pagination}
    {/exp:channel:entries}
{/case}

{case value="waffles" default="Yes"}
    {exp:channel:entries channel="waffles" dynamic="off"}
      {title}
      {sn-pagination}
    {/exp:channel:entries}
{/case}

{/exp:switchee}

```

don't forget to add the dynamic="off" param!

---
Tags: ajax, jquery, pagination
---


title: EE Calendar Tag & Low Yearly Achives

text:
# Question
Title: EE Calendar Tag & Low Yearly Achives
Im using Yearly archives to display articles by month:

```
{exp:low_yearly_archives channel="news" start_month="1" status="not closed" sort="desc" show_future_entries="no" start_year="" end_year=""}
  {months}
    {if num_entries > 0}
      {month} / {num_entries}
    {/if}
  {/months}
{/exp:low_yearly_archives}

```

I also have the EE mini calendar tag in my template.

**I'm trying to get the calendar tag to display the current month regardless of the url created by yearly archive tag.**

For example, I want December to show in the calendar tag but if I click on month links created by Yearly archive such as January and the url becomes: `news/month/2012/1/` the calendar changes to January and doesnt say on December. Ive tried playing about with `dynamic="no"` to no avail.

The beginning of my calendar tag looks like this:

```
{exp:channel:calendar channel="events" switch="calendarToday|calendarCell" start_day="monday" leading_zeroes="yes" show_future_entries="yes" show_expired="no" dynamic="no"}

{date format="%F %Y"}

```

Any ideas. Thanks

# Answer
> 5 votes
As I stated in the GetSat thread as well, this isn't an issue that has anything to do with Low Yearly Archives per se. It's native behaviour for the channel:calendar tag to change the month displayed by what's present in the URI. Even if you *didn't* put a LYA tag there, you'd still be able to change it by just simply adding `/YYYY/MM` to the URI.

That said, you should probably look at the `month=` and `year=` parameters and hard-code them using `{current_time}`. Something like this:

```
{exp:channel:calendar
    channel="events"
    month="{current_time format='%m'}"
    year="{current_time format='%Y'}"
    ...
}

```

Untested, but I'm guessing that's your best bet.

---
Tags: ee2, url, low-yearly-archives
---


# Question
Title: Setting a primary category for content entry
At the moment I can add multiple categories to a post which is fantastic. Is there a way to specify which of the selected categories is the primary category for that content?

The reason that I want to select the primary category is to present a clear breadcrumb trail.

For example an article of content could have the following categories:

```
A
   B
      C *
   D *
       E
F *
   G
   H

```

But the bread crumbs should reflect the primary category "C" (for example).

A \> B \> C \> The Content Title

# Answer
There's a commercial addon called Primary Category by Solspace which is what you are probably looking for.
> 6 votes

# Answer
I'd continue using the traditional method of defining categories associated with your entry, but, in order to specify the "primary" category, I'd use an add-on like Lonely Cat, which allows you to store a single category in a channel field. Then, I'd use that primary category to feed an add-on like GWcode Categories, which should be able to generate the categorical portion of your breadcrumb structure.
> 4 votes

---
Tags: ee2, categories
---


# Question
Title: How to trace channel fields when there is a relationship?
I need to write a custom query against the `exp_channel_data` table. However, one of the channel's field is a relationship field. How do I track that back to the appropriate column in the `exp_channel_data`?

I've looked in the `exp_channel_fields` table and found the relationship's `field_id` (say it's 10). However, when I look `exp_channel_data`.`field_id_10`, I just see some number in it. I was hoping it would give me the entry id of the row it's related to. Any ideas how to do this? I'm trying to do a JOIN based on the entry id.

# Answer
> 2 votes
The number that you are seeing in field\_id is the `rel_id` from the `exp_relationships` table in that table you have access to the child and parent id's so that you can build your query.

# Answer
> 1 votes
I would do something like this:

```
SELECT *
FROM exp_channel_data
INNER JOIN
exp_channel_titles
ON
exp_channel_title.entry_id = exp:channel_data.entry_id

```

To get the join right for the two main tables, but what kind of information do you need exactly from the relationship field?

---
Tags: channel-entries, database
---


title: Recording failed orders?

text:
# Question
Title: Recording failed orders?
Store 1.6.1 and Latest EE

Using PayPal Express. When a customer is transfered to PayPal but then decides to back out of the purchase, either by clicking the return to vendors website link or simply going else where - the failed order details are not recorded in Store (or am I wrong?). Be nice if they were, as the store owner could then follow up and perhaps make a sale.

Thanks Lee

# Answer
You should be able to see any failed orders by going to Orders under the Store dropdown menu and then clicking the Filter By Order Status dropdown and selecting Incomplete.
> 5 votes

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


# Question
Title: 404 page as a Page - is this doable/reasonable?
I am a little shaky on how a 404 that returns the proper information should be setup. Right now, I have a 404 template that I note in my .htaccess as my 404 page. I was considering switching this to a page in EE's Pages module. Is this compatible with a proper 404 setup?

# Answer
Your biggest point of attention should be the response header for your URL. EE will take care of setting it as a 404 response provided you have selected the template in use in the Global Template Preferences seen below. (Docs reference)

I'd recommend using a template rather than an entry + pages module. It's just simpler that way.
> 9 votes

# Answer
You don't need to use the Pages module, but you can use a channel entry to make the 404 page more dynamic, it just needs a dedicated template in order for the ExpressionEngine 404 handling to work correctly.

Often I'll simply duplicate my standard page template to be my 404 template and just hard code the entry in, instead of dynamically loading it from the URL.
> 3 votes

# Answer
You might find *Guide to 404 Pages with ExpressionEngine* useful:

http://joviawebstudio.com/index\_ee.php/blog/guide\_to\_404\_pages\_with\_expressionengine/
> 3 votes

---
Tags: module, pages, 404
---


# Question
Title: How to structure a category listing template?
What is the best way to create a category listing page where the category name is used in both the `<head>` and `<body>` tags?

This is what I have at the moment:

```
<!DOCTYPE html>
<html lang="en">
<head>
    {exp:channel:category_heading channel="news"}
        {if category_name}
            <title>{category_name} - News - {site_name}</title>
        {if:else}
            <title>Archive - News - {site_name}</title>
        {/if}
    {/exp:channel:category_heading}

    {common-page-head}
</head>
<body class="news-listing listing">
    {exp:channel:category_heading channel="news"}
        <h1>{category_name}</h1>
        {if category_description}
            <p>{category_description}</p>
        {/if}
    {/exp:channel:category_heading}

    {exp:channel:entries channel="news"}
        <article class="news">
            <h2>{title}</h2>
            {body}
        </article>
    {/exp:channel:entries}
</body>
</html>

```

Whilst this works, is it bad to have the `{exp:channel:category_heading}` tag twice on the same template? (i.e. excess queries).

Is there a way to place the page title into a temporary variable which can then be reused to avoid performing the same queries multiple times?

# Answer
For the title in the head I'd use Low Title:

```
<title>{exp:low_title:category url_title="{segment_n}"} - News - {site_name}</title>

```

Assuming you're looking to just list the category and its description for the article below, for the body you can just use Channel Entries and Low Seg2Cat:

```
{exp:channel:entries channel="news" category="{segment_n_category_id}"}
{categories}
    <h1>{category_name}</h1>
    {if category_description}
        <p>{category_description}</p>
    {/if}
{categories}
{/exp:channel:entries}

```
> 5 votes

# Answer
I can think of a couple solutions for you.

**Low Seg2Cat**

Since you're only using the category name in the title in the `<head>`, you could very easily use Low's excellent Seg2Cat extension. I use it on nearly every site, and it's great for grabbing all of your basic category metadata based on categories found in URL segments.

Assuming your url structure is something like `example.com/template/category/blue`, you could simply use `{segment_3_category_name}` in your title tag to output the displayed category name.

**Stash**

A more complicated method, which I frequently use as well is the Stash method. This would require that your header is added using an `{embed=""}` tag or that you're following the Stash Template Partials Method. I won't go into a ton of detail about how this would work, but basically within your one `{exp:channel:category_heading ...}` tag pair, you would use the Stash tags to set a variable containing the category title, which could then be output in your embedded template.

Example category template:

```
{embed="inc/header"}

<body class="news-listing listing">
    {exp:channel:category_heading channel="news"}
        <h1>{category_name}</h1>
        {if category_description}
             <p>{category_description}</p>
        {/if}
        {exp:stash:set_value name="category_title" value="{category_name}"}
     {/exp:channel:category_heading}

    {exp:channel:entries channel="news"}
         <article class="news">
            <h2>{title}</h2>
            {body}
         </article>
    {/exp:channel:entries}
</body>

```

Example head template:

```
<!DOCTYPE html>
<html lang="en">
<head>
    {if {exp:stash:not_empty name="category_title"}}
        <title>{category_title} - News - {site_name}</title>
    {else}
        <title>Archive - News - {site_name}</title>
    {/if}

    {common-page-head}
</head>

```
> 6 votes

---
Tags: ee2, templates, categories
---


# Question
Title: Need to list all channel:entries, and do something different on "some" of them
I have a need to pull all entries (in this case only 20 or so) from a channel, and have 5 random results do something different to the other 15. What's the best way to achieve this?

# Answer
I'm not sure there is a plugin already written that does this, but it'd be pretty easy to write one or, use PHP in the template to do the same thing.

Basically, you want to generate a list of entries to be selected first, outside the `{exp:channel:entries}` tag pair.

Then, inside the tag pair, you'll just check to see if the current `{count}` is in the array.

Something like this should work:

```
<?php
   $max = 20;
   $numels = 5;
   $range = range(0, $max);
   $vals = array_rand($range, $numels);
?>

{exp:channel:entries ... }
   <?php if(in_array('{count}', $vals)):?>random-entry<?php endif;?>
{/exp:channel:entries}

```
> 3 votes

# Answer
I did this in the end like so:

```
<?php
$randoms = array();
?>
{exp:channel:entries channel="styleguide" disable="categories|category_fields|member_data|pagination|trackbacks" dynamic="no" limit="5" orderby="random"}
<?php
array_push($randoms, '{entry_id}');
?>
{/exp:channel:entries}

<ul>
{exp:channel:entries channel="styleguide" disable="categories|category_fields|member_data|pagination|trackbacks" dynamic="no" orderby="title" sort="asc"}
    <li>
        <?php
        if (in_array('{entry_id}', $randoms)) {
            echo 'hoorah';
        }
        ?>
    </li>
{/exp:channel:entries}
</ul>

```

Except I removed the first entries pair and replaced it with a simple SQL query.
> 0 votes

---
Tags: entries
---


# Question
Title: How can I display sales tax in order confirmation email
I am trying to display sales tax in the order confirmation email but it does not appear to be available. Can I add my own variables that I want to make available in the email? If so, how and where would I do that?

thanks!

**Update specifics**

ah, well.. I thought that this **was** the support forum for the actual module but wasn't paying attention that it only said ExpressionEngine and not the actual module.

Anyway EE **v2.4.0 - Build: date 20120123** and it is the **Store** module by **Exp-resso 1.5.3**

# Answer
> 1 votes
As people have said in the comments you should as as much information as possible about your setup so that we can provide accurate results.

**Exp:resso Store** If you are using Exp:resso Store there are a few options you can use. To display item specific sales tax you would want to use `item_tax` tag inside of the items loop

```
{items}
 Item Tax = {item_tax}
{/items}

```

If you want to display the tax for the entire order there are a couple tags you can use as mentioned in the docs

```
{order_subtotal_tax} = All the tax that is applicable to the orders subtotal
{order_shipping_tax} = The tax that is applicable to the shipping cost
{order_tax} = All the tax applicable to the entire order (includes subtotal and shipping)

```

You can also display the tax information such as name and rate with the followingL

```
{tax_name} = Value for the tax rate based upon your settings in the CP
{tax_rate} = Value like "0.10"
{tax_percentage} = Value like "10%"

```

**CartThrob** If you are using CartThrob you would need to add the custom fields that you assigned to store tax, subtotal plus tax, shipping plus tax fields depending on what you want.

**BrilliantRetail** If you are using BrilliantRetail you would want to use something like this I haven't used BR in a really long time so I am not 100% sure of their tag structure but looking through the included templates should help.

---
Tags: add-on, expresso-store, ecommerce, email, order-info
---


# Question
Title: S=5eb7474c89555... in URL? What is it? How do I get rid of it?
I setup the links in my header navigation using `{path='site'}`, `{path='about'}`, etc. When I view the rendered pages, the links have an extra parameter S=.

Examples:

```
http://example.com/index.php/S=5eb7474c89555bd5d9e41ec21a99566906803a2d/
http://example.com/index.php/S=5eb7474c89555bd5d9e41ec21a99566906803a2d/site/about

```

What is the S parameter and how do I get rid of it?

I thought perhaps it was session variable or something, but I can't seem to find any information about it in the user docs.

Any assistance is appreciated.

# Answer
Hi if you go to admin \> security & privacy \> security and session preferences. Then change the user session type to "cookies only" and you should be fine.
> 12 votes

# Answer
You have to set User Session Type to Cookies in Admin =\> Security & Privacy =\> Security and Sessions.
> 5 votes

---
Tags: url, navigation
---


# Question
Title: Hiding/Showing Google Maps for ExpressionEngine
Using Objective HTMLs "Google Maps for ExpressionEngine" we can get the 3 maps from this query to show:

```
{exp:channel:entries channel="events" orderby="events_start_date" sort="desc"}
    {if count == 1}
    {exp:gmap:init id="map{entry_id}" class="google-maps" style="width:100%;height:380px" scrollwheel="false"}
    {exp:gmap:marker id="map{entry_id}" latitude="{events_map_latitude_field}" longitude="{events_map_longitude_field}" zoom="16"}
    {if:else}
    {exp:gmap:init id="map{entry_id}" class="google-maps" style="width:100%;height:380px" scrollwheel="false" script_tag="false"}
    {exp:gmap:marker id="map{entry_id}" latitude="{events_map_latitude_field}" longitude="{events_map_longitude_field}" zoom="16"}
    {/if}
{/exp:channel:entries}

```

The maps are in a div that uses jquery show/hide and the maps only show the first tile and the map is not centred correctly. If the show/hide is disabled the maps render correctly.

Is there a way to overcome this issue with maps and jquery?

# Answer
There are a lot of ways to solve this problem, so the best one will be the one that works best with your code. Below is a basic example of how to redraw the map when a trigger is clicked. Essentially, when a tab or an accordion is clicked, the map goes from hidden to visible. If the map was hidden before it was totally initialized, it will not get rendered correctly - which is why it needs to be redrawn.

```
$(document).ready(function() {

    // Trigger represents any selector you want to trigger the map to be redrawn

    $('.trigger').click(function() {

        var $t     = $(this);
        var id     = $t.data('id');
        var map    = window[id+'_map'];
        var center = window[id+'_options'].center;
        var bounds = window[id+'_bounds'];
        var delay  = 500;

        /* Allows the animation to start before the map is redrawn,
           the 500(ms) can be adjusted for optimal performance.
           If no animation is present, use 0 or remove the delay
           entirely. */

        setTimeout(function() {
            google.maps.event.trigger(map, 'resize');

            for(var x = 0;x < markers.length;x++) {
                bounds.extend(markers[x].getPosition());
            }

            // This will center the map on the calculated bounds
            map.fitBounds(bounds);
            map.setZoom(options.zoom);

            /* Do not use setCenter and fitBounds, use only the one that works best for you */

        }, delay);

        return true;
    });

});

<!-- Use the data-id property to map the specific map ID -->

<a href="#" class="trigger" data-id="map">Redraw Map</a>

```

One thing to note is the center variable. This script uses the map's default. Some people prefer to redraw the map according to the auto-calculated bounds (to fit all the maps in the same view) - if that is the case, use the **bounds** variable.
> 8 votes

# Answer
Your issue is answered here I believe: https://stackoverflow.com/a/3066751/135935

I recently fixed the same problem by changing my CSS to use the off-left positioning suggested in the answer. Worked perfectly.
> 4 votes

# Answer
Thanks Justin for this example.

I have placed that JS at the bottom of my page and updated my gmap code to:

```
{if count == 1}
    {exp:gmap:init id="map{entry_id}" class="google-maps" style="width:100%;height:380px" scrollwheel="false"}
    {exp:gmap:marker id="map{entry_id}" latitude="{events_map_latitude_field}" longitude="{events_map_longitude_field}" zoom="16" extend_bounds="false" center="{events_map_formatted_address}"}
{if:else}
    {exp:gmap:init id="map{entry_id}" class="google-maps" style="width:100%;height:380px" scrollwheel="false" script_tag="false"}
    {exp:gmap:marker id="map{entry_id}" latitude="{events_map_latitude_field}" longitude="{events_map_longitude_field}" zoom="16" extend_bounds="false" center="{events_map_formatted_address}"}
{/if}

```

As you suspected it centers on the middle of the ocean. Obviously I haven't told the map enough about centering - can you see where I've gone wrong?

Thanks
> 1 votes

# Answer
Can't beat the answer from Justin but I had a similar issue with MX Google Maps. Its definitely all about redrawing the map.

Why is MX Google Map not resizing in tab?

This was the javascript I used to refire/redraw the map.

```
$('a[data-toggle="tab"]').on('shown', function (e) {
google.maps.event.trigger(map, 'resize');
map.setZoom( map.getZoom() );
});  // refire the map

```
> 0 votes

---
Tags: ee2, jquery, google-maps, google-maps-for-ee, twitter-bootstrap
---


# Question
Title: How can I filter entries by category and/or year on the frontend?
On a current site the I have news entries archived by:

* Year (using Zoo Triggers)
* Category

In the sidebar of the each news template (index & detail) it simply lists the years entries appeared in and below that is another list of the categories the entries are categorized in. E.G.:

Yearly Archives

* 2012
* 2011
* 2010

Category Archives

* Category 1
* Category 2
* Category 3

Instead of static lists now the client is asking me to make each year and category a check box that can allow the user to select the years and categories of the entries they would like shown.

Examples include selecting:

* Category 1 + 2011 | shows all entries from Category 1 AND from 2011
* Category 2 + Category 3 | shows all entries from Category 2 OR Category 3
* 2012 + 2010 | show all entries from 2012 AND 2010

The only catches are:

* Site uses Structure
* Zoo Triggers is set up for yearly and category archives

My questions are:

* Is it possible to do this natively?
* Are there any add-ons available that I don't know about that can achieve this?

From my digging it looks like I should be looking at this as a custom "search" but I want to cover my bases first.

# Answer
> 1 votes
Don't think this is 100% suited to your requirements as I'm unfamiliar with Zoo Triggers but I needed to pull back Entries by year on a recent project and used:

**Year Archives:** https://github.com/ryanirelan/ri.yearlist.ee\_addon.2.0

Hope that's of use.

# Answer
> 0 votes
Why not skip EE altogether and use jQuery Isotope? Your lists would be generated by EE of course but each would have a class applied and filtering would happen via JavaScript. If not then you're probably better off making life easier on yourself and using Low Search.

---
Tags: category-archive, zoo-triggers
---


title: How to set and access session in EE?

text:
# Question
Title: How to set and access session in EE?
SEE: http://ellislab.com/forums/viewthread/224965/

I need to display something to the user only once. How do I do this in the templates? My idea is to store a value in session and use it to decide whether to output this something or not. Any ideas what I should do in EE?

# Answer
There is no native way to store session information, but there is an add-on, Session Variables, which does exactly what you're looking for.
> 5 votes

---
Tags: templates, sessions
---


# Question
Title: Expresso Store - possible to add 'OUT OF STOCK' to size drop down?
I'm building a Store selling garments using Size as the Product Modifier option and variation as the modifier Type so that each size has it's own SKU and Inventory.

My Size drop down looks like this on the product detail page:

* Small
* Medium
* Large

Is it possible to add 'Out of Stock' or 'In Stock' to the select options depending on individual stock levels so the drop down looks like this:

* Small - Out of Stock
* Medium - In Stock
* Large - In Stock

Thanks in advance

# Answer
The main problem is that options don't always have a direct mapping to a stock level. For example, if your products have both "Size" and "Color", it doesn't make sense to say "Red is out of stock" - it depends on the size as well.

Generally the best way to solve this is using dynamic css variables. For example, simply add `class="store_product_out_of_stock"` to an element inside your product tag, and it will be displayed only when the selected combination is out of stock.

Alternatively, *if all your products have exactly one modifier*, you can use the `{option_stock_level}` variable inside the `{modifier_options}` loop. This is somewhat of a hidden feature, because generally it's not a good idea to hard code this if your products might have more than one modifier.

```
{modifiers}
    {modifier_options}
        {option_name}
        <!-- the following variables are only available if
             your product has exactly one modifier -->
        {option_sku}
        {option_track_stock}
        {option_stock_level}
        {option_min_order_qty}
    {/modifiers_options}
{/modifiers}

```
> 8 votes

---
Tags: expresso-store, modifiers, drop-down, out-of-stock
---


# Question
Title: Trigger a 404 on a /news index which has categories and pagination running through it
I've yet to come up with a decent solution for this so thought I'd throw this out there.

Basically I have a /news/index template, it serves the initial set of news results, and also serves up paginated results and category results, for example:

* /news/P10
* /news/category/blogging

My question is: What is the best way to get EE to throw a proper 404 error on a url like /news/foo

Most sites I've seen don't cater for this, even Ellislab: http://ellislab.com/blog/foo

But I do see the clever folks at FocusLab have it nailed (http://focuslabllc.com/blog/foo) :)

Any suggestions/tips ?

# Answer
Following on from Eriks post, I've created a global variable for detecting whether the page is a pagination page, and it's set in my master config:

```
$vars['global:is_pagination'] = (preg_match('/P[0-9]+/', $_SERVER['REQUEST_URI'] )) ? TRUE : FALSE;

```

and then in my news/index

```
{if segment_2 != '' && segment_2 != 'category' && global:is_pagination == ''}
{redirect="404"}
{/if}

```

So essentially:

1. if a segment 2 exists
2. AND it's not 'category'
3. AND it's not pagination, throw a 404.

Thanks Erik!
> 6 votes

# Answer
We sometimes use

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

```

In instances where {segment\_3} is the feeder.
> 5 votes

# Answer
Mel touched on part of our approach. We use the `require_entry` parameter in most `channel:entries` loops. That's part of the process. Next, we imploy multiple conditionals to check for URL ~~hackers~~ errors.

**General URL Structure**

We like pretty and concise URLs so our `blog/index` EE template looks like this in its entirety:

```
{!--
/**
 * blog/index is a master template that just embeds 1 of 2 other templates based on segment 2. Pretty basic stuff.
 * We're using a custom built extension which registers a global variable "is_pagination_page" so we can use
 * the URL structure we want. It's very basic and I couldn't find any existing add-ons that did what I wanted
 * Add-ons that came close: MD Detect Page Type & Freebie. No dice though.
 */
--}
{if segment_2 == '' OR segment_2 == 'category' OR is_pagination_page}
    {embed="blog/_list"}
{if:else}
    {embed="blog/_entry"}
{/if}

```

The `is_pagination_page` global is exactly what the code comments describe.

**Blog single entry sample code** (`blog/_entry`)

```
{exp:channel:entries
    channel="blog"
    disable="category_fields|trackbacks"
    limit="1"
    require_entry="yes"
}
{if no_results}{redirect='say-what'}{/if}
{if segment_3 != ''}{redirect='{segment_1}/{segment_2}'}{/if}
...

```

**Blog listing page** (`blog/_list`)

To check category url pages we use Low Seg2Cat to make sure it's a legit category. (It it's not a real category, the global variable Seg2Cat creates is an empty string.)

```
{if segment_2 == 'category' && '{segment_3_category_name}' == ''}
    {redirect='say-what'}
{/if}

```

I hope this helps. It's exactly what we have setup on focuslabllc.com right now. We have some 404 checks on other sections but these seem to be the ones applicable to the question at hand.
> 3 votes

# Answer
what about using require\_entry="yes"

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

Then {if no\_results}{redirect="404"}{/if}
> 2 votes

---
Tags: templates, 404
---


title: SSL misdirected with MSM

text:
# Question
Title: SSL misdirected with MSM
I'm running into an issue trying to use SSL for a registration form on an MSM set-up.

When viewing pages via https on SITE A, the EE globals/paths are getting set incorrectly to SITE B instead of SITE A. For example:

```
{stylesheet='_css/styles.css'}

```

when viewed securely on SITE A, shows

```
https://SITEB.com/eeindex.php?css=_css/styles.css.v.1354718804

```

and

```
<a href="{path=LOGOUT}">Log Out</a>

```

viewed securely on a page on SITE B shows up as

```
https://SITEB.com/eeindex.php?ACT=10

```

When the page is viewed with just http://, it works fine.

Any ideas on how to fix this?

Thank you,

Paula

# Answer
Go into Admin -\> System Administration -\> Output and Debugging and turn on the Output Profiler, then look at the config variables displayed there. If you find one pointing at the wrong place, that is probably the place to look for the culprit. My best guess would be in the index.php for site a.
> 2 votes

# Answer
Are you logged in when experiencing this problem? Or, put another way, does this problem occur when you are **not** logged in? It appears that EE's `fetch_site_index` method is cached, so the base URL could theoretically be persisting across sites. Just something to try—I haven't thoroughly tested this yet.
> 0 votes

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


# Question
Title: how could you only email users that have entered something in a channel?
I would like to send an email to users who have submitted an abstract in the abstracts channel, but leave out users who have not submitted anything.

**what would be the best way to achieve this?**

I personally would just create a template, then have my abstract authors emails listed, and from there, ask my client to copy paste the list into his email app...

something like this:

```
{exp:channel:entries channel="abstacts"}
    {embed="_includes/_get_author_email" author_id="{author_id}"}
{/exp:channel:entries}

```

but I'm sure there's a better way to do this!
any thoughts?

# Answer
> 5 votes
Easiest method is to use the query module and get the distinct email addresses from all the authors to a particular channel.

This would list all the emails for authors in channel\_id 12

```
{exp:query sql="SELECT DISTINCT exp_members.email
            FROM exp_members
            LEFT JOIN exp_channel_titles
            ON exp_members.member_id = exp_channel_titles.author_id
            WHERE exp_channel_titles.channel_id = '12' "}
    {email}<br />
{/exp:query}

```

Simply swap out the 12 with the channel ID of your 'abstracts' channel.

---
Tags: email, list
---


# Question
Title: search:field_name= and special characters
I have a client site who is pulling in channel entries with dollar amounts in them; most of the dollar amounts are regular numbers, 2000, 100, etc., some are negative amounts (chargebacks?), -1600, etc., and some are just a dash "-".

I'm trying to filter the just dash "-" entries out of the results.

The parameter

```
search:tax_deductible_amount="not -"

```

removes all negative and just dash entries; however, the parameter with exact matching

```
search:tax_deductible_amount="=not -"

```

returns everything. Does it not recognize special characters?

Help?

Thanks!

# Answer
> 5 votes
I've just setup a few debug entries and excluding exact dash matches does seem to work.

```
{exp:channel:entries channel="about" search:about_body="=not -"}

```

All I can suggest is that you double-check that there's no whitespace surrounding your data and that you aren't being caught out by fancy dashes.

# Answer
> 1 votes
You might want to try the add-on Search Fields:

http://devot-ee.com/add-ons/search-fields

...if you can't get it to work with the Channel Entries tag. Search Fields is free and offers some other searchoptions too.

---
Tags: channel-entries
---


title: How to filter channel by numeric field?

text:
# Question
Title: How to filter channel by numeric field?
If I have a channel with the custom field "Age" (numeric type) how can I filter the channel so that only entries with `"Age" >= 24` are shown?

Likewise what would be the way to define and filter a custom field using a date?

Would this require custom SQL statements or could this be achieved using the `exp:channel:entries` tag?

# Answer
I don't think either of these things an be accomplished through the exp:channel:entries tag. I'm sure you could accomplish both of these things through the exp:query tag

as an example of filtering based on a field I know contains only numbers:

```
{exp:query limit="5" sql="SELECT title, entry_date, field_id_5
  FROM exp_channel_titles AS titles, exp_channel_data AS data
  WHERE titles.entry_id = data.entry_id AND titles.entry_id > 900"}
    <p>{title} - {entry_date format="%Y %m %d"} - {field_id_5}</p>
{/exp:query}

```

On your second question, there is a date fieldtype, in ee but it doesn't allow for sorting based on that date in the channel:entries tag, just displaying the output formatted as a date. To filter using the queries tag on dates, you need to be aware that the dates are stored as a unix timestamp. If you wanted to query on your custom date field (here field\_id\_262) being between 14 and 7 days ago:

```
{exp:query sql="SELECT titles.title, data.field_id_262
  FROM exp_channel_titles AS titles, exp_channel_data AS data
  WHERE titles.entry_id = data.entry_id
  AND data.field_id_262 > ((unix_timestamp(Now()))-(14*86400))
  AND data.field_id_262 < ((unix_timestamp(Now()))-(7*86400))"}
    <p>{title} - {field_id_262 format="%Y %m %d"}</p>
{/exp:query}

```
> 3 votes

# Answer
A quick addendum to the other answers (which are both fine for reading back values): **it is possible (and often a good idea) to change a text input field's allowed content from the default "all"** to "integer", "number", or "decimal". You can do this on the edit field screen:

This is important to do if you then want to filter/sort values numerically rather than alphanumerically, ie if you want the set `[32,3,133]` to be sorted as `[3,32,133]` and not as `[133,3,32]`. It's also important for ranges, as selecting `< 4` from the above range will select `[3,32,133]` if the field's content type is 'all' but `[3]` if the content type is 'integer'

Internally these values map to MySQL's `TEXT` ('all'), `INT` ('integer'), `NUMERIC` ('number') and `DECIMAL` ('decimal') datatypes.

When bypassing the `channel:entries` tag and pulling data direct from the DB, I tend to use the **ActiveRecord plugin** rather than the `query` tag as:

* It's far more secure if you're inserting dynamic data into your query, eg from url segments (the `query` tag does not escape variables, whereas the AR plugin does).
* It syntax is much more readable, which helps you (or another developer) to work out what you was trying to do when you return to the code months later
* There's no need to use prefixes (`exp_`) when selecting tables
* It supports pagination
> 8 votes

# Answer
Whilst a custom query is a good solution, you could also look to stash!

```
//This reads all your entries and records them as a list
{exp:stash:set_list name="my_entries" parse_tags="yes"}
{exp:channel:entries channel="my_channel"}

    {stash:entry_title}{title}{/stash:entry_title}
    {stash:entry_id}{entry_id}{/stash:entry_id}
    {stash:theage}{my_age_field}{stash:theage}

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

//Using the list captured above, match an age (could be a segment as well) against
the age captured
{exp:stash:get_list name="my_entries" match=[#24#] against={theage} limit="10"}
    <p><a href="/my_template/{entry_id}">{title}</a></p>
    <p>This is item {count} of {total_results} rows curently being displayed.</p>
    <p>This is item {absolute_count} of {absolute_results} rows saved in this list</p>
{/exp:stash:get_list}

```

Just putting it out there :)
> 1 votes

---
Tags: ee2, templates, channel, filter
---


# Question
Title: Can jquery-based sorting or loading, like isotope or infinite scroll have a negative effect on for SEO?
I'm curious what the community thinking is on this point. While infinite scrolling may present a user-friendly tool for listing a large number of entries, isn't there potentially a downside from an SEO perspective IF the content in question doesn't have its own single entry screen which would expose an SEO-friendly semantic URL?

For blogs posts, for example, a common URL structure might be domain.com/blog to list most recent entries and a single blog post might be domain.com/blog/comments/entry-utl-title. EE then gives you a simple way to generate category-sorted lists using the category segment with something like domain.com/blog/category/category-url-title (and if you use addons you can also potentially achieve parenting segments, but not natively). I have to assume that the category url titles themselves are good for SEO as well, all things being equal.

A suggestion I was given for filtering content on the front end - particularly around filtering content with combinations of categories or other entry data - was a jQuery plugin called Isotope (in place of using EE's native advanced search, for example). It's a really interesting functionality for the user on the front end, but it got me thinking about the single-category-at-a-time URL structure I've often used. With an EE implementation of something like the isotope jquery plugin to use tags to filter and sort your list, the category URLs, no longer exist, do they? Or do you retain them as fallback if the user has javascript turned off? I'm wondering if you are giving up something by going that route, or is the combination of list view and single entry view enough?

# Answer
The 'proper' way to do this is to link as normal to single pages that show the entry detail but then use JS to hijack the link's target and pull in just the content via ajax.

I use the MX Ajax Detect add-on to make a single template respond differently (ie, returning a full page vs returning just chunks of content) depending on whether it was requested via ajax: http://devot-ee.com/add-ons/mx-ajax-detect

You can see this in action on this page: http://www.ceridian.co.uk/about \- clicking on the faces makes an ajax request for the content, while search engine robots will still be able to index the href of the anchor tags, even though regular users will not arrive at those pages.
> 7 votes

# Answer
In most cases you wouldn't want your category, tag or archive pages being indexed anyway as it's much more important that the single-entry pages are the ones that are ranking, and also because you can run into duplicate content problems if some pages show exactly the same listing of posts.

As long as your isotoped or infinitely-scrolling pages link through to individual entry pages, I don't really see a problem.
> 3 votes

---
Tags: categories, filter, seo
---


# Question
Title: Unable to install, system folder path does not appear to be set correctly
I am experiencing some weird behaviour here. I am installing EE fresh from the zip, no changes, no bootstraps or anything like that. However, the system folder path message keeps showing up. It doesn't really matter what i enter as a var, allways getting the message. I tried the var as it comes out of the box (./system), i tried a hard-coded server path (/home/pvfonds/public\_html/dev/system), and everything else i could think of.

# Answer
> 2 votes
Found out what the problem was. the server had some setting that set all filenames to lowercase. When this was turned off, everything worked...

# Answer
> 1 votes
More than likely permissions. Drop to a terminal prompt within the site folder and would run the following two commands:

```
find . -type d -exec chmod 755 {} \;
find . -type f -exec chmod 644 {} \;

```

This sets all folders with 755 and all files with 644 recursively. This is the default starting point before you have to set specific permissions for files such as config.php etc.

See how you get in with that.

# Answer
> 0 votes
It looks like you're trying to run the site in a sub-folder called `/dev`. Are the other sites also running in sub-folders and have you tried running the site just beneath `/public_html`?

---
Tags: ee2, path
---


# Question
Title: Should EE error messages give HTTP 200 responses?
The Google crawler sometimes hits URLs have ExpressionEngine error messages on them and caches them because they respond with HTTP 200.

These error messages are handled by the `show_user_error()` method. Before I go and start hacking core, am I correct in suggesting that these error messages show return an HTTP error?

If so, which HTTP status should it show (I'm thinking 403 Forbidden but perhaps there is a more precise status)

# Answer
**TL;DR?** Just leave it as it is.

### Request Codes

Before getting into this it's worth familiarising yourself with different HTTP request codes. A 200 header (the default) has the following meaning:

> The request has succeeded. The information returned with the response is dependent on the method used in the request, for example:
>
> * GET an entity corresponding to the requested resource is sent in the response;
> * HEAD the entity-header fields corresponding to the requested resource are sent in the response without any message-body;
> * POST an entity describing or containing the result of the action;

In instances where an app has hit an exception it's common to send HTTP 500 headers:

> The server encountered an unexpected condition which prevented it from fulfilling the request.

Within the context of EE it's difficult to definitively state which headers should be sent with error messages. In apps that I've developed I've used 500 headers only when an uncaught exception is triggered, since this represents an unexpected behaviour that the app is unable to process/work around. The request has failed in a manner that wasn't/could not be anticipated.

If an expected error crops up, such as validation failure, I'll implement any redirects/status messages as necessary, but I won't send a 500 header. The request has 'succeeded' in the sense that 'an entity corresponding to the requested resource \[was\] sent in the response'.

With EE, error messages can crop up for both expected and unexpected errors, as there's no granularity to the native error handling. It doesn't matter whether someone's forgotten to enter their email address or a required extension could not be loaded, the same error handler is used.

There's a very strong argument that EE should have its error handling beefed up significantly, but with the current system it's debatable whether the `show_user_error` method should send non-standard headers. In some situations it might be appropriate, in others it wouldn't be. Throw in the fact that core modifications are generally inadvisable and I'd suggest that you're better off sticking to the default behaviour.

### Search Engines

A typical production EE site will only be displaying errors for validation issues, so error pages should never be indexed (as search engines don't `POST`). If your site is frequently returning errors for `GET` requests I'd have thought you'd want to focus on the underlying cause of those errors, rather than stopping them from being indexed.
> 6 votes

# Answer
Before you hack the core you can check out this add-on ($12):

http://devot-ee.com/add-ons/custom-system-messages

It allows you to use your own defined templates in case of an error. In the template you can use PHP, and thus send different headers.
> 0 votes

# Answer
Add meta no-index to your message templates:

`<meta name="robots" content="noindex">`
> 0 votes

---
Tags: http
---


# Question
Title: Importing content from EE1 into an existing EE2 website
We have a use case where we need to import content from an EE1 website to an EE2 website (with existing content). I'm guessing it has to be a custom scripting job, but asking here in case someone knows a smart way of doing this.

One idea I guess is to use DataGrab for the import, but we'd still need to do an export from EE1 in XML (or another format which can be read by DataGrab).

# Answer
> 4 votes
If you just need to export your weblog entries, you can use this add-on for EE1:

http://devot-ee.com/add-ons/weblog-entries-exporter

> This is a module for EE1; it basically allows CSV/XML export of weblog entries (if you choose XML it also deserializes the data in serialized fields).

# Answer
> 4 votes
I generally use a custom script to export data into XML files by channel, doing any manipulation of image paths, etc on that side.

Than I use DataGrab to import everything.

One tip, make sure you export and import an ID field from your old system, so you can update an import later without deleting all the entries if you realize something didn't export correctly.

---
Tags: ee2, ee1, export, datagrab
---


# Question
Title: What's the best way for displaying a three-level category tree?
What I'm trying to achieve is the following:
A three-level 'category' tree, with at the end channel\_entries. So users can browse between categories & access the entries related to that category.

* Category A
    + Category A.1
        - Entries
    + Category A.2
        - Entries
* Category B
    + Category B.1
        - Category B.1.1
            * Entries
        - Category B.1.2
            * Entries
* Category C

I'm already using the **Child Categories**-plugin,
but it seems like you can't access categories in such 'depth':

> Hi,
> This add-on supports only 2 levels of categories, i.e. you can display parents and children,
> but not grandchildren.

I also tried a combination between the native category tag & child categories,
but no success so far...

Or am I better off by writing a custom query?

What's the best way to approach this?

# Answer
I would go with gwcode-categories: **it allows you to target categories by depth**.

F.ex:

```
{exp:gwcode_categories channel="example" depth="3"}
    {cat_name}
{/exp:gwcode_categories}

```

You can find more info in the docs.

Anyway, your code should be something along these lines:

```
{exp:gwcode_categories channel="example"}
    {cat_name}
    {if depth == 3}
        <ul>
            {exp:channel:entries channel="example" category="{cat_id}"}
                <li>
                    {title}
                </li>
            {/exp:channel:entries}
        </ul>
    {/if}
{exp:gwcode_categories channel="example"}

```
> 6 votes

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


# Question
Title: If I add a plugin like Widon't to nearly every content field on a page, will performance be impacted?
I have a tempermental layout (and client) that seems to cause many widows in my content blocks. I'm planning to make use of Low Widon't to correct this programmatically but before I do, wanted to ensure there wouldn't be a performance hit by running that plugin upwards of 30 times per pageview.

# Answer
> 11 votes
> If I add a plugin like Widon't to nearly every content field on a page, will performance be impacted?

Short answer: **Yes**

The next question though: **How much?**

My suggestion in times like these is to implement the plugin as intended and run metrics against with and without it. Use either siege or ab in the command line to test varying loads on the page.

If you're not interested or able to run those types of tests you can use the Template Debugger and watch the time added to process the page with and without the plugin addition.

Ultimately if this is a problem that needs to be fixed, you can cache the results to mitigate performance problems. Caching isn't always the answer to a performance problem, but it has its place :)

# Answer
> 11 votes
The more methods you call (which is what you do with a plugin or module tag) the longer it will take to process it. So, as Eric said, yes. It will affect performance when you compare it to omitting it altogether.

However, it's never as black and white as this. The amount of time a tag takes to process differs. It depends on all sorts of things. In the case of Widon't, it's just a simple string manipulation, so that hardly takes any time at all. Other plugins/modules might query the DB, and that can be a much, much bigger impact on performance, especially if no caching is applied.

But, in your case, it shouldn't matter all that much. It will be hard to tell the impact, if noticeable at all.

# Answer
> 4 votes
The short answer is that this add-on is fine.

The longer answer is that you should be regularly monitoring the performance of the site as you are building it so that you are aware of issues when the appear.

Use your template debugger and list of queries so that you can see what's going on with each page load and what might be eating up a lot of resources.

http://ellislab.com/expressionengine/user-guide/cp/admin/output\_and\_debugging\_preferences.html

Use tools such as Pingdom to help monitor your page load speed.

https://www.pingdom.com/

Use caching where it makes sense (probably best to scan articles at this site to see what options are available for caching.)

Look through the general ExpressionEngine guide for performance.

http://ellislab.com/expressionengine/user-guide/general/caching.html

Do a general search with Google and Devot-ee to see what resources and add-ons are available for better performance.

From the above resources, you should know what is happening with your site and what tools are available to deal with problems as they appear. With this information, you should be able to answer your own questions on which add-ons may be causing problems.

You also need to have a general goal for what is acceptable for page load speeds. Different pages may have different goals (landing pages need to load as fast as possible, inner pages may be fine with slower loading speeds.)

Finally, tune your site performance to match your goals.

---
Tags: performance, plugin
---


# Question
Title: How to create a hybrid gallery with Images & Videos?
Trying to avoid using Matrix in this case but have an easily managed interface for the user.

Each will be a mini-gallery for a product page so would also prefer to avoid setting up a media channel and assigning media via a Playa field.

I like Channel Images - but not possible to chuck a video in the middle of all those images.... right?

What kinds of solutions have you used to combat the images/video hybrid gallery dilemma?

# Answer
I agree with Tom's comment on your question - more details and/or a rephrasing would be beneficial. However I'm going to provide an answer in any case.

I think the best way is to use Matrix as you can set two columns one for video and one for an image. All you need to is provide instructions that the client should choose either a video or an image but not both. You can then add other columns as needed for caption, title or whatever.

This really is the best solution for you and I'm not sure why you would want to avoid matrix in this case.
> 5 votes

# Answer
*( follow-up on CreateSean's answer )*

If you don't want to use Matrix because you don't want to spend $55 for the license, you could always use this free alternative:

**Grid Lite**: http://devot-ee.com/add-ons/grid-lite

> Grid allows you to dynamically add / delete and sort rows of data similar to a spreadsheet. Each data row can have one or more cells which are assigned to different custom fields (right now is only next fields available: Text input, Textarea, Select box, Checkbox, Dates, File. )
> 3 votes

---
Tags: image-galleries, channel-images, video
---


# Question
Title: EE 2.5.3 "no access to the directory specified for this field" error when updating entries
An ExpressionEngine install has begun to throw a "no access to the directory specified for this field" error when my client and I try to save updated entries.

The error relates to three optional image fieldtypes. If no image is selected for any of the three fields using File Manager I get the error. If I select an image for each field the error does not occur.

Our EE install is up to date: 2.5.3 and I've already checked that permissions on the upload directories are correct.

The Ellislabs support forums have a couple of instances of the same error (example here) but no solution.

Any help greatly appreciated.

**Update**

I have just reproduced the error as a Super Admin and have a PHP error displayed on the Edit Entry screen:

```
A PHP Error was encountered
Severity: Notice
Message: Undefined index: filename
Filename: libraries/File_field.php
Line Number: 77

```

# Answer
> 4 votes
Make sure the member group you are testing is selected on the **File Upload Preferences** page under the **Restrict file uploading to select member groups** section.

**Control Panel Location:** Content ‣ Files ‣ File Upload Preferences

**EE Docs:** http://ellislab.com/expressionengine/user-guide/cp/content/files/file\_upload\_preferences.html#restrict-file-uploading-to-select-member-groups

---
Tags: ee2, file-manager
---