# Question
Title: Matrix Pagination 'next' link links to empty page
Sorry, new code.

I have created a new channel - gallery. This channel has 4 custom fields - {gallery\_page\_heading}, {gallery\_sub\_heading}, {gallery\_image} and {gallery\_page\_content}, {gallery\_image} being my Matrix field. I also have a new template - gallery\_page.

The code in my gallery\_page template is as follows:

```
{embed="includes/site_header"}

{embed="includes/brand_and_nav"}

<div id="pageHeading">
    <div class="wrap">
        {exp:channel:entries channel="gallery" limit="1" disable="categories|category_fields|member_data|pagination"}
        <h1>{gallery_page_heading}</h1>
        <p>{gallery_sub_heading}</p>
    </div><!-- End wrap -->
</div><!-- End pageHeading -->

<div id="content">
    <div id="contentWrap" class="clearfix">
        <div id="mainContent">
            <div id="breadcrumb">
                <p>You are here: {exp:structure:breadcrumb inc_here="yes" here_as_title="yes" add_last_class="no"}</p>
            </div><!-- End breadcrumb -->
            <h2>{title}</h2>
            {gallery_page_content}
        {/exp:channel:entries}

        {preload_replace:rows_per_page="3"}
        {exp:channel:entries channel="gallery" url_title="{segment_3}" dynamic="no"}
            {if gallery_image}
                <div id="gallery" class="clearfix">
                    {gallery_image offset="{segment_4}" limit="{rows_per_page}"}
                        <div class="{switch="galleryImage|galleryImage|galleryImageLast"}">
                            <a href="{big_image}" rel="lightbox-gallery" title="{image_caption}"><img src="{small_image}" alt="{image_title}" /></a>
                        </div>
                    {/gallery_image}
                </div><!-- End gallery -->
                {if segment_4 > rows_per_page}
                    <a href="{page_url/}/{exp:simple_math calculate='{segment_4}-{rows_per_page}'}">
                    Prev
                    </a>
                {/if}

                {if "{gallery_image:total_rows}" > "{exp:simple_math calculate='{segment_4}+{rows_per_page}'}"}
                    <a href="{page_url}/{if segment_4}{exp:simple_math calculate='{segment_4}+{rows_per_page}'}{if:else}{rows_per_page}{/if}">
                    Next
                    </a>
                {/if}
            {/if}
        {/exp:channel:entries}

        </div><!-- End mainContent -->

        {embed="includes/site_sidebar"}

{embed="includes/site_footer"}

```

The images display on the page as they should, the 'next' pagination link displays when it should but it still links to an empty page. The gallery is currently held at `www.example.com/development/nails/gallery-test/` and when the 'next' link is clicked the url changes to `www.example.com/development/nails/gallery-test/3`. This page doesn't exist though and doesn't show the remainder of the images.

Thanks again for your help!

# Answer
> 2 votes
I managed to get this working via lots of help from Lisa Wess (legend) and \[Freebie\]\[1\]. I installed Freebie and set the 'Freebie Segments' to the number of images I wanted per page in my gallery. I then substituted all {segment\_x} tags with {freebie\_x} tags and changed some conditionals from my previous code above.

My new template code:

```
             {preload_replace:rows_per_page="3"}
                {exp:channel:entries channel="gallery" url_title="{freebie_2}" dynamic="no"}
                    {if gallery_image}
                        <div id="gallery" class="clearfix">
                            {gallery_image offset="{freebie_3}" limit="{rows_per_page}"}
                                <div class="{switch="galleryImage|galleryImage|galleryImageLast"}">
                                    <a href="{big_image}" rel="lightbox-gallery" title="{image_title}"><img src="{small_image}" alt="{image_title}" /></a>
                                </div>
                    {/gallery_image}
                        </div><!-- End gallery -->

                    {if freebie_3 == '3'}
                        <a href="{page_url}/">
                        Prev
                        </a>
                    {if:elseif freebie_3 > rows_per_page}
                        <a href="{page_url}/{exp:simple_math calculate='{freebie_3}-{rows_per_page}'}">
                        Prev
                        </a>
                    {/if}

                    {if "{gallery_image:total_rows}" > "{exp:simple_math calculate='{freebie_3}+{rows_per_page}'}"}
                        <a href="{page_url}/{if freebie_3}{exp:simple_math calculate='{freebie_3}+{rows_per_page}'}{if:else}{rows_per_page}{/if}">
                        Next
                        </a>
                    {/if}
                    {/if}
                {/exp:channel:entries}

            </div><!-- End mainContent -->

```

Because my gallery was located at www.mysite.com/development/nails/gallery-test/ I had to change some of the {segment\_x}/{freebie\_x} tags back one, so from {segment\_4}/{freebie\_4} to {segment\_3}/{freebie\_3}, previously the code was looking at the wrong url segment.

I hope this explanation saves anyone else from running into this issue with Structure and Matrix image galleries with pagination.

Thanks again to Lisa Wess for all her help!

# Answer
> 2 votes
Updating my answer. I've logged in and done some troubleshooting. I think that the problem with pagination is stemming potentially from using a Structure Page\_URL for this.

I set up a template group and template: pt\_test/pag and put this code in it:

```
 {preload_replace:rows_per_page="3"}
        {exp:channel:entries channel="gallery" url_title="{segment_3}" dynamic="no"}
        <h1><a href="{url_title_path='pt_test/pag'}">{title}: {url_title}</a>: segment 3: {segment_3}, segment 4: {segment_4}</h1>
        {page_url}<br />
            {if gallery_image}
                <div id="gallery" class="clearfix">
                    {gallery_image offset="{segment_4}" limit="{rows_per_page}"}
                        <div class="{switch="galleryImage|galleryImage|galleryImageLast"}">
                            <a href="{big_image}" rel="lightbox-gallery" title="{image_caption}">{row_id}<img src="{small_image}" alt="{image_title}" /></a>
                        </div>
                    {/gallery_image}
                </div><!-- End gallery -->

{if segment_4 > rows_per_page}
  <a href="{path='pt_test/pag/{url_title}'}/{exp:simple_math calculate='{segment_4}-{rows_per_page}'}">
    Prev
  </a>
{/if}

{if "{gallery_image:total_rows}" > "{exp:simple_math calculate='{segment_4}+{rows_per_page}'}"}
  <a href="{path='pt_test/pag/{url_title}'}/{if segment_4}{exp:simple_math calculate='{segment_4}+{rows_per_page}'}{if:else}{rows_per_page}{/if}">
    Next
  </a>
{/if}

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

```

If you visit this on the front-end and use the next and previous links, then you'll see that the pagination is working. I built the Next and Previous links a bit differently than you had, and I've got some diagnostics outputting by echoing out those segments to see what EE sees. But I think you should be able to take this working template and build from there.

Does that help?

# Answer
> 0 votes
Stephen, I did some more searching around and came across this tutorial, which uses Freebie:

http://www.idfive.com/blog/2011/02/matrix-structure-freebie-expression-engine-image-gallery/

I am wondering if that might be the answer you're looking for. :)

-Lisa

---
Tags: matrix, pagination
---


# Question
Title: Assets: problems assigning images. Call to a member function file_id() on a non-object
Call to a member function file\_id() on a non-object in /(path to my system folder)/expressionengine/third\_party/assets/views/thumbview/files.php on line 15

I get the above error message when I post my channel entry.

# Answer
Just a final follow-up - this has been fixed in the latest versions of Assets.
> 1 votes

---
Tags: assets, channel-images
---


# Question
Title: Changing Field Groups for existing channel
I've just (finally) upgraded from EE1.x to EE2.5.5. (I was able to use Importer and Matrix to recreate my photo galleries with enough functionality to maintain them as a "legacy" gallery. If you are interested in what I did, let me know.) But I digress.

I now want to take advantage of many of the new cool 3rd party field types like Wygwam, Channel Images, Polls, Tags, and others. (And, I'd like to remove field types that I no longer use such as embeds for videos and a second Summary field.)

My question is about the best to do this. And, really "how does it work"?

I've seen from an existing post that it is okay to simply convert existing text fields to Wygwam fields, so I get that and it makes sense.

What happens if I get rid of a field? Will that contents still be in the data base? Can I keep the code to display that field in place in my template and use a conditional to render it only if it exists (even though it is no longer a valid "input" field)?

Also, if I create a second field group that contains my new ideal setup and associate my channel with it, all the old entries will still render, again if I have the old field name in my template. Actually, I've tried this and it seems to work, I just had to use new unique names for each field and then use a conditional to print whichever one has content. This works, I just want to be sure my assumptions behind "why" are correct. So, comments on these "rules" are welcomed:

1. You can associate an existing field with a new field type. (But, I assume this is only for like types: text to text, for example. What happens if I try to convert an old text field to Matrix, for example?)
2. If I delete a field from my publish form, the data is still there and associated with the "old" field name? Can I now re-use that field name? (Haven't tried this till I understand what will happen.)
3. I can change the field group for a channel to a new group, but the fields must be uniquely named (can't have same name as old fields) and I need to update my templates to reflect this.

I think that's enough to let me know how this works. If it does work okay, then I'll need to figure out how to display search results from old and new fields, and some stuff like that. (Excerpt won't work across both field groups, I assume.) What other "gotchas" are there?

# Answer
> 4 votes
> What happens if I get rid of a field? Will that contents still be in the data base?

No, if you delete a field from a field group the data is gone.

> Can I keep the code to display that field in place in my template and use a conditional to render it only if it exists (even though it is no longer a valid "input" field)?

It shouldn't cause any issues as long as it is wrapped in a simple conditional. For example...

```
{if some_non_existent_field}{some_non_existent_field}{/if}

```

...is not rendered even though this isn't an existing field. But without the conditional you'll just see `{some_non_existent_field}` unparsed in the rendered template.

> You can associate an existing field with a new field type. (But, I assume this is only for like types: text to text, for example. What happens if I try to convert an old text field to Matrix, for example?)

It mostly seems to work just when converting text-type fields, or fields that store data in the same way, but there are exceptions. For example it works fine converting the native File fieldtype to Assets (haven't tested with the latest version, though). And I believe there are other special fieldtypes that have a built-in conversion utility for specific, similar fieldtypes.

In my test converting Textarea to Matrix the data was not immediately lost, but it was no longer shown in the template using the old tag. And the first time the entry was re-saved the data was gone (emptied or replaced by Matrix data). If you're unsure what the results would be just make a database backup and experiment, checking the result in the exp\_channel\_data table.

> If I delete a field from my publish form, the data is still there and associated with the "old" field name? Can I now re-use that field name? (Haven't tried this till I understand what will happen.)

Do you mean if you delete it from a *field group*? If you do this the data is gone (the field is deleted from the exp\_channel\_data table along with the data). You could immediately create a new field with the same name as the deleted field if you wanted to. If instead you mean hide a field in the publish form using Publish Layouts, nothing is lost or changed other than the field's visibility.

> I can change the field group for a channel to a new group, but the fields must be uniquely named (can't have same name as old fields) and I need to update my templates to reflect this.

Right. Every field must have a unique short name. And you'll have to update your templates.

---

One approach to moving forward with new fields while keeping legacy data intact is just to create new, parallel fields using any new fieldtypes you want to take advantage of. Then relabel your old fields (relabel, not rename) as "Legacy" and ignore them when you publish new entries. In your templates output content using conditionals based on the presence of data in the legacy fields or based on the date you switched over.

---
Tags: custom-fields, fieldtype
---


# Question
Title: What Forum Template do I modify to display Smileys?
I am working through the tangled web that is the EE Forum templates in search of the correct template for adding a link to the emoticons (smileys). So far I am coming up empty handed. Anyone with experience out there that can point me in the right direction?

Thanks!

# Answer
> 2 votes
Due to the underwhelming response, I was forced to dig deeper and finally found the template I was looking for. It is:

> form\_submission / submission\_form

---
Tags: forum
---


title: How to query only products on sale

text:
# Question
Title: How to query only products on sale
> **Possible Duplicate:**
> Displaying all products on sale with exp:resso store?

I want to have a page on our store that displays only items that are on sale. What's the most efficient way to write this query?

# Answer
You should be able to do the following

```
{exp:store:search search:on_sale="yes" search:in_stock="yes"}
    <!-- channel entry details -->
{/exp:store:search}

```

to only show products that are On Sale and In Stock as referenced in the docs here. The search tag would probably be better then writing your own query as it extends the channel entries tag so you would be able to use any of your custom fields also.
> 0 votes

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


# Question
Title: Section Navigation with Images Using Structure Entries, Assets, Structure
I am using Structure (v3.3.8), Assets (v2.0.5), Structure Entries (v1.2.8), and CE Image (v2.4.1). For the major section pages of my site (top-level navigation), I would like to output on the page a section-specific navigation which includes a "page image" (custom field), "page intro", title, and link. Everything is working fine except for the images, and I'm not sure if it's a Structure Entries problem or an Assets problem (or a CE Image problem).

I am trying to do this:

```
{exp:structure_entries depth="1" parent="{embed:my_parent_id}"}
<div class="column one-third">
    <div class="pic">

        {page_image}
            <a href="{page_uri}">
                {exp:ce_img:pair src="{page_image}" width="420" height="279" crop="yes"}
                    <img src="{made}" alt="{page_image:title}{if
                    page_image:author} - Photo by {page_image:author}{/if}" />
                {/exp:ce_img:pair}
                <div class="img_overlay_zoom"></div>
            </a>
        {/page_image}

    </div>
    <h3><a href="{page_uri}">{title}</a></h3>
    <p>{page_intro}</p>
</div>
{switch='||<div class="clearfix"></div>'}
{/exp:structure_entries}

```

On the calling page, I have this code:

```
{embed="embeds/_section_navigation_images" my_parent_id="{structure:page:entry_id}"}

```

The embed is working fine (the correct section is being displayed), but the images aren't showing up. This is the HTML code that is generated:

```
<div class="column one-third">
    <div class="pic">
        {page_image}
            <a href="/mysite/index.php/get-involved/donate">
                <div class="img_overlay_zoom"></div>
            </a>
        {/page_image}
    </div>
    <h3><a href="/mysite/index.php/get-involved/donate">Donate</a></h3>
    <p>Donate to our organization and help ...</p>
</div>
...

```

The `{page_image}` tags are not being parsed, and the image isn't being output at all.

## Debugger Output (Excerpt)

```
(26.607746 / 30.22MB)      Tag: {exp:structure_entries depth="1" parent="65"}
(26.608122 / 30.22MB)      Closing Tag Found
(26.608356 / 30.22MB)      Processing Tags
(26.608584 / 30.22MB)      Plugin Tag: Structure_entries/
(26.608702 / 30.22MB)      Including Files for Plugins and Modules
(26.608801 / 30.22MB)      Files for Plugins and Modules All Included
(26.608893 / 30.22MB)      Beginning Final Tag Data Processing
(26.609005 / 30.22MB)      Calling Class/Method: Structure_entries/
(26.609129 / 30.22MB)      Nested Plugins in Tag, Parsing Outward First
(26.609618 / 30.24MB) Tag: {exp:ce_img:pair src="{page_image}" width="420" height="279" crop="yes" filter="auto_sharpen"}
(26.610344 / 30.24MB) Closing Tag Found
(26.610655 / 30.24MB) Plugin Tag: Ce_img/pair
(26.610761 / 30.24MB) Including Files for Plugins and Modules
(26.610847 / 30.24MB) Files for Plugins and Modules All Included
(26.610974 / 30.24MB) Beginning Final Tag Data Processing
(26.611076 / 30.24MB) Calling Class/Method: Ce_img/pair
(26.611854 / 30.24MB) -> Class Called: Ce_img
(26.612009 / 30.25MB) -> Method Called: pair
(26.621115 / 30.26MB)   ***  CE Image debug: Base path: 'C:/Users/Amy/Dropbox/www/'
(26.621214 / 30.26MB)   ***  CE Image debug: Source image: '{page_image}', Fallback image: ''
(26.621292 / 30.26MB)   ***  CE Image debug: Source image is not readable or does not exist: '{page_image}'.
(26.621367 / 30.26MB)   ***  CE Image debug: Fallback source image is not readable or does not exist: ''.
(26.621515 / 30.27MB) Returning No Results Content
(26.621909 / 30.25MB) -> Data Returned
(26.623894 / 30.23MB)       -> Class Called: Structure_entries
(26.909353 / 30.25MB)      structure_entries: Starting main loop through entries. Total rows from DB=32
(27.371411 / 30.31MB)      structure_entries: tagdata= <div class="column one-third"> <div class="pic"> {page_image} <a href="{page_uri}"> <div class="img_overlay_zoom"></div> </a> {/page_image} </div> <h3><a href="{page_uri}">{title}</a></h3> <p>{page_intro}</p> </div> {switch='||<div class="clearfix"></div>'}
(27.371651 / 30.31MB)      structure_entries: ID=72 url=/ee-mjv/index.php/get-involved/donate
(27.377516 / 30.32MB)      structure_entries: tagdata= <div class="column one-third"> <div class="pic"> {page_image} <a href="{page_uri}"> <div class="img_overlay_zoom"></div> </a> {/page_image} </div> <h3><a href="{page_uri}">{title}</a></h3> <p>{page_intro}</p> </div> {switch='||<div class="clearfix"></div>'}

```

When I strip off the CE Image tags and just output the `{page_image}` it gives the filename. If I change it to `{page_image:url}`, it does not parse at all.

## Updated Code

I'm updating my code based on @Aaron's comments:

```
    {exp:structure_entries depth="1" parent="{embed:my_parent_id}" parse="inward"}
<div class="column one-third">
    <div class="pic">
        {page_image}
            <a href="{page_uri}">
                {exp:ce_img:pair src="{url}" width="420" height="279" crop="yes" filter="auto_sharpen"}<img src="{made}" alt="{title}{if author} - Photo by {author}{/if}" />{/exp:ce_img:pair}
                <div class="img_overlay_zoom"></div>
            </a>
        {/page_image}
    </div>
    <h3><a href="{page_uri}">{title}</a></h3>
    <p>{page_intro}</p>
</div>
{switch='||<div class="clearfix"></div>'}
{/exp:structure_entries}

```

The Assets field (page\_image) is still not being treated like a tag pair as it should.

I appreciate any help you can offer! Thanks.

# Answer
If you're using Structure 3.3.8, it already includes the Structure Entries functionality (Official Documentation). Maybe give the native version a try and see if that parses the Assets tag correctly?

```
{exp:structure:entries parent_id="{embed:my_parent_id}"}
...
{/exp:structure:entries}

```
> 3 votes

# Answer
I also just just noticed that you are using `{page_image}...{/page_image}` as a variable pair, and also using a single variable `{page_image}` inside that loop (that you are passing into the CE Image src= parameter). I think that's probably a typo, right? Shouldn't the single variable be `{url}`?
> 3 votes

# Answer
Since the Structure Entries add-on is a plugin, you'll need to add `parse="inward"` to the opening tag. That way, the plugin will parse its own variables before trying to parse the {exp:...} tags inside its tagdata (the text between the opening and closing {exp:}{/exp:} tags).

Modules and plugins behave in almost the same way, except for their default parse order. One advantage of plugins, is that you get to choose the order. By default, they wait until all the content inside them is parse by the EE parser before sending the tagdata to the parser. Modules, on the other hand, automatically parse inward.
> 1 votes

---
Tags: assets, structure, ce-image, navigation
---


title: Affiliate Links Management Addon?

text:
# Question
Title: Affiliate Links Management Addon?
I want to manage all my affiliate links in one place, e.g.:

mydomain.com/link1 -\> redirects to aff. link 1 mydomain.com/link2 -\> redirects to aff. link 2

Is there any addon that allows the management of affiliate links like this?

# Answer
> 3 votes
I know there is Detour Pro which is for doing redirects.

Since we are on the topic of affiliate and for future reference there are these add-ons which are for setting up your own affiliate links for your users FWIW:

# Answer
> 1 votes
You can use Detour Pro

This is being used for 301 redirection and works very well.

---
Tags: add-on, redirects, links, affiliate
---


# Question
Title: Expresso Store: Large quantity of items in cart gives PHP error
Getting a PHP error in Expresso Store if 35 products or more are in the cart.

```
Message: unserialize()[function.unserialize]: Error at offset 49148 of 49151 bytes
Filename: libraries/store_cart.php
Line Number: 900

```

Any ideas why this would happen? Tried recreating the issue and on the second time, the cart just empties when I add a 36th product.

# Answer
This has been fixed in our next upcoming release of Store.

If you need an immediate solution, edit your database and change the `contents` column in the `exp_store_carts` table from `TEXT` to `MEDIUMTEXT`. This will give you shopping carts more room to breathe.

When you install the next version of Store it will simply update this column type again so there is no issue with editing your database directly.
> 1 votes

---
Tags: expresso-store
---


# Question
Title: Where is the status of a channel entry stored?
In my plugin query, I basically just want to know what the status of an entry is.

I checked `exp_channel_entries` and its not there.

I see status field in `exp_channel_entries_autosave` but the table is empty.

Any ideas?

# Answer
It's in `exp_channel_titles` \- EE stashes its data all over the place.
> 3 votes

---
Tags: status
---


title: Low Search for a specific custom date

text:
# Question
Title: Low Search for a specific custom date
I'm trying to set up a search form that searches several things:

1. name
2. date
3. location

The site in question is a funeral home, and we want to set up a search where people can search by the name of the deceased, the location of the funeral, or the date of death. The name and location search work great, but I get no results when I search by date.

I've set it up so that the date that gets sent to the Low Search module is formatted as `YYYY-MM-DD`, but that doesn't seem to matter.

Your talk about range would apply here, but I only want to search for a single date, not a range of dates. In any case, I did try `range-from` (as you see below) and a hidden input for `range-to` with the same value. That didn't work.

Previously, I didn't use a range at all, and Low Search would return every all results (over 8500 of them!).

## My Code

```
{exp:low_search:form collection="obits|obits_archive" form_class="obit-search" query="" result_page="obit/results" secure="no"}
  <ul>
    <li><label>Name<br/>
    <input type="text" name="keywords" /></label></li>
    <li><label for="date-pick">Date of Death<br/>
    <input type="text" name="range-from:ob_dod" id="date-pick" value="" /></label><input type="text" style="display:none" name="range-to:ob_dod" /></li>
    <li><label>CCG Location<br/>
    <select name="child:ob_location[]">
      <option value="">All Locations</option>
      {exp:channel:entries channel="locations" dynamic="no" orderby="title" sort="asc"}
      <option value="{entry_id}">{title}</option>
      {/exp:channel:entries}
      </select></label></li>
    <li><input type="submit" name="submit" value="Search" id="submit" class="button"></li>
  </dl>
{/exp:low_search:form}

```

## Other Info

You'll almost certainly want to know that the date is not using EE's date fieldtype, but, rather, Stephen Lewis's Dropdate. Dates are stored as a UNIX timestamp.

# Answer
> 0 votes
As BKY mentioned, I'd go for an exact match here, instead of a range. You say you're saving the DropDate field as a UNIX timestamp. Low Search's range option only transforms a given date range to timestamps if the field is a native date field. Third party date fields aren't supported that way.

Given that, I'd set DropDate to save the date as YYYYMMDD, so an exact match is easier to get. As a parameter, you could use `search:ob_dod="20130201"` (Feb 1st, 2013) for an exact match of the DropDate field. Used as an input field in the Form tag, you can then use something like this:

```
<input name="search:ob_dod" />

```

...and perhaps use a datepicker or some custom JS to get the needed YYYYMMDD format.

# Answer
> 0 votes
How are you saving the date with DropDate field i.e in "UNIX timestamp" or "YYYYMMDD"? In this way you can directly match the "Date of Death".

Also, you will need to have some JavaScript stuff to convert the date format in either "UNIX timestamp" or "YYYYMMDD" OnChange the "Date of Death" input value.

---
Tags: low-search, date
---


# Question
Title: search=field_name: and special characters from URL segment
I am using the following tag to get only channel entries with a custom field matching the last URL segment:

```
{exp:channel:entries search:collection_name="={last_segment}"}

```

This works fine for most values, but I've found that when the field contains double quotes, no entries are returned.

For example, the following URL segments work, and only the matching entries are shown: `Collection`, `Collection 43`

However, this URL doesn't return any entries, even when there are matches in the DB: `The "new" collection`.

So I need to somehow escape these characters to allow this to work?

# Answer
> 2 votes
Since you have the search parameter variable prefixed with `=`, it's an exact match. Try removing the prefix.

```
{exp:channel:entries search:collection_name="{last_segment}"}

```

### Update

The problem is with special characters in the URL. EE strips out uppercase letters, spacing & special characters in the native `{url_title}` field for proper URL structure. So all the data in the `{collection_name}` custom field will need to be reformatted so the `{last_segment}` variable can be used properly in your use case. **The "new" collection** should really be **the-new-collection** in the collection name custom field.

However, I would approach this differently with either categories or even use Playa. With Playa, you could create a **Collection** Channel and then use a Playa field in the other channel to relate each entry to one or more collections. Then use `{exp:playa:parents}` tag to display all reverse related entries:

```
{exp:playa:parents channel="other_channel" url_title="{last_segment}"}

```

---
Tags: channel-entries, custom-fields, url, search
---


# Question
Title: CartThrob: Global options groups all in one select
I am using CartThrob's global options, with the multi group fieldtype to allow multiple groups to be selected.

What I need is to display all of the groups options all inside one select menu to allow the user to add any to the cart.

When I use this code inside the add to cart form:

`{exp:cartthrob:item_options entry_id="{entry_id}"}
 {options}
 {option_name} - {price}
 {/options}
 {/exp:cartthrob:item_options}`

*** Stack exchange is removing a open select and close select either side of the code above.

The select is created with all options from all groups, but when an item is added to the cart, it has a price of 0.00.

If I use this code:

`{exp:cartthrob:item_options entry_id="{entry_id}"}
 {select class="print-select"}
 {if option_first_row}
Choose a your option...
 {/if}
 {option_name} - {price}
 {/select}
{/exp:cartthrob:item_options}`

Each group is in a different select, but the price works...

How can I get it to work inside one select?

# Answer
I don' think this can be done automatically with a native CartThrob tag. However, if you're outputting the CartThrob field data between `{exp:channel:entries}` tags, you could just use the custom fields of each price modifier fields within a multi select tag like so to group:

```
<select multiple>
    {first_price_modifier_field}
        {if first_row}<optgroup label="First Label Name">{/if}
            <option value="{option_value}">{option_name}</option>
        {if last_row}</optgroup>{/if}
    {/first_price_modifier_field}

    {second_price_modifier_field}
        {if first_row}<optgroup label="Second Label Name">{/if}
            <option value="{option_value}">{option_name}</option>
        {if last_row}</optgroup>{/if}
    {/second_price_modifier_field}
</select>

```

### Update

You can't actually group all price modifier fields into one select group since each select menu needs to have it's own unique `name=` for CT to update pricing accordingly for that product:

```
<select name="item_options[first_price_modifier_field]">

```
> 2 votes

---
Tags: cartthrob
---


# Question
Title: P&T Assets: thumbs folder file permissions
Looks like Assets, when creating the "\_thumbs" folder... is using "666" permissions... This is creating an issue with being able to access files through my standard sftp account. Unless the file is 777 I cannot touch it.

Is there a reason the "\_thumbs" is not 777 ? Is this a bug possibly?

# Answer
> 1 votes
Roi,

We're using EE's filemanager to handle thumbnail creation, specifically below:

```
return $this->EE->filemanager->create_thumb($image_path, $preferences);

```

So this is something done by EE. Some hosts will put a mask on the level of permissions PHP scripts can set - so if a script tries to set one permission, that mask may change it. The latter is something to ask of your host.

But again, 666 permissions should be just fine for you to work with, so I'd also follow up on that point with your hosting provider.

-Lisa

---
Tags: assets, pixelandtonic, permissions
---


title: Integrating Freeform with two CRMs?

text:
# Question
Title: Integrating Freeform with two CRMs?
We have landing pages on our site, and we want to be able to export this form data into two separate CRMs: Leads360 and Microsoft Dynamics CRM. The forms are using FreeForm (the remote dev team chose this.) Both of these CRMs require the form data to be submitted to a custom POST URL.

Is this possible with Freeform? I can't find anything on the Solspace site in the Freeform documentation.

# Answer
We've used the post submit hook in Freeform to write our own extension that submits the data to SalesForce. In this case, we use cURL to simulate a post to SalesForce's Web2Lead form rather than work with the API.

If you start in that context - An extension using the post submit hook - You can write any number of functions in there. You could submit to 1, 2, 5, 10 different services with the data that was just posted.

**Updated:** Another option, if you don't want to go the Extension route:

You can enable PHP in a template and set that template to be the Redirect URL of your Freeform form. Write out all the PHP that integrates with those CRMs in that template. There should be a way to get the Insert ID of the new Freeform entry onto the redirect URL. Within that PHP template, you can redirect the user to any other page on the site you wish.

Either way, it's a file with the PHP that does the behind the scenes POSTs to those sites. The extension is the right way to do it.
> 1 votes

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


# Question
Title: ExpressionEngine 1.x - All pages redirecting to homepage
I'm sure this one is going to be pretty simple - but I'm banging my head against the wall here. It's been a while since I've worked on a 1.x build.

I have a client site which was just migrated to a new server. Following the migration, the homepage template loads correctly, the CP loads correctly. However, all subsequent page loads on the forward facing site redirect to the homepage.

The .htaccess file (removing index.php) is unchanged. I even had this site up on the SAME hosting environment temporarily as staging.clientname.com where everything worked perfectly.

However, as soon as I point the document root of the main domain to the document root of site (which was also in there as staging.clientname.com) the internal templates redirect.

I'm assuming this is an obvious config that I am just forgetting about.

Thanks so much for your help,

Michael

# Answer
Michael -

Have you enabled 'Force Query Strings' in Admin \> System Preferences \> Output and Debugging Preferences (this is from memory, sorry if the breadcrumb is a bit off).

I suspect that you just need to have a question mark after index.php - you can remove it with .htaccess, but that is the most common cause here and usually happens on installations where PHP is run as CGI.

The system preference above will add the question mark to all EE generated URLs.

I hope that helps!

-Lisa
> 2 votes

# Answer
It ended up, in this case, being a misconfigured apache configuration. The client had AllowOverride set to No. Thanks so much for your assistance!
> 0 votes

---
Tags: templates, redirects, 1.x
---


title: Control Panel forms not saving

text:
# Question
Title: Control Panel forms not saving
I am experiencing an odd issue. Randomly, form submissions within the control panel are not actually saving anything and redirecting me to the CP home. This happens with regular channel entry editing, Low Variables, Low Reorder, CE Cache... doesn't seem to matter what is getting saved. About 40% of the time, the form submission takes, and works as expected.

This only happens in production. It is hosted in a multi-instance environment (PagodaBox). I thought perhaps it had something to do with each request going to a different instance... but they are all sharing the same database.

Any ideas?

# Answer
> 1 votes
Does it still do this if you set `Process form data in Secure Mode?` in `Admin >> Security and Privacy >> Security and Sessions`

I have noticed this if I try and submit a form twice without any sort of page reload in between. Although not ideal, turning off the above fixed the issue for me.

---
Tags: control-panel, server, hosting
---


# Question
Title: Letting several Pages share the same URI?
I run multiple sites off one EE installation using the old method, and one issue with that is the Pages module. For example, I need an About Page for each site, directly following the domain. That means that when I setup these Pages, the Page URI would be /About/ in both cases.

This does not work (which the documentation does make clear), even if the Page content is stored in two separate channels and even if each uses a separate Template.

My question, then, is if there's any work-around for this issue? For example, each of my sites does have a site variable defined in index.php. Would it be plausible to use that in any way to allow multiple Pages to share the same URI.

# Answer
I do this with one website with the following setup: Both domains point to the same directory
(second.com is a ServerAlias for main.com)

in the main domain .htaccess redirects requests for second.com to a subdirectory "other"

```
### second.com to directory
RewriteCond %{HTTP_HOST} second.com$ [NC]
RewriteCond %{REQUEST_URI} !^/(other)
RewriteCond %{REQUEST_URI} !\.(jpe?g|js|gif|png|xml|swf|bmp|css|pdf)$
RewriteRule ^(.*)$ other/$1 [L]

### all requests to EE index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !\.(jpe?g|js|gif|png|bmp|swf|xml|css|html?|pdf)$
RewriteRule ^(.*)$ index.php?/$1 [L]

```

in the "other" directory the htaccess redirects to a 'hard' template group

```
### Allow some of the 'real' template groups
RewriteCond $1 ^(specialgroup|sometemplategroup)
RewriteRule ^(.*)$ index.php?/$1 [L]

### All others go to hardcoded template group other/$1
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !\.(jpe?g|js|gif|png|bmp|xml|css|html?|swf|pdf)$
RewriteRule ^(.*)$ index.php?/other/$1 [L]

```

In the index.php for the subdirectory, setup some config variables

```
$assign_to_config['template_group'] = 'other';
$assign_to_config['template']       = 'welcome';
$assign_to_config['site_404']       = 'other/404';

$assign_to_config['site_name']  = 'My Other Site';
$assign_to_config['site_url']   = 'http://second.com/';

```

To be able to actually use the "site\_name" and for it to work, you need to hack the core https://support.ellislab.com/bugs/detail/15461/#8283
or install an extension i developed for this.
http://devot-ee.com/add-ons/override\_site\_name

1. internally the 'real' segments will be `second.com/other/about`
while the browser only shows `second.com/about`
2. the "allow some real template groups" part, allows to show member pages or 'real' template groups like the `/specialgroup` or `/members` without prepending `other` to the url.
3. all assets (images, pdf, css, etc) still come from the main directory. The subdirectory 'other' only has an .htaccess and the index.php file in there.
> 1 votes

# Answer
Wouldn't a template setup as "about" fix this?
> 2 votes

# Answer
This is a perfect example of where using MSM would make your setup so much easier to manage then the old method as Pages URI's are site dependent so you could have multiple /about/ segments and similar on a per site basis.
> 2 votes

# Answer
I'm not sure if you're too far into this site to entertain using Structure, but it's easy to accomplish this with Structure. Your Structure URLs are stored separately from URL Titles. Initially, the Structure URL field copies the URL Title field, but you can then edit it to be any unique URL within its parent page/entry.
> 0 votes

---
Tags: module
---


title: Channel Entry in One Variable?

text:
# Question
Title: Channel Entry in One Variable?
Since I need bits and pieces of a channel entry on various parts of my page, is it possible to store the channel entry in one big variable that contains everything? That way, I can access it throughout the template (and embedded templates)?

I've used Stash for variables, usually for one field value only. Now I want the entire channel entry - all the fields.

# Answer
You can use Stash for this as well. Just create a variable for each value from the channel entry that you want to use.

It seems like you want a less manual process, but there isn't a default EE way of doing that. You probably could build a third party add-on to do something like this, but there aren't any that I know of that have this functionality.
> 3 votes

---
Tags: variable
---


title: Member Group preferences resetting

text:
# Question
Title: Member Group preferences resetting
I have a peculiar problem with a recent EE 2.5.5 site we launched. I've setup a member group for client access with appropriate channels assigned to them. The problem is that somehow their channel access keeps resetting resulting in no access to channels. I've reset their group preferences many times be it keeps getting reset back to none.

Could this be happening on the client end? The group preference doesn't allow them access to the Member area so I kinda doubt it. I rarely access this section of EE so I doubt it's something I'm doing.

Any advice would be appreciated!

# Answer
> 2 votes
YOU FOUND A BUG! I'm guessing you have more than one member group? I thought it had been fixed in 2.5.5... may not? there's a known solution over at: https://support.ellislab.com/bugs/detail/18234

---
Tags: members, channel-preferences
---


# Question
Title: What is the best way to set geolocalised variables?
I have a site that was happily outputting variables based upon a user's IP address. I was using code that looked to see if a cookie for a user's region was already set and if not, looking up the user's country and then setting said cookie and the appropriate variables.

My code was in a PHP enabled template parsing on output and included the following…

```
$sql = 'SELECT country FROM exp_ip2nation WHERE ip < INET_ATON("'.$_SERVER['REMOTE_ADDR'].'")
ORDER BY ip DESC LIMIT 0,1';
list($country) = mysql_fetch_row(mysql_query($sql));

```

But since updating the site in question I find that EE now uses **maxmind.com** data instead of **ip2nation.com**, and that what was a single **ip** field is now 2: **ip\_range\_low** and **ip\_range\_high**. As a consequence my code no longer works.

Can anyone suggest how to fix my code or suggest a better way of achieving the same end?

# Answer
I was just about to have a crack at a little plugin for this but it looks as though Andrew Weaver beat me to it. By the sound of it his plugin will do what you're after:

> `{exp:ajw_country}` to display the 2 letter country code of the current IP
> 3 votes

---
Tags: query
---


# Question
Title: PHP inside a User loop — what am I doing wrong?
On an article page, I'm trying to output "more from this author" using the User add-on from Solspace.

Unfortunately, there's a bug in the current version that prevents this from working:

```
{exp:user:entries channel="articles" status="open" user_author_id="1" entry_id="not 344"}
    {if count == "1"}
    // header and opening ul
    {/if}

        // list items with links to articles

    {if count == total_results}
    // closing ul
    {/if}
{/exp:user:entries}

```

The bug means that `entry_id` doesn't work with the "not" in there, so I can't exclude the current entry.

The workaround is to use PHP, and so I have something like this:

```
<?php $c = 0; ?>
{exp:user:entries channel="articles" status="open" user_author_id="1" limit="4"}
  {if entry_id != "344"}
    <?php $c++; ?>
    <?php if($c == 1): ?>
      <h3>More from this Author</h3>
      <ul class="author-more">
    <?php endif ?>

        <li><?php echo $c ?> <a href="/article/{url_title}">{title}</a></li>

  {/if}
{/exp:user:entries}
<?php if($c != 0) :?>
      </ul>
<?php endif ?>

```

Unfortunately, the results I'm getting are odd. I'm getting a list of three articles — the article with the id of 344 is being correctly omitted — but I'm not getting the header and open `ul` tag.

I'm echoing `$c` in there, and what results is a list of three articles numbered 2, 3, 4. It seems like `$c` is skipping straight from 0 to 2.

Hopefully I'm just doing something dumb...

# Answer
> 2 votes
You might be able to stick to EE code with the following?

Maybe relying on `total_results` & `count` would do it, and then within you could check for the current entry\_id to skip that one.

```
{if total_results>1}
{if count==1}
<!-- Set up header & UL -->
{/if}
{if entry_id != 344}
<!-- Output entry details -->
{/if}
{if:elseif count==1 && total_results==1}
{!-- This would never happen, right? Because if total_results==1, then you're looking at the only entry. So all you need is the single if --}
{/if}

```

Just to clarify what I've written there: I included an else statement for when there's only 1 result. But you'd never want that. Because the 1 result would be 344, and you don't want to show anything if that's the case.

If you kill the `elseif`, you can just do 2 separate `if` statements, right?

```
{if count==1 && total_results>1}
<!-- Set up header & UL -->
{/if}
{if entry_id != 344}
<!-- Output entry details -->
{/if}

```

Is that what you're looking for? Or am I missing something?

# Answer
> 3 votes
Oof, that's a lot of ugly PHP to have to add to get around a bug. May I suggest a couple of alternatives?

One would be to just fix the bug while you wait for Solspace to release an update. (Ha.)

But failing that, use the Query module to grab all of an author's entries and pass them to a standard channel entries loop (which you can then use your standard `limit`, `orderby`, etc on).

```
{embed="_embeds/_more_by_author" entry_ids="{exp:query sql="SELECT DISTINCT entry_id as user_entry_id FROM exp_user_authors WHERE author_id = {author_id} and entry_id != {entry_id}" backspace="1"}{user_entry_id}|{/exp:query}"}

```

(Since we're using variables from your currently-displayed entry, this would have to be inside your primary Channel Entries loop.)

Then in your embed:

```
{exp:channel:entries channel="articles" status="open" entry_id="{embed:entry_ids}"}
    {if count == "1"}
    // header and opening ul
    {/if}

        // list items with links to articles

    {if count == total_results}
    // closing ul
    {/if}
{/exp:channel:entries}

```

---
Tags: add-on, php, solspace-user
---


title: member registration using freemember

text:
# Question
Title: member registration using freemember
Using freemember to register a member with custom fields and when I submit a form intentionally with errors the appropriate inline errors are returned - that works as desired. When i submit the form with correct data the ugly EE error screen is output requiring all the custom member fields that were just submitted.

Any ideas?

# Answer
This sounds like you have the required = yes in the custom member field settings. IF you are using FreeMember it is best to leave those at not being required in the EE CP then requiring them with the required tag in your opening FreeMember tag.
> 3 votes

---
Tags: members, freemember
---


title: Pagination in Search results?

text:
# Question
Title: Pagination in Search results?
I'm trying to get some pagination at the bottom of my search results, and I can't seem to get it to work. All the results display as expected, but there's no pagination at the bottom. Here's my code:

```
<div class="col-100">

    <h1 class="section-header">{exp:search:total_results} Result(s) for "{exp:search:keywords}"</h1>

        <ul>
            {exp:search:search_results paginate="bottom" limit="4"}
                <li><strong><a href="{auto_path}">{title}</a></strong> from <em>{channel}</em><br/>{excerpt}<br/></li><br/>

        {if count == total_results}
        </ul>
        {/if}
        {paginate}
            <p>Page {current_page} of {total_pages} pages {pagination_links}</p>
        {/paginate}
        {/exp:search:search_results}

</div>

```

# Answer
> 4 votes
Your code looks correct. Could it be that you only have a single page of search results?

I see you have a `limit` parameter on the tag, but it actually does not accept that parameter. The number of search results per-page is actually determined by the `results` parameter on the Search Form tag which sends you to the results page.

---
Tags: search, pagination, simple-search
---


# Question
Title: "Old-Style" multiple sites on one installation
Many, many years ago, before MSM, there was a documented way to have multiple sites run on a single installation of EE. It involved creating a new folder at the site root and having an index.php and path.php file that redirected to the main installation.

I used this successfully for many years on EE1.x. Now that I've upgraded to EE2.x, it seems to have broken.

The main installation is at: www.rickandlynne.com

And, the second site is my wife's site at: www.rickandlynne.com/lynne

The trouble I am now having is with pagination, logins, and other blind navigation from my wife's site that ends up redirected to my site. For example, try pagination from her site and you'll see there is a "/" missing in the URL.

I've been experimenting with settings in the index.php and path.php and channel configurations and just can't figure out how to make this work any more.

Does anyone have experience with this and know how to get this "old style" multiple site scheme working in EE2? It appears to be possible because in the EE2.x index.php file there is a section shown here (with my configuration from EE1.x\_:

---

```
/*
 * --------------------------------------------------------------------
 *  CUSTOM CONFIG VALUES
 * --------------------------------------------------------------------
 *
 * The $assign_to_config array below will be passed dynamically to the
 * config class. This allows you to set custom config items or override
 * any default config values found in the config.php file.  This can
 * be handy as it permits you to share one application between more then
 * one front controller file, with each file containing different
 * config values.
 *
 * Un-comment the $assign_to_config array below to use this feature
 *
 * NOTE: This feature can be used to run multiple EE "sites" using
 * the old style method.  Instead of individual variables you'll
 * set array indexes corresponding to them.
 *
 */
    $assign_to_config['template_group'] = 'lynne';
    $assign_to_config['template'] = 'index';
    $assign_to_config['site_index'] = 'go';
    $assign_to_config['site_404'] = '';
    $assign_to_config['global_vars'] = array(); // This array must be associative

```

---

# Answer
> 3 votes
Yes it's possible. Assuming, you are still on the same server (since server variation can switch things up), not these things:

1. **Path.php is dead**. We've kept ours around on clients we upgraded to EE2, but added the note:

// THESE ITEMS ARE SET IN index.php and config.php AS OF EE2
2. **Check Your URI Protocol**. This dogged us for awhile, before we happened upon it looking for a solution to a totally different issue. EE2 defaults to 'AUTO' for the protocol, which should work, but hasn't yet worked for us on any server where we are using the Old School MSM method. Test 'PATH\_INFO' or the other methods. 'PATH\_INFO' has been our go to. (This is config.php)

$config\['uri\_protocol'\] = "PATH\_INFO";
3. **Pagination Sucks**. Even on primary domains, it tries to re-insert the /index.php before processing the data. Your issue seems to be two-fold: (a) Your wife's domain isn't pointing, because you couldn't get it to work and (b) that missing trailing slash.

Both of these maybe solved by getting the domains to work. But you may still need to do a little work. For one of our projects, we use FIND & REPLACE to clean-up the url. This is the clean url.

http://consumerservicesguide.org/resources/national/browse/category/197/P25

This is what the system produces

```
http://consumerservicesguide.org/csg/resources/national/browse/category/197/P25

```

And this is the code we use to clean it up

```
{paginate}
<div id="pagination">
<p>{exp:low_replace find="{segment_1}/" replace=""}{pagination_links}{/exp:low_replace}</p>
</div>
{/paginate}

```

Because of the use of custom segments, the `index.php` file isn't an issue, here, but has been on other sites. We test. If we manually remove the index.php and pagination still works, then we basically add `index.php/{segment_1}/` to the find and replace script. If pagination doesn't work without the `index.php`, we leave it in. This seems to be server dependent.

Those are the main points, but you can also check my response **here**, if you need more troubleshooting tips. But my thoughts are, as long as you've transferred the details from 'path.php' to index.php, and adjusted the URI PROTOCOL in 'config.php', if it was working before, on the same server, it should work again.

# Answer
> 0 votes
@nonprofit\_tech, here is where I am...

I edited the subsite index.php to look like this:

```
     $assign_to_config['site_name'] = 'lynne';
     $assign_to_config['site_url'] = 'http://www.rickandlynne.com/lynne';

     $assign_to_config['template_group'] = 'lynne';
     $assign_to_config['template'] = 'index';
     $assign_to_config['site_index'] = 'index.php';
     $assign_to_config['site_404'] = '';
     $assign_to_config['global_vars'] = array(); // This array must be associative

```

Changing the uri\_protocol did not seem to make any difference.

These changes make everything work. Pagination works and login from the subsite returns the user to the home page of the subsite. So, you definitely pointed me in the right direction.'

The subsite URLs do look weird, something like:

http://www.rickandlynne.com/lynne/index.php/lynne/comments/doggie\_snow\_angel

for a comment page, with the extra "lynne/index.php" stuff there. But, at least the site works. (On my sub site, I've named index.php to be "go" so it looks less weird.) I did not need to use the low find/replace in the pagination code, but may find that useful as I continue to learn how this works.

I did not set up any global\_vars for the subsite and exploring that might lead to further insight.

Anyway, thanks for pointing me in the right direction. My wife is now less upset about the disruption to her blog from the EE upgrade. Too bad the folks at EE (who were pmachine when I started using them) and who got their start from enthusiastic "hobbiest" supporters like me have abandoned support for hobbiests. As I recall, this all started as something of a hobby for Rick.

---
Tags: ee2-upgrades
---


title: How to manage templates?

text:
# Question
Title: How to manage templates?
Say I have the following URLs for my Channel entry page:

```
http://site.com/used-toys/231/
http://site.com/new-toys/235/

```

NOTE: the pattern is: `template_group/entry_id`

They use the same Channel and display the exactly the same thing. The URLs are different for SEO purposes. What should I do so that I can remain DRY in respect to the markup that display these Channel entries.

The non-DRY way to do this is to just make sure that `used-toys/index` is kept in sync with `new-toys/index`.

Stash is probably a solution, but I have struggled with that the moment I start doing complex things where parse order matters. I'm hoping for an easier, native-EE solution.

# Answer
If you are talking about, reusing the same template format, in multiple templates, then technically that is what `{embeds}` can be used for. To do this, we would do…

```
Template Group: used-toys/index
     {embed="include/toy-display"}

```

then

```
Template Group: new-toys/index
     {embed="include/toy-display"}

```

then have a single template that is used by both or any template, you wish the same display style for.

```
Template Group: include/toy-display
     {embed="include/header"}
     <div class="toy">
         your display details.
     </div>
     {embed="include/footer"}

```
> 4 votes

# Answer
You should not do this. It's going to harm your SEO more than it will improve it. Google will penalize you for having duplicate content, an generally only display one version of the content in its search results.

If you want to improve SEO for lots of different terms, you need to write good content for each term. Each page should have a single canonical URL where the content is accessible from. Simply displaying the same page in two different locations is misguided SEO.
> 0 votes

---
Tags: templates
---


title: Connecting to S3 on localhost WAMP

text:
# Question
Title: Connecting to S3 on localhost WAMP
I've managed to connect to the S3 bucket on my live server, but when pressing "Refresh" on my WAMP running on localhost that list doesn't populate / is blank.

There isn't an error message as far as I can tell. Is there a way that I can debug why this is happening?

Edit: to clarify, this is for Assets 2.

Cheers, Andrew

# Answer
> 1 votes
This was revolved by installing CURL on the WAMP machine. It's a bit odd that "New Version Check" worked without CURL, but perhaps that uses a different method or I misunderstood.

I enabled CURL in WAMP by going to WAMP \> PHP \> Extensions and enabling the CURL extension.

---
Tags: assets
---


# Question
Title: Creating AJAX endpoints for custom fieldtypes
I'm working on a custom fieldtype that requires some validation via AJAX, which means I need an endpoint to direct my `$.get()` requests to. I know that accessories support process\_x methods but fieldtypes don't appear to offer anything similar.

As far as I can see my options are to create a module (which otherwise I have no need for) or an extension (ditto, really). I noticed that the VZ URL fieldtype uses the sessions\_start hook for this but that's not ideal as it's adding a little overhead to every single request, even frontend ones.

Is there a better, simpler option that I'm missing?

# Answer
As far as i know, you cannot do this in a fieldtype in any other way. What i've seen most often is a accompanying module that registers an action so that the method in the module acts as the ajax endpoint.

That's not a huge amount of extra work thought is it really :)

I do fully appreciate what you're saying though, it's a shame it can't all be self contained in the fieldtype :(
> 3 votes

---
Tags: add-on-development, fieldtype
---


# Question
Title: Expresso Store error: Error calculating shipping: No rules match the current cart
I'm using Expresso Store and getting an error message: Error calculating shipping: No rules match the current cart. Have read the documentation, couldn't find any answers there. Do I have to link the products to the shipping in some way, or is there something I'm missing out on?

I'm having the problem with a live site and trying to fix this before I put the store live. I've set up a copy of ExpressionEngine with Store 1.6.1 on my local machine to play around with, but I'm getting the same error.

I've created a Products Channel and linked it to a Channel Field using the Store Product Details Field type. This is what I get when I go to Content \> Publish \> Products:

I've set up a dummy product as an example.

Then I'm going to Store \> Settings \> Shipping Methods.

I've created a Method called Weight and set a rule as shown here:

But unfortunately, I'm getting the above error message.

It's probable something silly I've done, or something small I've missed.

Edit: Screenshots:
https://i.stack.imgur.com/Q6oS4.jpg

https://i.stack.imgur.com/JWen0.jpg

Thanks.

# Answer
Store breaks shipping down into two concepts: *Shipping Methods* and *Shipping Rules*. Each Shipping Method has one or more rules.

For example, you might have two shipping methods: *Standard Delivery* and *Express Delivery*. For each of these methods, you would create some rules to calculate shipping costs. Shipping rules can be based on any or all of the following criteria:

* Country
* Region / State
* Postcode / ZIP
* Min & Max Order Quantity
* Min & Max Order Total ($)
* Min & Max Order Weight

When your customer has selected a shipping method, but no rules apply to them to calculate costs from, you will receive the error:

> Error calculating shipping: No rules match the current cart.

There are two ways to fix/avoid this error:

* In most cases, you would create a "catch-all" shipping rule with no criteria, with a shipping price for "everyone else".
* If the shipping method really doesn't apply to this customer (say the shipping method only applies to domestic shipping, but this customer has selected a different country for their shipping address), then you should use a conditional statement in your template so that the customer never sees or selects this payment method.
> 1 votes

---
Tags: expresso-store
---


# Question
Title: How can I keep track of sales count with Store, Matrix, & Playa?
**The Scenario**

I'm using Store, Matrix, and Playa addons for an ecommerce site. I now need to add a Gift List section to the site. This is not the typical scenario as an admin user will create the list in the control panel (CP)—no front-end sign-up and users can't add products themselves.

**Constraints**

I'm already using Store on other ecommerce parts of the site as a regular shop setup so I need all orders to still feed into the Store Orders section and the Store template variables available on the front-end as currently.

All SKU's must match a printed catalogue and they must all be unique within the system.

**The Problem**

Each gift needs a ***Quantity Requested*** and ***Quantity Received*** value associated to it. At first thought you think you can use the *Limit Stock* option in the *Store Product Details* field but this would tie those values to each and every gift meaning that if it was requested at a later date by someone else with different quantities then it wouldn't be possible to enter it as the SKU would be a duplicate. The SKUs ***have*** to match those of a printed catalogue and in the system obviously they ***have*** to be unique.

So I need to disassociate ***Quantity Requested*** and ***Quantity Received*** from the product itself. If I were to create these as separate columns in a Matrix field I need a way to keep a running counter of products purchased, match them to the list, and increment the ***Quantity Received*** column in the Matrix field. The checkout is running on Store so I have to use Store's template variables and hooks to retrieve the details upon order completion and then somehow post them back to update the ***Quantity Received*** field in the EE CP.

**The Setup** *(not in full or including non-important fields for brevity):*

Channel: Gifts

Fields: Store Product Details

Channel: Gift Lists

Fields: Matrix

Within a matrix row I have a column for ***Gift*** (Playa field) to pull in a requested gift. Then a column for ***Quantity Requested*** and another for ***Quantity Received***. Both of these fields are Number fields containing a simple integer. Looking like this.

**The Questions**

Is that setup the best way to handle things? If so, what is the best way to grab the values from a completed order run through Store and then update the appropriate entry in the ***Gift Lists*** channel? Would I be able to use Safecracker to post back and update values? Or is there a better way to do it in PHP? Recommendations?

# Answer
This looks like the best way to set things up.

All you really need to do is update the "quantity received" column after a purchase is made. This will require writing an extension to update your matrix field.

The first thing you need to do is remember which gift list the customer is purchasing from. I assume you have a page to display all items in the gift list and an "add to cart" button. What I would do here is use a custom text modifier to store the matrix row ID of the product they purchased. You can submit this as a hidden field as part of the add to cart form, and it will get stored in the cart alongside any other modifiers (e.g. Size, Color). You can also edit your checkout templates with some conditional statements to hide this matrix row ID from displaying the checkout pages (since the customer doesn't need to know or care about it), but you will need to know it later to know which gift list purchase count to increment.

Then you will need to create an extension (don't use php in templates if you can avoid it, it can create security holes in EE). Start by following the general EE extension development guide here. You will want to use the store\_order\_complete\_end hook which means your custom PHP code will be run every time an order is complete (paid for).

In your extension hook code, you will basically loop through the items in the order, and check for the text modifier you stored (which contains the matrix row ID). You can then easily +1 the "quantity received" column directly in your database (I'll leave it to you to decipher the matrix database schema).

It's a fairly involved process, but nothing particularly complicated. If you're not familiar with PHP and SQL it's probably worth hiring a developer who has worked with EE extensions before to help you out.
> 1 votes

---
Tags: expresso-store
---


# Question
Title: SafeCracker and Querying the database in the search for duplicate content
I have a safecracker form which I am using to register contacts for a contact manager. In an effort to eliminate duplications I would like the safecracker form to query the database and check for duplicate email or names in the contact entries.

I tried to install Ajax form Validator Plugin but the plugin does not seem to work and the developer is not responding in the help section.

How can I use Jquery/Ajax to perform an inline check before submitting the form?

Below is the script for the faulty Ajax Form Validator:

```
{exp:ajax_form_validator:script entry_id="none" form_id="comment_form" submit_button_id="submit_button" async_url="http://www.elinex.co.za/contact-manager/ajax_form_validator_async/" parse="inward"}

{ajax_form_validator field="name" required="yes" deny_duplicate_data_field="exp_members.screen_name|exp_members.username" duplicate_data_exception_field="exp_members.email" duplicate_data_exception_contained_in="email" field_required_alert_text="ERROR!\nName field cannot be empty!" invalid_indicator_id="name_field" invalid_class="invalidated" javascript_alert="yes" min_length="2" max_length="30" regex="/^[a-zA-Z0-9]+([\.\_\-][a-zA-Z0-9]+)*$/" min_length_alert_text="ERROR!\nThe name cannot consist of one letter." max_length_alert_text="ERROR!\nThe name cannot be longer than 30 characters." duplicate_data_alert_text="ERROR!\nThe name you entered is already in use by a registered member." regex_alert_text="ERROR!\nThe name you entered contains illegal characters or character combinations."}

{ajax_form_validator field="email" required="yes" deny_duplicate_data_field="exp_members.email" duplicate_data_exception_field="exp_members.screen_name|exp_members.username" duplicate_data_exception_contained_in="name" field_required_alert_text="ERROR!\nEmail field cannot be empty!" invalid_indicator_id="email_field" invalid_class="invalidated" javascript_alert="yes" max_length="50" max_length_alert_text="ERROR!\nThe email address cannot be longer than 50 characters." regex_alert_text="ERROR!\nInvalid email address." duplicate_data_alert_text="ERROR!\nThe email you entered is already in use by a registered member." regex="/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]:LD:2,6:RD:$/i"}

{/exp:ajax_form_validator:script}

{exp:safecracker channel="member_profiles" url_title="{segment_3}" dynamic_title="[member_first_name] [member_last_name]" return="contact-manager/added/ENTRY_ID"}

<label>Name</label>
<input type="text" name="name" value="" class="text"/>

<label>Email Address</label>
<input type="text" name="email" value="" class="text"/>

<input type="submit" name="submit" id="submit_button" style="margin-left:0px;" value="Add Contact"/>

{/exp:safecracker}

```

# Answer
> 1 votes
To answer this question, ignoring the AJAX Form Validator, which I'm unfamiliar with.

> How can I use Jquery/Ajax to perform an inline check before submitting the form?

You can create a template that loads a segment variable, such as the email address, into an `exp:query` tag/SQL statement, and check for the address that way. You can then return a 1 or a 0.

If the URL is /email-check/someone@somewhere.com

```
{exp:query sql="Select * from exp_channel_data where field_id 2 = '{segment_2}'}
{if total_results > 0}1{if:else}0{/if}
{/exp:query}

```

Now you can just use your own jQuery/AJAX code to pass the email address to that template's URL, and validate the form based on the 1/0 response.

---
Tags: safecracker, ajax, jquery
---


# Question
Title: Edit .htaccess File Within ExpressionEngine
I have a client that wants to edit their .htaccess file within ExpressionEngine's CP as opposed to editing the file locally and FTP'ing it back to the server. Is it possible to customize EE to allow for such, that is, read in the contents of the .htaccess file and once updates are made, write the contents back to the file and save on the server's hard disk? I searched Devot:ee and didn't see any add-ons or plugins to do so. Thanks in advance...

# Answer
You're going to want NSM .htaccess Generator, Marc. This will update the .htaccess as they add new entries, as well as edit the baseline of the .htaccess file, itself.
> 2 votes

# Answer
Detour Pro is recommended often around here as well, if they're just looking to manage redirects.
> 1 votes

# Answer
.htaccess Maker allows you to use any EE template (and so any template tags) to generate your .htaccess file each time any template is updated (or you can invoke generation manually from CP). And it's free :)
> 0 votes

---
Tags: htaccess
---


# Question
Title: SAEF + Matrix + Date_field + custom layout, datepicker not displaying
I have a Matrix with a field called end\_date and its cell type set to Date.
When the Matrix field is placed inside the following Safecracker form, the end\_date datepicker displays correctly in the table cell.

CODE\_1

```
{exp:safecracker channel="browse" return="some/path/URL_TITLE" url_title="{segment_3}" require_entry="yes"}
    {field:my_matrix_field_name}
{/exp:safecracker}

```
However, I want to customise the layout, so have instead used this \[post\]\[1\] to create:

CODE\_2

```
{exp:safecracker channel="browse" return="some/path/URL_TITLE" url_title="{segment_3}" require_entry="yes"}
    {my_matrix_field_name}
        <input type="hidden" name="my_matrix_field_name[row_order][]" value="row_id_{row_id}" />
        <input type="text" name="my_matrix_field_name[row_id_{row_id}][col_id_1]" value="{end_date}">
    {/my_matrix_field_name}
{/exp:safecracker}

```
**Issue with CODE 2**: The data for the end\_date field displays, BUT the datepicker does not display for the field. It just displays the default input field.

**Simple question**: Should the datepicker display by default?
**Possible solution**: Or do I need to use Stash to changer the parse order, as per this \[post\]\[2\]?

I am using EE 2.5.2 and Matrix 2.5.3.

I have read every post I can find over the last 24hrs looking for a solution.

# Answer
> 1 votes
Since you're not using the Matrix fieldtype's internal display method, you'll need to manually call the datepicker on that input (otherwsie it's just a plain text field).

Target it with a class name or id, then apply some jQuery to it. You'll also need to format the existing field value if you're displaying your form as an edit form (otherwise it will show up in the field as as UNIX timestamp).

```
<input type="text" class="my-date-field" name="my_matrix_field_name[row_id_{row_id}][col_id_1]" value="{end_date format="%Y-%m%-d %g:% %A"}">

<script>
$(document).ready(function()
{
    var date = new Date(),
    hours = date.getHours(),
    minutes = date.getMinutes();

    if (minutes < 10) minutes = '0'+minutes;

    if (hours > 11) {
        hours = hours - 12;
        var meridiem = " PM";
    } else {
        var meridiem = " AM";
    }

    var time = " \'"+hours+':'+minutes+meridiem+"\'";

    $('.my-date-field').datepicker({
        constrainInput: false,
        dateFormat: $.datepicker.W3C + time
    });
});
</script>

```

# Answer
> 0 votes
Further to Dereks answer and just to wrap things up, here is the code I've used that includes altFormat and altField. It allows datepicker to display without the time in the field, but still pass the date + time in the required format back to EE.

```

<input type="text" value="{end_date format="%Y-%m-%d"}" id="my_datepicker_date">
<input type="text" name="my_matrix_field_name[row_id_{row_id}][col_id_1]" value="{end_date format="%Y-%m-%d %g:%h %A"}" id="stored_date">

$(document).ready(function()
{
    var date = new Date(),
    hours = date.getHours(),
    minutes = date.getMinutes();

    if (minutes  11) {
        hours = hours - 12;
        var meridiem = " PM";
    } else {
        var meridiem = " AM";
    }

    var time = " \'"+hours+':'+minutes+meridiem+"\'";

   $('#my_datepicker_date').datepicker({
        constrainInput: false,
        dateFormat: 'yy-mm-dd',
        altField: "#stored_date",
        altFormat: $.datepicker.W3C + time
    });

    $('#my_datepicker_date').change(function () {
        var $value = $(this).val();
        if ($value == '') $("#stored_date").val('');
    });
});

```

---
Tags: safecracker, matrix, date
---


# Question
Title: Trouble Creating an accessory that will access DB field and modify value
I am creating an accessory that will access a table that I have created to update the value of a field. I have it set up so that if the value is 1 the page will be rendered and if the value is 0 the page will not be rendered. I have gotten everything down except getting the value to change via the access class.

What I currently have is a link that will execute an onclick to call another function within the accessory that evaluates the value of the field and then decides to change the value based on that.

Here is a sample of the code:

```
/**
 * The Blog Switch Accessory
 *
 * @package ' '
 * @author Jeremy Herb
 */
class Blog_switch_acc {
var $name         = 'Blog Switch';
var $id           = 'blog_acc';
var $version      = '1.0';
var $description  = 'This accessory will allow you to turn your blog page on and off';
var $sections     = array();
/**
* Constructor
*/
public function Blog_switch_acc()
{
$this->EE =& get_instance();
}

//onclick execute function to change value
public function set_sections()
{
$this->sections["On/Off Switch"]  = "
  <a  href='#' onclick='switcher()'>On/Off</a>
  <p>To turn the blog on or off click the button above</p>";
}

public function switcher()
{
$query = $this->EE->db->query("SELECT blog_on_off FROM db_options");
$set_to = $query == false;
$this->EE->db->query("UPDATE db_options SET blog_on_off = $set_to");
}
   }

/* End of file acc.blog_switch.php */
/*Location:./system/expressionengine/third_party/blog_switch/acc.blog_switch.php*/

```

My apologies if it looks bad on the forum, this is my first post here.

Thanks, Jeremy Herb

# Answer
> 1 votes
Welcome Jeremy! You appear to be confusing PHP functions and javascript functions. In your "On/Off Switch" accessory code, you're calling a *javascript* function with the `onclick` event. For that to call your `switcher()` PHP function, you'd need to add more javascript that will make that click an AJAX call to your accessory method which runs via PHP on the server.

You can do this with accessories by using the process\_ method. So, you'd rename `switcher()` to `process_switcher()`, then make an AJAX call to `C=addons_accessories&M=process_request&accessory=blog_switch&method=process_switcher`.

Also, your code inside of the `switcher()` function does not follow EE code guidelines. It should be more like this:

```
$query = $this->EE->db->query("SELECT blog_on_off FROM db_options LIMIT 1");
if($query->num_rows() == 1)
{
    $set_to = ($query->row('blog_on_off') == false) ? 1 : 0;
    $this->EE->db->query("UPDATE db_options SET blog_on_off = $set_to");
}

```

(Review the EE database class documentation here.)

---
Tags: database
---


# Question
Title: What's better for performance when storing multiple vars in a single entry with stash? Set or Set_list?
I'm curious if anyone that has either done a comparison between the two or simply knows why one would be more efficient than the other. Stash set vs. set\_list in storing multiple individual field variables for a single entry.

Example:

A template group index that generates "pages" on the basis of entries that includes, for example, the following fields:

* title (obviously)
* alt menu title
* body (RTE field)
* promo image
* extended body (RTE field)
* Meta Title
* Meta Description
* Meta Keywords

So to create a variable out of each one of these fields distinctly, I could either wrap each with a simple stash:set tag pair or I could wrap the whole thing with a stash:set\_list tag pair and wrap each variable with the tag pair to set each as list elements.

Then in the wrapper template, in the set\_list scenario, when I have several of these elements that actually need to appear together (like title, body, extended body and promo image, for example), I can use a single get\_list tag pair to retrieve the several of them I need whereas with the simple set scenario, I would need a get for each variable separately, even if four of them follow one another sequentially in the markup.

What are the performance issues I should be worries about? Or should I be worries about it? To me, they seem to run about the same speed, but I wonder if the database and stash experts out there can speak to how/if there would be differences, particularly as the number of fields in a given field group climbs.

I have thought about the fact that the stashed body of the page could in fact combine several of the fields in the field group into a single stashed set (whether list or not). But for the purposes of this example/question, I thought I'd keep them separate.

# Answer
A stash list is simply a serialized variable. Setting and getting a list is the same process as setting/getting a single variable, except the list has some additional processing to separate out the elements, serialize/unserialize, sort and paginate. In practice if you are not saving the variables with `save="yes"` then there is little appreciable difference in speed or memory use. However, if you are saving your variables then a list is more efficient than multiple individual variables because it requires only a single query to retrieve, regardless of how many times the list is iterated over in your template.

Another option for saving multiple variables as a single cached item (especially where individual parameters are required per variable, e.g. `match` / `against`) is the `{exp:stash:bundle}` tag pair.
> 5 votes

---
Tags: stash, database, performance
---


# Question
Title: Stash + conditionally embed content from different channel
I have a feeling I'm missing something incredibly basic but I'm stuck so here goes. I have a basic html page {stash:embed:layouts:standard} that holds a 2-col layout. The main column and sidebar have content from the "site" channel but in the sidebar the user has a choice to embed 1 (the most recent) item from the "news" channel (using a PT switch field). The standard way I know but I'm stumped on doing this the stash way.

layouts:standard is basically

```
 <div class="container">

    {exp:stash:get name="intro"}

    <div class="main" role="main">
        {exp:stash:get name="main_content"}
    </div><!-- .main -->

    <div class="sub">
        {!-- this should be conditional --}
        {exp:stash:get name="nieuws"}

        {exp:stash:get name="sidebar"}
    </div><!-- .sub -->
</div><!-- .container -->

```

My main template is simply

```
{!-- main layout --}
{stash:embed:layouts:standard}

{!-- main content --}

{exp:channel:entries channel="site" disable="member_data|pagination" category="{segment_1_category_id}" dynamic="off" url_title="{segment_2}"}
{if no_results}{redirect="404"}{/if}

{exp:stash:set name="banner"}{cf_site_main_image}{/exp:stash:set}

{exp:stash:set name="main_title"}{cf_site_main_title}{/exp:stash:set}

{exp:stash:set name="sub_title"}{cf_site_sub_title}{/exp:stash:set}

{exp:stash:set name="intro"}{intro}{/exp:stash:set}

{exp:stash:set name="main_content"}{body}{/exp:stash:set}

{exp:stash:set name="sidebar"}{sidebar}{/exp:stash:set}

 {if cf_site_add_news == "y"}
    {!-- the single news entry here only if switch set to yes --}
 {/if}

{/exp:channel:entries}

{!-- news item for sidebar --}

{exp:stash:set name="nieuws" save="yes"  scope="site" parse_tags="yes"replace="yes" refresh="240"output="yes"}
{exp:channel:entries channel="nieuws" disable="categories|category_fields|member_data|pagination" dynamic="off" limit="1"}
    {cf_nieuws_content}
{/exp:channel:entries}
{/exp:stash:set}

```

What trips me up is the conditional if statement {if cf\_site\_add\_news == "y"} - how and/or where do I process it? Am I making it clear enough?

# Answer
> 1 votes
First, capture the value of `cf_site_add_news`:

```
{exp:stash:set name="site_add_news" type="snippet"}{cf_site_add_news}{/exp:stash:set}

```

(Note that setting `type="snippet"` means the variable can be evaluated as a simple conditional)

Then you can use a conditional in your layout like this:

```
{if site_add_news == "y"}
{stash:nieuws}
{/if}

```

(Note that in a stash embed, stash variables can be accessed using the syntax `{stash:my_var}`)

# Answer
> 1 votes
Ok, let's see if I understand. I try to do all my logic outside of my wrapper template whenever possible. If the content of your sidebar can change based on user choices, I would put the conditional logic in the partial template.

I would first build my different sidebar pieces, then assemble them using conditional logic further down.

Something along the lines of:

```
{!-- main layout --}
{stash:embed:layouts:standard}

{!-- main content --}
{exp:channel:entries channel="site" disable="member_data|pagination" category="{segment_1_category_id}" dynamic="no" url_title="{segment_2}"}
    ...
    {exp:stash:set name="sidebar_site"}{sidebar}{/exp:stash:set}
    {exp:stash:set name="sidebar_add_news"}{cf_site_add_news }{/exp:stash:set}
{/exp:channel:entries}

{!-- news item for sidebar --}
{exp:stash:set_list name="sidebar_nieuws" parse_tags="yes" save="yes" replace="no" refresh="240" scope="site"}
    {exp:channel:entries channel="nieuws" disable="categories|category_fields|member_data|pagination" dynamic="no" limit="1"}
        {stash:nieuws_content}{cf_nieuws_content}{/stash:nieuws_content}
    {/exp:channel:entries}
{/exp:stash:set_list}

{!-- build sidebar --}
{exp:stash:set name="sidebar"}

    {exp:stash:sidebar_site}

    {if "{exp:stash:sidebar_add_news}" == "y"}
        {exp:stash:get_list name="sidebar_nieuws"}
            {nieuws_content}
        {/exp:stash:get_list}
    {/if}

{/exp:stash:set}

```

You could further optimise this using switchee or ifelse

**EDIT:** as suggested by Mark, using type="snippet" will get you a (leaner) simple conditional

---
Tags: stash
---


# Question
Title: If statement with OR always returning TRUE
I'm doing lots of checks against segments to try and perm redirect a very large list of old URLs and seem to have run into an issue with conditionals.

```
{if segment_1 == 'category' OR segment_1 == 'Category'}

```

Seems to always return true, even if segment\_1 == 'sajdhjknsdjksad'. Is there a known bug, or am I doing something incredibly stupid?

**UPDATE**

The cause of the issue appears to be the redirect plugin I'm using getting evaluated before advanced conditionals, and then proceeding to redirect even if it shouldn't have actually been called. I'm using RedirectURL by Rodrigo Passos

# Answer
Per the comments, it appears this isn't a problem with your conditionals. It's a problem with the RedirectURL extension redirecting users before your page has finished parsing.

Generally in EE, all plugins/tags are parsed before conditionals are applied. A plugin which drastically alters the response (such as performing a redirect) should take this into account, and use an extension hook and some cunning to perform the redirect only after the template finishes parsing.

In this particular case, it's probably easier to find a different plugin to handle your redirects.
> 0 votes

---
Tags: conditionals, advanced-conditionals
---


# Question
Title: Double up of Assets File Upload preferences within Assets addon
We've just updated to the latest version of Assets v2.0.4 and have noticed that there's two of every upload preference displaying in the side column. We're using the Focus Lab Config for this site and have the preferences set in the config.master.php similar to the following:

```
    1 => array(
        'name'        => 'Files - Documents',
        'server_path' => $media_path . '/files/documents/',
        'url'         => $media_url  . '/files/documents/'
    )

```

There looks to be two possible problems, the first being that changing something in the config, doesn't reflect the change in Assets, and the problem of the subject matter whereby we see two of each File Upload preference. The above example would have entries in the side column for:

```
Files - Documents
documents

```

The proper name, and the name of the directory.

Any assistance would be greatly appreciated.

**UPDATE:**

Thought I would update showing what's going on in my instance. First of all here's my upload preferences so you can see they're pretty normal beasts.

Now this is the output from Assets (v2.0.5) at time of capture.

Note that I have an 'All Media' upload preference so that it can be set within WYGWAM as it only allows for a single upload location. The dated folders at the top of the Asset upload point listing are actually subfolders of the Files: Board Documents pref.

# Answer
So it looks like we ran into this problem as the first version of Assets that was released didn't honour the settings in our config.master.php for the upload preferences array. This was fixed in Assets v2.0.2 but we had already run the update on the production database (yeah, Rookie mistake) so this is what I did to rectify.

1. I exported the 'exp\_assets' and 'exp\_assets\_entries' table from a pre Assets v2.x backup.
2. For good measure I went into each of the 'Content \> Files \> File Upload Preferences' and hit the update button to make sure the paths etc are saved into the database as well as still in the config and they match.
3. I dropped all the Assets v2 tables from the active database that has the messed up tables including 'exp\_assets\_files', 'exp\_assets\_folders', 'exp\_assets\_index\_data', 'exp\_assets\_selections' and 'exp\_assets\_sources'.
4. Imported the old Assets v1x from the old backup that I exported in step 1 - 'exp\_assets' and 'exp\_assets\_entries' into the active database.
5. Changed the version number for Assets back to v1.1.5 in 'exp\_extentions', 'exp\_fieldtypes' and 'exp\_modules' within the active database. This triggers Assets to run the update process on the database tables and do all its work.
6. From the EE CP, go to 'Add-ons \> Modules' and click on the 'Assets' module - you should be presented with a warning about backing up the database prior to running the v2.x update. Make sure you update the database prior, then click on the 'Update' button. It will go and do its thing and you should be presented back to Assets with all the correct upload points presented in the left column.

Confirm the Upload Preference selection has been retained by checking an Assets custom field's settings, ie. it should be checked as it was previous to the update. Also double check the front end and be sure images are rendering, and finally edit an entry and just update it to make sure the Assets fields are sticking with the original images and not disappearing.

You can also now run your 'Update Index' inside Assets and there shouldn't be any references (or at least very little) that will appear that are suggested to be deleted (in this case I ran an update index on one and it was clean.
> 0 votes

---
Tags: add-on, assets, focus-lab-master-config
---


# Question
Title: Can a freemember login form be sent securely?
Say I force SSL on my public login page (with DM Force SSL), and I'm using a fairly standard freemember login form:

```
{exp:freemember:login return="PREVIOUS_URL" error_handling="inline" error_delimiters='<span class="error">|</span>'}

bla bla

{/exp:freemember:login}

```

When the login form is submitted, Safari will throw this in a dropdown sheet:

> This form will be sent in a way that is not secure. Are you sure you want to send it?

Is this because freemember lacks the ability to send the form securely? (Solspace's Freeform Pro, for instance, has a `secure_action="yes"` attribute for its tags. Is there some workaround?

# Answer
Aha.

> Secure Form (https) - Feature Request
>
> would be great if you could specify that the form action should be secure. i did this by adding the following to the \_build\_form method in mod.freemember.php:

```
if ($this->EE->TMPL->fetch_param('secure_action') == 'yes')
{
$data['action'] = str_replace('http:', 'https:', $data['action']);
}

```
> 1 votes

---
Tags: freemember, ssl
---


# Question
Title: Is there any way to strip inline styles added by the client?
My client has an incredibly bad habit of adding inline styles to tons of elements on the page. One of the many reasons I was hired to do this job is because of my focus on semantics, yet they still choose to do things like this.

Is there any way to strip style attributes from elements when they submit the entry? I'm currently using WYGWAM, if that helps.

# Answer
> 2 votes
If you jump into your WYGWAM configurations, there are a few settings you can add to aid this errant behavior.

Modules \> Wygwam \> Edit Configuration

* ForceAsPlainText
* EnterMode
* PasteFromWordRemoveStyles

And a few more dependent on your needs.

I also am in the habit of wrapping any wygwam content inside a `<div class="wygwam">` so I can target via CSS any stuff that makes it through.

# Answer
> 3 votes
I'm not sure how agressive you want to get with stripping inline styles or if there are certain instances where you'd need to allow them, but you could use some simple jQuery to strip them out.

Something like has worked for me in the past:

```
$('.wygwam p').removeAttr('style');

```

You could obviously modify this depending on the element(s) your client typically adds the styles to.

You can read more about the method here: http://api.jquery.com/removeAttr/

---
Tags: wygwam, editor
---


# Question
Title: {exp:number_format} not working on some pages
I have a snippet

```
{exp:number_format number="{price}" decimals="2"  dec_point="." thousands_sep=","}
I use this snippet in two pages.

```

The weird thing about this is that in one page, it outputs correctly while in the other one does not.

For example, I passed 19000.00 in both of them.

In one page, I get 19000.00 but in the other one I got 0.00

UPDATE:

Ok I noticed that in the problem page, I am using Switchee while in the working page, I don't.

I tried changing the problem page to not use Switchee and it worked.

Does this mean that this is somewhat a parse order problem?

UPDATE 2:

Here is the sample code

```
{exp:switchee variable="{segment_2}" parse="inward"}
        {case value="#some regex expressions here#"}
            {exp:low_search:results
            limit="10"
            channel="foo"
            paginate="bottom"
            status="open"
            parse="inward"}
        {/case}
        {case default="Yes"}
            {exp:low_search:results
            query="{segment_2}"
            limit="10"
            channel="foo"
            paginate="bottom"
            status="open"
            parse="inward"}
        {/case}
    {/exp:switchee}
        ........
        <h2>{snippet.that.contains.the.number.format.code}</h2>
        ........
{/exp:low_search:results}

```

Here is the snippet code

```
${exp:number_format number="{price}" decimals="2"  dec_point="." thousands_sep=","}

```

UPDATE 3:

I tried changing

```
 ${exp:number_format number="{price}" decimals="2"  dec_point="." thousands_sep=","}

```

to

```
${exp:number_format decimals="2"  dec_point="." thousands_sep="," parse="inward"}{price}{/exp:number_format}

```

in hopes of solving the problem. Unfortunately, it didn't work.

P.S.

For all intents and purposes, {exp:low\_search:results} is functionally the same as {exp:channel:entries}

# Answer
> 1 votes
This is more of a guide then a solution, experimentation is your friend.

```
{exp:stash:set parse_tags="yes"}
    {exp:switchee variable="{segment_2}" parse="inward"}
        {case value="my case value"}
            {stash:query}all{/stash:query}
        {/case}
        {case default="Yes"}
            {stash:query}{segment_2}{/stash:query}
        {/case}
    {/exp:switchee}
{/exp:stash:set}

```

Further down the template, ese the stash'ed variable holding the variable defined above as the query.

```
 {exp:low_search:results
    query="{exp:stash:query}" // Whack the stash Var in here
    limit="10"
    channel="foo"
    paginate="bottom"
    status="open"
    parse="inward"}

      <h2>{snippet.that.contains.the.number.format.code}</h2>

  {/exp:low_search:results}

```

PS. You will need to install Stash obviously :)

# Answer
> 0 votes
I really believe your issue is with have the closing tag outside of the switchee cases. You can completely remove Switchee and use a simple conditional to show/hide the `query` parameter since it only seems to be on a unique case.

```
{exp:low_search:results
  {if segment_2 != "something"}query="{segment_2}"{/if}
  limit="10"
  channel="foo"
  paginate="bottom"
  status="open"
  parse="inward"
}

```

### Update

What if you nested Switchee in between the `{exp:low_search:results}`:

```
{exp:low_search:results
    {exp:switchee variable="{segment_2}" parse="inward"}
        {case value="#some regex expressions here#"}
            limit="10"
            channel="foo"
            paginate="bottom"
            status="open"
        {/case}
        {case default="Yes"}
            query="{segment_2}"
            limit="10"
            channel="foo"
            paginate="bottom"
            status="open"
        {/case}
    {/exp:switchee}
}

```

---
Tags: number-format
---


# Question
Title: How can I show all available UPS Shipping methods at once?
I am trying to add UPS to a store and have it show all the UPS choices in the US and all the International choices automatically for the user. Is there a simple way to add all the UPS choices to the Checkout page?

From what I see it looks I would need to create 10 different UPS plugins each with UPS credentials and then use jQuery to manually switch based off which country the user uses?

Please tell me I am dense and missed something obvious. Thanks...

# Answer
You aren't missing anything obvious. It's a design flaw of our shipping plugin system that each installed instance of a shipping plugin can only return a single rate (hence the only way around this currently if you are offering both domestic and international shipping is to create multiple shipping methods using the same plugin).

We're well aware of this issue, and it will be addressed in our next major release. It will require breaking backwards compatibility with some existing checkout templates so not something we can just slip into a point release unfortunately.
> 1 votes

---
Tags: expresso-store
---


title: Benefit of Saving Templates as Files

text:
# Question
Title: Benefit of Saving Templates as Files
Aside from being able to edit files without the Template Manager – is there any advantage to saving templates as files in ExpressionEngine?

Does it improve performance, security, etc.?

Would be grateful for a reply from a knowledgeable person.

# Answer
> 10 votes
To rewrap your question in a "pros/cons" list:

**Pros**

* Editing through your favorite editor -\> faster
* Enables you to version your files with a VCS
* You can DIFF files
* Easier to maintain code markup/layout

**Cons**

* Slightly slower because EE needs to check the files for a new version (i guess it only uses the file versions in the latest EE releases).
* Could be a lot slower on a provider with a slow file system.
* Synchronization hassle

For sites who need max performance I tend to work with files on my local development environment and disable "save as file" on the live site (sync templates first!).

---
Tags: templates
---


# Question
Title: Expresso Store - Go straight to checkout when adding item to cart
Is it possible to go straight to the checkout page when the user adds an item to the cart?

# Answer
You would achieve that using the return="" parameter on the product tag.

```
{exp:store:product return="checkout"}
    <!-- add to cart form -->
{/exp:store:product}

```

See also the example templates which are installed with Store (in your `store_example` template group, or in the `third_party/store/templates` directory).
> 3 votes

---
Tags: expresso-store
---


title: Removing an add-on/extension?

text:
# Question
Title: Removing an add-on/extension?
I had Two-Mile redirect add-on/extension installed.

I have since removed it.

Now when Im trying to register a member, upon clicking the activation link, it stats

> Unable to load the following extension file:
>
> ext.twomile\_login\_redirect.php

Any idea on how I can remove it fully?

**UPDATE**

Can I simply (or safely) remove these two rows from the database?

# Answer
> 4 votes
Yes, that table is the only place extensions are registered (as long as the extension doesn't also include a "Module").

You can safely delete those rows. You could also just set `enabled` to `n` which will disable the extension.

---
Tags: add-on, delete
---


# Question
Title: Is there a way to change the parse order of snippets or plugins?
Is there a way to force snippets or plugins to be parsed late or at least after advanced conditionals are parsed?

# Answer
There are plenty of plugins to mess with the parse order, but I usually try to avoid installing plugins if I can help it.

The simplest solution, which works in 99% of cases, is to just use an embed. Embeds are parsed after everything else, so whenever you have an early parsing issue, just throw the problem code into an embed.

It's true that embeds have slightly worse performance, but most people worry about this way too soon. Don't optimize for performance until performance is a problem. YAGNI.

Before:

```
{exp:channel:entries}
    {exp:annoying_plugin parameter="{entry_id}"}
{/exp:channel:entries}

```

After:

```
{exp:channel:entries}
    {embed="partials/.my_embed" entry_id="{entry_id}"}
{/exp:channel:entries}

```

Inside `partials/.my_embed`:

```
{exp:annoying_plugin entry_id="{embed:entry_id}"}

```
> 4 votes

# Answer
You can use Stash to delay the parsing of an arbitrary group of tags until after template parsing has completed:

```
{exp:stash:parse process="end"}
   {exp:channel:entries}
       ...
   {/exp:channel:entries}
{/exp:stash:parse}

```

However, parse order issues generally arise when you need to pass values generated by one tag to another tag or position somewhere else in your template. Adopting the template partials pattern can help you avoid these parse order problems in the first place.
> 1 votes

---
Tags: snippets
---