# Question
Title: Solspace Calendar: Color Code events by Category
I would like to color code the day cell according to the event category. I have 4 categories Islamic, TRA, Global and UAE.Following is a screenshot of the calendar I would like to have.

Can anyone help me with an example code that does this.

# Answer
> 6 votes
On the {exp:calendar:cal} tag, I believe you could do enable="categories". You could then output the category for each event with class="category{categories}{category\_id}{/categories}" and then just create some CSS to apply the colour for each class - such as category1, category2 etc.

Something like that might work.

# Answer
> 1 votes
I had to do something similar but categories were being used for something else, so in the calendar setup I split event categories into separate calendars and then used the events calendar ID to create class names as explained above. Same solution, different route.

---
Tags: solspace-calendar
---


# Question
Title: Site response is very slow for some areas. Any suggestion to speed up ExpressionEngine?
Recently I’ve build a site with protected area. The template of this area is a single file that first check if a visitor in logged or not and that show entry basing on url segments (use a lot of if\_segment tag). The entries that is showing is only one and contains a very big Matrix field with images ad some other columns. The site has installed Trascribe too.

Every time this page is request it take about 16 sec to be ready… I haven’t any idea of the cause!

Can someone help me?

Debugging the page EE tells me:

```
Loading Time: Base Classes   0.0143
Controller Execution Time ( Ee / Index )   19.0798
Total Execution Time   19.0944

(0.319188 / 16.42MB) Calling Extension Class/Method: Transcribe_ext/transcribe_matrix_data_query
(5.559691 / 16.95MB) Calling Extension Class/Method: Transcribe_ext/transcribe_matrix_data_query

```

# Answer
If you have a lot of `if segment ==` or just a lot of `if`s in general, depending on what is within your `if`s this can slow your site down. If you have a lot of `channel:entries` calls within each `if`, for example. EE actually parses all the info within the `if`s regardless of whether they are valid or not. This can mean your entire page is parsing. So if it's long that's a lot, especially if it has a lot of embeds.

I would look into the switchee plugin. It is more powerful in its comparisons (you can use regex) but most importantly it processes the conditionals first and then only parses those ee tags that are within the matched conditionals.

Example URL `domain.com/some-url-title`

```
{if segment_1 != ''}
  {exp:channel:entries parameters etc}
    This will all get parsed because the conditional is true
  {/exp:channel:entries}
{/if}
{if segment_1 != 'foo'}
  {exp:channel:entries parameters etc}
    This will also get parsed because of the way ee handles conditionals
  {/exp:channel:entries}
{/if}

```

with switchee

```
{exp:switchee variable="{segment_1}" parse="inward"}
  {case default="yes"}
    {exp:channel:entries parameters etc}
      This will get parsed because the conditional is true
    {/exp:channel:entries}
  {/case}
  {case value='foo'}
    {exp:channel:entries parameters etc}
      This will not be parsed because the switchee case is not true saving valuable time
    {/exp:channel:entries}
  {/case}
{/exp:switchee}

```

Also simple conditionals are processed differently and take less time than complex conditionals such as if:else.
> 2 votes

# Answer
Best solution ever worked is CE-Cache! Also, try to adjust your .htaccess file with:

```
    DirectoryIndex index.php
    AddDefaultCharset UTF-8

<IfModule mod_rewrite.c>

     Options +FollowSymLinks
        RewriteEngine on
        #RewriteBase /subdirectory/

    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

    RewriteCond %{REQUEST_URI} !^/(media)/
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-l
    RewriteRule (.*) /index.php?/$1 [L]
</IfModule>
<IfModule mod_rewrite.c>

    #------------------- remove trailing slash -------------------
    RewriteCond %{REQUEST_URI} !^/system [NC]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.+)/$ /$1 [R=301,L,QSA]

    #------------------- index.php -------------------
    #strip index.php from the URL if that is all that is given
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.php\ HTTP/
    RewriteRule ^(([^/]+/)*)index\.php$ http://%{HTTP_HOST}/ [R=301,NS,L,QSA]
    #strip index.php/* from the URL
    RewriteCond %{THE_REQUEST} ^[^/]*/index\.php/ [NC]
    RewriteRule ^index\.php/(.+) http://%{HTTP_HOST}/$1 [R=301,L,QSA]
    #------DESABLE if not USING CE-CACHE------
    #------------------- CE Cache Static Driver -------------------
    RewriteCond %{REQUEST_URI} !^/system [NC]
    RewriteCond %{QUERY_STRING} !ACT|URL [NC]
    RewriteCond %{REQUEST_METHOD} !=POST [NC]
    RewriteCond %{DOCUMENT_ROOT}/static/ce_cache/08e5d9/static%{REQUEST_URI}/index\.html -f [NC]
    RewriteRule (.*) /_static_cache_handler.php%{REQUEST_URI}/index\.html [L,QSA]

    #------------------- EE -------------------
    #rewrite all non-image/js/css urls back to index.php if they are not files or directories
    RewriteCond $1 !\.(css|js|gif|jpe?g|png) [NC]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /index.php/$1 [L,QSA]
</IfModule>
<IfModule mod_php5.c>
    php_value memory_limit 128M
    php_value max_execution_time 10000
    php_flag magic_quotes_gpc off
</IfModule>

<IfModule mod_security.c>
    SecFilterEngine Off
    SecFilterScanPOST Off
</IfModule>

<IfModule mod_ssl.c>
    SSLOptions StdEnvVars
</IfModule>

<IfModule mod_expires.c>
    ExpiresDefault "access plus 1 year"
</IfModule>

<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresDefault "access plus 10 days"
    ExpiresByType text/css "access plus 1 week"
    ExpiresByType text/plain "access plus 1 month"
    ExpiresByType image/gif "access plus 1 month"
    ExpiresByType image/png "access plus 1 month"
    ExpiresByType image/jpeg "access plus 1 month"
    ExpiresByType application/x-javascript "access plus 1 month"
    ExpiresByType application/javascript "access plus 1 week"
    ExpiresByType application/x-icon "access plus 1 year"
</IfModule>
# compress text, html, javascript, css, xml:
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript

# Or, compress certain file types by extension:
<files *.html>
SetOutputFilter DEFLATE
</files>
<ifModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file .(html?|txt|css|js|php|pl)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</ifModule>

```

Uninstall modules you don't use!!!!

Without CE-Cache your pages should fly!

Check this out: Recent Project(still in development) At the bottom you will see loading time.
> -1 votes

---
Tags: matrix, transcribe, speed
---


# Question
Title: Can you write a conditional which tests against image dimensions in Assets?
Using Assets, can I write a conditional which tests against the dimensions of an image? So as an example if an image height is \>= 200px add this class, \< 200px add that class.

# Answer
> 0 votes
Turns out this is the easiest thing in the world, and I'm a lazy lazy boy for asking before reading the documentation:

`{assets_field}
 {if '{width'} >= '200px'}

 {if:else}

 {/if}
{/assets_field}`

---
Tags: assets, conditionals, file-uploads
---


# Question
Title: Transcribe add-on: How to output content depending on the language selected
I am running Transcribe add-on to manage a multi language website and I am trying the following but doesn't seem to work:

```
{if '{transcribe:language_abbreviation}' == 'en'}
          {exp:structure:nav start_from="/about" include_ul="no"}
{/if}

```

Thanks

**UPDATE** It actually works but my template for some reason wasn't updating EE. Sorry about this.

# Answer
> 1 votes
It actually works but my template for some reason wasn't updating EE. Sorry about this.

---
Tags: transcribe
---


# Question
Title: All "file" fieldtypes being required since upgrade
Sorry to keep whining to you guys :)

After upgrading from 2.5.3 to 2.7.0 and then to 2.7.1 in the last few days, I've discovered that creating new content and editing existing content are both failing with the complaint that "no file was selected for upload". This happens at every instance of the native "file" datatype, and it happens in spite of none of them being marked as required. A quick scan of the DB confirms that the "not required" setting is also correctly being stored in the exp\_channel\_fields table.

Oddly, this only happens when the attribute is intended to receive an image. Channels which can take an optional generic file upload can be entered without problems without an attachment being present.

Nothing obvious in the console, nothing at all in the log files.

Anybody seen this before?

# Answer
> 4 votes
I think it's a bug, look at this bug report: https://support.ellislab.com/bugs/detail/19732

Francois

---
Tags: file-uploads, ee2-upgrades, uploads, files
---


# Question
Title: Stash Nested Append List with Matrix and Playa
I have a channel with a matrix field named `expedition_days`, and inside of that matrix, there is a playa column named `resources`. I am trying to create a stash list for each row of the matrix. It seems like you can't use the playa module tags inside of append\_list, unless I'm missing something.

```
{exp:channel:entries
    channel="expedition"
    dynamic="no"
    limit="1"
}
    {expedition_days}
        {exp:stash:append_list
            name="expedition_days"
            parse_tags="yes"
        }
            {stash:item_day}{row_count}{/stash:item_day}
            {stash:item_location}{location}{/stash:item_location}

            {exp:playa:children
                col="resources"
            }
                {exp:stash:append_list:nested name="resources_{row_count}"}
                    {stash:item_title}{title}{/stash:item_title}
                {/exp:stash:append_list:nested}
            {/exp:playa:children}
        {/exp:stash:append_list}
    {/expedition_days}
{/exp:channel:entries}

```

# Answer
I actually realized that the nested list is completely unnecessary. Since I am building the list off of the matrix row, I can simplify it to be this:

```
{exp:channel:entries
    channel="expedition"
    dynamic="no"
    limit="1"
}
    {expedition_days}
        {exp:stash:append_list name="expedition_days"}
            {stash:item_day}{row_count}{/stash:item_day}
            {stash:item_location}{location}{/stash:item_location}
        {/exp:stash:append_list}

        {resources}
            {exp:stash:append_list name="resources_{row_count}"}
                {stash:item_title}{title}{/stash:item_title}
            {/exp:stash:append_list}
        {/resources}
    {/expedition_days}
{/exp:channel:entries}

```
> 2 votes

# Answer
Whenever I encounter these parse order issues with Stash, I find it helps to promote your Stash tags higher up the nesting hierarchy. Remember that the `set` and `set_list` methods automatically detect tags that loop, so often, you won't need to use the append methods. Try this for example:

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

    {exp:stash:set_list name="expedition_days" parse_tags="yes"}
        {expedition_days}
            {stash:item_day}{row_count}{/stash:item_day}
            {stash:item_location}{location}{/stash:item_location}

            {exp:stash:set_list:2 parse_tags="yes" name="resources_{row_count}"}
                {exp:playa:children col="resources"}
                    {stash:item_title}{title}{/stash:item_title}
                {/exp:playa:children}
            {/exp:stash:set_list:2}

        {/expedition_days}
    {/exp:stash:set_list}

{/exp:channel:entries}

{!-- ==============================
TEST OUTPUT
=================================== --}

{exp:stash:parse process="end"}
    <ul>
    {exp:stash:get_list name="expedition_days"}
        <li>
            <h3>day: {item_day} - location: {item_location}</h3>
            <ul>
              {exp:stash:get_list:2 name="resources_{item_day}"}
                 <li>{item_title}</li>
              {/exp:stash:get_list:2}
            </ul>
        </li>
    {/exp:stash:get_list}
    </ul>
{/exp:stash:parse}

```

Also, are you sure you want to use the `playa:children` tag? I don't know what your exact use-case is here, but you may find that using the simple primary tag pair (`{resources}...{/resources}`) gives you what you're looking for (assuming you're trying to output each row's related items, as opposed to the entire set of relationships in the column, which is what the `playa:children` tag will do).
> 2 votes

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


# Question
Title: Latest entry being used if invalid entry segment?
I have 'strict urls' enabled in my build, with a 404 pages set up.

For some reason, if an incorrect entry segment is used within a template group URL it is displaying the latest entry.

For instance if the following is loaded (doesn't actually exist):

```
http://www.domain.com/greeting-cards/view/entry-1

```

It loads the latest entry created in that channel.

How can I have it display a 404 error?

# Answer
The `exp:channel:entries` just filter its listed entries if there is one entry that matches the segments 2 or 3. Otherwise it will list how many entries the `limit` parameter allow.

If you want to return a 404, you need to use `if no_results` conditional variable and the `require_entry` parameter:

```
{exp:channel:entries limit="1" require_entry="yes" [...] }
     [...]
     {if no_results}
         {redirect="404"}
     {/if}
{/exp:channel:entries}

```

From the docs:

> This parameter tells the channel tag that it should expect the URL to contain a valid entry ID or a valid URL title. If an ID is not found in the URL, the tag will not display any data. Normally, the channel tag will show something, even if the URL doesn’t point to a particular entry. For example, your main channel page will typically show several of your most recent entries. Whereas your “single entry” pages, like your comment page, will show a single entry based on information in the URL. However, if one of your single entry pages is requested, but it doesn’t contain a valid ID, this parameter will tell the tag that you do not wish the template to display anything.
>
> Note
>
> You will often use this parameter in conjunction with the if no\_results conditional.
> 1 votes

---
Tags: channel-entries, url, segments
---


# Question
Title: Can't edit Freeform Pro entries via the CP
I am having an issue with editing entries via the CP.

When I change something (a text field) and hit submit, I get the spinner png for a second or two and then nothing. If I manually reload the page I can see the edits didn't stick. I don't see any console errors.

I upgraded to the latest of everything, still no luck.

Runnin:

EE 2.7.0 Freeform Pro 4.1.2

Any help would be great.

Thanks, Adam

# Answer
> 1 votes
You might be having an issue with the **Hon-ee Pot Captcha** extension. If you're not using it, I recommend disabling it. If not, try adding a custom field in your Freeform form with the name of your Hon-ee Pot field.

What gave it away was looking at the browser's console. After submitting the form in Freeform, look for a URL in the console which is the ajax URL used to save the data. At least in Chrome, click that URL, which will take you to the *Network* tab of the browser console. Click the same URL again there, and look at the *Preview* or *Response* tab, which will reveal the Hon-ee Pot Captcha error:

> Sorry, but we think you might be a robot.

Extra reading: This thread from the old Solspace forums: http://www.solspace.com/forums/viewthread/7490/

---
Tags: solspace-freeform
---


title: Parse Order 2.6.1 and SafeCracker

text:
# Question
Title: Parse Order 2.6.1 and SafeCracker
I recently upgraded to 2.6.1 and I am running into an issue that seems like it could be parse order related, I have the following code that was working before the upgrade.

```
{if segment_3=="summary"}
     {exp:safecracker channel="jobs"
          return="jobs/application/thanks/ENTRY_ID/{username}/{current_time format="%Y-%g-%d_%H-%i"}"
          {if segment_4 != "new"}entry_id="{segment_4}"{/if}
          preserve_checkboxes="yes"
          include_jquery="yes"
          safecracker_head="yes"
          class="safecracker"
          author_only="yes"}
      {/exp:safecracker}
 {/if}

```

The global {username} variable is returning the encoded "%7Busername%7D" opposed to actually showing the username. I tested the {username} global variable inside the safecracker loop and outside of it and it works - just is not parsing in the parameters section of safecracker.

Any ideas or thoughts?

# Answer
> 2 votes
I don't think the `{username}` global variable is parsed early enough for it to be used within a parameter as you have there.

A couple solutions:

1) You could use Rob Sanchez' Mo' Variables add-on, which adds early parsed member variables.

2) Is the username really necessary within your return URL? Since you are redirecting to the ENTRY\_ID, you should be able to pull the username from the author of that entry within the template you're directing to. Within the `{exp:channel:entries}` tag, the `{author}` and `{author_id}` variables are available.

---
Tags: safecracker
---


title: Extend login period for Admins

text:
# Question
Title: Extend login period for Admins
Is there a way to extend the login period for admins? Usually booted out withihn about 30mins of inactivity. I have a client who's wanting it to be much longer if possible...

A usergroup setting I've missed perhaps?

Running EE 2.7

# Answer
> 2 votes
Check out the Hidden Configuration Variables page in the User Guide. You can adjust the `$config['cp-session-ttl'] = xx;` variable to extend the admin session length.

---
Tags: ee2, login
---


title: Display pages viewed to a member

text:
# Question
Title: Display pages viewed to a member
I wish to show to a logged in member, a list of pages they have recently viewed.

I have looked into the default Tracking module and Solspace tracker, but these all seem to just work to display on a particular entry or in the CP, rather than displaying on say an account page for a member.

Has anyone done this before?

Thanks.

# Answer
> 1 votes
You might find Rob Sanchez' Mo' Variables useful for this situation. The add-on adds variables for `{last_page_visited}`, `{one_page_ago}`, `{two_pages_ago}`, etc. up to 5 pages back.

---
Tags: solspace-tracker, tracking
---


# Question
Title: How do I exclude certain entries based on one or more categories
I'm having some trouble with the {category="not 8"} for example. On my page I have two categories that a user might check when publishing a new entry. It's "show on front page" and "do not show facebook comments". Based on these, I want to exclude these entries on certain places.

On the front page, I want to exclude categories with category\_id 8. If the entry has only category 8 checked, this works. However, if both category 8 and 9 are checked, this doesn't work.

On the article layout, I want to exclude category 9 if it's checked. This should hide facebook comments. However, same thing happens here. If the entry has both category 8 and 9 checked, this doesn't work.

Any ideas? How do you guys solve these kind of things? I'm guessing this is something you should see quite often?

# Answer
Yeh, it's a common and rather unintuitive problem. In your particular scenario, I'd say your use-case doesn't semantically fit well with the category system anyway: why not just use custom checkboxes? Even better, use the 'checkbox group' field provided in the PT Field Pack instead of the native ones, as they allow you to separate the value from the name. Much easier... http://devot-ee.com/add-ons/field-pack

Then in your `channel:entries` tags you can use the search parameter to examine the values of your options and filter accordingly - something like this:

```
{exp:channel:entries search:article_options="show_on_hp"}
   <h2>{title}</h2>
{/exp:channel:entries}

```
> 2 votes

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


title: Adding an 'active' class to a category

text:
# Question
Title: Adding an 'active' class to a category
```
{exp:channel:categories channel="News" style="nested"}

    <a href="{path='news/show/'}">{category_name}</a>

{/exp:channel:categories}

```

This code generates a nav unordered list of all the categories.

The categories are: News, Video, Press Releases. When users are on the 'news' page how do I give that category an 'active' class in the nav so user understand they are on that page.

# Answer
> 3 votes
Assuming you are using category URL titles in your URL, like http://domain.com/category/news, then you can simply add a conditional within the loop like this:

```
{exp:channel:categories channel="News" style="nested"}

    <a href="{path='news/show/'}" {if segment_2 == category_url_title}class="active"{/if} >{category_name}</a>

{/exp:channel:categories}

```

# Answer
> 5 votes
If you are using the `exp:channel:categories` in dynamic mode, no matter if using category\_name on URL or category ID, you can use the `{if active}` conditional:

```
{exp:channel:categories channel="News" style="nested"}
    <a href="{path='news/show/'}" {if active} class="active"{/if}>{category_name}</a>
{/exp:channel:categories}

```

If you are not on dynamic mode **or** you're using Low Seg2Cat, you can use this:

```
{exp:channel:categories channel="News" style="nested"}
    <a href="{path='news/show/'}" {if segment_X == category_url_title} class="active"{/if}>{category_name}</a>
{/exp:channel:categories}

```

Replace `segment_X` by the segment related to your category.

Or you can set one class to every category and to the HTML or BODY element and use just CSS and child selector.

---
Tags: categories
---


# Question
Title: Exclude recurring events from {exp:calendar:events} loop
Is there a way to exclude recurring events from the `{exp:calendar:events}` tag output? I need to display a maximum of 6 upcoming events but only if they are non-recurring events. Example :

```
{exp:calendar:events
  dynamic="no"
  event_limit="6"
  date_range_start="today"
}

...

{/exp:calendar:events}

```

Looking at the DB tables Calendar uses I see there is a column in the 'exp\_calendar\_events' table called 'recurs' which could act as a flag (n/y). Is there any easy way within Solspace Calendar to tap into this so I could exclude events with 'recurs' set to 'y' (without trying to recreate the call with the Query Module)?

# Answer
The keyword here is **upcoming** events. If you're looking to display entries in a chronological order (such as upcoming events), use `{exp:calendar:cal}`. It's the only tag that can do that kind of accurate ordering.

More detailed on why {exp:calendar:cal} should be used, and how other main Calendar tags work, please refer to this very useful documentation page: http://www.solspace.com/docs/calendar/getting\_started/

To remove recurring events from the listing created by {exp:calendar:cal}, you can use the `{if event_recurs}{/if}` conditional: http://www.solspace.com/docs/calendar/events//#if\_event\_recurs

FYI, most of the conditionals listed in {exp:calendar:events} are available for use within the {events}{/events} tag pair inside {exp:calendar:cal}.
> 1 votes

---
Tags: solspace, solspace-calendar
---


title: Matrix (2.5.8) update database error

text:
# Question
Title: Matrix (2.5.8) update database error
I was updating a local EE install from EE 2.5.1 (20120529) to EE 2.7.1 (20130924). I've updated Matrix 2.4.1 to 2.5.8

When clicking on Matrix in the fieldtypes addon section i get the following error:

```
A Database Error Occurred
Error Number: 1060
Duplicate column name 'is_draft'
ALTER TABLE `exp_matrix_data` ADD `is_draft` TINYINT(1) UNSIGNED DEFAULT '0'
Filename: /third_party/matrix/ft.matrix.php
Line Number: 509

```

I also got a error for Playa, but that seemed to correct itself on refresh.

Any ideas what's up?

# Answer
> 5 votes
Take a look at the columns in exp\_matrix\_data table in the database.

* Does it have a field var\_id? If no, then the version you should set is 2.2.
* If yes, does it have a field is\_draft? If no, then the version you should set is 2.3
* If yes, then the version you should set is 2.5.8

Now, set the version number we determined in the previous three steps for the Matrix field in the exp\_fieldtypes table and go visit the Add-ons -\> Fieldtypes -\> Matrix page and hit submit.

Everything should be all working now.

---
Tags: matrix
---


# Question
Title: Newrelic Application Name set by default to: ExpressionEngine v2.7.0
Just upgraded to EE 2.7.0. We already use NewRelic for a while to monitor server and application performances.

After upgrading the website to EE 2.7 the site shows up in the Newrelic Application list as: "ExpressionEngine v2.7.0" instead of with the sites name.

Where can I change these, apparently default settings, to show the sites name instead?

# Answer
> 2 votes
At the current version, which is 2.7, you can't change the App Name on New Relic, because the name is set on `\system\expressionengine\libraries\Newrelic.php`:

```
public function set_appname()
{
    newrelic_set_appname(APP_NAME.' v'.APP_VER);
}

```

I filled a bug report for this.

---

UPDATE:

This is fixed on EECMS 2.7.1. The name can be set on Admin ‣ System Administration ‣ Output and Debugging or by `$config['newrelic_app_name'] = 'My Site';`.

# Answer
> 0 votes
Expression Engine 2.7.1 solved the reported issue by adding $config\['newrelic\_app\_name'\] = 'My Site'; to the config file.

However, after upgrading from 2.7.0 to 2.7.1 the site no shows up 3 times in the NewRelic panel as:

* ExpressionEngine v2.7.0 (the old site)
* ExpressionEngine v2.7.1 (the upgraded)
* My Site - ExpressionEngine v2.7.1 (the upgraded + app name in the the config file)

---
Tags: ee2, newrelic
---


# Question
Title: How to capture a users email address before offering a download?
I'm building a site that is going to offer some free PDF downloads (reports, guides etc.) but the client would like to collect the users email in return for the download.

Any thoughts on the best way to do this using ExpressionEngine?

As always, all help will be appreciated.

# Answer
I think your best bet would be to use Solspace Freeform then. The free version will work just fine.

Setup your form as normal using the `{exp:freeform:form}` tag. And set the return parameter to include the form entry ID, like this: `return="template_group/template/%%entry_id%%"`

Then on your return template, use the `{exp:freeform:entries}` tag, passing the entry ID from the URL into the entry\_id parameter `entry_id="{segment_3}"`.

Within the entries tag pair, you can use the no results variable pair to handle if the entry ID is invalid. `{if freeform:no_results}Sorry, no results were found.{/if}`

After that, it's just a matter of putting whatever HTML you want to show your download to the user.
> 2 votes

---
Tags: email, url, html
---


title: Resize uploaded images, delete original

text:
# Question
Title: Resize uploaded images, delete original
is there a way to upload an big images -\> resize the big image to a small one -\> delete the original images.

I\`m not talking about Image Manipulations function, but an direct resize.

# Answer
> 1 votes
Use Channel Images plugin to do that. Excellent plugin. link

# Answer
> 1 votes
Photo Frame is a great utility for this, and has loads of advanced settings so it can work exactly how you need. It's different approach to image editing and manipulation. It has a new Focal Pack that allows clients to define a focal point when uploading a photo, then you (the developer) can crop it in any way you need within the template. You could use `{exp:photo_frame:resize}` tag, or you could even use CE Image.

The great thing about using focal points to crop vs actually cropping, is you can resize this photo is so many ways and shapes, without compromising the shot and center point of the focal. You never know when in the future you want to reuse the same photo, with a 1:3 ratio in addition to a 1:10 with the same exact center point.

Resize Tag Reference

https://objectivehtml.com/photo-frame/documentation/tag/resize

More information on Photo Frame and the Focal Pack.

https://objectivehtml.com/articles/read/photo-frame-1.2

---
Tags: image, resize
---


# Question
Title: Random strings in my url's for all navigation
I have simple links such as:

```
 href="{path='PCP/alliance_blog/'}"

```

and the result in the url bar will be:

```
example.com/PCP/Index#.UkryCGTXhvk

```

^ What is the deal with the "#.xxxxxx" code being generated here? Other sites I've worked on and built out do not have this issue. Admittedly this site is absolutely enormous compared to them..

# Answer
> 1 votes
I assume you're using AddThis on your site?

You can disable the "click tracking" that they add to URLs by following instructions on the AddThis site.

If you're not using AddThis, I'd imagine you're using another service that does something similar.

---
Tags: url, path
---


# Question
Title: pagination with current URL in custom module
I added pagination to a module, in a mod.filename.php

Below is my code, it outputs the pagination (after it lists all the reviews) if you pass yes into the template tag parameter as seen below. After you click the first link for pagination, it appends the number to the end of the URL (ex: domain.com/news/1), then if you click another pagination link, it appends another number to the URL, (ex: domain.com/news/1/1). I know why this happens, because I am fetching the current URI.

I know I can pass segments into a parameter to append in the mod file, but I am looking for the cleanest, easiest (on the user) way possible.

```
{exp:module_name:reviews entry_id="{entry_id}" entry_type="electronics" pagination="yes"}
  // template tags
{/exp:module_name:reviews}

public function __construct()
{
    $this->EE =& get_instance();
    $this->EE->load->library('pagination');
}

private function paginate($entry_id, $entry_type)
{
    $p_config['base_url'] = $this->EE->functions->fetch_current_uri();
    $where = array(
        'entry_id'      =>  $entry_id,
        'entry_type'    =>  $entry_type,
    );

    $p_config['total_rows'] = $this->EE->db->where($where)->count_all_results('bmi_review');
    $p_config['per_page'] = 1;

    $this->EE->pagination->initialize($p_config);
    $vars['pagination'] = $this->EE->pagination->create_links();

    return $vars['pagination'];
}

public function reviews()
{
    $entry_id = $this->EE->TMPL->fetch_param('entry_id', false);
    $entry_type = $this->EE->TMPL->fetch_param('entry_type', false);
    $pagination = $this->EE->TMPL->fetch_param('pagination', false);

    $reviews = $this->_get_data("reviews");

    $output = '';
    $count = 0;

    if(count($reviews) === 0)
        return false;

    foreach($reviews as $review)
    {
        $count++;

        $vars = array(
            'review'            =>  $review->review,
            'review_author'     =>  $review->author,
            'review_date'       =>  $review->date,
            'review_count'      =>  $count,
            'review_total'      =>  count($reviews),
        );

        $output .= $this->EE->TMPL->parse_variables_row($this->EE->TMPL->tagdata, $vars);
    }
        if($pagination == "yes")
            $output .= $this->paginate($entry_id, $entry_type);

    return $output;
}

```

# Answer
> 1 votes
Try this code:

```
$basepath = $this->EE->functions->create_url($this->EE->uri->uri_string);
$query_string = ($this->EE->uri->page_query_string != '') ? $this->EE->uri->page_query_string : $this->EE->uri->query_string;

if (preg_match("#^P(\d+)|/P(\d+)#", $query_string, $match))
{
    $start = (isset($match[2])) ? $match[2] : $match[1];
    $basepath = reduce_double_slashes(str_replace($match[0], '', $basepath));
}

$config['base_url']     = $basepath;

```

It will strip 'P1' segment off your URL.

---
Tags: add-on-development, module, pagination
---


# Question
Title: Register member during checkout doesn't work in Store2 [solved]
**Edit: Problem solved in store update. Just download and install it.**

After installing Store 2 on a new site, i am no longer able to register members during checkout. To be sure, I also tried with the code I can confirm works on store 1, but it doesn't work on store 2. My form looks like this.

I have also enabled "Allow New Member Registrations" in EE.

If anyone can spot my problem, or give me some direction, it would keep me from ripping my hair out and be much appreciated! Thanks

```
{exp:store:checkout
form_class="form default"
next="butikk/personalia"}

{if no_items}
    {redirect="butikk/handlevogn"}
{/if}

<div class="two-col">
    <div class="col">
        <h2>Faktureringsadresse</h2>
        <label for="">Fornavn</label>
        {field:billing_first_name} {error:billing_first_name}
        <label for="">Etternavn</label>
        {field:billing_last_name} {error:billing_last_name}
        <label for="">Adresse</label>
        {field:billing_address1} {error:billing_address1}
        <label for="">Postnummer</label>
        {field:billing_postcode} {error:billing_postcode}
        <label for="">Sted</label>
        {field:billing_address2} {error:billing_address2}
        <label for="">Land</label>
        {field:billing_country} {error:billing_country}
        <div class="bump"></div>
        <label for="">Telefon</label>
        {field:billing_phone} {error:billing_phone}
        <label for="">E-post</label>
        {field:order_email} {error:order_email}

        <span class="create-accountt">
            <label for="password">Passord</label>
            {field:password} {error:password}
            <label for="password_confirm">Bekreft passord</label>
            {field:password_confirm} {error:password_confirm}
        </span>
        <label for="register_member" class="inline toggle-create-account">
            {field:register_member} Opprett konto (valgfritt)
        </label>
    </div>
    <div class="col">
        <h2>Leveringsadresse</h2>
        <span class="same-as">
            <label for="">Fornavn</label>
            {field:shipping_first_name} {error:shipping_first_name}
            <label for="">Etternavn</label>
            {field:shipping_last_name} {error:shipping_last_name}
            <label for="shipping_address1">Adresse</label>
            {field:shipping_address1} {error:shipping_address1}
            <label for="shipping_postcode">Postnummer</label>
            {field:shipping_postcode} {error:shipping_postcode}
            <label for="">Sted</label>
            {field:shipping_address2} {error:shipping_address2}
            <label for="shipping_country">Land</label>
            {field:shipping_country} {error:shipping_country}
            <div class="bump"></div>
            <label for="shipping_phone">Telefon</label>
            {field:shipping_phone} {error:shipping_phone}
        </span>
        <label for="shipping_same_as_billing" class="inline toggle-same-as">
            {field:shipping_same_as_billing} Samme som faktureringsadresse
        </label>
    </div>
</div> <!-- .two-col -->
<div class="clearfix"></div>
<span class="right">
    <input type="submit" name="next" value="Fortsett" class="btn-flat green">
</span>
{/exp:store:checkout}

```

# Answer
> 1 votes
This was a known issue and fixed in the v2.0.3 release yesterday :)

https://exp-resso.com/docs/release\_notes.html#store\_203

---
Tags: expresso-store
---


title: Expresso Store - Resend Order Email

text:
# Question
Title: Expresso Store - Resend Order Email
I am currently using Expresso Store for non-members to purchase printable tickets for events. I don't want to require account creation for the checkout process but am concerned that a ticket purchaser will not receive an email with the order details.

I would like to be able to modify the order email and resend the confirmation mail. Is there anyway to do this with Expresso Store?

# Answer
> 2 votes
In Store you can have multiple order emails and multiple order statuses. The easiest way to send a second email would be to assign a new template to an additional Order status. Then when you change the order status the second email will be sent.

# Answer
> 1 votes
To resend the email, simply change the order status. You can take advantage of the fact that by default the "order confirmation" email is tied to the "new" order status, and there is nothing to stop you changing a status to the same status.

So if you click "Edit Status" and then immediately hit "Submit" on the order details page, it will resend the order confirmation email for you.

---
Tags: expresso-store
---


title: Products Sold by Modifier

text:
# Question
Title: Products Sold by Modifier
If I have an item (for instance, a concert VIP Package, that includes a T-Shirt.. ) that is single SKU with a modifier (T-Shirt Size..), is there any straightforward way to generate a report with a count of the number of each modifier sold?

I tried using a SQL COUNT that joined exp\_store\_orders to exp\_store\_order\_items but modifiers ia base64 encoded JSON string...

# Answer
> 1 votes
Not really (without looping through the orders in PHP which would be very slow). That's the point of having separate SKUs.

SKU stands for "Stock Keeping Unit", and so by definition if you want to keep track of how many of each item was purchased you should use separate SKUs. In fact Store already provides built in reports to display how many of each SKU you have sold.

The "Single SKU modifier" was really only added in Store 1 to avoid people having to make up lots of SKUs if they didn't need them. But now in v2 SKU names are no longer required fields, so there is not much need for the single SKU modifier any more, you can just create them as regular multi-SKU products, leave the SKU names blank, and get the advantages of separate reporting etc.

---
Tags: expresso-store, modifiers
---


title: Initiate Wygwam with <p class="name">

text:
# Question
Title: Initiate Wygwam with <p class="name">
When a Wygwam field gets loaded, the first thing you type is within `<p>` tags. Is it possible to make the default tag `<p class="something">`?

# Answer
> 1 votes
Why not just wrap a div around the content and use a bit of jquery to handle that. I don't think wygwam can handle this without some trickery.

---
Tags: pixelandtonic, wygwam
---


# Question
Title: Mutli-language, i18n, multilingual - addon suggestions?
I'm building a EE site and the front end needs to support multiple languages.

Requirements:

* control panel does not need to support multiple languages Needs translations:
* static content in the front end
* MAYBE the channel entries (not a strong requirement)
* field labels need translations
* having a segment in the URL indicating the language might be useful. It would be good if the language segment allows for something like "en-us", "en-uk", etc. and not just "en"

Any addon suggestions? Looking for suggestions from people that have actually used such addons. Also, any tips on "gotchas" would be helpful.

**Some Addons I've Found**

1. Publisher, $175 (Honorable Mention, 2012 New Module of the Year), latest update September 9, 2013
2. Transcribe, $150, latest update October 17, 2012

# Answer
> 1 votes
Publisher \- it offers the most flexibility - especially in having URLs relative to the language (good for native users and for SEO), easy toggling between language entries. This also neatly handles rewriting for custom language identifiers in the URL.

Although you can roll your own solution, using tips and tricks found elsewhere and something like Republic Variables to store your variables.

Here's a few older posts of approaches if you decide to do it yourself:

Carl describes how to create the language specific root segments in your URL via language folders and additional index.php files: http://cwcrawley.co.uk/2010/01/multi-lingual-websites-in-expressionengine/

Taken from my blog post regarding complex language translation (written prior to Publisher being released), but I would highly recommend using Publisher and save yourself the grief.

---
Tags: add-on, multi-language, multilingual
---


# Question
Title: Add custom validation to Content_publish form
In our system, entries are created from the Control Panel, and one of our custom entries needs more complicated validation rules.

Basically, depending on the status of the submitted entry, we need to determine whether other fields are required, validate the submission based on that and then show errors as per normal validation rules.

I've looked into getting access to the data from the `entry_submission_ready` hook and setting the errors via `ee()->form_validation->_error_array['foo'] = 'bar'`, but this hook is called after validation has already completed and passed.

Ideally I would prefer not having to rewrite any core code, though I am willing to override `Content_publish` if this can be done cleanly from a module/extension.

# Answer
You're using the wrong hook. Try using entry\_submission\_start and/or publish\_form\_entry\_data

Update:
> 3 votes

---
Tags: control-panel, module, extension, validation
---


title: Suddenly can not upload images

text:
# Question
Title: Suddenly can not upload images
I suddenly can not upload images and get the following error (Even though all is writeable)

I tried to upload files that i had previously uploaded to make sure they are not damaged and still get the same error

What else could i check to make sure all is correct?

ExpressionEngine v2.5.5

```
A PHP Error was encountered

Severity: Warning

Message: imagecreatefromjpeg() [function.imagecreatefromjpeg]: gd-jpeg, libjpeg: recoverable error: Premature end of JPEG file

Filename: libraries/Image_lib.php

Line Number: 1246
A PHP Error was encountered

Severity: Warning

Message: imagecreatefromjpeg() [function.imagecreatefromjpeg]: '/home/*/public_html/cms/images/uploads/general/656.jpg' is not a valid JPEG file

Filename: libraries/Image_lib.php

Line Number: 1246
A PHP Error was encountered

Severity: Warning

Message: Cannot modify header information - headers already sent by (output started at /home/*/public_html/cms/system/codeigniter/system/core/Exceptions.php:170)

Filename: core/Common.php

Line Number: 408
Thumbnail could not be created for the image. Please make sure the thumbnail directory is writable.

Upload to general

Upload File

```

# Answer
Check that the images are actually of the type uploaded. The error is suggesting they're not valid JPEGs, so it's worth checking they've not been saved as, say, a PNG file and renamed to JPEG.

Alternatively, the file could be corrupt either at your or the server end. Finally, if part of the file has been written it's possible the disk is full at the server end, leading to a premature end of file.
> 3 votes

---
Tags: file-uploads, error, image
---


title: Assets 2 loses Rackspace thumbnails

text:
# Question
Title: Assets 2 loses Rackspace thumbnails
The first time I upload via Rackspace, the thumbnails on the backend appear fine.

However, if I delete the expressionengine/cache directory and it regenerates the images, the result is 70 byte 'jpgs' are created in expressionengine/cache/assets/rs\_sources with the following content

`<html><h1>Not Found</h1><p>The resource could not be found.`

* i.e. the response you would get from Rackspace if the image cannot be found.

However, the images are available and accessible (right click -\> View file returns the correct image with a Rackspace URL). They also appear fine on the front-end, so it's just the process which deals with the generation of thumbnails for the backend.

# Answer
> 1 votes
I found that when you use the subfolder option, the leading forward slash is removed which malforms the URL which means the curl request fails

In sources.rs.php, I added a forward slash manually to compensate on line 1089, but there is obviously a deeper issue as to why the forward slash gets stripped - just don't have time right now to figure it out.

`$prefix = isset($this->settings()->subfolder) ? $this->settings()->subfolder . "/" : '';`

---
Tags: assets
---


title: Set From Name to system generate emails

text:
# Question
Title: Set From Name to system generate emails
Is it possible to set a from name to system generated emails - at the moment the from field is just the email address. Would be nice to be able to tidy that up if at all possible.

The control panel setting page at Admin \> Email Configuration doesn't seem to allow this, but you can change the from address in the field titled 'Return email address for auto-generated emails'

Many thanks in advance for your help.

# Answer
Possibly a little overkill for this one task, I am pretty sure you could use Postmaster for this. Just setup a "Send System Email" hook. Then you can define any from name/email you want.

More Information on Postmaster

https://objectivehtml.com/postmaster

Reference to the Send System Email hook.

https://objectivehtml.com/postmaster/hooks/send-system-email
> 1 votes

# Answer
Haven't tested this, but it *should* work:

```
"Your Name" <email@address.com>

```
> 0 votes

---
Tags: email, settings, config
---


# Question
Title: Store2 fails to map member fields during account creation in checkout
I know that not being able to create accounts during checkout was a bug in the initial release of Store 2 which was fixed in a recent update, so I'm wondering if this is a bug as well, or if i shall continue troubleshooting? This was working for me in the previous version of Store (pre 2), but i could still of course be doing something wrong.

I have of course created and mapped the member fields in ee/store admin.

Thanks in advance

# Answer
The problem was in fact solved in the latest update. I was messing up the templating.

I got it working with input type="text" id="billing\_first\_name" name="billing\_first\_name" class="{if error:billing\_first\_name}error{/if}" value="{billing\_first\_name}"

I feel silly. Still new to EE. Sorry
> 1 votes

# Answer
This was fixed in the recent Store 2.0.3 release. For all other bug fixes you can take a look at the Release Notes.
> 1 votes

---
Tags: expresso-store
---


title: Change Day format to Sun Mon

text:
# Question
Title: Change Day format to Sun Mon
I am using Solspace Calendar. I would like to change the date format from Sunday, Monday to Sun, Mon Can anyone help me with this?

# Answer
You can format the names with standard EE date formatting. try {day format="%j"}, as documented in the ExpressionEngine User Guide.
> 1 votes

---
Tags: solspace-calendar
---


# Question
Title: Can I use the SEO Lite title field as a Structure custom title?
In some cases I need to use custom page titles while using Structure. I know you can set up a custom field and use that, but I am also wondering if there is a way to use the Title field within the SEO Lite module?

If not, I think I could always hide the SEO Lite Title field and replace it with my own custom field, but I am hoping there is a simple way to accomplish it natively?

Thanks for your help!

# Answer
> 2 votes
Pop the following in your header:

```
{exp:seo_lite entry_id="{structure:page:entry_id}"}

```

If you **do not** add a title into the SEO Lite title field, the entry title will be used for the title meta tag.

If you **do** add a title into the SEO Lite title field, that will be used.

---
Tags: structure, title, seo-lite
---


title: Why is an un-required field required?

text:
# Question
Title: Why is an un-required field required?
I have a template with just two fields is it, an optional field for a thumbnail photograph and a body field for text. Only the body field is required. However, when I attempt to save an entry with just the body content entered I am unable to save the entry and I get a notice below the File field that says:

> You did not select a file to upload.

I have double checked the field several times and confirmed that it is not required. Has anyone else had this experience and better yet know how to resolve the problem? I am running ee 2.7.1.

Thanks.

# Answer
> 3 votes
I just found the answer. It is a bug: https://support.ellislab.com/bugs/detail/19732

---
Tags: file-uploads, fields
---


# Question
Title: EE 2.7.1 Publish Layout fields disappearing
So I upgraded to EE 2.7.1 and I am having issues with my publish layouts. If I leave things well alone, all seems good in the world. However, if I go in and edit the layout to rearrange fields in a more friendly manner, they disappear when I go in to publish a new entry or edit an existing entry.

Very basic... If I split the difference between title and url\_title, save the layout, exit the entry, go back into the entry or create a new entry, the url\_title is gone and a blank box is sitting on the "eyeball" icon in the toolbar.

Has anyone else run into this? How the heck do you fix this?

# Answer
There are a couple of bugs with publish layouts that have popped up in 2.7.1. Here's a link to one that sounds like it might be related and contains a fix file to download and apply:

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

Let us know if that fix works for your issue as well.
> 4 votes

---
Tags: ee2, custom-fields, publish-layout, custom
---


# Question
Title: Are PDFs still an XSS problem with EE uploads?
I keep running into this and I'm hoping there is a suitable solution - PDF uploads by anyone other than a super admin run into the error "the file cannot be written to disk". This persists unless, as I've spotted in the bug tracker, the "solution" of turning off XSS filtering. But as I understand it, XSS is a good thing when it comes to security. Is there any way around this? Should I be particularly concerned about security if I turn off XSS filtering on file uploads? My clients generally LOVE to be able to simply and easily upload a PDF file through the entries screen, but we don't want to create security holes either.

# Answer
There is a better solution!

You can change the XSS filtering member group by using some extra directives in your config file.

Add the following, replacing the member group numbers as required;

```
$config['xss_clean_member_group_exception'] = "1|6";

```

Using this method you can keep XSS filtering turned ON but remove it just for trusted members.

I *think* you can do it with member IDs too but can't recall the config key. Maybe try;

```
$config['xss_clean_member_exception'] = "35|64";

```
> 34 votes

# Answer
The issue is that certain PDFs falsely trigger the XSS screener's detection routines. And yes, this IS still a bug, although it is fairly difficult to predict which PDFs will be affected. I have had *consistent* issues with:

* PDFs exported from Microsoft Word on any platform
* PDFs with embedded color profile data

The best way around it if you only need certain member groups to be able to upload PDFs is to use the hidden config variables that @foamcow mentions in a separate answer, as follows:

`$config['xss_clean_member_group_exception'] = "1|6";`

**OR**

`$config['xss_clean_member_exception'] = '3|14|83';`

However, if you need to allow generic users to upload PDFs, such as through an open Safecracker form, I do not know of any solution other than disabling XSS filtering entirely.
> 13 votes

# Answer
This is not a solution, but I am using EE 2.7 and have been able to narrow down the offending code. Simply commenting out these three lines allowed for my offending PDFs to pass. I personally am not using this in production, and I have spent time trying to modify the code to get it to work... with no luck. Maybe someone can use this information to help update the code - I don't want to pollute the bug tracker with this.

**/system/codeigniter/system/core/Security.php - xss\_clean()**

```
// Near line 345
if (preg_match("/<a/i", $str))
{
    $str = preg_replace_callback("#<a\s+([^>]*?)(>|$)#si", array($this, '_js_link_removal'), $str);
}

// Near line 365
$str = $this->_remove_evil_attributes($str, $is_image);

// Near line 377
$str = preg_replace_callback('#<(/*\s*)('.$naughty.')([^><]*)([><]*)#is', array($this, '_sanitize_naughty_html'), $str);

```

**EDIT:**

Rather than commenting out the lines above, you can check whether or not the file is a PDF and wrap each of the above in `if( !$is_pdf ) { ... }`. Put the following code near the top of `xss_clean()`:

```
// NOTE: Requires PHP >= 5.3
$finfo = new finfo(FILEINFO_MIME_TYPE);
$is_pdf = $finfo->buffer($str) == "application/pdf";

```
> 3 votes

---
Tags: security, uploads, xss
---


# Question
Title: Building a UGC site using ExpressionEngine
Apologies in advance for the long post...

I've been tasked with building a User-generated content site with ExpressionEngine. I had a rough idea of how I was going to proceed but - as I have progressed - it feels like I'm having to "bend the rules" more and more to achieve my intentions, which usually means that I'm doing something wrong :( Any feedback would therefore be greatly appreciated.

I'll first start by describing the intended architecture: The site consists of an open membership system which allows front-end registration, login, logout and profile capabilities. There are then a number of channels such as "jobs", "events", "workshops" - each following a similar structure of listing/view page - to which members can contribute from the front end. Once they have submitted an entry to one of these channels, they should be able to Edit or Delete the entry at a later date, or mark it as closed (filled).

So far, I've been working along the following lines of implementation: I'm using Structure to manage the pages and Zoo Visitor to handle the membership system (chosen as there were a number of checkbox fields that I needed to add to the registration form). This side of things is all working fine.

When a new job is added, I intend to have it use the id and job title to form the URL string, so that if another job already exists with the same title I don't end up with things like "web-developer-2". I haven't actually done this yet, but I imagine that I can just populate a hidden field on the add form.

For any one of these given areas (eg. /jobs/ ), I intended to have the following URL structure:

```
/jobs/                           jobs listing page
/jobs/<id>-<job-title>/          job single page
/jobs/add/                       add job page
/jobs/edit/<id>-<job-title>/     edit job page
/jobs/delete/<id>-<job-title>/   delete job page
/jobs/success/                   success page for add/edit/delete job
/jobs/filter/today/              jobs posted today
/jobs/filter/this-week/          jobs posted in last 7 days
/jobs/filter/2013/oct/           jobs posted in october 2013
...                              (previous 12 months)
/jobs/filter/2012/nov/           jobs posted in november 2012
/jobs/filter/archive/            (including those with a status of 'closed')

```

Obviously on top of all this there is pagination which takes the form of p10, p20 etc (10 to a page)

I've been using Freebie to ignore anything after the /jobs/ segment, and then I've been using the jobs/index template a kind of controller:

```
{!-- Archive pages --}
{if freebie_3 == "archive"}
    {embed="jobs/archive"}

{!-- CRUD pages --}
{if:elseif freebie_3 == "add"}
    {embed="jobs/add"}
{if:elseif freebie_3 == "edit"}
    {embed="jobs/edit"}
{if:elseif freebie_3 == "delete"}
    {embed="jobs/delete"}
{if:elseif freebie_3 == "success"}
    {embed="jobs/success"}

{!-- Listing / Single page --}
{if:else}
    {embed="jobs/view"}

```

In the view template, I've the got:

```
{exp:channel:entries channel="jobs" required_entry="yes" limit="1" url_title="{freebie_last}" dynamic="no"}
    {if no_results}
        {!-- jobs listing page --}
    {/if}
    {!-- jobs detail page --}
{/exp:channel:entries}

```

In the add template I've got:

```
{if logged_in}
    {embed="jobs/_form"}
{if:else}
    <p>Sorry, you must be logged in to use this feature.</p>
{/if}

```

In the edit and delete templates, I've got:

```
{if logged_in}
    {exp:channel:entries channel="jobs" required_entry="yes" limit="1" url_title="{freebie_last}" dynamic="no"}
        {if no_results}
            {redirect="404"}
        {/if}
        {!-- Edit code here --}
    {/exp:channel:entries}
{if:else}
    <p>Sorry, you must be logged in to use this feature.</p>
{/if}

```

The add/edit/delete templates will use Channel:form (formerly Safecracker) for the allow the adding, editing and deleting of entries. (I haven't written the code which detects if the form has been submitted and actually does the edit/delete action yet).

I guess I'll need to wrap the latter two functions in...

```
{if author_id == logged_in_member_id}

```

...to make sure that people can only edit/delete their own entries.

So I guess my question is...

**Is there a better method - module or otherwise - of handling CRUD functionality from the front end, other than that which I have described?**

It had dawned on me that a better approach might be to write a custom module that interacts directly with the database (rather than using the channels at all) as this might keep the model/controller cleaner and more separated from the view; but I haven't done this before so I'm hesitant to go down this road as I'm sure it will throw up a whole new set of hurdles...

Any advice is greatly appreciated :)

# Answer
> 5 votes
Your question is not very specific, so we can't give you specific answers... however EE can handle all of this stuff, but it does take some planning. Here are a few comments in no particular order that may help...

Firstly I'd recommend ditching Structure, as you'll be fighting it at every step for control of your URLs and you could also find that it hinders future growth. (Imagine for example, expanding the site to include multiple client sub-domains or something fun like that). This will save you the awkwardness of building 'controller'-like routing templates and instead use native URL handling. This will be especially handy for filtering by date, which EE can do natively if you just pass along the right segments.

Building a custom module would be an excellent clean option and even if it's your first you probably won't regret it as you'll have complete control, and it's a great learning experience as well as good fun. Bear in mind that you can also take a half-way approach, which would be to use Safecracker/Channel Form etc, but build your own add-on that hooks into Safecracker's routines and does extra stuff before/after submission: http://ellislab.com/expressionengine/user-guide/development/extension\_hooks/module/channel\_form/index.html

Another couple of points: Safecraker/Channel Form has an author\_only="yes" parameter to do what you describe for editing entries.

Safecracker has no native capability for deleting entries. It's straight-forward to build this functionality yourself with the help one of the existing deletion add-ons (http://devot-ee.com/search/results?keywords=delete&addon\_version\_support=ee2), but naturally you have to be extremely conscious of security, making sure that a logged-in member can only delete their own entries and locking down things like the channel from which they can delete etc. This is where your own custom add-on can help tighten things up a bit.

Ben's Open-API mentioned previously looks like it will become a brilliant alternative to Safecracker/Channel Form, however at this point in time (I think) it lacks support for 3rd party fieldtypes, so that may become an issue.

One other little bit of advice is that instead of using loads of repetitive `{if logged_in}...{if:else}` sections, consider instead using a single redirection snippet that can be placed at the top of any non-public templates to redirect logged-out users to a generic 'permission-denied' template (or a standard login template). This avoids the 'advanced conditionals trap' and also allows you to easily alter the logic of what exactly constitutes a 'logged-in' user (eg, what happens when your site grows and you start accepting membership from job applicants as well as job advertisers etc).

Good luck - this will be a fun project for you. I've recently completed a sporting web app where the content is entirely user-generated, and EE coped admirably - though with a lot of help from a custom add-on that basically served to tie together Matrix, Playa, Profile:Edit, Safecracker, Postmaster and Cartthrob into a cohesive and secure whole.

# Answer
> 2 votes
Ben Croker of PutsYourLightON has been working on an API specifically designed for CRUD functionality. You should take a look at it here... http://www.putyourlightson.net/open-api

And here is the repo for it... https://github.com/putyourlightson/open-api

I have messed with this some and it has some great potential.

# Answer
> 1 votes
Here's a different page/embed approach to ponder, it may make maintenace much easier.

Think inside out and consider using partials. about partials

Heres our layout. Template = layout/.default

```
<!DOCTYPE html>
<html lang="en">
    <head>
        <title>{exp:stash:head_title} - LocalYak</title>
        {sn_head}
        {gv_jquery}
        {exp:stash:head_links}
        {gv_google_analytics}
    </head>
    <body>
        {sn_body_top}
        <div id="main_bkgd">
            <div id="main" class="device_{ress} view_{view}">
                {exp:stash:content_above}
                <div id="content" class="{if ress > 1}rounded{/if} {exp:stash:get name='content_class'}">
                    {exp:stash:content}
                </div>
                {exp:stash:content_below}
            </div>
        </div>
        {sn_footer}
    </body>
</html>

```

And heres a (page) template that calls and uses that layout.

```
{embed="layout/.default"}
{exp:stash:set name='head_title'}Compare{/exp:stash:set}
{exp:stash:set name='head_links'}
    <link rel='stylesheet' type='text/css' media='screen' href="{stylesheet='advertise/.css_advertise'}" />
    <link rel='stylesheet' type='text/css' media='screen' href="{stylesheet='pages/.css_pages'}" />
    <meta name="description" content="Compare advertising packages" />
{/exp:stash:set}
{exp:stash:set name='content_class'}tab-advertise outline{/exp:stash:set}
{exp:stash:set name='content'}
    <div class="page_select body_wrap">
        <h1>Compare packages</h1>
        [put your page content here.... or if you are forced to like we did on this occassion, create an extra embed]{embed="advertise/.select_type"}
    </div>
{/exp:stash:set}

```

And if you need to show different content for the page, simply wrap using simple conditional like this

```
{if segment_3 == ""}
    {exp:stash:set name='content_class'}category splash{/exp:stash:set}
    {exp:stash:set name='content'}some content or tags{/exp:stash:set}
{/if}
{if segment_3 != ""}
    {exp:stash:set name='content_class'}category splash{/exp:stash:set}
    {exp:stash:set name='content'}some different content or tags{/exp:stash:set}
{/if}

```

Our site is mostly built on that one single default layout, however we do use a total of seven layouts.

And here an example of a safecracker page (channel form)

```
{embed="layout/.mybusiness" page_id="latest_news"}
{exp:stash:set name='head_title'}Edit latest news{/exp:stash:set}
{exp:stash:set name='head_links'}
    <link rel="stylesheet" type="text/css" media="screen" href="{stylesheet='_ee_saef_css'}"/>
{/exp:stash:set}
{exp:stash:set name='body_wrap_class'}edit edit_news{/exp:stash:set}
{exp:stash:set name='content'}
    {exp:safecracker
        channel = "browse"
        url_title = "{segment_3}"
        return = "mybusiness/view/URL_TITLE/{segment_4}/latest_news"
        require_entry = "yes"
        include_jquery = "no"
        {if global:sc_https_on}
            secure_action = "yes"
            secure_return = "yes"
        {/if}
        }
        <div class="rounded border box">
            <label class="first" for="latest_news">Enter your latest community news.</label>
            {field:latest_news}
            <p>
                <div class="btn_wrap"><a href="{path='mybusiness'}/view/{segment_3}/{segment_4}/latest_news" class="btn green" rel="nofollow">cancel</a></div>
                <div class="btn_wrap"><button type="submit" name="submit_button" class="btn green"><span>save</span></button></div>
            </p>
        </div>
    {/exp:safecracker}
{/exp:stash:set}

```

---
Tags: safecracker, structure, zoo-visitor, channel-form, freebie
---


title: query string params

text:
# Question
Title: query string params
Got a site that want to use tracking in URLS like http://domain.com/segment\_1/segment\_2/?utm\_campaign=google

Now this works fine locally but on the production server, it renders the 404.

On MAMP I've set the config\['uri\_protocol'\] = 'PATH\_INFO' and have tried this in production but still get the problem.

Any suggestions?

# Answer
```
RewriteRule ^(.*)$ /index.php?/$1

```

Instead of...

```
RewriteRule ^(.*)$ /index.php/$1

```

Normally the first thing I try when query strings go wrong!
> 2 votes

---
Tags: url, segments, parameters, path, google-analytics
---


title: Upgrading 2.7 to 2.7.1 with MSM

text:
# Question
Title: Upgrading 2.7 to 2.7.1 with MSM
I have EE 2.7 running with MSM 2.16 and want to upgrade to EE 2.7.1 to fix some bugs

Outside of restoring the three files that come with MSM is there anything else that has to be done differently because of MSM?

# Answer
> 0 votes
No, that is all you have to do.

---
Tags: multi-site-manager, upgrade, ee2-upgrades, 2.7.0, 2.7.1
---


# Question
Title: How to stop displaying title of next and privous article in my current article?
i am using following code for display title of next and previous article in current article detail page

```
          {exp:channel:prev_entry}
            {exp:channel:entries channel="teaching_tips" dynamic="off" limit="1" sort="desc"}
            <p> « Previous Article: <a href="{url_title}">{title}</a></p>
            {/exp:channel:entries}
            {/exp:channel:prev_entry}

            {exp:channel:next_entry}
            {exp:channel:entries channel="teaching_tips" dynamic="off" limit="1" sort="desc"}
            <p>Next Article: <a href="{url_title}">{title}</a> » </p>
            {/exp:channel:entries}
            {/exp:channel:next_entry}

```

now i want to display only title of next and previous article which have same channel ="teaching\_tips" but this code is display another channel entries how to stop this ?

and i want to display next article link when i will open 1st entry and when i will open last entry i want to display only previous article link how this i can do this ?

Thank you.

# Answer
> 2 votes
You would want to remove the channel entries loops you have stuck within the next entry and previous entry tags - they themselves should contain the channel parameter:

```
{exp:channel:prev_entry channel="teaching_tips"}
   <p> « Previous Article: <a href="{url_title}">{title}</a></p>
{/exp:channel:prev_entry}

{exp:channel:next_entry channel="teaching_tips"}
   <p>Next Article: <a href="{url_title}">{title}</a> » </p>
{/exp:channel:next_entry}

```

Like the entries loop itself, the pref\_entry and next\_entry tags, in absence of a channel parameter, will load from all channels.

---
Tags: ee2, next-prev
---


# Question
Title: User:Stats No Longer displaying correct info for Member Types
I have a members area where the user can either be `Male/Female`, `Building Muscle/Losing Weight`, and either `Beginner/Intermediate/Advanced`

The way it worked before is if the user was a `Female`, trying to `Lose Weight`, and was a `Beginner` it would display content for that user.

**EDIT: Sorry I thought I mentioned the issue! The problem is it will either display content randomly or nothing at all and I'm using User 3.4.5 and EE 2.7** This is how the Supplement Section was coded:

```
{exp:user:stats}
    <ul id="membersboxes" class="block-grid three-up clearfix">
        <li>
            <div class="membersbox">
                {if member_gender == "Female" && member_goal == "Build Muscle" && member_level == "Beginner"}
                {exp:channel:entries channel="supplement_guides"  category="42|43|45" dynamic="no" limit="1" status="open"}
                <h4><a href="{page_url}">{title}</a></h4>
                <p>{exp:trunchtml chars="150" inline="..."}{guide_content}{/exp:trunchtml}</p>
                {/exp:channel:entries}
                {/if}

                {if member_gender == "Female" && member_goal == "Build Muscle" && member_level == "Intermediate"}
                {exp:channel:entries channel="supplement_guides"  category="42|43|46" dynamic="no" limit="1" status="open"}
                <h4><a href="{page_url}">{title}</a></h4>
                <p>{exp:trunchtml chars="150" inline="..."}{guide_content}{/exp:trunchtml}</p>
                {/exp:channel:entries}
                {/if}

                {if member_gender == "Female" && member_goal == "Build Muscle" && member_level == "Advanced"}
                {exp:channel:entries channel="supplement_guides"  category="42|43|47" dynamic="no" limit="1" status="open"}
                <h4><a href="{page_url}">{title}</a></h4>
                <p>{exp:trunchtml chars="150" inline="..."}{guide_content}{/exp:trunchtml}</p>
                {/exp:channel:entries}
                {/if}

                {if member_gender == "Female" && member_goal == "Lose Weight" && member_level == "Beginner"}
                {exp:channel:entries channel="supplement_guides"  category="42|44|45" dynamic="no" limit="1" status="open"}
                <h4><a href="{page_url}">{title}</a></h4>
                <p>{exp:trunchtml chars="150" inline="..."}{guide_content}{/exp:trunchtml}</p>
                {/exp:channel:entries}
                {/if}

                {if member_gender == "Female" && member_goal == "Lose Weight" && member_level == "Intermediate"}
                {exp:channel:entries channel="supplement_guides"  category="42|44|46" dynamic="no" limit="1" status="open"}
                <h4><a href="{page_url}">{title}</a></h4>
                <p>{exp:trunchtml chars="150" inline="..."}{guide_content}{/exp:trunchtml}</p>
                {/exp:channel:entries}
                {/if}

                {if member_gender == "Female" && member_goal == "Lose Weight" && member_level == "Advanced"}
                {exp:channel:entries channel="supplement_guides"  category="42|44|47" dynamic="no" limit="1" status="open"}
                <h4><a href="{page_url}">{title}</a></h4>
                <p>{exp:trunchtml chars="150" inline="..."}{guide_content}{/exp:trunchtml}</p>
                {/exp:channel:entries}
                {/if}

                <span class="seeall"><a href="{path='members-area/supplement-guides/'}">See All Supplement Guides</a></span>
            </div>
        </li>
    </ul>
{/exp:user:stats}

```

This is just the supplements part of the female section, but for the entire code for Males/Females and including everything else you can visit THIS LINK

Here is an image of the member fields: categories

Here is an image of the categories:

And here is how a user changes the type of member they are:

And the code for that part of the settings page:

```
{exp:user:edit return="{path='member/updated-settings/'}"}
    <div class="settingswrap">
        <div class="membersheader">
            <h2>Current Level</h2>
        </div>
        <div class="member-settings">
            <label>Gender</label>
            <select name="member_gender">
                {select_member_gender}
                <option value="{value}" {selected}>{value}</option>
                {/select_member_gender}
            </select>
        </div>
        <div class="member-settings">
            <label>Goal</label>
            <select name="member_goal">
                {select_member_goal}
                <option value="{value}" {selected}>{value}</option>
                {/select_member_goal}
            </select>
        </div>
        <div class="member-settings">
            <label>Level</label>
            <select name="member_level">
                {select_member_level}
                <option value="{value}" {selected}>{value}</option>
                {/select_member_level}
            </select>
        </div>
        <div class="save-settings">
            <input type="submit"  class="small blk button radius" name="submit" value="Save Settings" />
        </div>
    </div>
{/exp:user:edit}

```

It was working perfectly before.. not sure if the 2.7 update could of changed anything but I don't know what to do.

Please help if you can.. this site is suppose to go up soon and I don't know what to do

# Answer
> 1 votes
I went in and also noticed that your entry was displayed, using on your {exp:channel:entries} code in the above first block of code, despite category 45, "Beginner", not being selected in the entry. However, I notice you are using

```
category="41|43|45"

```

...in `{exp:channel:entries}`. I assume in this case you want to have entries with categories 41 AND 43 AND 45, is that correct? If so, you need this syntax:

```
category="41&43&45"

```

Here's the reference in the EE documentation: http://ellislab.com/expressionengine/user-guide/modules/channel/channel\_entries.html#category

---
Tags: solspace-user
---


# Question
Title: Expresso Store, shipping address only working for logged out customers
I'm using EE 2.5.2 and Store 1.6.3 and I'm only able to capture a different shipping address if the customer is logged out.

On the shipping page, I have two sets of content, one for logged in and one for logged out users. When a logged out users unticks the "shipping same as billing" box, they can enter different details, which will show up correctly on the next screen.

However, logged in users, when they untick it and enter new details, they don't show up on the next page, they just get the "same as billing details message"

Thanks,

Edit shop code:

```
 {case value="customer_details"}
    <section class="light_brown_flat"> {!-- ===/ login check and guest account registration /=== --}
  {if logged_out}
  {exp:channel:entries channel="static_pages" limit='1' url_title="billing_intro"}
  {body_content}{content_body}{/body_content}
  {/exp:channel:entries}
  <div class="grid_7">
        <h3>You are Checking out as a Guest</h3>
        {exp:store:checkout form_class="form-horizontal" next="{segment_1}/confirm" error_handling="inline" error_delimiters='<span class="help-inline">|</span>' require="name|address1|address3|country|billing_phone|billing_region" register_member='no'}
        {if no_items}
        {redirect="{segment_1}/checkout"}
        {/if}
        <fieldset id="billing_details">
      <input id="password" type="hidden" value="" name="password">
      <h3>Billing Details</h3>
      <div class="grid_6">
            <div class="control-group {if error:billing_name}error{/if}">
          <label class="control-label" for="billing_name">Name</label>
          <div class="controls"> {field:billing_name} {error:billing_name} </div>
        </div>
            <div class="control-group {if error:billing_address1}error{/if}">
          <label class="control-label" for="billing_address1">Address</label>
          <div class="controls"> {field:billing_address1} {error:billing_address1} </div>
        </div>
            <div class="control-group {if error:billing_address2}error{/if}">
          <div class="controls"> {field:billing_address2} {error:billing_address2} </div>
        </div>
            <div class="control-group {if error:billing_address3}error{/if}">
          <label class="control-label" for="billing_address3">City</label>
          <div class="controls"> {field:billing_address3} {error:billing_address3} </div>
        </div>
            <div class="control-group {if error:billing_postcode}error{/if}">
          <label class="control-label" for="billing_postcode">Postcode</label>
          <div class="controls"> {field:billing_postcode} {error:billing_postcode} </div>
        </div>
          </div>
      <div class="grid_5">
            <div class="control-group {if error:billing_country}error{/if}">
          <label class="control-label" for="billing_country">Country</label>
          <div class="controls"> {field:billing_country} {error:billing_country} </div>
        </div>
            <div class="control-group {if error:billing_region}error{/if}">
          <label class="control-label" for="billing_region">Region</label>
          <div class="controls"> {field:billing_region} {error:billing_region} </div>
        </div>
            <div class="control-group {if error:billing_phone}error{/if}">
          <label class="control-label" for="billing_phone">Phone</label>
          <div class="controls"> {field:billing_phone} {error:billing_phone} </div>
        </div>
            <div class="control-group {if error:order_email}error{/if}">
          <label class="control-label" for="order_email">Email</label>
          <div class="controls"> {field:order_email} {error:order_email} </div>
        </div>
          </div>
    </fieldset>
        <fieldset>
      <h3>Is this a Gift?</h3>
      <div class="grid_6">
            <div class="row">
          <div class="control-group">
                <label class="control-label" for="order_custom4">Recipient Name:</label>
                <div class="controls"> {field:order_custom4} {error:order_custom4} </div>
              </div>
        </div>
            <div class="control-group">
          <div class="row">
                <label class="control-label" for="order_custom5">Recipient Email Address:</label>
                <div class="controls"> {field:order_custom5} {error:order_custom5} </div>
              </div>
        </div>
          </div>
    </fieldset>
        <fieldset>
      <h3>Special Deliver Instructions</h3>
      <div class="grid_6">
            <div class="row">
          <div class="control-group">
                <label class="control-label" for="order_custom6">Delivery Instrctions</label>
                <div class="controls">
              <textarea name="order_custom6" class="grid_5"> </textarea>
            </div>
              </div>
        </div>
          </div>
    </fieldset>
        <fieldset>
      <h3>Shipping Details</h3>
      <div class="control-group">
            <div class="controls">
          <label for="shipping_same_as_billing" class="checkbox"> {field:shipping_same_as_billing} Same as Billing Details </label>
        </div>
          </div>
      <div id="shipping_details_drawer">
            <div class="grid_6">
          <div class="control-group {if error:shipping_name}error{/if}">
                <label class="control-label" for="shipping_name">Name</label>
                <div class="controls"> {field:shipping_name} {error:shipping_name} </div>
              </div>
          <div class="control-group {if error:shipping_address1}error{/if}">
                <label class="control-label" for="shipping_address1">Address</label>
                <div class="controls"> {field:shipping_address1} {error:shipping_address1} </div>
              </div>
          <div class="control-group {if error:shipping_address2}error{/if}">
                <div class="controls"> {field:shipping_address2} {error:shipping_address2} </div>
              </div>
          <div class="control-group {if error:shipping_address3}error{/if}">
                <label class="control-label" for="shipping_address3">City</label>
                <div class="controls"> {field:shipping_address3} {error:shipping_address3} </div>
              </div>
          <div class="control-group {if error:shipping_postcode}error{/if}">
                <label class="control-label" for="shipping_postcode">Postcode</label>
                <div class="controls"> {field:shipping_postcode} {error:shipping_postcode} </div>
              </div>
        </div>
            <div class="grid_5">
          <div class="control-group {if error:shipping_country}error{/if}">
                <label class="control-label" for="shipping_country">Country</label>
                <div class="controls"> {field:shipping_country} {error:shipping_country} </div>
              </div>
          <div class="control-group {if error:shipping_region}error{/if}">
                <label class="control-label" for="shipping_region">Region</label>
                <div class="controls"> {field:shipping_region} {error:shipping_region} </div>
              </div>
          <div class="control-group {if error:shipping_phone}error{/if}">
                <label class="control-label" for="shipping_phone">Phone</label>
                <div class="controls"> {field:shipping_phone} {error:shipping_phone} </div>
              </div>
        </div>
          </div>
    </fieldset>
        <fieldset>
      <h4>Terms and Conditions</h4>
      <div class="control-group">
            <div class="controls">
          <!-- label for="shipping_same_as_billing" class="checkbox"> {field:shipping_same_as_billing} I have read and accepted the <a href="/legal/terms_and_conditions" target="_blank">Terms and Conditions</a> </label> -->

          <p>{field:accept_terms}
                <label for="accept_terms">I accept the terms & conditions</label>
                {if error:accept_terms}

          <div class="control-group">
                <div class="alert alert-error">{error:accept_terms}</div>
              </div>
          {/if}
          </p>
        </div>
          </div>
    </fieldset>
        <div class="form-actions"> <a href="{path='{segment_1}/checkout'}" class="button_empty">Back</a>
      <input type="submit" name="next" value="Continue" class="inpbtn" />
    </div>
        {/exp:store:checkout} </div>
  <div class="grid_4">
        <p>Have a Account? Login to retrieve billing details (Optional)</p>
        {exp:member:login_form id='login_form' return="shop/customer_details"}
        <div class="row">
      <label for="username" class="grid_4">Email</label>
      <input type="text" class="grid_4" name="username" id="username" />
    </div>
        <div class="row">
      <label for="password" class="grid_4">Password</label>
      <input type="password" class="grid_4" name="password" id="password" />
    </div>
        <div class="grid_6">
      <input type="submit" id="login" value="Log in"  class="inpbtn" />
      <p><a href="{site_url}login/forgot">Forgot your password?</a></p>
    </div>
        {/exp:member:login_form} </div>
  <div class="clearfix"></div>
  {/if}

  {if logged_in}
  {exp:channel:entries channel="static_pages" limit='1' url_title="billing_intro"}
  {body_content}{content_body}{/body_content}
  {/exp:channel:entries}
  {exp:store:checkout form_class="form-horizontal" next="{segment_1}/confirm" error_handling="inline" error_delimiters='<span class="help-inline">|</span>' require="name|address1|address3|country|phone"}
  {if no_items}
  {redirect="{segment_1}/checkout"}
  {/if}
  <fieldset id="billing_details">
        <h3>Billing Details</h3>
        <div class="grid_6">
      <div class="control-group {if error:billing_name}error{/if}">
            <label class="control-label" for="billing_name">Name</label>
            <div class="controls"> {field:billing_name} {error:billing_name} </div>
          </div>
      <div class="control-group {if error:billing_address1}error{/if}">
            <label class="control-label" for="billing_address1">Address</label>
            <div class="controls"> {field:billing_address1} {error:billing_address1} </div>
          </div>
      <div class="control-group {if error:billing_address2}error{/if}">
            <div class="controls"> {field:billing_address2} {error:billing_address2} </div>
          </div>
      <div class="control-group {if error:billing_address3}error{/if}">
            <label class="control-label" for="billing_address3">City</label>
            <div class="controls"> {field:billing_address3} {error:billing_address3} </div>
          </div>
      <div class="control-group {if error:billing_postcode}error{/if}">
            <label class="control-label" for="billing_postcode">Postcode</label>
            <div class="controls"> {field:billing_postcode} {error:billing_postcode} </div>
          </div>
    </div>
        <div class="grid_5">
      <div class="control-group {if error:billing_country}error{/if}">
            <label class="control-label" for="billing_country">Country</label>
            <div class="controls"> {field:billing_country} {error:billing_country} </div>
          </div>
      <div class="control-group {if error:billing_region}error{/if}">
            <label class="control-label" for="billing_region">County/Region</label>
            <div class="controls"> {field:billing_region} {error:billing_region} </div>
          </div>
      <div class="control-group {if error:billing_phone}error{/if}">
            <label class="control-label" for="billing_phone">Phone</label>
            <div class="controls"> {field:billing_phone} {error:billing_phone} </div>
          </div>
      <div class="control-group {if error:order_email}error{/if}">
            <label class="control-label" for="order_email">Email</label>
            <div class="controls"> {field:order_email} {error:order_email} </div>
          </div>
    </div>
      </fieldset>
  <fieldset>
        <h3>Is this a Gift?</h3>
        <div class="grid_6">
      <div class="row">
            <div class="control-group">
          <label class="control-label" for="order_custom4">Recipient Name:</label>
          <div class="controls"> {field:order_custom4} {error:order_custom4} </div>
        </div>
          </div>
      <div class="control-group">
            <div class="row">
          <label class="control-label" for="order_custom5">Recipient Email Address:</label>
          <div class="controls"> {field:order_custom5} {error:order_custom5} </div>
        </div>
          </div>
    </div>
      </fieldset>
  <fieldset>
        <h3>Special Deliver Instructions</h3>
        <div class="grid6">
      <div class="row">
            <div class="control-group">
          <label class="control-label" for="order_custom6">Delivery Instructions</label>
          <div class="controls">
                <textarea name="order_custom6" class="grid_5"> </textarea>
              </div>
        </div>
          </div>
    </div>
      </fieldset>
  <fieldset>
        <h3>Shipping Details</h3>
        <div class="control-group">
      <div class="controls">
            <label for="shipping_same_as_billing" class="checkbox"> {field:shipping_same_as_billing} Same as Billing Details </label>
          </div>
    </div>
        <div id="shipping_details_drawer">
      <div class="grid_6">
            <div class="control-group {if error:shipping_name}error{/if}">
          <label class="control-label" for="shipping_name">Name</label>
          <div class="controls"> {field:shipping_name} {error:shipping_name} </div>
        </div>
            <div class="control-group {if error:shipping_address1}error{/if}">
          <label class="control-label" for="shipping_address1">Address</label>
          <div class="controls"> {field:shipping_address1} {error:shipping_address1} </div>
        </div>
            <div class="control-group {if error:shipping_address2}error{/if}">
          <div class="controls"> {field:shipping_address2} {error:shipping_address2} </div>
        </div>
            <div class="control-group {if error:shipping_address3}error{/if}">
          <label class="control-label" for="shipping_address3">City</label>
          <div class="controls"> {field:shipping_address3} {error:shipping_address3} </div>
        </div>
            <div class="control-group {if error:shipping_postcode}error{/if}">
          <label class="control-label" for="shipping_postcode">Postcode</label>
          <div class="controls"> {field:shipping_postcode} {error:shipping_postcode} </div>
        </div>
          </div>
      <div class="grid_5">
            <div class="control-group {if error:shipping_country}error{/if}">
          <label class="control-label" for="shipping_country">Country</label>
          <div class="controls"> {field:shipping_country} {error:shipping_country} </div>
        </div>
            <div class="control-group {if error:shipping_region}error{/if}">
          <label class="control-label" for="shipping_region">County/Region</label>
          <div class="controls"> {field:shipping_region} {error:shipping_region} </div>
        </div>
            <div class="control-group {if error:shipping_phone}error{/if}">
          <label class="control-label" for="shipping_phone">Phone</label>
          <div class="controls"> {field:shipping_phone} {error:shipping_phone} </div>
        </div>
          </div>
    </div>
      </fieldset>
  <fieldset class="grid_12">
        <h3>Terms and Conditions</h3>
        <div class="control-group">
      <div class="controls">
            <label for="shipping_same_as_billing" class="checkbox"> {field:shipping_same_as_billing} I have read and accepted the <a href="/legal/terms_and_conditions" target="_blank">Terms and Conditions</a> </label>
          </div>
    </div>
      </fieldset>
  <div class="clearfix"></div>
  <div class="form-actions grid_12"> <a href="{path='{segment_1}/checkout'}" class="button_empty">Back</a>
        <input type="submit" name="next" value="Continue" class="inpbtn" />
      </div>
  {/exp:store:checkout}
  {/if} </section>
{/case}

```

# Answer
> 1 votes
Have you set the default value for the field? Otherwise when unticked that field isn't sent with the form, so will pick up the previous saved value.

```
<input type="hidden" name="shipping_same_as_billing" value="0" />
<input type="checkbox" name="shipping_same_as_billing" value="1" id="deliveryCheckbox" {shipping_same_as_billing_checked} >
<label for="deliveryCheckbox">Same as Billing Address</label>
{error:shipping_same_as_billing}

```

Edit - Update your code to:

```
<h3>Shipping Details</h3>
<div class="control-group">
     <div class="controls">
         <input type="hidden" name="shipping_same_as_billing" value="0" />
         <label for="shipping_same_as_billing" class="checkbox"> {field:shipping_same_as_billing} Same as Billing Details </label>
    </div>
</div>

```

---
Tags: expresso-store
---


title: Template Caching breaks Minimee

text:
# Question
Title: Template Caching breaks Minimee
I am using Minimee 2.1.9 to combine and minify my css and js scripts on my EE 2.6.1 site. All works wonderfully if I don't have Template Caching turned on. When I turn on template caching for a particular template, the page will load the first time, but after that, the minimee tags just return something like this "{f4acc930e16260a7c8fcfd443f232ba1fb6b238e}" instead of the minified/crunched or tag.

My issue seems similar to what's happening with this thread:

Stash, switchee and template caching outputs a random string {6ee64145dfa4ae5926a9c326266d5954499133923}

But I'm not using 'Stash'.

Any idea how I can get around this, so I can use template caching?

Also, my {minimee} tags are within some Low Variables snippets, but I don't think that's related, as I've done a test where I bypassed low variables and got the same issue.

THANKS!

# Answer
(I've given the following answer in the @devot-ee support forums, but am reposting for anyone who comes across it...)

Hi PaleoSun,

The random tag parameter isn’t relevant here, because it’s a slightly different issue to the one that is meant to resolve...

At least in the short-term, there is no real fix other than to disable caching of any template that contains Minimee queue or display tags. It turns out this is pretty much a requirement for the Queue method to work correctly. I’ll try to explain why:

With Queuing, Minimee’s template tags are initially parsed during the normal stages in EE’s parse order. Yet instead of processing and creating the cache, it waits to see if any other queue tags are run, each time saving what it finds in the session. When it encounters the “display” tag, it replaces it with a placeholder string (that “{f4acc930e16260a7c8fcfd443f232ba1fb6b238e}” thing).

Once all template processing is done, by hooking into the “template\_post\_parse” hook, Minimee then processes all of the tags it found during runtime, compile the results, and then replaces the placeholder string with the final result.

The way EE template caching works, it caches the result of normal tag parsing, but *before* the template\_post\_parse hook. That’s why the placeholder string is still there in the template, and why on subsequent runs even though the template\_post\_parse hook runs, Minimee won’t have any saved tags to process. I hope that makes some sense.

If you were to ever use CE Cache, it has tags that allow you to escape it’s caching, so Minimee can still work very well alongside that, even the queue method (as long as all of Minimee’s tags are escaped).

I will make a note in Minimee’s docs as to the caveat with the Queue method, and I’m sorry for the inconvenience.

Cheers, John
> 3 votes

---
Tags: templates, caching
---