title: If statement inside a loop?

text:
# Question
Title: If statement inside a loop?
I am using the store finder module, and am trying to insert a "title" for each "state". If I have 20 stores in a certain state, I would only like to display the "title" once. Is there any way this could be done with an if statement? to kind of break the loop?

```
{exp:store_locator:stores}
<ul>
        <li style="width:260px; padding-right:20px; float:left; height:100px;">
            <h5>{name}</h5>

            {if address_line1 !=""}
            {address_line1}<br/>
            {/if}

            {city}, {state}
            {postal_code}<br />

            {if phone != ""}
            <strong>Phone:</strong> {phone}
            <br/>
            {/if}

            {if url != ""}
            <strong>Website:</strong> <a href="http://www.{url}" target="_blank">{url}</a>        <br/>
            {/if}
        </li>
    </ul>

    {/exp:store_locator:stores}

```

# Answer
> 2 votes
There is an add-on from EE Garage that I have used to do that on a store finder before.

It's called NSM Channels. http://ee-garage.com/nsm-channels

Not sure if there is something similar on Devot-ee.com for free, but I know this works.

# Answer
> 2 votes
You can use stash lists. Store the state separately. On output order by the unique states and use a nested get\_list to get the entries/stores per state.

*(example from Croxton slide: Stash core principles )*

```
{exp:stash:set_list name="my_stores" parse_tags="yes" scope="site"}
  {exp:store_locator:stores}
    {stash:item_state}{state}{/stash:item_state}
    {stash:item_name}{name}{/stash:item_name}
    {stash:item_info}
        {address_line1}<br>
        {city}, {state}<br>
        {postal_code}
    {/stash:item_info}
  {/exp:store_locator:stores}
{/exp:stash:set_list}

```

Then retrieve the unique states, and accompanying stores via:

```
{exp:stash:get_list name="my_stores" orderby="item_state" unique="item_state" scope="site"}
  <h2>{item_state}</h2>
  {exp:stash:get_list:nested name="my_stores" orderby="item_name" scope="site"
    match="#^{item_state}$#"
    against="item_state"
    prefix="result"}
      <h3>{result:item_name}</h3>
      {result:item_info}
  {/exp:stash:get_list:nested}
{/exp:stash:get_list}

```

Note: if you use conditionals, like in your example for address\_line1, etc., i'ld suggest adding the parameter parse\_conditionals="yes" in set\_list.

# Answer
> 1 votes
I think you'll need to enable PHP in the template, set it to parse on input and use it to store the value of {state} on each iteration of the loop, at the top of the loop check to see if state is equal to itself or not, if not the write out the value as a heading. :)

It's possible you might be able to achieve the same result with Stash but I'm not really familiar with that. :)

---
Tags: ifelse, loop
---


title: Alternative to MSM?

text:
# Question
Title: Alternative to MSM?
We're running several big sites on a MSM install, but we're finding it's becoming increasingly difficult to upgrade one site without breaking another. It's just become a tangled mess actually and we're also concerned about the ballooning size of the database as we opened up a user loyalty component to one of the sites.

Our only thought is to break each site into its own EE install, but how do still share posts across sites? JSON feed from one site with a Datagrab cron job on the other site? Any one have experience with a set up like this?

# Answer
That is a tricky one, but i would check out Open Api which is a nice api in which to perform CRUD operations, you might run into some cross-site ajax issues though, but it can definitely be done.
> 2 votes

---
Tags: multi-site-manager, datagrab, json
---


title: Multiple downloads with Cartthrob

text:
# Question
Title: Multiple downloads with Cartthrob
I've been tasked in researching whether CT is capable of multiple downloads. For example, if someone adds a CD to their cart and two, separate MP3 files. When the person checks out will the two MP3 files be available for download or can only 1 file be available? I can probably run this through to test it out but thought I would see if anyone knows before spending a few hours testing.. Thoughts?

# Answer
You can indeed have multiple downloads. You can use the `{exp:cart throb:download_file_form}` tag inside your loop for all the available downloads. There is a quick video that explains the download tag on Vimeo: Download Tag Video
> 1 votes

---
Tags: cartthrob
---


# Question
Title: Products not adding to cart (Exp:resso Store 2.0.6)
Running on my localhost, I can't get Store 2 to add products to the cart.

* I've completely removed my .htaccess file and set my index page to `index.php` to eliminate rewrites as a potential cause.
* You do not need to be logged-in to purchase (via settings)
* SSL is not required for checkout actions (via settings)
* Running EE 2.7.2 and Store 2.0.6

My template code looks like:

```
{exp:store:product entry_id="{entry_id}" return="cart/index" disable_javascript="yes"}
    <button class="btn">Add to Cart</button>
{/exp:store:product}

```

Which renders to:

```
<form method="post" class="store_product_form">
    <div style="margin:0;padding:0;display:inline;">
    <input type="hidden" name="return_url" value="cart/index">
    <input type="hidden" name="entry_id" value="2786">
    <input type="hidden" name="nosubmit" value="1">
    <input type="hidden" name="ACT" value="41">
    <input type="hidden" name="RET" value="book/[url_title_redacted]">
    <input type="hidden" name="site_id" value="1">
    <input type="hidden" name="_params" value="69KWfitkNRkGcCM70xb/xVBDRDgS8b+Gidj4Jm17QqWWwRtxKugeyL9rqZbeUJCEoAjGCVwAIpUaWG9crrWenIab/MHr9uS1p/7XVJNV9Ei5jfM0Crio4DhMjdb0GvizwuV4r5x2Qx3GlbWHpNJ9+RPXrGkZEamm/FaJJIaTBzM=">
    <input type="hidden" name="XID" value="785db0072762b9f7c3397ea0e4b95f9a5efbf092">
    </div>
    <button class="btn">Add to Cart</button>
</form>

```

After submission, I get to my **/cart** template, but only the contents of my `{if no_items}` conditional displays. Removing the `{if no_items}` conditional results in no output between the `store:checkout` tag pair at all.

Where to troubleshoot next?

# Answer
Add a item\_qty field to tell Store how many products to add to the cart.

```
<input name="item_qty" value="1">

```

---

Also, there is a debug tag that will help you see what's happening in your cart more clearly. Pop this into any of your templates:

```
{exp:store:checkout_debug}

```
> 4 votes

# Answer
I'm not sure this will help, but I have a the same setup to yours and I have found that product URLs that have a period do not add to cart while without do.

So for example "item\_no.2" will not add, while "item\_no2" will.

I'm currently trying to work out if it's related to buildwithstructure potentially.
> 0 votes

---
Tags: expresso-store, shopping-cart
---


# Question
Title: Alternative ways to pass embed variables
Is there an alternate way to pass embed variables other than passing them as attributes?

# Answer
> 3 votes
Not natively I believe.

I typically use Stash to do this nowadays. It will give you persistent variables as well as template inheritance so you can do things like this.

**Wrapper template**

```
<!DOCTYPE html>
<!-- paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/ -->
<!--[if IE 7]><html class="no-js lt-ie9 lt-ie8" lang="en"><![endif]-->
<!--[if IE 8]><html class="no-js lt-ie9" lang="en"><![endif]-->
<!--[if gt IE 8]><!--><html class="no-js" lang="en"><!--<![endif]-->

<head>

    <meta charset="utf-8" />
    <link rel="dns-prefetch" href="//use.typekit.com" />

    {if "{exp:stash:not_empty name='st_html_title'}"}<title>{exp:stash:get name="st_html_title"} - Site name</title>{if:else}<title>Site name</title>{/if}

    <meta name="viewport" content="width=device-width" />

    <link rel="shortcut icon" href="{site_url}/favicon.ico" />

    <link rel="stylesheet" media="screen" href="{site_url}/assets/css/screen.css" />

</head>

    <div id="maincontent" role="main">

        {!-- built wisth stash and template partial approach--}
        {exp:stash:get name="content"}

    </div>

</body>
</html>

```

**Partial template**

```
{!-- Layout used --}
{stash:embed:layouts:page}

{!-- Meta data --}
{exp:stash:set name="st_html_title"}Products{/exp:stash:set}

{!-- Build list --}
{exp:stash:set_list name="st_products_list"}
    {exp:channel:entries disable="categories|category_fields|member_data|trackbacks" channel="products" status="open" orderby="date" sort="desc" limit="10"}
        {stash:st_item_title}{title}{/stash:st_item_title}
        {stash:st_item_summary}{cf_product_summary}{/stash:st_item_summary}
    {/exp:channel:entries}
{/exp:stash:set_list}

{!-- Build page content --}
{exp:stash:set name="content"}

    {exp:stash:get_list name="st_products_list" prefix="stashprefix"}

        {if count == "1"}<ul>{/if}
            <li>
                <h2><a href="{st_url}">{st_title}</a></h2>
                <p>{st_item_summary}</p>
            </li>
        {if count == total_results}</ul>{/if}

        {!-- if no results --}
        {if stashprefix:no_results}<p>No Products Found</p>{/if}

    {/exp:stash:get_list}

{/exp:stash:set}

```

It takes a bit of time to wrap your head around that approach but it is worth it IMHO. Here are a few resources to get you started:

---
Tags: embeds
---


# Question
Title: Stash MVVM - A guide to what goes where?
Reading through the Stash Wiki and various Stack Exchange threads I found it difficult to try to fully wrap my head around the MVVM template model advocated by Mark Croxton.

This thread aims to provide a community Wiki with a concise and definitive explanation of what goes where and how they interact.

I'm very new to this model - so I'd appreciate any edits to correct mistakes. I'm not convinced my understanding of the partials part of the equation is right yet.

# Answer
## Snippets

Snippets are loaded in just one database query - but this query returns *every single snippet* on the website - even if the page doesn't need it.

This behaviour makes what is otherwise a really efficient way of reusing elements really quite inefficient.

You should only use Snippets for elements that are used throughout the site.

The things that are on every page, or the majority of pages:-

* Headers
* Footers
* META Tags
* Common Date Formats
* etc.

Elements that are only used on the site once or twice (gallery, comments, etc.) wouldn't be efficient to store as snippets and would probably be better served as Partials.

---

## Partials

Partials could be thought of as the next step up from Snippets. They're loaded only when needed but are slightly heavier.

For elements such as galleries, sidebars or "configure this product" on eCommerce websites they allow for DRY reusable code without the overhead of storing them all in snippets.

**Aside Note:** A layout should try to avoid ExpressionEngine code as much as possible other than `{exp:stash:get}` and the View Model should try to avoid markup as much as possible. This is a strong separation of concerns.

Partials allow for a middle-ground. You can use markup within them but are called from the View Model.

For example - if you have a "Blog" entry page and a "Press Release" entry page they would be almost identical, so would share the same layout. However a "Blog" would have a "About this author" section and Comments, while a Press Release would not. In this instance, the about the author section and comments could be partials.

You could think of partials as sub-templates.

**Partials are usually Stash templates.**

---

## Layouts

Your website should have a unique layout for each use case or purpose on the website. That is to say that a product page should have a different layout than a landing page, than a blog, than a standard text page.

Even if they're 99% the same, separating them allows for future expandability and highly understandable code.

When two parts of a website share the same purpose, for example a "Blog" index page and a "Press Releases" index page they could share the same layout.

Layouts contain your markup. It is the front-end to the View Model's back-end.

Within them call upon your snippets such as `{sn_header}` so that you don't need to rewrite that on every layout.

**Layouts are usually Stash templates.**

---

## View Model

The view model is the behind the scenes part. It does the following:-

1. Tells the page which layout to use
2. Grabs data from ExpressionEngine's database
3. Adds any partials that it requires

**View Models are standard ExpressionEngine templates.**
> 3 votes

---
Tags: stash
---


# Question
Title: Javascript Validation not working on EE FreeForm
My script works when its all coded without FreeForm, but when I use FreeForm I cant get it to validate text boxes.

I want the javascript to load up a pop that tells the user they need to fill in the field.

Here is the code that I have for the form:

>

```
            {exp:freeform:form
                    form_name="contact_form"
                    template="contact_email"
                    form:class="contact"
                    return="contact_/index#sent"

                }

                    <span class="input_container">
                        <span class="input_info">FIRST NAME</span>
                        <input type="text" value="" class="w168 mrR14"  name="fname" id="fname" />
                    </span>
                    <span class="input_container">
                        <span class="input_info">LAST NAME</span>
                        <input type="text" value="" class="w168" name="lname" id="lname" />
                    </span>
                    <div class="clr"></div>
                    <span class="input_container">
                        <span class="input_info">COMPANY</span>
                        <input type="text" value="" class="w350" name="company" id="company" />
                    </span>
                    <div class="clr"></div>
                    <span class="input_container">
                        <span class="input_info">EMAIL</span>
                        <input type="text" value="" class="w350" name="email" id="email" />
                    </span>
                    <div class="clr"></div>
                    <span class="input_container">
                        <span class="input_info">ADDRESS</span>
                        <input type="text" value="" class="w350" name="address" id="address" />
                    </span>
                    <div class="clr"></div>
                    <span class="input_container">
                        <span class="input_info">CITY</span>
                        <input type="text" value="" class="w168 mrR14" name="city" id="city" />
                    </span>
                    <span class="input_container">
                        <span class="input_info">PROVINCE/STATE</span>
                        <input type="text" value="" class="w168" name="state" id="state" />
                    </span>
                    <span class="input_container">
                        <span class="input_info">POSTAL CODE/ZIP</span>
                        <input type="text" value="" class="w168 mrR14" name="postalcode" id="postal" />
                    </span>
                    <span class="input_container">
                        <span class="input_info">COUNTRY</span>
                        <input type="text" value="" class="w168" name="country" id="country" />
                    </span>
                    <span class="input_container">
                        <span class="input_info">PHONE NUMBER</span>
                        <input type="text" value="" class="w168 mrR14" name="phone1"id ="phone" />
                    </span>
                    <span class="input_container">
                        <span class="input_info">SPECIFY</span>
                        <input type="text" value="" class="w168" name="specify" id="specify" />
                    </span>
                    <span class="input_container">
                        <span class="input_info">OCCUPATION</span>
                        <select id="occupation" name="occupation" class="w168 cw168" style="background:#f2f2f2;border:0px;color:#000;font-size:12px;"><option>architect</option><option>interior designer</option><option>contractor/consultant</option><option>retailer</option><option>end-user</option><option>other</option></select>
                    </span>
                    <span class="input_container cmrL14">
                        <span class="input_info">HOW DID YOU HEAR ABOUT US?</span>
                        <select id="about" name="about" class="w168 cw168" style="background:#f2f2f2;border:0px;color:#000;font-size:12px;"><option>magazine - specify</option><option>tradeshow</option><option>website/search engine</option><option>other - specify</option></select>
                    </span>
                    <div class="clr"></div>
                    <span class="input_container pdT8">
                        <span class="input_info">COMMENTS</span>
                        <textarea value="" class="w350" name="comment"id="comment" style=""></textarea>
                    </span>
                    <div class="clr"></div>
                    {if captcha}
                        <span class="input_container pdT8">
                            <span class="input_info">Please enter in the word you see below:</span>
                            <input type="text" class="w168" name="captcha" id="captcha" value="" size="40" />
                            <span class="input_info">{captcha}</span>
                        </span>
                    {/if}
                    <input type="submit"  name="submit"  id="submit" value="SUBMIT"class="submitbutton" style="cursor:pointer"/>
                {/exp:freeform:form}
                <div class="clear"></div>

```

# Answer
> 2 votes
I never used Solspace Freeform, but, looking at the docs, I had one idea.

> form:ATTRIBUTE\_NAME=
>
> This parameter allows you to control any form attribute for the form in your template. Simply replace ATTRIBUTE\_NAME with an attribute name such as **id, name, class, onsubmit, etc,** and specify a value for that attribute. You can specify this parameter multiple times to control as many attributes as necessary. **This would normally be done to control your form with Javascript or style it with CSS.**

Shouldn't you be using the parameter `form:name` too?

```
{exp:freeform:form
     form_name="contact_form"
     template="contact_email"
     form:class="contact"
     return="contact_/index#sent"
     form:name="contact_form"
}

```

# Answer
> 2 votes
As far as I can see you have not assigned an event to validateForm(). Nothing is executing this query, not so strange that it's not working.

For example Ise jQuery to assign the function to you submit button. Something like this:

```
$(“input[type=submit]”).click(function(){
  ValidateForm();
});

```

# Answer
> 1 votes
Perhaps you can give the Forms JS Validation plugin a try http://devot-ee.com/add-ons/forms-js-validation.

Example:

```
{exp:forms_js_validation:init}
{exp:forms_js_validation:add
  selector=".contact"
  input_element_wrapper=".input_container"
  require_class="require"
}

{exp:freeform:form
  form_name="contact_form"
  template="contact_email"
  form:class="contact"
  return="contact_/index#sent"
}
  <span class="input_container">
    <span class="input_info">FIRST NAME</span>
    <input type="text" value="" class="w168 mrR14 require"  name="fname" id="fname" />
  </span>

  <span class="input_container">
    <span class="input_info">LAST NAME</span>
    <input type="text" value="" class="w168 require" name="lname" id="lname" />
  </span>

  <div class="clr"></div>

  <input type="submit"  name="submit"  id="submit" value="SUBMIT"class="submitbutton" style="cursor:pointer"/>
{/exp:freeform:form}
<div class="clear"></div>

```

---
Tags: ee2, solspace-freeform, validation
---


# Question
Title: Solspace Comment Upload allowing all file types
I am using the Solspace Comment Upload extension to allow users to attach files to their comments. I would like to restrict the uploading of file types to only the MIME types listed in mimes.php. Currently it is allowing any file type to be uploaded, but the system seems to be restricting the download of file types that are not listed in mimes.php. Any help is greatly appreciated.

# Answer
I don't believe there is a built in parameter to limit file types, but have a look at this old forum post which describes where in the ext code you can look to modify the allowed upload types.

http://www.solspace.com/forums/viewthread/13764/
> 0 votes

---
Tags: add-on, file-uploads, solspace
---


# Question
Title: Grouping Matrix rows based on Playa relationship field
I have my Field groups set up like so;

Trail

* title
* related\_things \[Playa\]

Thing

* title
* content \[Matrix\]
* + content\_text \[Wygwam\]
* + content\_trail \[Playa, assigns a Trail above\]

When I edit a 'Thing', i'm adding multiple rows to the Matrix and assigning each {content\_text} with a {content\_trail}, which uses Playa:

.

However, some rows may have the same Trail assigned in the {content\_trail}. This is not a problem, but in the template I would like the content displayed and grouped by the {content\_trail}.

Here is my updated code using Stash;

```
{!-- Iterate over an array of unique Trails in the list --}
{exp:stash:set_list name="@:content_trail" parse_tags="yes" parse_depth="33"}
    {!-- For each Trail output a data for the matching Trail --}
    {exp:stash:get_list name='@:content'
      orderby="content_trail"
      sort="desc"
     }
        {!-- This is the content_text column from the content Matrix table --}
        {stash:content_text}{content}{content_text}{/content}{/stash:content_text}
        {stash:content_trail}{exp:playa:children col="content_trail"}{title}{/exp:playa:children}{/stash:content_trail}
    {/exp:stash:get_list}
{/exp:stash:set_list}

{exp:stash:get_list name='@:content_trail' unique="yes"}
    {!-- Get the unique Trail title --}
    <h2>{content_trail}</h2>
    {!-- Get all content_text Matrix rows for this Trail --}
    {exp:stash:get_list:nested name="@:content" prefix="result" orderby="total" match="#^{content_trail}$#" against="content_trail"}
        {content_text}
    {/exp:stash:get_list:nested}

{/exp:stash:get_list}

```

What this is now doing is successfully getting the unique content\_trail Playa data and displaying it all in one h2 tag like: Aviation TrailHeritage Trail, instead of creating two separate h2's. Also, it is not displaying the content\_text rows that match the unique content\_trail's.

# Answer
> 0 votes
I went ahead and messed around with what you had done so far, and you should be able to use the following to get started. It works when I tested it, but you'll of course need to put your own field names in. (Based on this support thread: "Simulating 'group by' filtering and sorting.")

```
{!-- ----------------------
ONE -  Grab all possible trails, and other variables needed.
---------------------- --}
{exp:stash:set_list
    name="@:content"
    parse_tags="yes"
    parse_depth="1"
    trim="yes"
}
    {exp:channel:entries
        channel="ch_programs"
        entry_id="{segment_3}"
        dynamic="no"
        status="not closed"
    }

        {!--   matrix   --}
        {YOUR_MATRIX_FIELD_NAME var_prefix="mx"}

            {!--   playa column   --}
            {stash:trail}
                {mx:YOUR_PLAYA_COLUMN_NAME var_prefix="pl"}
                    {pl:title}
                {/mx:YOUR_PLAYA_COLUMN_NAME}
            {/stash:trail}

            {!--   another column   --}
            {stash:second}{mx:A_SECOND_MATRIX_COLUMN}{/stash:second}
            {!--   ...continue adding any other matrix variables you will need to output later...   --}

        {/YOUR_MATRIX_FIELD_NAME}

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

{!-- ----------------------
TWO - Iterate over an array of unique Trails in the list.
---------------------- --}
{exp:stash:set_list name="@:content_trail" parse_tags="yes"}
    {exp:stash:get_list
        name='@:content'
        orderby="trail"
        sort="desc"
     }
        {stash:trail}{trail}{/stash:trail}
    {/exp:stash:get_list}
{/exp:stash:set_list}

{!-- ----------------------
THREE - Output with formatting.
---------------------- --}
{exp:stash:get_list name='@:content_trail' unique="yes"}

    {!-- Get the unique Trail title --}
    <h2>{trail}</h2>

    {!-- Get all other Matrix data you've set that match this Trail --}
    {exp:stash:get_list:nested name="@:content" match="#^{trail}$#" against="trail"}

        {!--   ...output any other variables you have set with formatting...   --}
        <p>Second variable: {second}</p>
        <p>etc...</p>

    {/exp:stash:get_list:nested}
{/exp:stash:get_list}

```

---
Tags: matrix, playa, stash
---


# Question
Title: Using native EE search to create A to Z search
I need to know how to create an A to Z search using the native ExpressionEngine search, not an add on. Is it possible to do this and display results alphabetically by letter? Thanks for any help.

# Answer
The native EE Search module does *not* have the ability to search either the Title or any custom field based only on the first letter contained therein, no. It also contains no hooks to allow you to manipulate the search query.

Just buy Low Alphabet and be done with it!
> 3 votes

---
Tags: search
---


# Question
Title: Solspace User : Edit Profile - Avatar Uploading
How can I get the size of the avatar uploaded and inform the user if the file is too big? Indeed, it seems like the edition does not proceed for a certain size of the avatar file.

# Answer
When uploading a file too big for the Avatar restrictions, the error page displayed should already display a message such as

> **The form you submitted contained the following errors**
>
> The maximum allowed size for images is 50 kilobytes

If you're looking to fetch and display the maximum dimensions for avatars dynamically and *before* someone attempts to upload a too large avatar file, you'll need to dig this information up from EE's exp\_sites table. The data is serialized and base64 encoded, so you'll need PHP to retrieve the data.
> 2 votes

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


# Question
Title: What is the benefit of using {exp:stash:static} over {exp:stash:cache}?
I am using fragment caching in most places with Stash to cache the data from ExpressionEngine on my current project, but there are a few instances where pages are totally static, such as the about page. There is nothing dynamic at all going on with it, and therefore nothing that needs to be escaped from caching.

It seems I could just as easily use either {exp:stash:static} as {exp:stash:cache}. I set up the template with {exp:stash:cache} and I now see it sitting the db as a fully cached flat file. If I were to use {exp:stash:static}, then it would do the same thing but write it as a file to the specified directory instead of the database, I guess.

So my question is, for instances like this when there is no content that needs to be escaped from the cache, is one method significantly more performant than the other? I'd assume using the static cache is more performant as then there is no call to the database, but I'd appreciate some views on this before choosing it as my preferred method. Thank you!

# Answer
> 4 votes
`{exp:stash:static}` caches the entire page to a static file. The cached output is not stored in the database. And you can't cache just a region / section of the page.

When it works for you to use `{exp:stash:static}`, it should return pages noticeably faster than `{exp:stash:cache}`, and also (since the page requests route directly to the static file, without touching EE) put less load on your server memory.

`{exp:stash:cache}` caches either the entire page, or a region / section of the page. And the cache is stored in the database. Requests to `{exp:stash:cache}` do route through EE, but all of the processing that normally would occur (i.e., whatever you have inside the `{exp:stash:cache}` tag pair) is replaced by a shortcut / fast call to the database to get the results.

For comparison, if you're familiar with CE Cache, `{exp:stash:static}` is like CE Cache's static page caching--the `{exp:ce_cache:stat:ic}` tag, and `{exp:stash:cache}` is like CE Cache's database-backed caching--the `{exp:ce_cache:it drivers="db"}{exp:ce_cache:it}` tag pair.

(caveat: I'm still getting the hang of using Stash, so this is more from studying the documentation and a small number of experiments, than from production experience. I do have a lot of production experience with CE Cache and Solspace's Static Page Caching, however.)

# Answer
> 1 votes
That's my understanding too. But rather than me trying to explain why, I think you'd be best contacting Nexcess to ask them to send you a copy of their *ExpressionEngine – Caching, and Best Practices for Performance* PDF they released after their presentation at the recent EECI Conference as it goes into great detail about the different caching methods available to ExpressionEngine.

It doesn't discuss Stash directly but it does talk about db v static caching in relation to CE Cache by Causing Effect (as well as other methods) and the differences/similarities would be pretty much the same I'd imagine.

They tweeted about it shortly after the conference with a link to download the file, but it didn't work for me so they asked me to email them and then emailed it back.

It's definitely worth the effort to get hold of.

---
Tags: stash, cache, caching
---


# Question
Title: {site_url} when updating on localhost and transfer to remote server
I'm a newbie upgrading an ExpressionEngine site from 1.6.8 to 2.7.2. I did this on my local server. Worked pretty well but I lucked out since I don't have any add-ons to upgrade. However, not everything is showing up on my home page or control panel. I'm guessing that the other navigation links and some css and image srcs are tied to the site\_url in the database, which would be looking for these elements on mydomain.com and not the local server.

I'm assuming that this would all be OK when uploaded to the remote server and the absolute paths are restored, but I want to be careful. Can I change the {site\_url} in the database or admin somewhere to check this and give it another look? Should I just upload changes from localhost and make the necessary adjustments in the control panel?

# Answer
To get all your paths/urls changed is a bit of a PITA since they are located in so many different sections of the CP. The easiest way to do this is with an addon. The two most popular are:

Deeploy Helper $22 (I prefer this one - use it on almost every build)

or

REElocate (free)
> 3 votes

# Answer
Set the value of `$config['site_url']`on the file `system/expressionengine/config/config.php`.

But you gonna maybe have to set another variables, too:

* $config\['cp\_url'\]
* $config\['tmpl\_file\_basepath'\]
* $config\['avatar\_path'\]
* $config\['avatar\_url'\]
* $config\['captcha\_path'\]
* $config\['captcha\_url'\]
* $config\['theme\_folder\_path'\]
* $config\['theme\_folder\_url'\]

And don't forget about the file upload preferences.

Take some time to study about `config.php`. It will save your life sometimes.
> 2 votes

# Answer
In your config.php, you can set the site URL like this, and it should work on both your localhost and live server without needing to be updated.

```
$config['site_url'] = 'http://' . $_SERVER['HTTP_HOST'];

```

Or, you can put the literal URL in there, and edit it once you move the file from server to server.
> 2 votes

# Answer
Another option is to use Focus Lab's Master Config. It connects into your config.php file and creates the concept of multiple server environments with their own individual configuration options. It also sets a lot of the path and URL config variables dynamically, making moving between servers painless.
> 1 votes

---
Tags: control-panel, database, url, upgrade, links
---


title: Stateless authentication

text:
# Question
Title: Stateless authentication
Is it possible to use some sort of stateless authentication to control access to the site front end?

For example oAuth or openID (is this stateless)?

The use case is we are trying to work out a way to authenticate users of an iOS/Android app that will interface with an existing EE site.

EDIT: I think my original question may have been badly phrased. What we were looking for was a means to use HTTP authentication so an iPhone app could interface with the EE front end. Apparently if we used the regular EE authentication this might cause issues getting the app approved by Apple. They prefer "native" over "web"

EDIT:

I feel the need to clarify the reason behind this authentication requirement.

Its more about REST best-practices than getting the app Approved.

REST is by nature stateless (see here: en.wikipedia.org/wiki/Representational\_state\_transfer), however EE uses Session-based authentication. Turning on Basic HTTP Auth allows us to authenticate statelessly with the API rather than play around with a session cookie on the client side. Also worth noting that the libraries being used on the clients-side have nice support for Basic HTTP Auth, ie: http://cocoadocs.org/docsets/AFNetworking/1.3.1/Classes/AFHTTPClient.html#//api/name/setAuthorizationHeaderWithUsername:password:

In terms of Approval, wrapping a web view in a thin native shell might get the app rejected so consuming the data via REST and caching/displaying it natively is the best option.

# Answer
For the benefit of others it appears we have solved our problem by setting HTTP authentication on the templates we are using.

Do this via Design-\>Template preferences, select the template and set HTTP authentication to 'yes' (the option at the bottom of the form).

This uses HTTP authentication against the EE member credentials stored in the database and allows our phone app to use HTTP authentication rather than EE's sessions which apparently can make it easier to get app approval from Apple.

What this means for us is that we can basically create a template group which acts as a kind of API and let's us return data to the phone app as needed.

This appears to work OK for our needs but it's early days and we were just experimenting so your results/requirements may differ and we may run into issues further along the line.
> 8 votes

---
Tags: authentication, oauth
---


# Question
Title: prev_entry and next_entry not outputting url_title_path
I have a bit of a weird situation. I have an entry, and want to show next/previous buttons. I'm using Low Reorder, and this is my code:

```
<div class="grid__col bp1--full bp2--one-half">
    {exp:low_reorder:prev_entry
        set='projects'
        url_title='{segment_3}'
    }
        <a href="{url_title_path='work/projects'}" class="cta cta--full cta--prev"><span class="entypo chevron-thin-left"></span> {title}</a>
    {/exp:low_reorder:prev_entry}
</div>
<div class="grid__col bp1--full bp2--one-half">
    {exp:low_reorder:next_entry
        set='projects'
        url_title='{segment_3}'
    }
        <a href="{url_title_path='work/projects'}" class="cta cta--full cta--next">{title} <span class="entypo chevron-thin-right"></span></a>
    {/exp:low_reorder:next_entry}
</div>

```

When the template gets rendered, it doens't render the `{url_title_path=''}`, but just outputs it raw. This also happens with native `next_entry` and `prev_entry` (which I reckon Low Reorder delegates to). When i put in `/work/projects/{url_title}` that does work however. Anyone have a clue what's going on here?

# Answer
> 2 votes
Actually, Low Reorder does *not* use the native prev/next entry methods, it uses its own. Also, `{url_title_path=""}` is *not* available as a variable in either the native tags nor in the Low Reorder tags. It is specific to the channel:entries tag only.

Use this instead: `{path="work/projects/{url_title}"}`

# Answer
> 0 votes
I'd try adding `parse="inward"` to the `{exp:low_reorder}` tag.

---
Tags: next-prev
---


title: Pagination breaks the page markup

text:
# Question
Title: Pagination breaks the page markup
Hello!

I have an index page template with 3 columns. Each column has pagination buttons in the bottom. You can see the screenshot below (I've highlighted the buttons by red rectangle).

But then I go to the next page by clicking pagination button I get the broken markup. See the screenshot below

The template code:

```
{embed="global/header" page_title="рейтинг пива, статьи и полезная информация о пиве"}
  <div id="left_col">
    <div id="last_news" class="grid_10_index">
    {exp:channel:entries channel="news" limit="6" dynamic="no" paginate="bottom"}
        <div class="last_news_item">
            <div class="last_news_item_title_wrapper"><div class="last_news_item_title"><a href="{url_title_path='news'}">{title}</a></div></div>
            <div class="last_news_item_body">

                <div class="last_news_item_date">{if news_date!=""}{news_date format="%j %M %Y г."}{if:else}{entry_date format="%j %M %Y"}{/if}</div>

                <div class="last_news_item_author">автор: {if news_author!=""}{news_author}{if:else}{author}{/if}</div>

                <div class="last_news_item_content">
                    {if news_announce!=""}
                        {news_announce}
                    {if:else}
                        {exp:trunchtml chars="300" ending="<a href="{url_title_path='news'}">...</a>"}
                            {news_body}
                        {/exp:trunchtml}
                    {/if}
                </div>
                <div class="last_news_item_comments">{if comment_total}<a href="{url_title_path='news'}#news_item_comments">Комментариев: {comment_total}</a>{/if}</div>
            </div>
        </div>
{paginate}
    {pagination_links}
        <ul id="pages">
    {page}
        {if current_page}
            <li class="pages_item active"></li>
        {if:else}
            <li class="pages_item"><a href="{pagination_url}"></a></li>
        {/if}

    {/page}
        </ul>
    {/pagination_links}
{/paginate}
    {/exp:channel:entries}
    </div>
</div>

<!-- <div id="last_actions_wrapper" class="grid_9">
</div> -->

<div id="center_col" class="grid_10_index">
    {!-- <div id="last_events"><a href="#"><span>Последние события на сайте</span></a></div> --}
    <div id="last_comments_wrapper" class="round_5">
        <div id="last_comments">
            <div class="last_comments_title">
                Последние комментарии
            </div>
            <div class="last_comments_item odd">
                <div class="last_comments_item_author">VIPERRR666</div>
                <div class="last_comments_item_date">22.04.2013</div>
                <div class="last_comments_item_content">
                    Не плохое пиво, но пока оно холодное, пил я его прошлым летом - как теплеть начинает, так всё... помойка.... уже не помню, но там чё то с градусами был косяк - в одном месте на бутылке...
                </div>
                <div class="last_comments_item_topic"><a href="#">Amber Weiss Wheat Beer</a></div>
            </div>

            <div class="last_comments_item even">
                <div class="last_comments_item_author">Сергей</div>
                <div class="last_comments_item_date">19.05.2013</div>
                <div class="last_comments_item_content">
                    В Москве пока было обнаружено только в Ашане
                </div>
                <div class="last_comments_item_topic"><a href="#">Юзберг Weissbier</a></div>
            </div>

            <div class="last_comments_item odd">
                <div class="last_comments_item_author">Алексей</div>
                <div class="last_comments_item_date">20.05.2013</div>
                <div class="last_comments_item_content">
                    В центре - практически в каждой палатке продаётся....
                </div>
                <div class="last_comments_item_topic"><a href="#">Юзберг Weissbier</a></div>
            </div>

            <div class="last_comments_item even">
                <div class="last_comments_item_author">Гость</div>
                <div class="last_comments_item_date">25.04.2013</div>
                <div class="last_comments_item_content">
                    Вот интересно, как сравнивая Венское Хамовники и Венское Цвай Мастер можно умудриться оценить второе выше? Хамовники - очень вкусное пиво, с небольшой горчинкой и мощным солодовым вкусом, а Цвай Мастер... не о чем...
                </div>
                <div class="last_comments_item_topic"><a href="#">Хамовники венское</a></div>
            </div>
        </div>
        <ul id="pages">
            <li class="pages_item active"></li>
            <li class="pages_item"><a href="#"></a></li>
            <li class="pages_item"><a href="#"></a></li>
            <li class="pages_item"><a href="#"></a></li>
        </ul>

    </div>

    <div id="last_posts_wrapper">
        <div id="last_posts">
            <div class="last_posts_title">
                Новые темы на форуме
            </div>
            <div class="last_posts_item odd">
                <div class="last_posts_item_author">VIPERRR666</div>
                <div class="last_posts_item_date">22.04.2013</div>
                <div class="last_posts_item_content">
                    Где в Москве попить пива?
                </div>
            </div>

            <div class="last_posts_item">
                <div class="last_posts_item_author">Сергей</div>
                <div class="last_posts_item_date">19.05.2013</div>
                <div class="last_posts_item_content">
                    Странная информация на бутылке...
                </div>
            </div>

            <div class="last_posts_item odd">
                <div class="last_posts_item_author">Виталий</div>
                <div class="last_posts_item_date">17.04.2013</div>
                <div class="last_posts_item_content">
                    Есть ли пиво в России?
                </div>
            </div>

            <div class="last_posts_item">
                <div class="last_posts_item_author">Недовольный</div>
                <div class="last_posts_item_date">14.04.2013</div>
                <div class="last_posts_item_content">
                    Проблемы с сайтом
                </div>
            </div>

            <div class="last_posts_item odd">
                <div class="last_posts_item_author">Водка</div>
                <div class="last_posts_item_date">22.04.2013</div>
                <div class="last_posts_item_content">
                    Пейте водку !!!
                </div>
            </div>

            <div class="last_posts_item">
                <div class="last_posts_item_author">Монах</div>
                <div class="last_posts_item_date">19.05.2013</div>
                <div class="last_posts_item_content">
                    Предлагаю траппистское пиво своего произв...
                </div>
            </div>

            <div class="last_posts_item odd">
                <div class="last_posts_item_author">Папа Римский</div>
                <div class="last_posts_item_date">17.04.2013</div>
                <div class="last_posts_item_content">
                   Жаль у нас в Ватикане нету такого сайта(((
                </div>
            </div>

        </div>
        <ul id="pages">
            <li class="pages_item active"></li>
            <li class="pages_item"><a href="#"></a></li>
            <li class="pages_item"><a href="#"></a></li>
            <li class="pages_item"><a href="#"></a></li>
        </ul>

    </div>
</div>

<div id="right_col" class="grid_4_index">
    <div id="last_tests_wrapper">
        <div id="last_tests">
            <div class="last_tests_title">
                Последние пробы
            </div>
            <div class="last_tests_item">
                <a href="">
                    <div class="last_tests_item_title">
                        <div class="last_tests_item_img">
                            <img src="/img/beer/asterie.jpg" alt="">
                        </div>
                        <div class="last_tests_item_name">ASTERIE</div>
                    </div>

                    <div class="last_tests_item_type">Blanche</div>
                    <div class="last_tests_item_strength">4,9%</div>
                    <div class="last_tests_item_country"><img src="/img/flags/belgium.png" alt=""></div>
                    <div class="last_tests_item_rating">7</div>
                </a>
            </div>

            <div class="last_tests_item">
                <a href="">
                    <div class="last_tests_item_title">
                        <div class="last_tests_item_img">
                            <img src="/img/beer/altmuller.jpg" alt="">
                        </div>
                        <div class="last_tests_item_name">ALTMULLER</div>
                    </div>
                    <div class="last_tests_item_type">Weissbier</div>
                    <div class="last_tests_item_strength">5,4%</div>
                    <div class="last_tests_item_country"><img src="/img/flags/german.png" alt=""></div>
                    <div class="last_tests_item_rating">7.5</div>
                </a>
            </div>

            <div class="last_tests_item">
                <a href="">
                    <div class="last_tests_item_title">
                        <div class="last_tests_item_img">
                            <img src="/img/beer/uzberg.jpg" alt="">
                        </div>
                        <div class="last_tests_item_name">ЮЗБЕРГ MUNCHENER HELLES</div>
                    </div>
                    <div class="last_tests_item_type">Pilsner</div>
                    <div class="last_tests_item_strength">4,8%</div>
                    <div class="last_tests_item_country"><img src="/img/flags/russia.png" alt=""></div>
                    <div class="last_tests_item_rating">6</div>
                </a>
            </div>
        </div>
        <ul id="pages">
            <li class="pages_item active"></li>
            <li class="pages_item"><a href="#"></a></li>
            <li class="pages_item"><a href="#"></a></li>
            <li class="pages_item"><a href="#"></a></li>
        </ul>
    </div>
</div>
    {embed="global/footer"}

```

Does anybody know how to fix this trouble?

# Answer
> 1 votes
can't see the code but seems to me you forgot a closing div with the pagination block

---
Tags: templates, pagination
---


# Question
Title: Clicking Update Button Wipes Out the Code
Has anyone encountered that? When I click "Update" button on "Edit Template" page, all the code that the template contained is mysteriously gone. The browser shows blank page.

What happens? How to prevent that?

# Answer
Sounds like an addon is getting in the way or your EE install is off somehow. Try disabling Extensions and check for JS errors. You might need to reupload your CP theme as well.
> 3 votes

# Answer
Could be that your host has ran out of Disk Space, the same happened to us and this was the issue!
> 0 votes

---
Tags: templates
---


# Question
Title: Schedule emailing members - PM notification
Members can set to be notified (or not) when they receive a private message from another member. However, this email is sent immediately after the private message is sent.

Ideally, the email notification can be bundled and sent, say, once a day. And if the private message is already read before the email notification is sent, the no need to send email notification for that private message. Is this possible to configure in EE (or via addon)?

# Answer
You might want to take a look at Postmaster (https://objectivehtml.com/postmaster/) for doing this. With Postmaster I believe you can create 'tasks' which can be executed by cron and it provides facilities to handle custom messaging etc.

It's also possible to set up notifications with some templating logic and these can also be triggered via a cron.

I'm not super-familiar with it (as you can probably tell!) but I think it will help you in this case and the author provides very good support.
> 4 votes

# Answer
it is not possible to do this with standard EE function. So you need make a new add-on - module with action which you can run by cron. Every time when cron will be run, you can get unread PM for last 24 using next query:

```
SELECT md.message_id as message_id, md.message_date as message_date, md.message_subject as subject,  md.message_body as message, mc.recipient_id as recipient_id, m.email as email, m.screen_name as name
FROM exp_message_data as md
LEFT JOIN exp_message_copies as mc ON md.message_id = mc.message_id
LEFT JOIN exp_members AS m ON m.member_id = mc.recipient_id
WHERE mc.message_read = 'n' AND md.message_date > UNIX_TIMESTAMP(NOW() - INTERVAL 24 HOUR)

```

This query give us enough info to send message. After that send email by ee email function or send it to Mandrill/Postmark/SendGrid/PostageApp(you can also just use plugins like Escort to route emails to third-party transactional email services).

Approximate time of developing - 2-3h.

p.s. you also need to disable option ("Notify me via email when someone sends me a private message") in *Member Profile Templates \> Email Preferences Form* or replace it with select *Send email immediately / Once per 24h*.
> 4 votes

---
Tags: add-on, members, email
---


# Question
Title: Upload directory path - keeps reverting back to 'blogs'
EE v2.6.1

When I log in as a content manager and try to upload a file, the destination directory in File Manager reverts to 'blogs', even though the destination has been set to another directory.

If I log in as a super admin to do this, I notice that when the upload window opens initially it states momentarily that the destination is the 'blogs' directory, but then it flashes to the correct destination.

I have tried adding a new destination directory, changing permissions, and I've checked that the content user has permissions to upload to other directories.

This has just started happening, the content user was able to upload to the correct directories before, I am not entirely certain what may have changed as other users have access, but they wouldn't have changed much if anything.

# Answer
Sounds like an addon is getting in the way. You can check to see if it's an Extension causing the issue by temporarily disable Extensions by adding this into your /system/expressionengine/config/config.php file:

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

```
> 1 votes

---
Tags: uploads
---


title: Problems with pagination

text:
# Question
Title: Problems with pagination
On the backend administration area, I am unable to go to any of the pages of articles via the page number links naturally.

The Page links go to: `http://mydomain.com/C=content_edit&tbl_offset=50`

But should be going to this: `http://mydomain.com/manager.php?D=cp&channel_id=1&C=content_edit&tbl_offset=50`

How can this be fixed? Is there a file that needs an edit to it someplace? For some reason it is not picking up the beginning of the URL after the `mydomain.com` part.

I found a topic that is somewhat similar to mine ( http://ellislab.com/forums/viewthread/217792/ ), but the fix was specific for Member Sorting, this is not the case in my situation.

# Answer
> 1 votes
It definitely sounds like your control panel URL configuration isn't correct. This needs to be set to match the URL you use to access the control panel, so it can generate the links correctly.

# Answer
> 0 votes
If you are using the Zenbu module on your EE install to change the Edit page, it may be the source of the issues. Try uninstalling and retest the links.

If you aren't using Zenbu look at all your installed addons to see if any others are making changes to the Edit page.

You can test to see if it's an Extension causing the problem by adding this to your config file which is located here /system/expressionengine/config/config.php:

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

```

---
Tags: url, pagination, links
---


title: Can I do this with conditionals

text:
# Question
Title: Can I do this with conditionals
Hi I'm looking for a way to repeat this process to build a title with conditionals

In the php version of my site I can use the following

```
if (!empty($PostKeyword)) {
    $PostTitle = $PostKeyword." Jobs";
    if (!empty($PostLoc)) {
        $PostTitle = $PostKeyword." Jobs in ". $PostLoc;
    }
} elseif (!empty($PostCategory)) {
    $PostTitle = $PostCategory." Jobs";
    if (!empty($PostLoc)) {
        $PostTitle = $PostCategory." Jobs in ". $PostLoc;
    }
} else {
    $PostTitle = "Jobs In ". $PostLoc;
}

```

I was hoping this could do the same with this in EE but it just throws errors

```
{if {super_search_keywords} !=""}

    <h1>{super_search_keywords} Jobs</h1>

{if:elseif super_search_category_name !=""}

    {if {super_search_job_location} !=""}
        <h1>{super_search_category_name} Jobs In {super_search_job_location}</h1>
    {/if}

    <h1>{super_search_category_name} Jobs</h1>

{if:else}

    <h1>Jobs In {super_search_job_location}</h1>

{/if}

```

Sorry for the look I cant find a way to format this nicely

# Answer
> 3 votes
The error happens because, sometimes, the conditionals brakes after a stage of parsing. Example:

```
{if {x} != ""}

```

If, `x` is empty, the conditional will be turned into:

```
{if != ""}

```

Which doesn't make sense.

So, you can use:

```
{if "{x}" != ""}

```

Or the what the Template Class calls "short conditionals":

```
{if x}

```

I suggest you to try:

```
{if "{super_search_keywords}" !=""}

    <h1>{super_search_keywords} Jobs</h1>

{if:elseif "{super_search_category_name}" !=""}

    {if "{super_search_job_location}" !=""}
        <h1>{super_search_category_name} Jobs In {super_search_job_location}</h1>
    {/if}

    <h1>{super_search_category_name} Jobs</h1>

{if:else}

    <h1>Jobs In {super_search_job_location}</h1>

{/if}

```

# Answer
> 1 votes
First, I would recommend using the excellent IfElse plugin to reduce load with advanced conditionals. To do this wrap your entire conditional in these tags:

```
{exp:ifelse parse="inward"}
  code goes here
{/exp:ifelse}

```

Now onwards, please post the errors you are seeing as that will help us help you. Second, I would start off by simplifying your entire conditional to a single conditional and checking if that works. If it does then add the next part and repeat until you have found the error or have the entire thing working.

You might also try putting supersearch variables inside quotes:

```
{exp:ifelse parse="inward"}
    {if '{super_search_keywords}' !=""}

        <h1>{super_search_keywords} Jobs</h1>

     {/if}

    {if '{super_search_category_name}' !=""}

        {if '{super_search_job_location}' !=""}
            <h1>{super_search_category_name} Jobs In {super_search_job_location}</h1>
        {/if}

        <h1>{super_search_category_name} Jobs</h1>

    {if:else}

        <h1>Jobs In {super_search_job_location}</h1>

    {/if}
{/exp:ifelse}

```

# Answer
> 1 votes
Thanks Robson Sobral you set me on the right track the following fixes the conditionals

```
{if "{super_search_keywords}" !=""}
    <h1>{super_search_keywords} Jobs {if "{super_search_job_location}" !=""}
         In {super_search_job_location}
    {/if}</h1>

{if:elseif "{super_search_category}" !=""}
 <h1>{super_search_category} Jobs {if "{super_search_job_location}" !=""}
         In {super_search_job_location}
    {/if}</h1>

{if:else}
    <h1>Jobs In {super_search_job_location}</h1>
{/if}

```

I have one more thing which maybe should ask in a new question the {super\_search\_category} can only pull back the category ID is there anyway to convert this id to the name

---
Tags: conditionals, solspace, supersearch
---


title: Download mailing list

text:
# Question
Title: Download mailing list
I'm hoping this is a simple question to answer ...

How do I download an ExpressionEngine mailing list?

I can easily add emails to an existing or new mailing lists however I can not work out how to download a list (in a spreadsheet or similar).

# Answer
You should be able to do this with the query module in a template (or with a query directly to your database, of course).

Something simple like this should output what you need:

```
{exp:query sql="SELECT email FROM exp_mailing_list WHERE list_id = '1'"}
{email}
{/exp:query}

```

**EDIT**

To improve this furher, you could use the Download Content plugin like this:

```
{exp:download_content filename="list.csv"}
    {exp:query sql="SELECT email FROM exp_mailing_list WHERE list_id = '1'"}
    {email}
    {/exp:query}
{/exp:download_content}

```

This should make the list download as a CSV file which can open in Excel. You may need to tinker with the spacing a bit (like removing the tabs) so you don't get blank lines in the file.
> 4 votes

---
Tags: email, plugin, mailinglist, mailing
---


title: Control Panel Login Timeout issues

text:
# Question
Title: Control Panel Login Timeout issues
I'm on EE 2.7 and clients are complaining of short logout times.

> I’m forced to re-log into EE within 20-30 minutes of non-usage even though you’ve set the timeout to 8.3 hours.

My current settings are

```
$config['admin_session_type'] = "s";
$config['cp_session_ttl'] = 30000; // Keep admins logged in for one business day

```

Any thoughts on other settings to check/change?

# Answer
> 5 votes
Change the **Control Panel Session Type** to "Cookies only".

Control Panel Location: Admin ‣ Security and Privacy ‣ Security and Sessions

> Only cookies are used to track the admin user. When this setting is used a “remember me” checkbox will appear next to the Control Panel login page, enabling users to stay permanently logged in.

# Answer
> 1 votes
You can use addon Stay Up Forever for this purpose.

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


title: Filemanager API

text:
# Question
Title: Filemanager API
Does somebody knows, if there is such an API for the filemanager. Just simple upload a file (simply as `base64_encode(file_get_contents())`) not via a form.

Let me know.

# Answer
Sound like you need the **ExpressionEngine Add-On Development docs**.
> 1 votes

---
Tags: file-uploads, file-manager
---


title: Headings from Grid Column Values

text:
# Question
Title: Headings from Grid Column Values
Is there a method where I could generate a heading using a grid column value?

My grid is output as a table sorted by the column “sport” with values like “hockey, baseball, soccer” etc.

So as I loop through the different sports, I’d like a heading for each. So when it shows the entries sorted with the value ‘hockey’ there would be a heading ‘Hockey’ displayed. Any thoughts on doing that?

# Answer
> 2 votes
One way to do this. You add a grid field for the heading value, then when you input data ensure that field is only present in the first row of a group.

The template code would then go something like this:

Lets say your grid name is sport\_grid, and the grid has two field, grid\_heading and grid\_item

```
{sport_grid}
{if sport_grid:sport_heading}<h1>{sport_grid:sport_heading}</h1{/if}
{sport_grid:sport_item}
{/sport_grid}

```

So what the tenplate is doing is only outputting the heading if it exists.

---
Tags: grid, sort, title
---


# Question
Title: ExpressionEngine & Expresso - How to check if product was added to cart after return
I am using Expresso with ExpressionEngine. I was wondering if there is a way to know what product was just added to the cart on return after the product is successfully added to the cart? I could add the {entry\_id} to the end of the return parameter but was hoping there was a cleaner way of doing this.

What I am looking to do is that after a product is added to the cart I want to display a modal window with some related accessories to the product that was just added to the cart.

Ideas?

# Answer
Just did a quick test and it appears Exp:resso cart show the most recently added item last in the cart items list so you could use the {if item:count == item:total\_results} variable to do stuff, you may be able to use that to trigger your modal window...

```
{items}
  {!-- output titles of items in cart __}
  {title}

  {!-- if the last item do something here --}
  {if item:count == item:total_results}
  TRIGGER SOMETHING
  {/if}

{/items}

```
> 0 votes

---
Tags: ee2, expresso, related-entries, shopping-cart
---


title: Multilingual site using MSM?

text:
# Question
Title: Multilingual site using MSM?
I'm about to begin a couple of multilingual websites using EE. I've been researching options and thought that MSM might be the best option as I'm able to have language specific URLs and a way to simplify site updates by multiple authors.

I have not used MSM and am struggling to get it setup locally. I've got it running, but how do I create the URL's to the second domain locally. I really would love to have the address be local.domain.com/en for the default site and local.domain.com/fr for the secondary site. Is this done in MAMP Pro?

Second issue... I really want to continue using the Focus Lab Master Config, but I'm finding it confusing to setup with MSM.

Any help would be greatly appreciated.

# Answer
MAMP Pro will allow you to setup "custom" URLs for your local environment for each of the sites. I have mine on a separate laptop and then use a local IP Number (instead of local.domain.com) to access the laptop like a web server. Regular MAMP doesn't make this easy. So a local IP number would then give you access to "en" and "fr" as follows...

`192.168.0.2/fr`

`192.168.0.2/en`

(stack exchange won't let me post numeric IP numbers here so I'm afraid you'll have to figure that out)

But MAMP pro has to be setup for that.

As mentioned by Mark Jr. for the MSM setup you would have two directories setup in MAMP, one for en and one for fr. The setup for the main one include the Exp Eng system directory and the cloned/copied site has its own directory that is essentially the same as the first but without the system directory. Then you use the admin.php and the index.php in the cloned directory to "communicate" with the Exp Eng system in the other directory. That's why you need to make sure you install and setup MSM as explained in the Exp Eng official documentation.
> 0 votes

# Answer
For your first issue you simply need to create a new folder say "es". In that es folder you copy over your admin.php (or whatever you renamed it to) and your index.php file and update the paths. You'll also need to uncomment the bits about MSM as well. Have you looked at the MSM docs located here?

http://ellislab.com/expressionengine/user-guide/cp/sites/

The documentation is pretty good but if you still need assistance please make sure you have followed their instructions first and post any relevant issues you are having and we'll get you squared away!
> 1 votes

---
Tags: ee2
---


title: Displaying only products on sale

text:
# Question
Title: Displaying only products on sale
I am trying to display only the products that are on sale using the following code but instead of only displaying the one product I have on sale, it is displaying all my products. Please can someone tell me what is wrong with my code.

I am testing using Expression Engine 2.7.1 and Expresso Store 2.0.6

```
{exp:store:search channel="products" search:on_sale="yes" }

        {title}

{/exp:store:search}

```

# Answer
The `search:on_sale="yes"` parameter hasn't been implemented in Store 2 yet, due to the complexity of the new global sales functionality.

To mimic this behaviour you should be able to use the `on_sale` conditional like so:

```
{exp:store:search channel="products"}
    {if product_details:on_sale}
        <!-- product details -->
    {/if}
{/exp:store:search}

```

This parameter will be added back in the next version of Store 2.
> 1 votes

# Answer
The Store tag needs to go inside a Channel entries tag, something like this...

```
{exp:channel:entries channel="products"}
{exp:store:product}
  {if on_sale}
  {title}
  Price: <del>{regular_price}</del> <ins>{price}</ins>!
  {/if}
{/exp:store:product}
{/exp:channel:entries

```
> 0 votes

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


# Question
Title: Adjust shipping cost based on product Variation?
We're using Store to sell magazines that have three variations: Print, Digital and Print + Digital. We're currently using Flat Rate shipping with a base rate and a per-item cost. However, if the visitor selects only the Digital version of an individual magazine, can we override the shipping costs for that particular product, while keeping Flat Rate shipping costs in place for any other products in the cart?

# Answer
> 2 votes
At the moment you would need to write an extension or a custom shipping extension to have per variation specific shipping rates. I would recommend sending an email to support@exp-resso.com with the feature request so they can add it to the Feature Request list to see about getting it added to a future release.

You can find the extension hooks documentation here.

# Answer
> 1 votes
It's not possible to add different shipping prices to product variations using Store's built in features. You have two options:

* Write an extension using the extension hooks to change the shipping price based on what the customer has selected.
* Create separate products for digital/print versions of your magazines, and use categories to separate them. That way you can add additional handling charges to the print versions.

---
Tags: expresso-store
---


# Question
Title: autosave does not work as expected. Specifically RTE and WYGWAM
EE's autosave is not entirely clear in the Docs. Here are the facts:

Autosave (tested versions 2.5.5, 2.6.1, 2.7.2) is on by default. http://ellislab.com/forums/viewthread/222582/#1023950

You can 'disable' it by a hidden config var either in a bootstrap file, to your config or through the CP global vars. Set the value to 0. http://ellislab.com/expressionengine/user-guide/general/hidden\_configuration\_variables.html#autosave-interval-seconds

In my testing the default is set to 60 seconds. (I haven't searched through the source code, this is from using a stop-watch).

What's not clear in the docs is what triggers an autosave. The timer starts from the moment a value is added to an entry field (Publish/Edit screen). So editing an existing entry does nothing until something has been altered on the page.

To test: edit an existing entry, change the title, wait 60 seconds, autosave posts a message next to the 'submit' button. (in testing changing autosave-interval-seconds to 10, works as expected).

When amending an RTE or WYGWAM field autosave does not execute.

Any help confirming this, help from Ellislab or Pixel & Tonic would be appreciated.

# Answer
> 5 votes
I now have definitive answers. Basically neither works with autosave. EllisLab have noted that their Grid fieldtype doesn't work either.

**EllisLab**
https://support.ellislab.com/bugs/detail/19838

**P&T**
Have responded with:

> Unfortunately, Wygwam currently doesn't have support for EE's auto-save functionality, but I've added to our list to look into for a future release.

Not ideal but at lease it confirms that they know WYGWAM doesn't work. I've also checked PLAYA and that doesn't work either.

In conclusion, unless you've got a very simple fieldset in EE, autosave won't work.

# Answer
> 2 votes
I've tested in in v2.7.1 - Build Date: 20130924

I added a new entry gave it a title and waited. It then said 'autosaved' by the submit button.

I then hit submit and clicked "Edit This Entry" added some text then waited.

Entry then said 'autosaved' by the submit button (I didn't time it but would suggest it was also about 10 seconds).

I then added some more text in a text field waited and it autosaved.

Finally to check I clicked the 'edit' tab and returns to the entries list, found the new entry and saw it had autosaved. I clicked the autosave button and the text I added could be seen.

# Answer
> 2 votes
Until we get a better autosave fix from ellislab I went ahead and make a really simple extension that integrates the autosave plugin for CKeditor into wygwam.

The extension uses the ckeditor autosave plugin, which saves the content of the wygwam fields into local storage as you type, and prompts you to import any missing content on pageload.

Hopefully this is helpful to people:

https://github.com/familiar-studio/Wygwam-Autosave

---
Tags: wygwam, rte
---


# Question
Title: Memory error crippling site. Ideas for how to debug?
A client of mine just reported getting the following error when trying to edit one specific entry via the EE control panel:

> Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 71 bytes) in \[server path removed\]/codeigniter/system/database/DB\_result.php on line 49

When I've seen memory errors on this site in the past it's been due to users trying to upload images via Channel images in safecracker that are way too large. I've identified which images belong to this entry and temporarily deleted them via FTP but that has not solved the problem.

Since I can't edit the entry on front or backend due to the memory error I don't know how to find out what's wrong with it and debug the issue?

Is anyone familiar with these memory errors and know how I could find out what's the problem?

# Answer
The most common Publish Page DB error for site where member can publish they entries is happens because spammers registered too many accounts. And Publish page just going down when it trying to load the authors list. In Safecracker you don't have author list field, so it's why this issue is not effected on SC form. But you can tested it just trying to open Member list.

As temporary solution is setup

```
"Include Members in PUBLISH page multi-author list?" = NO

```

for your default member group.

But the main action is to close your site from spammers and cleanup the exist DB. For protection you can use add-ons like Snaptcha.

For cleanup DB from Spammers I used different queries based on what I see in DB and site specific. Most spammers can be removed by analyzing bio field.

My queries examples \- needs to be carefully with using this (and make backup first), but you can delete more then 90% spammers this way.
> 5 votes

# Answer
A couple of things to try:

Can you increase PHP's memory limit?

Also - since you mentioned Safecracker - is this an older site - and are you using anything other than Channel Images for your images? I've had issues with Imgsizer and switching to CE image helps.

Finally, can you either delete or turn off the entry via the db directly to get back into the cp?
> 3 votes

---
Tags: error, channel-images, memory-limit, memory
---


# Question
Title: Forgotten password link is not parsed properly
I have these set in my forgotten email email notifications template

```
{name},

To reset your password, please go to the following page:

{reset_url}

If you do not wish to reset your password, ignore this message. It will expire in 24 hours.

{site_name}
{site_url}

```

I get this output

```
foobar@gmail.com,

To reset your password, please go to the following page:

http://qux.com/?ACT={AID:Member:reset_password}&id=FPeUNsWS

If you do not wish to reset your password, ignore this message. It will
expire in 24 hours.

Qux
http://qux.com/

```

If you look at the url, {AID:Member:reset\_password} is not parsed. Why?

# Answer
> 1 votes
`{AID:Member:reset_password}` should be replaced with an action ID. If it's not, it means the action ID likely isn't present in your actions database table. Check your actions table rows against these. Add whatever may be missing.

---
Tags: email, forgot-password
---


title: login form always returns to home page

text:
# Question
Title: login form always returns to home page
Problem solved. If you are already logged in and log in again the return does not WORK

using this form the return is always redirected to the home page but it should use the redirect tag.

```
{exp:member:login_form return="/courses/online/53"}
<input name="username" class="form-login" title="Username" value="" size="30" maxlength="2048" id="username" /></div>
<div id="login-box-name">Password:</div><div id="login-box-field"><input name="password" type="password" class="form-login" title="Password" value="" size="30" maxlength="2048" id="password" /></div>
<br />
<span class="login-box-options"><input type="checkbox" name="1" value="1"> Remember Me <a href="{path=login/forgot_password}" style="margin-left:30px;">Forgot password?</a></span>
<br />
<br />
<input type="image" name="submit" value="Submit" src="/images/login-btn.png"  style="margin-left:90px;" />
{/exp:member:login_form}

```

# Answer
Problem solved. If you are already logged in and log in again the return does not WORK
> 3 votes

---
Tags: login, redirects
---


# Question
Title: field Type no passing tag data to replace_tag function
having a bit of a problem with a field type and trying to pass in tag data.:

in my template i have

```
{entries ...} {field} {keys}{key}{/keys}{/field} {/entries}

```

however when i do a `var_dump($tag_data)` in the `replace_tag()` function i am getting false.

however a `var_dump($data)` if producing the expected data in the same function..

Any Ideas?

Additional: i have already tried a tag pair in the same format as `{myfield:option}
 Tag data here
{/myfield}`

# Answer
> 4 votes
You have to add the `has_array_data` property to your fieldtype class:

```
class My_field extends EE_Fieldtype {
  public $has_array_data = TRUE;

  ...
}

```

---
Tags: fieldtype
---


title: Non Super Admins users can't login?

text:
# Question
Title: Non Super Admins users can't login?
I had client of mine contact me this morning about them not being able to login to the CP of the site. I thought at first it was a cookie/session issue, but after having them clear their browser history numerous times, try other browsers, etc., it was doing the same. So I asked for their password and tried locally myself and the same thing was happening, it would just redirect back to the login page. However, I'm able to login since my user is in the **Super Admin** group. Anyone else experience this before or know of any fixes?

EE 2.7.2

# Answer
I found the culprit to be Zoo Flexible Admin. More here
> 1 votes

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


# Question
Title: How do I search reviews on information in custom ratings fields using Solspace Rating and paginate results?
I am using Solspace Rating to allow users to review and rate entries from several different channels. I have set up custom rating fields in the Rating module to store different rating criteria for the different channels, using up to a dozen different custom fields for reviews in one channel.

I would like to allow users to search for reviews based on different criteria stored in the custom fields. The Rating module has no facility for doing this so I am having to work out my own way.

So far I am able to build a custom SQL query, based on POSTed form field data, to use the EE Query module to successfully get the particular results I am after. However, I have not been able to find a way of paginating the results as the data from the form fields is lost when you click on the link to view the second page of results.

Has anyone else come across this problem with the Rating module before? If so, how have you managed to implement search for reviews, based on information that is only stored in the Rating custom fields and not in the channel entries that have been reviewed?

# Answer
> 1 votes
Sounds like this would be an issue with anything using POST variables in the EE query module and using pagination, not just with the Rating module. What if the search term was in the URL as a regular segment and you used that in the EE module? eg. http://mysite.com/rating/search/keyword/**great**, then

```
{exp:query sql="SELECT * FROM exp_rating WHERE my_review_field LIKE '%{segment_4}%'"}

```

Unfortunately Rating does not have a search feature built-in. I recommend submitting this as a Feature Request under the specific add-on category. It'll also give other users the option to vote up the feature request, and help us prioritize features to add in upcoming versions of this add-on. http://support.solspace.com/support/discussions

---
Tags: solspace, search, pagination, solspace-rating
---


# Question
Title: Cartthrob cart isn't properly tracking sessions or cookies/Can't add to cart on Ubuntu 12.04
**Our setup**

We were previously running a load balancer with a 4gb cloud server and 4gb DB server on the Rackspace Cloud. We were using Ubuntu 10.04 + PHP 5.3.2, EE 2.7.2 + Cartthrob 2.4. Everything was running smoothly on both the EE and CT side of things.

We recently added additional, identical servers to the load balancer (total of 3) and upgraded to PHP 5.3.27 on Ubuntu 12.04. Nothing has changed with our EE or CT code.

On our transaction page, we use CT Ajax calls to add to cart and checkout without the user leaving the page.

**The Issue**

Since moving to the new servers, no transactions have been processed. We did some digging and found via the response headers that values were being added to the cart; however on the checkout request, the response returned a exp\_cartthrob\_session\_id instead of exp\_session\_id.

Because of this mismatch, the system thinks the cart is empty and doesn't allow a transaction to process.

When using a browser that has previously processed a transaction and has cookies stored, we're able to make a sale successfully. When logged in, transactions process successfully. It only returns a cart empty response on machines that have cookies cleared or are in an incognito window.

**What We've Tried**

* Looked through possible XID issues, but those appear to be updating successfully.
* Checked the db and confirmed a mismatch in session ids: 3 are being created, 2 of which match, and the 3rd that happens on checkout doesn't match.
* Confirmed that all of our php config is identical to the old server.
* Tried multiple fingerprinting methods and cleared out all existing sessions.
* All tests on old server are successfully processed.

Any ideas on what could be causing this?

---

**Update: 11.18.2013**

* Works locally on os x lion + php 5.3.14 & 5.4.4
* Breaks consistently on dev server with ubuntu 12.04 + php 5.3.27 OR php 5.4.21

After further digging, it appears that our sessions/cookies aren't being properly set. They appear in as a response cookie, but never as a request cookie.

We setup a non-ajax form to add to cart + checkout, and found that items are never being added to the cart. In the exp\_cartthrob\_sessions table, a new row is added on each attempted add to cart.

Because CT runs all commands through XSS filtering and ignores the EE global config, we believe there's a possible issue with the xss filtering of cookies. Our current theory is that the filter function is stripping out needed characters, causing a session mismatch, thus creating a new session. *See similar issue: http://ellislab.com/forums/viewthread/237467/*

*It seems that the issue is only present on Ubuntu 12.04*

# Answer
> 3 votes
After a few weeks of attempting to track down this bug, we finally found the culprit was misconfigured cookie\_domain setting.

In our config file, we dynamically set the cookie domain so cookies work with our various MSM sites:

```
$config['cookie_domain']            = '.' . preg_replace('#^www\.(.+\.)#i', '$1', $_SERVER['HTTP_HOST']);

```

During our server switch, we began using RightScale templates to dynamically create our msm index.php files. The new templates wrongly included the malformed cookie\_domain config:

```
$assign_to_config['cookie_domain'] = '*.sub.domainname.com'

```

Because the cookie was being set for a non-existent tertiary domain, the cookie never matched, thus the cart technically didn't exist.

After removing the incorrect cookie\_domain from our MSM index files, the issue was resolved.

So, if you're having similar issues, make sure your cookies are set properly!

---
Tags: cartthrob, sessions, cookies
---


# Question
Title: Optimizing performance when sorting through hundreds of entries
Currently working on a new EE site that I've inherited, and having difficulty optimizing performance. Everything was dandy until I finished imported all the old content. Now there are ~700 page entries which cause some pages to take ~18 ***SECS*** to render!

I have pages entries setup where you can checkbox multiple categories that the page would belong to. User can select multiple categories which a resulting page widget would filter and display entries that correspond with the selected categories.

```
Categories(example)
- News
--Featured
--Internal
--External

- Year
--2013
--2012

-Product
--Food
--Cars
--Tech

```

I have a filter template (filter\_template) that was made that apparently sorts through all page entries and displays content. I also have a higher level widget which passes the params to the template. \*categories is a WB Category Select type. probably a plugin from whom I inherited from.

```
{embed="includes/filter_template" _cat_ids="{categories}{cat_id}|{/categories}"}
--> passes to
{exp:channel:entries entry_id="{embed:_entry_ids}" category="{embed:_cat_ids}" limit="200"...}
*Do stuff
{/exp:channel:entries}

```

Looking through online forums, people are saying to convert the calls directly to ee sql queries. However, for the life of me, I'm really bad at SQL...

EDIT: I've managed to get the queries used by EE by using the output profiler. Now my question is how can I use this direct query within my page, so I can bypass EE channel calls?

```
/*Grab All Entries*/
SELECT DISTINCT(t.entry_id) FROM exp_channel_titles AS t
                LEFT JOIN exp_channels ON t.channel_id = exp_channels.channel_id LEFT JOIN exp_channel_data AS wd ON t.entry_id = wd.entry_id LEFT JOIN exp_members AS m ON m.member_id = t.author_id INNER JOIN exp_category_posts ON t.entry_id = exp_category_posts.entry_id
                         INNER JOIN exp_categories ON exp_category_posts.cat_id = exp_categories.cat_id WHERE t.entry_id !='' AND t.site_id IN ('1')  AND t.entry_date < 1384799111  AND (t.expiration_date = 0 OR t.expiration_date > 1384799111) AND exp_categories.cat_id = '58' AND t.status = 'open' ORDER BY t.sticky desc, wd.field_id_61 desc, t.entry_date desc, t.entry_id desc LIMIT 0, 200

/*Grab relevant data text, links etc... of entries*/
SELECT  DISTINCT(t.entry_id),  t.entry_id, t.channel_id, t.forum_topic_id, t.author_id, t.ip_address, t.title, t.url_title, t.status, t.view_count_one, t.view_count_two, t.view_count_three, t.view_count_four, t.allow_comments, t.comment_expiration_date, t.sticky, t.entry_date, t.year, t.month, t.day, t.edit_date, t.expiration_date, t.recent_comment_date, t.comment_total, t.site_id as entry_site_id,
                        w.channel_title, w.channel_name, w.channel_url, w.comment_url, w.comment_moderate, w.channel_html_formatting, w.channel_allow_img_urls, w.channel_auto_link_urls, w.comment_system_enabled,
                        m.username, m.email, m.url, m.screen_name, m.location, m.occupation, m.interests, m.aol_im, m.yahoo_im, m.msn_im, m.icq, m.signature, m.sig_img_filename, m.sig_img_width, m.sig_img_height, m.avatar_filename, m.avatar_width, m.avatar_height, m.photo_filename, m.photo_width, m.photo_height, m.group_id, m.member_id, m.bday_d, m.bday_m, m.bday_y, m.bio,
                        md.*,
                        wd.*
                FROM exp_channel_titles        AS t
                LEFT JOIN exp_channels         AS w  ON t.channel_id = w.channel_id
                LEFT JOIN exp_channel_data    AS wd ON t.entry_id = wd.entry_id
                LEFT JOIN exp_members        AS m  ON m.member_id = t.author_id
                LEFT JOIN exp_member_data    AS md ON md.member_id = m.member_id WHERE t.entry_id IN (605,244,...717) ORDER BY t.sticky desc, wd.field_id_61 desc, t.entry_date desc, t.entry_id desc

SELECT field_id, field_name FROM exp_category_fields WHERE site_id IN ('1')

/*Grab category-filter information*/
SELECT c.cat_name, c.cat_url_title, c.cat_id, c.cat_image, c.cat_description, c.parent_id,
                        p.cat_id, p.entry_id, c.group_id , cg.field_html_formatting, fd.*
                FROM    (exp_categories AS c, exp_category_posts AS p)
                 LEFT JOIN exp_category_field_data AS fd ON fd.cat_id = c.cat_id
                            LEFT JOIN exp_category_groups AS cg ON cg.group_id = c.group_id
                WHERE    c.cat_id = p.cat_id
                AND        p.entry_id IN ('605','244'...'717') ORDER BY c.group_id, c.parent_id, c.cat_order

```

Any help for a web dev just trying to piece it together?

# Answer
I'd grab a copy of the EE Debug Toolbar and install it:

http://devot-ee.com/add-ons/ee-debug-toolbar

It adds a better interface for EE's template debugging, including a graph to plot the performance & time of each page render. Look for all the places where the processing time jumps.

If you have a number of {embed=} tags, particularly within a loop of any kind, work hard to refactor those away. Without seeing more of your template it's hard to know what to recommend.

Also, a limit of 200 for a channel entries loop is not insignificant. Is that section paginated, can you reduce that limit to something lower?
> 1 votes

# Answer
I'm not very familiar with SQL myself, so unfortunately I don't have a direct answer to your question. But once you've sorted out the most efficient way to pull in the entries / data you need I'd recommend taking a look at CE Cache.

It's not a replacement for well written code, but it can be incredibly helpful for situations like the one you're describing. It does a great job of lessening the load on your server by providing some nifty caching options (which should help dramatically drop your query count). The page load boost it can provide is black magic, crazy awesome kind of stuff.
> 0 votes

---
Tags: channel-entries, mysql, performance, optimization
---


# Question
Title: Grab random entry without orderby="random"?
I'm using DevDemon's Channel Videos to include videos into my entry. I'd like to output only up to 2 videos, randomly selected from my list. Unfortunately the orderby="random" option isn't available. Is there another way to easily accomplish this? Thanks for any help.

# Answer
If you were to output your Channel Video tag loop into a Stash list, using `{stash:set_list}`, then you could pull a random subset out via `{stash:get_list orderby="random" limit="2"}`.

Here are links, for more info: Stash Set List and Stash Get List. There also are lots of Stash list examples here on the EE Stack Exchange.
> 2 votes

# Answer
If you can get the total number of returned results (say, 10 videos) you could probably use one of the two add-ons below to return a random number in that range for a {if count == "3"} conditional?

http://devot-ee.com/add-ons/random-between

or

http://devot-ee.com/add-ons/low-random

Just thinking outside the box with no experience with Channel Videos.
> 2 votes

# Answer
Thanks all for your answers. In the end Stash looks like the most direct solution. Though it's nice to know those other random generators exist--I was close to trying out low\_random just for the heck of it since it looks so useful.

Here's my stash code btw

```
        {exp:stash:set_list name="videos" parse_tags="yes"}
    {exp:channel_videos:videos entry_id="{entry_id}" embed_width="300" embed_height="169"}
       {stash:embed_code}{video:embed_code}{/stash:embed_code}
            {/exp:channel_videos:videos}
        {/exp:stash:set_list}

        {exp:stash:get_list name="videos" orderby="random" limit="2"}
           {embed_code}
        {/exp:stash:get_list}

```
> 0 votes

---
Tags: orderby, channel-videos, random
---


title: Can't tell if Stash cache is working

text:
# Question
Title: Can't tell if Stash cache is working
I have two chunks of data in the same 'viewModel' template:

```
{!-- Getting data for kitchen list --}
{exp:stash:set_list
    name="kitchen_list"
    parse_tags="yes"
    save="yes"
    scope="site"
    refresh="1440"
    replace="no"
}
  {exp:channel:entries
    channel="kitchen_list"
    disable="member_data|pagination|categories"
  }
    {stash:title}{title}{/stash:title}
    {stash:url_title}{url_title}{/stash:url_title}
    {stash:url_title_path}{url_title_path='sky-island-natural-foods/whats-cooking'}{/stash:url_title_path}
    {stash:description_brief}{kitchen_description_brief}{/stash:description_brief}
    {stash:description_full}{kitchen_description_full}{/stash:description_full}
    {stash:photo_product}{kitchen_photo_product}{/stash:photo_product}
  {/exp:channel:entries}
{/exp:stash:set_list}

{!-- Getting data for kitchen list page --}
{exp:stash:set_list
    name="kitchen_page"
    parse_tags="yes"
    save="yes"
    scope="site"
    refresh="1440"
    replace="no"
}
  {exp:channel:entries
    channel="kitchen_page"
    disable="member_data|pagination|categories"
    limit="1"
  }
    {stash:title}{title}{/stash:title}
    {stash:sidebar_heading}{kitchen_page_sidebar_heading}{/stash:sidebar_heading}
    {stash:sidebar}{kitchen_page_sidebar}{/stash:sidebar}
  {/exp:channel:entries}
{/exp:stash:set_list}

```

It all works fine, but when I look at the stash table with Sequel Pro as I navigate the pages, it seems that the kitchen\_list does not get rewritten to the database (I thought replace="no" took care of this) on each subsequent page visit, but kitchen\_page does get rewritten every time I revisit a page which uses that data. So there are multiple row in the table for kitchen\_page with identical data, just different IDs, but there is only one row for kitchen\_list.

I expected that by caching the fragments of data and using replace="no", I would only see a single row in the stash table for that fragment, no matter how many times the stash list was called.

I can't tell if there is something off with my code, or just my assumptions/understanding of the caching. Thank you.

# Answer
I figured it out eventually. I am using a config bootstrap which I set up when I was first learning ExpressionEngine and haven't looked at it much since, apart from updating db settings etc.

I had: `$config['enable_db_caching'] = "y";`

and EE was caching the stash chunks before stash could which was causing all the trouble when I was logged in. I've turned this setting off in the config now and it is behaving as expected.

I now realize this setting was causing problems with some of the other modules I'm using. A few issues I've had now make sense!
> 1 votes

# Answer
If your code above is in a Stash file (i.e., not a regular EE template), double-check to make sure that you have this Stash config set:

`$config['stash_file_sync'] = TRUE;`

I've had this happen to me a few times: I make a change in a Stash file, forget that I have that setting set to `FALSE`, and wonder why my code isn't working as expected.
> 2 votes

# Answer
I'm afraid I cannot reproduce this problem. Logged in/out, cookies enabled or disabled, I find that the cached items are generated only once until they expire. Tested with both EE 2.6.1 and EE 2.7.2 and Stash 2.4.6.

To rule out a server vs php timezone configuration issue (where the expiry date may fall in the the past of the server) please try with `refresh="0"` (never expires).

You mentioned you are using a third party cache-breaking extension. Please remove this extension entirely from your system folder and make sure it is not listed in the `exp_extensions` table (if it is, delete the record). Make sure that the Stash extension IS installed.

Please truncate your `exp_stash` table, and delete your cookies for the testing domain.

Create a new template with only your code above in it, and view it.

Do you still have the problem? If so, as you are using `scope="site"` the session\_id in the stash table for each variable should be `_global`. Is that the case or do you see a long string of characters?
> 2 votes

---
Tags: stash, cache, caching
---


# Question
Title: Category Field - Select All, or All Children
Currently I am using categories to allow an entry to be filtered for the areas in which it is available. Therefore, as such I am by default selected most categories, and this is becoming tedious!

I have searched Devot-ee and other places, but cannot find anything that would allow for the "select all" facility on categories so that they can be deselected for the areas that are not available.

Another alternative would be to allow the functioning of the parent category being ticked, and auto selecting all of its children elements.

Can anyone advise, or think of a better alternative here? Crucially note that this is then searched on the front end, so that ability needs to remain in an efficient manner.

Thanks, N

# Answer
> 3 votes
MX Default Category \- tell me if is it something what you need.

> MX Default Category ext. helps to select default categories for any channels.
>
> It is also add select all trigger on parent checkbox to select/deselect all child.

---
Tags: categories
---


title: Field Pack not storing icon hex

text:
# Question
Title: Field Pack not storing icon hex
I have a Field Pack Dropdown field for authors to select an icon. In the field settings I have the following options:

```
👀 : View
📝 : Compose
🔒 : Lock
🔓 : Unlock
🔑 : Key
📞 : Phone
✉ : Mail
💬 : Chat
👥 : Users
 : Location
 : Connection
“ : Quote
 : List
⚙ : Settings
📅 : Calendar

```

This shows up in the publish page as expected:

```
<select name="field_id_5">
    <option value="👀">View</option>
    <option value="📝">Compose</option>
    <option value="🔒">Lock</option>
    <option value="🔓">Unlock</option>
    <option value="🔑">Key</option>
    <option value="📞">Phone</option>
    <option value="✉">Mail</option>
    <option value="💬">Chat</option>
    <option value="👥">Users</option>
    <option value="">Location</option>
    <option value="">Connection</option>
    <option value="“">Quote</option>
    <option value="">List</option>
    <option value="⚙">Settings</option>
    <option value="📅">Calendar</option>
</select>

```

The problem is the field is not storing the data, and on the front-end calling the field outputs a null value.

Any ideas what the issue could be, or any workarounds I could try?

# Answer
> 3 votes
I removed the'&#' characters from the dropdown options

```
👀 : View

```

has now become

```
x1F440; : View

```

and added those characters to my template output instead.

```
&#{standard_icon}

```

The field is storing the value as expected and the icon is being output fine in the template.

---
Tags: pixelandtonic, field-pack
---


# Question
Title: Super Search Results Conditionals Based on Channel / Custom Field
I would like to have a search results page with results from 8 different channels.

The results depends on the channel name.

For instance

{if channel\_name = channel1} Display {custom field} - {custom field 2} And additional text here. {/if}

{if channel\_name = channel2} {title} - {excerpt} - More stuff you don't see unless the results have that channel. {/if}

{if channel\_name = channel3} {custom field 3} - {custom field 4} {/if}

and so on.... Any idea on how to do this. It's not clear in the documentation. Thanks!

# Answer
Did you try these conditionals and it didn't work? I would expect that or `channel_short_name` to work just fine in a conditional. In my test using Supersearch 2.1.3 and EE 2.7.1 this conditional works as expected:

```
{exp:super_search:results}
    <div class="search-result">
        <h3>{title}</h3>
        {if channel_short_name == "articles"}
            <p>This result is from the articles channel</p>
        {/if}
        {if channel_short_name == "recipes"}
            <p>This result is from the recipes channel</p>
        {/if}
        <p>{excerpt}</p>
    </div>
{/exp:super_search:results}

```
> 1 votes

---
Tags: solspace, supersearch
---