# Question
Title: is the needle haystack method possible with stash?
a lot of people are comparing stash with nsm\_transplant, so I was wondering if the same thing could be achieved with stash:

```
{exp:nsm_transplant:body}
 {cf_textarea}
 {cf_images_matrix}
     {exp:nsm_transplant:content id="image_{row_count}"}
      {exp:ce_img:pair src="{image_url:url}" width="200"}<img src="{made}" width="{width}" height="{height}" alt="{gv_alt}" />{/exp:ce_img:pair}
     {/exp:nsm_transplant:content}
 {/cf_images_matrix}
{/exp:nsm_transplant:body}

```

that way all the {image\_x} needles within the {cf\_textarea} get replaced with the corresponding tag.

would be nice if stash could do that!

**EDIT: Follow up for more complex example**

Now, while your example (see next answer) works like a charm, I've tested a few more cases:

**Complex example in standalone mode**:

```
{preload_replace:pre_prefix="static"}
{exp:channel:entries channel="ch_static" entry_id="1130" limit="1" disable="categories|member_data|pagination"}
    {exp:stash:parse process="end"}
        {cf_{pre_prefix}_block_matrix}
            <article class="content_block">
                {if title}<h1>{title}</h1>{/if}
                {if media AND text}
                    <div class="image">
                        {media}
                    </div>
                    <div class="text">
                        {text}
                    </div>
                {if:else}
                    {text}{media}
                {/if}
            </article><!-- end content_block -->
        {/cf_{pre_prefix}_block_matrix}
    {/exp:stash:parse}

    {cf_{pre_prefix}_images_matrix}
        {exp:stash:set name="bild_{row_count}" type="snippet"}
            {if image_zoom == "y"}
                <a class="modalbox_zoom img_link" title="{image_url:title}" href="{exp:ce_img:pair src='{image_url:url:max_size}' width='1200' height='800'}{made}{/exp:ce_img:pair}">
            {/if}
            {exp:switchee variable="{image_size}" parse="inward"}
                {case value="left"}
                    {exp:ce_img:pair src="{image_url:url:max_size}" width="255" allow_scale_larger="yes"}<img src="{made}" class="{image_alignement}" width="{width}" height="{height}" alt="{title} {image_url:title} {image_url:desc} {gv_alt}" />{/exp:ce_img:pair}
                {/case}
                {case value="right"}
                    {exp:ce_img:pair src="{image_url:url:max_size}" width="311" allow_scale_larger="yes"}<img src="{made}" class="{image_alignement}" width="{width}" height="{height}" alt="{title} {image_url:title} {image_url:desc} {gv_alt}" />{/exp:ce_img:pair}
                {/case}
                {case value="full"}
                    {exp:ce_img:pair src="{image_url:url:max_size}" width="600" allow_scale_larger="yes"}<img src="{made}" class="{image_alignement}" width="{width}" height="{height}" alt="{title} {image_url:title} {image_url:desc} {gv_alt}" />{/exp:ce_img:pair}
                {/case}
                {case value="untouched"}
                    <img src="{image_url:url}" width="{image_url:width}" height="{image_url:height}" alt="{title} {image_url:title} {image_url:desc}" class="small_image img_link" />
                {/case}
            {/exp:switchee}
            {if image_zoom == "y"}</a>{/if}
        {/exp:stash:set}
    {/cf_{pre_prefix}_images_matrix}

{/exp:channel:entries}

```

**template partials approach:**

the standard template:

```
{embed="_wrapper/_standard"}

{preload_replace:pre_prefix="static"}
{if in_group(1)}{preload_replace:pre_status="open|Draft"}{/if}{preload_replace:pre_status="open"}

{exp:channel:entries channel="ch_static" limit="1" status="{pre_status}" disable="categories|member_data|pagination"}

    {!-- misc stuff --}
    {exp:stash:set scope="site"}
        {stash:entry_id}{entry_id}{/stash:entry_id}
        {stash:title}{title}{/stash:title}
        {stash:og_image}{cf_{pre_prefix}_images_matrix limit="1"}{exp:ce_img:pair src="{image_url:url:max_size}" width="250"}{made}{/exp:ce_img:pair}{/cf_{pre_prefix}_images_matrix}{/stash:og_image}
        {stash:status}{pre_status}{/stash:status}
        {stash:background_image}{cf_{pre_prefix}_background limit="1"}{url:max_size}{/cf_{pre_prefix}_background}{/stash:background_image}
        {stash:color}{sp_color}{/stash:color}
    {/exp:stash:set}

    {!-- preparing the content, but not outputting it yet --}
    {exp:stash:set scope="site" name="main_content" parse_tags="yes" parse_conditionals="yes" output="no"}
        {cf_{pre_prefix}_block_matrix}
            <article class="content_block{if status == 'Draft'} logged_in{/if}">
                {if title}<h1>{title}</h1>{/if}
                {if media AND text}
                    <div class="image">
                        {media}
                    </div>
                    <div class="text">
                        {text}
                    </div>
                {if:else}
                    {text}{media}
                {/if}
            </article><!-- end content_block -->
        {/cf_{pre_prefix}_block_matrix}
        <p class="last_edited hidden"><time datetime="{entry_date format="{sp_datetime_format}"}">Letzte Änderung am {edit_date format="%Y-%m-%d"}</time></p>
    {/exp:stash:set}

    {!-- setting the inline edit links --}
    {exp:stash:set scope="user" name="edit_main_content" parse_tags="yes" parse_conditionals="yes"}
        {if member_group == "1"}<p  class="hide_on_demand"><a class="modalbox_edit" href="/backend/index.php?D=cp&C=content_publish&M=entry_form&channel_id={channel_id}&entry_id={entry_id}" title="Zuerst «Senden» drücken, dann «Schliessen und Neuladen»! Esc um abzubrechen">{title} bearbeiten ↑</a></p>{/if}
    {/exp:stash:set}

    {!-- setting the needles --}
    {cf_{pre_prefix}_images_matrix}
        {exp:stash:set name="bild_{row_count}" type="snippet"}
            {if image_zoom == "y"}
                <a class="modalbox_zoom img_link" title="{image_url:title}" href="{exp:ce_img:pair src='{image_url:url:max_size}' width='1200' height='800'}{made}{/exp:ce_img:pair}">
            {/if}
            {exp:switchee variable="{image_size}" parse="inward"}
                {case value="left"}
                    {exp:ce_img:pair src="{image_url:url:max_size}" width="255" allow_scale_larger="yes"}<img src="{made}" class="{image_alignement}" width="{width}" height="{height}" alt="{title} {image_url:title} {image_url:desc} {gv_alt}" />{/exp:ce_img:pair}
                {/case}
                {case value="right"}
                    {exp:ce_img:pair src="{image_url:url:max_size}" width="311" allow_scale_larger="yes"}<img src="{made}" class="{image_alignement}" width="{width}" height="{height}" alt="{title} {image_url:title} {image_url:desc} {gv_alt}" />{/exp:ce_img:pair}
                {/case}
                {case value="full"}
                    {exp:ce_img:pair src="{image_url:url:max_size}" width="600" allow_scale_larger="yes"}<img src="{made}" class="{image_alignement}" width="{width}" height="{height}" alt="{title} {image_url:title} {image_url:desc} {gv_alt}" />{/exp:ce_img:pair}
                {/case}
                {case value="untouched"}
                    <img src="{image_url:url}" width="{image_url:width}" height="{image_url:height}" alt="{title} {image_url:title} {image_url:desc}" class="small_image img_link" />
                {/case}
            {/exp:switchee}
            {if image_zoom == "y"}</a>{/if}
        {/exp:stash:set}
    {/cf_{pre_prefix}_images_matrix}
{/exp:channel:entries}

```

here's the wrapper template:

```
<!DOCTYPE html>
<html lang="de">
<head>
    <meta charset="utf-8" />
    {exp:seo_lite entry_id="{exp:stash:get name='entry_id'}" parse="inward"}
    <meta property="og:site_name" content="Café Kairo Lorraine"/>
    <meta property="og:title" content="{exp:stash:get name='title'}" />
    <meta property="og:image" content="{exp:stash:get name='og_image'}" />
    {sp_global_head}
    {exp:stash:get name='color'}

</head>
<body id="{segment_1}">

{embed="_includes/_admin"}

{gv_start}

    <header id="header">
        <h1 id="logo"><a href="{path='/'}" class="hide-text">...</a></h1>
    </header>

    <section id="content_container">
        <!-- main navigation -->
        <nav id="main_nav">
            {exp:structure:nav start_from="/" max_depth="1" status="{exp:stash:get name='status'}" css_id="none" parse="inward"}
        </nav><!-- end main_nav -->
        {!-- getting the main content and replacing the needles --}
        {exp:stash:parse process="end"}{exp:stash:get name='main_content'}{/exp:stash:parse}

        {!-- edit links --}
        {exp:stash:get name='edit_main_content' scope="user"}
    </section><!-- end #content_container -->

    <footer id="footer">
        <p>...</p>
    </footer><!-- end #footer -->

{gv_before_end}
{embed="_includes/_end"}

<script type="text/javascript">
    jQuery(function($){
        $.supersized({
            //Background image
            slides  :  [ { image : '{exp:stash:get name='background_image'}' } ]
        });
    });
</script>
{gv_end}

```

so far it works great and also the speed is now better than ever! just one single embed. I am fascinated!

cheers stefan

# Answer
You could do this:

```
{exp:channel:entries ...}

 {cf_images_matrix}
     {exp:stash:set name="image_{row_count}" type="snippet"}
      {exp:ce_img:pair src="{image_url:url}" width="200"}<img src="{made}" width="{width}" height="{height}" alt="{gv_alt}" />{/exp:ce_img:pair}
     {/exp:stash:set}
 {/cf_images_matrix}

 {exp:stash:parse process="end"}
     {cf_textarea}
 {/exp:stash:parse}

{/exp:channel:entries}

```
> 2 votes

---
Tags: stash
---


# Question
Title: EE date timestamps have different values for the same date/time
i have a list of movie screenings sorted by date. now the client wants to be able to order additionaly with a custom order field, i don't get to the second order\_by however...

it seems when you enter a date random seconds are added to the EE timestamps. if they enter "2013-03-01 08:00 PM" it always has a different timestamp: 1362186000, 1362186018, 1362186025, 1362186032,...

where are those seconds coming from? and how can i solve it?

my template:

```
{exp:channel:entries channel="screenings" status="open" dynamic="off" category="3&21" orderby="screening_datetime|screeningorder"  sort="asc|asc"  limit="200"}
            {screening_datetime} - {screening_datetime format="%d %M %Y  %G:%i"} hrs {screeningorder}
            {related_entries id="screening_movie"}
                <a href="{title_permalink="programacion/pelicula/"}">{title}</a>
            {/related_entries}
{/exp:channel:entries}

```

# Answer
Since by default the datepicker does not include seconds, EE saves the *current time's* seconds (minus 1 second) to the entry date (and in fact any custom date field). So the last part of the timestamp for each of these fields is based on when the entry was created.

(Looking under the hood, it appears there have been two approaches over the years to this - at one time, seconds were set to `00`, but then this was reverted, as it meant that entries submitted within the same minute had identical timestamps, which is not accurate.)

You can use the hidden configuration variable `include_seconds` to your **config.php** file to add the seconds to all datepickers, allowing you to set the date precisely.

```
$config['include_seconds'] = 'y';

```

Or, since this is a custom date field you're using (not the Entry Date), you can use DropDate, which bypasses EE's date handling and saves the timestamp directly, using `00` for the seconds value.
> 4 votes

---
Tags: custom-fields, date
---


# Question
Title: Is it safe to get all tag params in one go with $this->EE->TMPL->tagparams?
*Apologies if this is very obvious for experienced addon devs, but I'm experimenting with writing more bespoke plugins rather than gluing together other people's...*

I know the official way to fetch parameters is one-by-one by name with `$this->EE->TMPL->fetch_param('key')`, but I'm currently writing a plugin in which I'd like to iterate over my tag's parameters without having to define in advance what those parameters are in my plugin class.

I see that I can access the tag parameters array directly via `$this->EE->TMPL->tagparams`, **but is it safe to do so?**

As far as I can see from reading the Template parser source, `fetch_param()` just does a bit of tidying up to ensure tag params are uniformly formatted and returns false if a requested param is not set, neither of which are a concern in my use case. However, I want to be sure I'm not introducing unnecessary fragility (or indeed a vulnerability) into my plugin inadvertently.

# Answer
> 4 votes
Take a look at the `fetch_param()` method in the Template library. There you can see all it does is return the value of the given key in the `tagparams` array, offering a fallback default.

So, it should be completely safe, unless EllisLab decides to make it a private property, which I doubt they'll do.

# Answer
> 2 votes
Plenty of add-ons rely on that public `tagparams` property (ours included). So you would certainly not be the first to rely on it (e.g. my answer here).

That doesn't mean EllisLab won't change/break it in future, but rest assured your add-on won't be the only one that breaks :)

---
Tags: add-on-development, plugin, parameters
---


# Question
Title: Single add to basket in Exp:resso Store?
I'm using Exp:resso store, everything is working fine, but I have multiple "Add to Cart" buttons on the page, one for every product. Is there anyway to have just one Single Add to Cart at the bottom of the form?

As an example, my products page currently has 50+ items listed, each with there own Add to Cart button beside it. I'd like the customer to be able to go down through the list, entering the totals as they go, then clicking on an one Add to Cart button of the bottom of the list to update the cart.

Any help much appreciated.

Thanks.

# Answer
> 3 votes
Yes, this is referred to (at least by Store) as "multi add to cart".

You should take a look at the Product Form Tag. From the docs:

> The product form tag is used to create custom add to cart forms, which allow the customer to add multiple items to their cart at once. Most websites will not need to use this tag, as the Product Tag already provides an add to cart form wrapped around a single product.

Really simple example:

```
{exp:store:product_form}
  {exp:channel:entries channel="products" dynamic="no" limit="5"}
      {exp:store:product disable_form="yes" entry_id="{entry_id}"}
          <!-- add to cart form / product details -->
    {exp:store:product}
  {/exp:channel:entries}
{/exp:store:product_form}

```

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


# Question
Title: Decrementing a field value in an Events channel when a form is submitted
I was wondering if anyone can help me. I've got an events channel with a 'number of places available' number field, which users uploading an event populate with how many spaces they have available for an event. When people book an event, through freeform, I want them to input a number as to how many places they want, and for this number to be substracted from the 'number of places available' number field. Does anyone know of a module or fieldtype that could do this?

Thanks, Julie

# Answer
Take a look at my answer here.

There I recommend using Safecracker instead of Freeform, to store these as entries. You can then use an add-on or your own PHP code to handle the email notifications that Freeform would have generated.

When using Safecracker, you'll want to have a postprocessor template as your redirect URL. In that template, you can use `exp:query` to update your database, or PHP. Either way, you'll be manipulating those values directly.

You can include the new entry's ID on the redirect URL for reference in your postprocessor template. You can set PHP to output, and get the entry using `exp:channel:entries entry_id="{segment_x}"`.

Within that postprocessor template, you can have a redirect to send the user on to the target destination.

**Updated:** I'm suggesting Safecracker as it will ultimately give you more flexibility in your event management data. If you think of it as a relational database, you have event records and registration records. Those are really registration entries in a registration channel, referencing an event. You'll ultimately have more flexibility in this sort of system by treating those as a channel, and possibly find exp\_channel\_data easier to manipulate.

Freeform also has a post submit hook. You can write an extension that will manipulate your Event channel data using PHP/SQL in an extension, and register that extension to run every time a particular form is submitted. But I'd consider storing relational data entirely in channels, not split between a channel and Freeform. That way you can do custom reports with `exp:channel:entries`, etc.
> 1 votes

# Answer
Mark Reeves is correct in stating that this could potentially be better handled within the Channel Entries, just using SafeCracker Form to complete. Not because Free Form Pro couldn't handle the job and well. But primarily, because most add-ons work on channel entries. Though if it is a plugin that's applied via the template, then it should work on Free Form Pro as well.

Basically your looking for plugins for two things:

Derek Hogue, Amphibian Design, has created Tally which is a plugin that would allow you to easily retrieve total 'tickets' or 'registrations' for the event, then either PHP or a second 'math' based plugin could be used to do the subtraction. I've used 'Math' by and have heard good things about MX Calculator, but have never used it. Normally, if necessary, I just drop into PHP.

You'll want to — Total the number of RSVPs, subtract RSVPs/attendees from max registration field. Display remainder. (which you've mentioned), but you'll also need to stop the registration process, when max attendees has been reached. This can be done via CSS, hiding the submit button from view, and maybe a modification to the submit id, so if people are using screen readers or use to pushing 'enter', that the submit fails.

It's doable, either way, Free Form or SafeCracker. The plugins should/may work on the Free Form fields, so give them a try. But they aren't really submitting data back to the system, just doing math on the template itself. Which is why you need to put safeguards in place to stop registrations over the max total.
> 0 votes

---
Tags: fieldtype, number-format
---


title: Entry links across multiple sites

text:
# Question
Title: Entry links across multiple sites
I am using ExpressionEngine 2.5.2 with Multisite Manager installed.

I have a blog that is pulling entries from two different sites. I am able to successfully show those entries on the main blog page, but I am having trouble linking the entry to the correct site. The code I am using is trying to find all posts on the main site, when some of them exist on the 2nd site. Could someone tell me the correct way to do this? Here is the code on the main blog page:

```
{exp:channel:entries  channel="news"  site="default_site|characterized" orderby="date"  limit="6"  }
<div class="box">
    <a class="img-holder" href="{url_title_path='news'}">
    <img src="{news_thumbnail}" width="336" height="196" alt="image description" />
</a>
<div class="info">
    <h3><a href="#">{title}</a></h3>
    </div>
</div>
{/exp:channel:entries}

```

The part that's not working correctly is **a href="{url\_title\_path='news'}"** in the 3rd line above.

# Answer
My favorite way to handle this is to use the {comment\_url\_title\_auto\_path} variable (instead of url\_title\_path=). That will pull that setting from the channel settings.

Does that work for you? Even if you're not using comments, it's a good "permalink" variable.
> 1 votes

---
Tags: channel-entries, url, multi-site-manager
---


title: EE1 to EE2 upgrade issues

text:
# Question
Title: EE1 to EE2 upgrade issues
I'm trying to upgrade a site from EE1 to EE2 and I followed the EL docs to the letter but when I go to run the wizard I get "Click here to install a brand new copy of ExpressionEngine". Anyone know why this might be occurring?

UPDATE: Forgot to add that I would be upgrading an EE1.7.3 site to EE2.5.5 running on a MT GS server.

# Answer
> 2 votes
Stuart,

This usually indicates that EE is not finding your old EE 1 config.php. Step 4 of the upgrade instructions has you placing your backed up EE 1 config.php in /system/expressionengine/config:

> Copy your old 1.x version of system/config.php to system/expressionengine/config/config.php

And that should help you to avoid this issue. I know you said you're following the docs to the letter, but please do double check that your config.php in /system/expressionengine/config is the EE 1 config. That should get you moving forward!

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


title: Deny Multiple Login Override in config

text:
# Question
Title: Deny Multiple Login Override in config
Is there a way to disable Deny Multiple Logins via a $config override?

Thank you.

# Answer
You can use \[allow\_multi\_logins\] =\> n in your config.php for this. Make sure it's in the same format as the other config items.

You can find the full list in the wiki, via the Wayback Machine: EE 2 Config Overrides.
> 2 votes

---
Tags: config, login, config-overrides
---


# Question
Title: How to make the channel entries tag return the same entry more than once?
I am passing a pipe-delimited list of entry ids into a standard channel entries tag:

```
{exp:channel:entries
    entry_id="149|453|321|149"
    dynamic="no"
    limit="4"}

        {title}

{/exp:channel:entries}

```

I only get 3 results returned, with the second 149 ignored. There seems to be some filter stripping it out. I have gone through the docs but I have not found any parameter along the lines of allow\_duplicates="".

How can I make the channel entries tag return the same entry twice if I explicitly request it by entry id?

# Answer
You can't. The channel:entries tag will always return unique/distinct entries. No way around it.
> 2 votes

# Answer
A more advanced approach, but your best bet might be to use Stash \- stash that entry in your logic template, then use it more than once if needed in the wrapper template. Since you're trying to return a duplicate entry, you may need to also stash the entry ID or something so you can use it in your wrapper template to target it distinctly. For a primer on template partials using Stash, have a look at Adrienne Travis' article on eeinsider.
> 0 votes

# Answer
You could loop through the values you're using to create the pipe-delimited list and call `exp:channel:entries` for each hit.

I tried getting all rows in SQL, so you could use `exp:query` and pass each `entry_id` into an embed, but SQL only returns the distinct rows as well, seemingly no matter what you throw at it.

```
Select entry_id from exp_channel_titles t where entry_id in (1, 2, 3, 1)

```

If you do pull each entry individually in a loop, consider making it a plugin or using `exp:query` to optimize things.
> 0 votes

---
Tags: channel-entries
---


# Question
Title: How to retrieve a value from a Store field within a Playa relationship with a Matrix Cell?
I can't quite get my head around this one but I'm using Expresso Store, Playa, and Matrix. The parent entry has a Matrix field with a Playa relationship field in one of the cells. This links to a product which is of the Store field type. I need to retrieve the price of that product in the other channel. How?

To clarify, I have a '*Lists*' channel and a '*Gifts*' channel. The *Gifts* channel stores the product info using the Store field. The *Lists* channel is the parent and makes the relationship. The product is related (by title of the product) in a Matrix field in the parent. I can extract the title of the product successfully like this:

```
{product_list} {!-- Matrix field of the parent --}
    {product}  {!-- Matrix cell of the above field --}
        {title} {!-- Title of the product successfully retrieved --}
    {/product}
{/product_list}

```

The above works. The following doesn't work but it's the kind of thing that I want to be able to do but don't know how with this level of nesting or retrieval:

```
{product_list} {!-- Matrix field of the parent --}
    {product}  {!-- Matrix cell of the above field --}
        {title} {!-- Title of the product successfully retrieved --}
        {product_info} {!-- Store field of the related product in Gifts channel --}
            {regular_price} {!-- Price field within the Store field --}
        {/product_info}
    {/product}
{/product_list}

```

# Answer
> 3 votes
There are a couple of ways to approach this if you are just wanting to have price you would want do something along the following (as referenced here)

> Most variables can also be used outside of the product form, inside a standard {exp:channel:entries} loop. For example, if your Store products custom field is named “product\_details”, then the price is also accessible as: `{product_details:price}`

```
{product_list} {!-- Matrix field of the parent --}
    {product}  {!-- Matrix cell of the above field --}
        {title} {!-- Title of the product successfully retrieved --}
        {product_info:price} {!-- This is the format of custom_field_name:value_to_retieve --}
        {product_info:regular_price}
        {product_info:sale_price}
    {/product}
{/product_list}

```

If you are wanting to add the item to the cart you would want to do something along the lines of:

```
{product_list} {!-- Matrix field of the parent --}
    {product}  {!-- Matrix cell of the above field --}
        {title} {!-- Title of the product successfully retrieved --}
        {exp:store:product entry_id="{entry_id}"} {!-- Store field of the related product in Gifts channel --}
            {regular_price} {!-- Price field within the Store field --}
Other fields here like quantity, modifiers, and a submit button
        {/exp:store:product}
    {/product}
{/product_list}

```

---
Tags: expresso-store, matrix, playa, relationships
---


# Question
Title: Comment form not submitting data, not returning to proper return URL
I have a comment form that is not functioning properly.

When I try to submit a comment, nothing gets saved to the database, and instead of retuning me to the specified return URL it returns me to the same single entry page with the comment form. No error is given and no other indication that anything is wrong.

Other forms on the site like Freeform contact form works fine. Just the comment form is not working.

The weblog and entry I’m testing on both have comments enabled.

Here’s is my template code:

```
{exp:comment:form channel="blog" preview="blog/comment" form_class="default" return="{homepage}blog/comment-thanks"}
     <fieldset>
      <ul class="formRow">
       {if logged_out}
       <li class="third">
        <label>Name <span class="req">*</span></label>
        <input type="text" name="name" value="{name}">
       </li>
       <li class="third">
        <label>Email <span class="req">*</span></label>
        <input type="text" name="email" value="{email}">
       </li>
       <li class="divider">.</li>
       {/if}
       <li class="wide">
        <label>Comment <span class="req">*</span></label>
        <textarea name="comment">{comment}</textarea>
       </li>
       {if captcha}
       <li class="divider">.</li>
       <li class="wide">
        <label>{captcha} <span class="req">*</span></label>
        <input type="text" name="captcha">
       </li>
       {/if}
       <li class="divider">.</li>
       <li class="buttons">
        <a class="btn submit arrow" href="#">Submit Comment</a>
       </li>
      </ul>
     </fieldset>
    {/exp:comment:form}

```

I’ve read in other places that forcing trailing slashes on URLs or removing “www” from URLs can cause problems with form submissions. I am using .htaccess to remove index.php but I am not removing “www” nor am I forcing trailing slashes. And as said above other form submissions are working fine, just not comment form.

With no error message it’s becoming very difficult for me to tell why else it wouldn’t work.

Any ideas? How can I debug this?

# Answer
> 1 votes
You should try by using entry\_id or url\_title parameter with comment form tag like:

```
{exp:comment:form channel="blog" preview="blog/comment" form_class="default" return="{homepage}blog/comment-thanks" entry_id="ENTRY_ID"}

```

OR

```
{exp:comment:form channel="blog" preview="blog/comment" form_class="default" return="{homepage}blog/comment-thanks" url_title="URL_TITLE"}

```

This will specify the entry on which comment will be posted.

Hope this would help you.

# Answer
> 0 votes
If you have the comment form code inside the channel entries loop take it out. It needs to stand alone. It will grab the url\_title dynamically.

---
Tags: comments, comment-form
---


# Question
Title: How to correctly use {if allow_comments}?
I'm having trouble grasping the usefulness of {if allow\_comments}. The comment:entries loop and comments form code are both supposed to be **outside** of channel:entries, but presumable {if allow\_comments} only works **inside** channel:entries. So I find myself having to use the channel:entries tag repeatedly around the elements in order to use the conditional. So my code get's all ugly like this:

```
{exp:channel:entries channel="blog" disable="category_fields|member_data|pagination" dynamic="no" status="Open|Featured" url_title="{segment_3}" limit="1" require_entry="yes"}
{if allow_comments && comment_total > 0}
                <div class="dividerBig">.</div>
                <h1>Comments</h1>
                <ul class="comments">
                {/if}<!-- end allow comments -->
            {/exp:channel:entries}

                    {exp:comment:entries channel="blog" url_title="{segment_3}" orderby="date" sort="asc"}
                    <li>
                        <h3><span>{name}</span></h3>
                        {comment}
                        <span class="date">{comment_date format="%F %d, %Y"}</span>
                    </li>
                    {/exp:comment:entries}

            {exp:channel:entries channel="blog" disable="category_fields|member_data|pagination" dynamic="no" status="Open|Featured" url_title="{segment_3}" limit="1" require_entry="yes"}
                {if allow_comments && comment_total > 0}
                </ul>
                {/if}<!-- end allow comments -->

                {if allow_comments}
                <div class="dividerBig">.</div>
                <h1>Write a comment</h1>
                {/if}<!-- end allow comments -->
            {/exp:channel:entries}

                {exp:comment:form channel="blog" url_title="{segment_3}" preview="blog/comment" form_class="default" return="{homepage}blog/comment-thanks"}

```

Etc...

This looks rediculous and I'm sure using so many channel:entries tags is a performance hit, but how else do you effectively use the {if allow\_comments} conditional?

Do people put their comment:entries and comments forms inside embed templates? Is that any better?

# Answer
I usually do something like this, within my Channel Entries tag:

```
{if comment_total > "0" || allow_comments}
    {embed="blog/_comment_list"}
{/if}

{if allow_comments}
    {embed="blog/_comment_add"}
{if:else}
    <p>Sorry, comments are closed.</p>
{/if}

```

With the appropriate chunks of `comment:entries` and `comment:form` code in those embeds respectively. Much cleaner.
> 2 votes

---
Tags: conditionals, comments, comment-form
---


# Question
Title: Search Date on channel field of type date
I have a form which will have a date range split into day month year as 3 individual HTML select options for FROM and TO -

From: SELECT option day, month year

To: SELECT option day, month, year

I need to search on a channel field of type date (Currently stored as a UNIX time stamp)

What would be the best solution to get the entire range to search and how best to convert the date supplied?

I am not seeing the default search functionality will help me?

# Answer
There are two search addons that may help:

**Low Search**

> Limiting entries by a given range, based on channel fields;

---

**Super Search**

> Anything you might want to search for... keywords, channels, categories, statuses, authors, custom fields, **date ranges**, custom field numeric ranges, etc, can be loaded into a single URI segment with the Super Search syntax.
> 2 votes

---
Tags: channel-entries
---


# Question
Title: View/download Freeform Pro entries in MS Word format or other readable format
I have an application form on a web page using "free-form pro" add-on. I can download the entries in CSV / xml / json / text formats but I was wondering if it's possible to download it in a Word format or other more readable format?

The form is made up of around 25 questions (many are text box areas) and reviewing the applications in CSV format is not helpful (lots of horizontal scrolling). Ideally, I would like to view each application separately going through the questions and answers vertically.

The only thing I can think of is taking the xml and mapping it on a web page.

Thanks

# Answer
> I was wondering if it's possible to download it in a Word format or other more readable format?

For readability, a PDF is your best bet.

We had an EE application that pulled in XML data, which we stored in entries. We then output that on HTML pages using XSLT in PHP, and we generated PDF versions of the reports available on demand.

We accomplished that with a whole bunch of PHP in templates set to allow PHP on output. Of course, that should really all go into a plugin.

We used PDFLib. There are other options if you Google around.

With PDFLib, we were able to:

* Have a PDF template with header and footer
* Plot any content/data into the PDF with PHP
* Draw image graphics on the fly with another library, also used on the HTML pages, and insert those into the PDF

You can set your headers in PHP to force the content type to PDF data or whatnot. Then when the user clicks the download link, they'll be prompted to download the file. There is no file on the server - Your PHP script is generating PDF output - but you need to tell the browser that. There are lots of resources on that.

If you're determined to do something in Word, I attempted years ago to merge data/content into RTF format by saving an existing doc as RTF and cracking it open. It was messy. Something that allows you to programmatically insert and plot content into a PDF is what you're looking for.
> 3 votes

# Answer
You can create a regular ExpressionEngine template and output the information in whatever format you like.
Use the Freeform entries tag to display the data.
> 2 votes

# Answer
IMO, the best for readability is to import into Excel from a CSV export.

After exporting to CSV, change the file name to .txt if it isn't using that already. Then go into Excel and select Open from the File menu, navigate to your .txt file and select it. This will start the Excel import wizard. Click through the wizard and select the appropriate options based on the file and when you get to the end you will have all your data in Excel organized with the appropriate columns.
> 0 votes

---
Tags: solspace-freeform
---


# Question
Title: How Does ExpressionEngine Handle Outside Directories?
I have a directory in my web root (let's call it `microsite`) that is not managed by my main ExpressionEngine site, but people still need to access it. So, naturally, I just navigate to http://mysite.com/microsite and I'm good to go.

What I'm wondering is what is ExpressionEngine's process when it encounters a URL segment that isn't a template, but isn't a 404 either? What are the steps it/the server takes for me to ultimately arrive at my non-EE destination?

# Answer
> 5 votes
This will depend entirely on how you have your server set up. ExpressionEngine is only aware of things that go through the index.php file (or if you have by chance renamed this file, then whatever you renamed it). On Linux servers, often .htaccess will be used to remove index.php from the URL but still send all requests through index.php. So for instance, here is the htaccess configuration I typically use:

```
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]

```

To keep things short, what that essentially does is have the server check if the file or folder the URL is requesting exists. If it does, then that file or folder is served. If not, then the request goes through index.php, and therefore through ExpressionEngine. EE of course then decides whether to serve a template or to throw a 404. How EE handles all that will depend on your EE configuration, whether you have strict URLs turned on, whether the template group exists, etc.

As I said, you could have a different configuration and that will affect this information, but I hope this helps.

# Answer
> 3 votes
Is this URL failing?

EE shouldn't do anything. Since the directory exists on the server it should load just fine.

There will only be an issue if you have a template group with the same name. In that case, EE will load the template group if I remember correctly.

---
Tags: segments, server, 404
---


# Question
Title: Missing "Create" options, such as Channel, on ExpressionEngine CP Dashboard
I am fairly new to ExpressionEngine, I have noticed my admin page is missing "Channel", "template", and "template group" as seen on this page:

http://ellislab.com/expressionengine/user-guide/how\_to/building\_a\_simple\_news\_site.html#before-you-begin

Can someone please advise?

Many thanks.

# Answer
> 4 votes
I expect the developer who configured the site restricted your admin privileges so that you can create entries and post content to the site, but not configure the website.

Channels, template groups and templates are all underlying components that structure what the site supports and how it renders. They all need to be accompanied by code to work on the website, as opposed to posting/editing content entries, which the templates you have in place should already match.

# Answer
> 2 votes
It sounds like you need to be set as a SuperAdmin if you do not have access to a SuperAdmin that can change your account type you have a few options.

The easiest would be to:

If you have access to Tools \> Data \> SQL Manager \> Database Query Form you can simply run the following command

```
UPDATE exp_members SET group_id=1 WHERE member_id=X

```

Where "X" is your member\_id. If you need to find out your member\_id you can goto Members \> View All and then search for your username.

The other option would be to reset the initial Super Admins password to something along the lines of "password" for you to login and change it.

To do that you would want to run the following command

```
UPDATE exp_members SET password='5f4dcc3b5aa765d61d8327deb882cf99' WHERE member_id=1

```

This can also be done from phpMyAdmin if you do not have access to the Tools menu.

---
Tags: templates, channel, admin
---


title: Wygwam and modal windows for images

text:
# Question
Title: Wygwam and modal windows for images
This issue has come up several times in the past with clients, and I can't seem to think up a clever way of doing it. A few of my clients would like to upload images in the body copy of their text that will popup a jQuery modal window with a larger version of the image when clicked on, rather than a new tab/window default behavior.

This would probably be easy if they were limited to one image in the body, but I don't want to limit them with just one image... and plus I'm very curious if this can be done ;-) If it matters, I'll be using Assets as well.

Thanks!

# Answer
> 2 votes
Well, I guess there are several ways of doing this, one of them is finding a way to *modify* preferences window (target or similiar) of a link. But I found it much easer instruct clients to add css class to the link they make.

They make a normal link to big image they want to open in modal window, and in Advanced tab they add special css class. Based on that class you make js call to your modal window, fancybox etc.

This can be easy included in documentation and can be actually used on all channels.

---
Tags: assets, jquery, wygwam, modal
---


title: Language file parse error

text:
# Question
Title: Language file parse error
I have a language file in my foo add-on

```
<?php

$lang = array(

/* ----------------------------------------
/*  Required for MODULES page
/* ----------------------------------------*/

'foo_name'=>
'Foo',

'foo_description'=>
'Adds Foo information data in the field',

//-----------------------------------------//

/* END */
''=>''
);
?>

```

I got this error

```
Parse error: syntax error, unexpected T_VARIABLE in /home/test/public_html/system/expressionengine/third_party/foo/language/english/foo_lang.php on line 1

```

Any idea why this is happening? I am probably missing something obvious.

# Answer
> 0 votes
This is probably either a problem with your text editor, or your FTP client (e.g. https://stackoverflow.com/questions/11514498/odd-unexpected-t-variable).

Try copy pasting it into a new file and saving. Make sure the file is saved with unix line endings, and NO byte order mark (BOM).

Also try running it locally, instead of on your server, to rule out problems with your FTP client (assuming you're getting the error on a server, that is).

# Answer
> 0 votes
The file should be named `lang.foo.php`, not `foo_lang.php`

---
Tags: add-on-development
---


# Question
Title: Add a "Like" button to a native comments entries tag?
Like some of the social comment engines, is there an add-on to allow users to "like" a comment within an entry (and not the entry itself)?

# Answer
Take a look at Flag Master; it's built specifically to allow you do exactly that (and a whole lot more). You can setup your own "sets" of options (or just 1) and is completely AJAX compatible and made with love.
> 0 votes

# Answer
Likee is free and on my shortlist to try out. http://booyant.com/likee
> 1 votes

# Answer
Although not using the native EE comment module, if you use Solspace's Rating module instead, you can use the **review** field in a Rating form as an entry comment. This can be done without using the **rating** field. Then, users can rate a rating/review *up* or *down* using the {exp:rating:insert\_rating\_vote} tag. This could be used as an equivalent of "liking" (or "disliking") a comment.
> 0 votes

# Answer
Might be not exactly what you're looking for, but you can use Bookmarks to let users bookmark comments.

Though different, the concept is still similar to likes.

Use can use `{exp:bookmarks:by type='comment' data_id='{comment_id}'}{total_results}{/exp:bookmarks:by}` to display total number of bookmarks for the comment and `{exp:bookmarks:check}` to display 'add-to-bookmarks' form
> 0 votes

# Answer
If one were so inclined, you could take Low's http://mijingo.com/products/screencasts/how-to-develop-expressionengine-add-on/ which does 'likes' for an entry and modify it to do likes for a comment entry.
> 0 votes

---
Tags: comments
---


title: ExpressionEngine snapshot add-ons?

text:
# Question
Title: ExpressionEngine snapshot add-ons?
My client is forever concerned with making big changes in EE. For instance, using Structure to reorder pages, or renaming entire sections of the site.

I'm wondering: Are there any add-ons that can essentially take a snapshot of the current state of the site, then allow you to roll back to that state if you make a destructive or unwieldy change, or just plain break something?

ideally this would be something that works in the EE system and won't require any manual DB backups or anything.

# Answer
I'm afraid there is not. What i would recommend is that you get a test site setup on either the same server as the live site but in a subdomain so for example 'test.mysite.com', (password protect that of course!), or on a server of identical specification as the live one.

Then take a copy of your live site, put it in the test subdomain and test your changes. Once you are happy that your change is ok and hasn't broken anything, you can apply it to the live site.

There are more complex methods which i'll not go into right now, but the above is, in it's simplest terms, what you should be doing :)
> 2 votes

# Answer
Backup pro http://devot-ee.com/add-ons/backup-pro allows you to backup both the DB and your files, as does Safe harbor http://devot-ee.com/add-ons/safe-harbor.
> 2 votes

# Answer
There is a number of backup add-ons. Some of them back up both database and files. So what you can do is simply making a backup of files and database before you make some changes and then simply restore from backup if you do something wrong.
> 1 votes

---
Tags: add-on, extension, plugin
---


# Question
Title: Setting Default Categories on Publish Page
Is there a way to pre-select categories when publishing an item? For instance, I have several category groups for my news articles. I want to preselect several of these every time; but it would be great if EE (either natively, or via a plugin) could preselect these for me?

# Answer
Yup, it's native functionality!

http://ellislab.com/expressionengine/user-guide/cp/admin/channels/channel\_edit\_preferences.html#default-category
> 3 votes

---
Tags: categories
---


title: Weblog doesn't show any entries

text:
# Question
Title: Weblog doesn't show any entries
First I'm glad to join this community! I'm experiencing very weird problem: using EE 1.68 in a template I'm trying to display entries from a weblog, but always got one entry and one specific. I tried adding new ones, checked the expiration dates, statuses, even created new weblog with default settings - same result. I'm using dynamic off and no limits - see below:

```
{exp:weblog:entries weblog="banners" dynamic="off"}
  {title}
  {/exp:weblog:entries}

```

Does anybody experienced some problem? The actual site was moved on a new hosting. Everything worked fine before.

Note\* If I open some of the older entries with status closed - it instantly shows??

# Answer
> 1 votes
I would recommend experimenting with some parameters to the entries tag and see whether you start to see what you are expecting. Specifically I would start with `status="open"` and `limit="10"` (one at a time) to see if any of those affect what you get out. You probably also want to turn on template debugging and see what comes out there. If you really want to see what the entries tag gets if status isn't affecting it at all you can do something like `status="not undefined"` (assuming you haven't defined a status named undefined)

---
Tags: ee1
---


# Question
Title: When submitting comment form Fatal error: Class 'Api' not found
My problem: I could submit a comment, but the data wouldn´t be saved into the database. But no error message was shown. After submisseion EE would just take the comment, throw it away and then would show the SE-page again.

Checked around, found this tip here on EESE, got rid of the NSM htaccess generator. Now I´m back to the normal index.php-Syntax.

Now I can submit Comments, but I get the following error message, when I submit a comment as a logged in user

```
Fatal error: Class 'Api' not found in {removed}/system/expressionengine/
libraries/api/Api_channel_fields.php on line 3

```

When I comment as a non-logged in user I just get a blank page.

But the comments are saved. I can see and edit them in the CP and the comments are attached to the respective entry. So, the process works, I "just" need to get riod of the error message and have EE return to the SE-page.

I tried to set the return value as

```
return="entry/index/url_title"

```

but this didn´t work.

I checked the Api\_channel\_fields.php. This is what I see in line 3

```
class Api_channel_fields extends Api {

```

I even uploaded a fresh Api\_channel\_fields.php from my installation package. Nothing helped. Any thoughts, how I can fix that? I would love to get the .htaccess back to work, but for now I´d be happy to just get rid of the fatal error

**Edit to answer Adrian Macneil questions**

What other plugins/extensions are you using? 1. BW Channel Count 2. Channel Videos 3. Content Elements 4. Developer 5. HJ Social Bookmarks 6. Entry Type 7. httpHeader 8. ImageSizer 9. Low Nospam 10. Low Replace 11. Low Seg2cat 12. Minimee 13. NSM Morphine 14. PDF Press 15. PT Fieldpack 16. Recent Entries 17. Republic Variables 18. SuperGeekery Tag Stripper 19. Sitemap 20. Taggable 21. Template Variables 22. TruncHTML

Are you using the built in EE comment form? Yes, I copied the code from the EE help pages and adapted it. The comment module is on. This is my template code

```
{exp:comment:form channel="artikel"}
    <fieldset>
    <legend>Ihr Kommentar</legend>
        <label for="name">Name (erforderlich)</label>
        <input type="text" name="name" value="{name}"/>
        <label for="email">E-Mail (erforderlich, wird nicht veröffentlicht)</label>
        <input type="text" class="twelve" name="email" value="{email}" />
        <label for="url">Web-Site</label>
        <input type="text" class="twelve" name="url" value="{url}" />
        <label for="comment">Ihr Kommentar</label>
        <textarea name="comment">{comment}</textarea>
        <input type="submit" class="button" name="submit" value="Kommentar absenden" />
        <p> </p>
    </fieldset>
{/exp:comment:form}

```

This is the code as it is rendered on the SE-page

```
<form id="comment_form" method="post" action="http://www.bandikutmedia.de/eintrag/journalisten-auf-die-rote-liste"  >
    <div class='hiddenFields'>
        <input type="hidden" name="ACT" value="1" />
        <input type="hidden" name="RET" value="http://www.bandikutmedia.de/eintrag/journalisten-auf-die-rote-liste" />
        <input type="hidden" name="URI" value="eintrag/journalisten-auf-die-rote-liste" />
        <input type="hidden" name="PRV" value="" />
        <input type="hidden" name="XID" value="31203ae5e27a3ba65d1cbaec73d7ae6ea2ba9fc8" />
        <input type="hidden" name="entry_id" value="33" />
        <input type="hidden" name="site_id" value="1" />
    </div>
    <fieldset>
    <legend>Ihr Kommentar</legend>
        <label for="name">Name (erforderlich)</label>
        <input type="text" name="name" value=""/>
        <label for="email">E-Mail (erforderlich, wird nicht veröffentlicht)</label>
        <input type="text" class="twelve" name="email" value="" />
        <label for="url">Web-Site</label>
        <input type="text" class="twelve" name="url" value="http://" />
        <label for="comment">Ihr Kommentar</label>
        <textarea name="comment"></textarea>
        <input type="submit" class="button" name="submit" value="Kommentar absenden" />
        <p> </p>
    </fieldset>
</form>

```

# Answer
> 3 votes
Ok- so the issue for me turned out to be "Content Elements" plugin from Krea. After disabling this, the errors went away!

# Answer
> 0 votes
Please download new Content Elements 1.1.1 release: http://devot-ee.com/add-ons/content-elements

We have fixed problem with comments.

Thank you, team Krea

---
Tags: htaccess, comment-form
---


# Question
Title: Order entries alphabetically by category group?
I have entries which are assigned to two category groups. In one category group, the entry will only every belong to one category.

Is it possible to order entries alphabetically by category group? Something like:

```
orderby="category_group:2" sort="asc"

```

?

# Answer
Also have a look at NSM categories by EE-garage

http://ee-garage.com/nsm-categories
> 2 votes

# Answer
This should do the trick. The category tables' structure in ExpressionEngine is really simple and using SQL is more powerful than any of EE's category tags:

You'll need to enable the Query module if you haven't.

```
{exp:query
sql="Select g.group_name, c.cat_name, t.title, t.url_title
From exp_category_groups g
join exp_categories c
on g.group_id = c.group_id
join exp_category_posts cp
on c.cat_id = cp.cat_id
join exp_channel_titles t
on cp.entry_id = t.entry_id
where g.group_id = 4
order by g.group_name, c.cat_name, t.title asc"}
{if ...}<h2>{group_name}</h2>{/if}
{if ...}<h3>{cat_name}</h3>
<ul>{/if}
<li><a href="{url_title}">{title}</a></li>
{if ...}</ul>{/if}

```

I didn't fill in the `if` statements. You'll need some conditional logic to figure out when in the loop to show a group or category heading and start a new list, because those are on every result returned. That might need to be PHP, so you can keep track of the previous value and compare them.

GWCode Categories also fills in many of the gaps in EE's category tags.

**Updated:** The `exp:query` tag is a great technique to master, as it offers 'middle ground' between EE's tags and doing custom PHP/app dev. You're right (in your comment) that you'll lose out on some built-in parameters, but you may be able to include some in your SQL. Check out GWCode Categories too, though. It might offer solution and its docs include plenty of examples.
> 2 votes

# Answer
I'm not sure I totally understand your question, but Low's Reorder add-on is really useful for working with categories and unique sorting options. I suspect it may help you tackle what you're describing. http://gotolow.com/addons/low-reorder

And if you're not already familiar with it, his Seg2Cat add-on is definitely worth a look too. It doesn't relate to your question specifically, but it's super useful and can make certain category related tasks much, much easier:
http://gotolow.com/addons/low-seg2cat
> 0 votes

---
Tags: categories, parameters
---


# Question
Title: JSON output thumbnails and other image sizes
I'm currently using this plugin: **http://devot-ee.com/add-ons/json**

It does pretty much everything I want it to-do but unfortunately it doesn't out put images and all the different versions of that image.

I have edited the plugin to return the data I want but What I have written seems a bit messy and isn't very flexible.

Does anyone have a better solution to editing the **JSON** output of this plugin to include all image sizes.

Or is this a built in feature I missed. Any help would be appreciated.

# Answer
I found this plugin which allows me more flexibility: http://devot-ee.com/add-ons/json-encode
> 0 votes

---
Tags: templates, plugin
---


# Question
Title: Why are some image paths wrong after migration to Nexcess?
I recently migrated our sites over to Nexcess EE hosting. After that I notice that some images are not showing up. Some images in certain directories work as expected, while others in the very same directory do not. Upon further investigation in the source the image paths read the following:

```
//chrootimages/uploads/image.png

```

We are expecting to see:

```
http://example.com/images/uploads/image.png

```

Has anyone seen this? What is a possible remedy?

# Answer
So it was an issue with CE-Image and the paths it uses to find images. Since we moved directories it was looking for some images in the old location and the rest in the current which is why the fact that some worked was somewhat perplexing.

Added this config setting to our bootstrap and we are looking good.

```
$config['ce_image_src_regex'] = array( $images_url . '/' => $images_path . '/' );

```
> 6 votes

# Answer
I had this issue as well, but for me it turned out be a misconfigured server "base path" issue. Which is explained in the CE Image Common Solutions docs. Setting the config variable in my (NSM) config bootstrap file solved the issue for me:

```
'ce_image_document_root' => NSM_BASEPATH

```

or as stated on the solutions page:

```
$config['ce_image_document_root'] = '/some/server/path/to/document_root/';

```
> 4 votes

# Answer
I would look at your image paths Content \> Files \> File Upload Prefs and make sure that your image directories have the appropriate paths.

It's a good idea to bootstrap your config for upload directories so that they work regardless of what server you're on.
> 1 votes

# Answer
I had a similar problem with CE Images -- some images working and others not after migrating to a remote Linux server. I turned on Template Debugging and found that the `/~user` segment of my temporary URL was messing things up. Causing Effect has the answer to this problem in their CE Image user docs here: http://www.causingeffect.com/software/expressionengine/ce-image/user-guide/common-solutions#base\_path. Adding the additional lines to the config.php file fixed the base path issue for me.
> 1 votes

---
Tags: ce-image, image-path
---


# Question
Title: Page refresh on submission of entry_form with the text "select" in it
I'm using the exp:channel:entry\_form to allow users to add content to my site. A nagging bug for quite some time has been that the page the entry form is submitted on just refreshes if the form contains the text "select", even in the form of a longer word like "selection". It's not always consistent, some forms do go through. I'm sure it's a sql security thing but this particular constraint is too tight. I haven't been able to figure out how to solve it (and I'm quite familiar with editing system files). I could detect it in JS and warn the user against using it but I feel this would be a poor mans patch. Any advice?

# Answer
> 2 votes
You should be using Safecracker, where surely this bug does not exist. From the docs for the Stand-Alone Entry Form:

> "Deprecated since version 2.1.5: This tag is deprecated in favor of SafeCracker and will be removed from future versions of ExpressionEngine. It is no longer supported."

---
Tags: forms, security
---


title: Hard Coding date_default_timezone_get()

text:
# Question
Title: Hard Coding date_default_timezone_get()
I am getting this error when I transferred my ee site to a new host:

```
A PHP Error was encountered
Severity: Warning
Message: date_default_timezone_get(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'UTC' for 'GMT/0.0/no DST' instead
Filename: libraries/Core.php
Line Number: 227

```

Unfortunately in my current hosting solution we are not allowed to adjust the php.ini file and the date setting are set to UTC on the server. I was wondering if there was a way to set this function to be UTC without trying to grab the result from the PHP.ini form.

Because of the nature of the site and the company, I don't have the option to move to a new host or to request this change to PHP.ini.

Thanks for any help you can offer. My version of Expression Engine is v2.2.2

# Answer
> 3 votes
Can you try doing that in your .htaccess file, in the root of your site?

```
php_value date.timezone 'Europe/London'

```

You should also be able to edit that core EE file, like so:

```
date_default_timezone_set('Europe/London');

```

But doing it in .htaccess will ensure it updates the whole application.

Solution found here. Here are all the timezones that are supported.

---
Tags: database
---


title: SQL Query Help Needed

text:
# Question
Title: SQL Query Help Needed
During a migration from 1x to 2x on an EE site, I needed to switch to current Google Maps add-ons and chose MX Google Maps (for now anyway). The site was using a geotagger that filled a Latitude field and Longitude field with data, so those are still in place.

Since MX Google Maps uses it's own fields, I need to find a way to migrate current db data to MX Maps. But I'm hella bad at this SQL query stuff.

Right now, the lat/lon are stored in exp\_channel\_data in field\_id\_41 (lat) and field\_id\_42 (lon). MX Maps stores Lat/Lon in field\_id\_46 as a pipe delimited set (lat|lon). It also stores data for each entry in it's own table at exp\_mx\_google\_map.

In exp\_mx\_google\_map it has

* point\_id (a sequential number for each post)
* entry\_id (tied to the entry itself)
* latitude
* longitude
* address (not using)
* city (not using)
* zipcode (not using)
* state (not using)
* field\_id (in this case 46)
* icon

With about 2400 entries storing lat/lon, what's the best way to go about moving this data over? Besides drinking heavily and sleeping on it, which I've tried and doesn't work.

# Answer
> 4 votes
That should be as simple as this, using the correct `channel_id`:

```
Update exp_channel_data
set field_id_46 = concat(field_id_41, '|', field_id_42)
where channel_id = 1

```

For the Maps table, it's something like this:

```
Insert into exp_mx_google_map
(entry_id, lat, long, some_example_field)
Select entry_id, field_id_41, field_id_42, 'Some example value'
from exp_channel_data
where channel_id = 1

```

You can fill in the other fields from there.

**Updated:** Sorry, the `values` line caused an error in the `Insert` statement. I've updated that.

I only included a few sample fields in that. You'll want to be sure to map the rest. Note that you can pass your own values, they don't all have to be from fields.

As UltraBob suggested, you can use PHPMyAdmin, Sequel Pro, Navicat, etc to set the `point_id` field to `AUTO_INCREMENT`. You don't need to include it in your `insert` then. It will get a value as each record is created.

---
Tags: add-on, database, mysql, queries, mx-google-map
---


# Question
Title: How do I use Amazon S3 with local fallback in case of S3 outage?
I need to wrap my head around this...
With Assets I can upload images directly to S3. With CE Image I can store the manipulated images on S3. Is it easy to switch to local images in case S3 is not available? Maybe via the fallback image parameter of CE image?

# Answer
> 2 votes
Let me give you a different spin on this that maybe a much easier situation for you to implement as it should work regardless of the add-ons being used your using.

Rather than have individual addons upload the assets to S3, keep them on the local server, but setup a CloudFront distribution, but set it up to reverse proxy from your server.

Let's say the address of your CloudFront distribution is d24532452345.cloudfront.net.

You set that distribution up to reverse proxy from your server, so d24532452345.cloudfront.net/assets/image1.jpg is pulled once from www.yourserver.com/assets/image1.jpg, then cached on cloudfront for future requests. Requests for that file, until it expires will be pulled from CloudFront.

You simply setup a folder in ExpressionEngine that has the path pointing to the local server but the URL pointing to CloudFront.

If you should run into an issue with CloudFront, you simple update that URL to point to your local server, requests are instantly pointed back to your server again working round any issues.

You can further automate this by setting up a cname for the CloudFront distribution, so d24532452345.cloudfront.net has a cname of cdn.yourdomain.com.

There are then a few DNS services out there that you could easily use to test for the availability of an asset that should always be present, if you get a failure for any reason, it automatically updates the cname to point back to your server rather than CloudFront.

This will speed up delivery of your assets. The downside to this approach is that your not offloading the assets from your server, only offloading the delivery of them to the visitor. It's a very flexible approach though that does not require heavy customisation of any one addon to achieve the desired result.

If this sounds like it would work for you, let me know and I'll get some more info up here to better explain how you would set it up.

Update:

Here's a good article that gives more detail on how to setup CloudFront to reverse proxy your assets:

http://www.newvem.com/enable-cloudfront-for-your-applications-non-dynamic-content/

The section two thirds of the way down called Serving Javascript and CSS files is using the reverse proxy concept. In essence though all we are doing is telling CloudFront not to fetch the content from S3 instead fetch it from our own server.

For the DNS side of things, I think gunning for automatic failover maybe a little overkill, but it's doable without question. The simple solution I think would be to do monitoring with any web monitoring service to notify you if it falls over, you set the TTL low on the DNS record, switching it should there ever be an issue, the low TTL will ensure DNS does not cache the record for too long.

If automatic failover is a requirement, then someone like DNS Made Easy would work. That's who I use. You setup monitoring to check for a single text string in a file, that shoudl always be present, if in any check that text string is not present a failure can be assumed, you then have it switch the cname record to your server rather than CloudFront.

# Answer
> 1 votes
Disclosure: I'm the author of CE Image.

Unfortunately, I have not found a good solution to automate this so that CE Image would serve local assets if AWS is offline. In order to do that, I would have to first check if the service was online with PHP, and then serve it up. While it is possible to do that, it is very slow, which is the opposite of what using AWS is trying to accomplish to begin with. :)

## Enabling AWS for CE Image

However, it is quite easy to turn off AWS for CE Image. As a little bit of background, you enable AWS for CE Image in your config (the following code is from the CE Image Advanced Configuration Page):

```
/*
| Amazon S3 settings and optional headers. For use with the option AWS
| extension. See the installation instructions for more details on how
| to install the extension.
*/
$config['ce_image_aws_key'] = '';
$config['ce_image_aws_secret_key'] = '';
$config['ce_image_bucket'] = '';
$config['ce_image_aws_request_headers'] = array();
$config['ce_image_aws_request_headers']['Cache-Control'] = 'max-age=' . (30 * 24 * 60 * 60);
$config['ce_image_aws_request_headers']['Expires'] = gmdate("D, d M Y H:i:s T", strtotime('+1 month') );
$config['ce_image_aws_storage_class'] = 'STANDARD';
/*
| To use cloudfront with your AWS setup, simply add your cloudfront
| subdomain (in addition to the above AWS info) to the following config
| item. If the cloudfront URL is d38tz0dcx54k85.cloudfront.net, then
| the subdomain would be 'd38tz0dcx54k85'.
*/
$config['ce_image_aws_cloudfront_url'] = '';
// END CE Image advanced config items

```

## Disabling AWS for CE Image

If you set the 'ce\_image\_bucket' setting, CE Image will use Amazon S3 (or Cloudfront if you have it configured), for each image that is manipulated. If you want to disable AWS in one fell swoop, simply set the bucket setting back to an empty string, like so:

```
$config['ce_image_bucket'] = '';

```

If you are only using S3 on certain images in your site (by specifying the bucket= parameter in your EE tags), or if you are using different buckets for different content, then you should be able to simply comment out the credentials in the config to turn it off:

```
/*
$config['ce_image_aws_key'] = '';
$config['ce_image_aws_secret_key'] = '';
*/

```

---
Tags: assets, ce-image
---


# Question
Title: Playa: find children of two specified parents (inclusive)
```
{exp:channel:entries channel="courses" dynamic="no" orderby="title" sort="asc" search:course_category="{embed:entry_id}" search:sub_cat="{embed:subentry_id}"}
Test {course_category}{entry_id}{/course_category} vs {embed:entry_id} - {sub_cat} {entry_id}{/sub_cat} vs {embed:subentry_id}
{embed="includes/.testcourse" compare="{course_category}{url_title}{/course_category}" page="{embed:page}" subcat="{embed:subcat}" subcatc="{sub_cat}{url_title}{/sub_cat}" title="{name_for_menu}" url="{url_title}" brand="{embed:brand}" {if url_title == "{embed:url_title}"}class="active"{/if}}

{/exp:channel:entries}

```

Ok, this code basically checks the category and the sub-category of the course are correct before adding them to the page.

Heres the bad part:

Test 15 vs 5 - 29 vs 9 Makaton Signing for Babies

Test 15 vs 5 - 29 vs 9 Parent and Carer

DOH! Clearly they don't match, its just found them because it contains them

Now, I figured this was just because I hadn't used exact match searching, so i changed the code to:

```
{exp:channel:entries channel="courses" dynamic="no" orderby="title" sort="asc" search:course_category="={embed:entry_id}" search:sub_cat="={embed:subentry_id}"}
Test {course_category}{entry_id}{/course_category} vs {embed:entry_id} - {sub_cat}{entry_id}{/sub_cat} vs {embed:subentry_id}
{embed="includes/.testcourse" compare="{course_category}{url_title}{/course_category}" page="{embed:page}" subcat="{embed:subcat}" subcatc="{sub_cat}{url_title}{/sub_cat}" title="{name_for_menu}" url="{url_title}" brand="{embed:brand}" {if url_title == "{embed:url_title}"}class="active"{/if}}
{/exp:channel:entries}

```

And now no entry shows despite (more code from the previous debug): Test 5 vs 5 - 10 vs 10 Business Administration Test 5 vs 5 - 10 vs 10 ChildCare Test 5 vs 5 - 10 vs 10 Customer Service Test 5 vs 5 - 10 vs 10 Hospitality and Catering Test 5 vs 5 - 10 vs 10 Hospitality Supervision

Now I can't see why they wouldn't match the correct ones on an exact match search (I've tried it with quotes around to check for nbsp or similar)

As you may have guessed {course\_category} and {sub\_cat} are playa fields. So how do I do an exact match search vs a playa element?

Thanks!!

# Answer
This is no the way to go about filtering on a Playa field. The reason it's not working is because Playa does not store what you might expect in the custom field. A typical entry looks like this:

`[9] [makaton-signing-for-babies] Makaton Signing for Babies`

What you want to do is use the Playa Parents and Playa Children tags, which can be filtered using all standard Channel Entries parameters.
> 1 votes

---
Tags: add-on, channel-entries, playa, channel, search
---