# Question
Title: Expresso Store: AJAX shipping cost update
I'm kind of stuck on getting AJAX shipping cost update for Expresso Store.

Shipping part in the checkout page looks like:

```
        <tr>
            <td>Shipping</td>
            <td colspan="2">
                {field:shipping_method}
                {if error:shipping_method}<p class="help-block">{error:shipping_method}</p>{/if}
            </td>
            <td style="text-align:right"><div id="order_shipping">{embed="cart/shipping"}</div></td>
        </tr>

```

then "cart/shipping" include looks like:

```
{exp:store:checkout}
{order_shipping}
{/exp:store:checkout}

```

All works fine when I use "Update Total", but my goal is to update shipping cost on shipping method select using AJAX below

```
<script type="text/javascript">
$(document).ready(function() {
    $("#shipping_method").change(function() {

        var url = $(this.form).attr('action');
        var data = $("#shipping_method").val();

        $.post(url, data, function() {
            $("#order_shipping").load("/cart/shipping");
        });
        return false;

    });
});
</script>

```

In that case I'm not able to retrieve updated shipping cost.

Any clue where I have made an error?

**UPDATE**

"cart/shipping" updated to:

```
{exp:store:checkout}
<div id="oso">{order_shipping}</div>
{/exp:store:checkout}

```

And AJAX part looks now like:

```
$(document).ready(function() {
    $("#shipping_method").change(function() {

        var url = $(this.form).attr('action');
        var data = $(this.form).serialize();

        $.post(url, data, function() {
            $("#order_shipping").load("/cart/shipping #oso);
        });
        return false;

    });
});

```

It can retrieve shipping cost, but initial cost for the shipping, when checkout process is started, it becomes selected first from the shipping method list but with real value of 0. I have try to `.prepend` empty option field, but no matter what is selecting first shipping method for new carts (I'm using UPS shipping module). Default shipping method for new carts from the Store settings is not working either.

# Answer
> 4 votes
After some guidance from Ahmad Saad below (thanks Ahmad!) I was able to get shipping (and total) calculated after shipping method change.

First it will require to change template where shipping form field is located. That part is required due to default shipping value is not loaded when new cart created (in my case). My looks like:

```
<tr>
<td>Shipping</td>
<td colspan="2">
<select id="shipping_method" name="shipping_method">
<option>Choose Shipping Method</option>
{shipping_method_options}
</select>
{if error:shipping_method}<p class="help-block">{error:shipping_method}</p>{/if}
</td>
<td style="text-align:right"><div id="order_shipping">{embed="cart/shipping"}</div></td>
</tr>

```

and AJAX part handling JSON response:

```
$(document).ready(function() {
    $("#shipping_method").change(function() {

        var url = $(this.form).attr('action');
        var p_data = $(this.form).serialize();

        $.ajax({
            url: url,
            type: "POST",
            data: p_data,
            context: this,
            error: function () {},
            dataType: 'json',
            success : function (response) {
                 $("#order_shipping").html(response.order_shipping_total);
                 $("#order_total").html(response.order_total);
            }
        });

        return false;

    });
});

```

No clue why guys from Expresso Store didn't included that in their code by default :\

Hope it will help other Expresso Store users.

# Answer
> 1 votes
as answer for your last update change your code to :

```
$(document).ready(function() {
    $("#shipping_method").change(function() {

        var url = $(this.form).attr('action');
        var p_data = $(this.form).serialize();

        $.post(url, p_data , function(data) {
            var new_shipping = $('<div />').append(data).find('#oso').html();
            $("#order_shipping").html(new_shipping);
        });
        return false;

    });
});

```

try it and let me know.

Regard's.

---
Tags: expresso-store, ajax, shipping
---


title: Random template embedding?

text:
# Question
Title: Random template embedding?
I know you can easily load a random entry from a channel, but I wanted to know if the functionality exists in EE to randomly embed and load a template from a group?

Thanks in advance for any guidance on this.

# Answer
a quick thought come to my mind is to create templates with the same name and change the prefix number for e.g: test\_1,test\_2,test\_3......,test\_100

then use this plugin to generate the random number:

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

```
{embed='test_{exp:ga_randombetween start="0" stop="100"}'}

```

Regard's.
> 1 votes

---
Tags: ee2, templates, embeds, random
---


# Question
Title: Store Locator with Google Maps for ExpressionEngine
first use of the Google Maps add-on for EE here so pardon any ignorance on my part.

I'm trying to set up a pretty standard store locator. I'm using this Sample Store Locator Code and tweaking with my field names (see below).

{address\_geocoded} is the field set to store the return from Google.

I'm getting errors along the lines of:

> ‘address\_geocoded’ is not valid post variable.

Firefox and Safari generate the error right away on template load. Chrome loads the form then errors after I enter my current location and submit.

Any idears?

```
<div>
    {exp:gmap:search
        channel="retailers"
        latitude_field="address_lat"
        longitude_field="address_long"
        geocode_field="address_geocoded"
        distance_field="distance_max"
        cache_post="false"
        return="/locations/test2#demo"}

        <ul>
            <!-- <li>
                <label for="title">Title</label>
                <input type="text" name="title_like" id="title" value="" />
            </li> -->
            <li>
                <label for="location">Location</label>
                <input name="location" id="location" value="{if post:location}{post:location}{/if}" type="text">
                {if error:location}<p class="error">{error:location}</p>{/if}
            </li>
            <li>
                <label for="location">Distance</label>
                <select name="distance_max">
                    <option value="" {if="" !distance_max="" ||="" distance_max="=" ""}selected="selected" {="" if}="">Any</option>
                    <option value="5" {if="" distance_max="=" 5}selected="selected" {="" if}="">5</option>
                    <option value="10" {if="" distance_max="=" 10}selected="selected" {="" if}="">10</option>
                    <option value="20" {if="" distance_max="=" 20}selected="selected" {="" if}="">20</option>
                    <option value="50" {if="" distance_max="=" 50}selected="selected" {="" if}="">50</option>
                    <option value="100" {if="" distance_max="=" 100}selected="selected" {="" if}="">100</option>
                </select>
            </li>

            <li>
                <button type="submit">Search</button>
            </li>
        </ul>

    {/exp:gmap:search}
</div>

<div>

    {exp:gmap:init id="map" class="gmap" style="width:100%;height:200px"}

    {exp:gmap:results order_by="distance" sort="asc" parse="inward"}

        {if has_searched}
            <ul>
            {results}
                <li>{title} - {distance}</li>
            {/results}
            </ul>

            {results}
                {exp:gmap:marker id="map" latitude="{address_lat}" longitude="{address_long}"}
            {/results}

        {if:else}
            {exp:channel:entries channel="retailers" dynamic="no" disable="member_data|categories|category_fields|pagination" parse="inward"}

                {location_gmap id="map"}

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

        {if absolute_count == 1}
        <p><em>Hint: Try searching for 'Hoosier National Forest' at a distance of 20 miles.</em></p>
        {/if}

        {if no_results}

            <p>No results found</p>

            {exp:channel:entries channel="retailers" dynamic="no" disable="member_data|categories|category_fields|pagination" parse="inward"}

                {location_gmap id="map"}

            {/exp:channel:entries}

        {/if}

    {/exp:gmap:results}

</div>

```

# Answer
> 1 votes
as I think you must you must use `geocode_field` param value as a name for your HTML input.

so in your code you change the `geocode_field` from location to address\_geocoded but you keep the HTML field name as it "location".

so the code try to find $\_post\['address\_geocoded'\] and it not find it.

this is a guess , because I don't work on Google Maps add-on for EE before, but I almost sure if you change the HTML input name to address\_geocoded this will solve the problem.

**Update:**

the address field is required but you can use more fields that will create an address string that will be geocoded as mention here :

https://www.objectivehtml.com/google-maps/documentation/tag/search#geocode\_field

so if you want to use another field like "address\_geocoded" you must change your code to:

```
    {exp:gmap:search
    channel="retailers"
    latitude_field="address_lat"
    longitude_field="address_long"
    geocode_field="address|address_geocoded"
    distance_field="distance_max"
    cache_post="false"
    return="/locations/test2#demo"}

```

notice **geocode\_field="address|address\_geocoded"** and you must add a new HTML field with address\_geocoded name.

I hope this will do the trick

Regard's.

# Answer
> 0 votes
I think my issue was mainly the browser caching the post variables, so when I would make a code change and reload the page the same error would generate. I got past the post variable related errors with this code:

```
 <div>
    {exp:gmap:search
        channel="retailers"
        latitude_field="address_lat"
        longitude_field="address_long"
        geocode_field="address_map|address_geocoded"
        distance_field="distance_max"
        cache_post="false"
        return="/locations/test2#demo"}

        <ul>
            <li>
                <label for="address_geocoded">Location</label>
                <input name="address_geocoded" id="address_geocoded" value="{if post:address_geocoded}{post:address_geocoded}{/if}" type="text">
                {if error:address_geocoded}<p class="error">{error:address_geocoded}</p>{/if}
            </li>
            <li>
                <label for="distance_max">Distance</label>
                <select name="distance_max">
                    <option value="" {if="" !distance_max="" ||="" distance_max="=" ""}selected="selected" {="" if}="">Any</option>
                    <option value="5" {if="" distance_max="=" 5}selected="selected" {="" if}="">5</option>
                    <option value="10" {if="" distance_max="=" 10}selected="selected" {="" if}="">10</option>
                    <option value="20" {if="" distance_max="=" 20}selected="selected" {="" if}="">20</option>
                    <option value="50" {if="" distance_max="=" 50}selected="selected" {="" if}="">50</option>
                    <option value="100" {if="" distance_max="=" 100}selected="selected" {="" if}="">100</option>
                </select>
            </li>

            <li>
                <button type="submit">Search</button>
            </li>
        </ul>

    {/exp:gmap:search}
</div>

<div>

    {exp:gmap:init id="map" class="gmap" style="width:100%;height:200px"}

    {exp:gmap:results order_by="distance" sort="asc" parse="inward"}

        {if has_searched}
            <ul>
            {results}
                <li>{title} - {distance}</li>
            {/results}
            </ul>

            {results}
                {exp:gmap:marker id="map" latitude="{address_lat}" longitude="{address_long}"}
            {/results}

        {if:else}
            {exp:channel:entries channel="retailers" dynamic="no" disable="member_data|categories|category_fields|pagination" parse="inward"}

                {address_map id="map"}

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

        {if absolute_count == 1}
        <p><em>Hint: Try searching for 'Hoosier National Forest' at a distance of 20 miles.</em></p>
        {/if}

        {if no_results}

            <p>No results found</p>

            {exp:channel:entries channel="retailers" dynamic="no" disable="member_data|categories|category_fields|pagination" parse="inward"}

                {address_map id="map"}

            {/exp:channel:entries}

        {/if}

    {/exp:gmap:results}

</div>

```

Now onto other issues - like the search not returning results...;)

---
Tags: google-maps-for-ee
---


# Question
Title: General backup security question when using Amazon S3
I have a general security/privacy question about addons that use Amazon S3 for backup / file storage.

Here's my scenario: I host most of my client sites myself and use my own Amazon S3 account to backup various databases and files. However, when using a number of popular addons, at the S3 configuration stage of the setup you enter the authentication details and are then able to see all the buckets in that account.

This of course means that any Super Admin of any one of these sites potentially has access to buckets belonging to other clients. See the security/privacy issue?

Does anyone know a workaround for this, other than each client having their own S3 account?

Cheers

Jim

# Answer
> 2 votes
I believe what you're looking for is different access permissions for the same bucket. If that's correct, you might want to take a look at the AWS Identity and Access Management (IAM). I've never used it but it does appear to offer what you're after.

That said, with Backup Pro, you can't actually see anything on S3 from within the module so there's no security issue there. The only files that get displayed are those that are mirrored locally on the server. \</shameless\>

# Answer
> 0 votes
Here's the full info to help.

1. Set up a new bucket for the client
2. Set up a new user in IAM with a set of access keys but no password, thus can't login to AWS control panel.
3. Under the Permissions tab for this new user attach a user policy as below. Be sure to enter bucket name.

> ```
> {
>   "Version": "2012-10-17",
>   "Statement": [
>     {
>         "Effect": "Allow",
>         "Action": "s3:ListAllMyBuckets",
>         "Resource": "arn:aws:s3:::*"
>     },
>     {
>       "Sid": "Stmt1395087711000",
>       "Effect": "Allow",
>       "Action": [
>         "s3:*"
>       ],
>       "Resource": [
>         "arn:aws:s3:::<bucket-name>",
>         "arn:aws:s3:::<bucket-name>/*"
>       ]
>     }
>   ]
> }
>
> ```

Now you can use the key and private key to access the bucket in addons or via S3 tools. You can also adjust permissions to allow only PUTting of files and no viewing/deletion, etc.

---
Tags: security, s3, backup
---


# Question
Title: 404 ErrorDocument returns home page incorrectly
We have created http://www.macobserver.com/tmo/404\_not\_found — That page works.

I then added

```
ErrorDocument 404 /tmo/404_not_found

```

to our apache config. Without that line in there Apache delivers its default 404, so I know that logic works. With that line in there, though, I get our home page, NOT the 404 template. It comes in with a 404 header properly, but it doesn't display the right template.

Any ideas why? I've been beating my head on this one before posting here (as we all do, I'm sure :)

(and yes, we renamed our index.php to tmo years ago with EE 1.x)

# Answer
First, make sure you have enabled "Strict URLs" and chosen you 404 template in in the control panel.

> **Control Panel Location:** Design \> Templates \> Template Preferences

Take a look at Global Template Preferences in the ExpressionEngine User Guide for more information.
> 1 votes

# Answer
you just need to add index.php

```
try:

ErrorDocument 404 /index.php/tmo/404_not_found

OR:

ErrorDocument 404 /index.php?/tmo/404_not_found

```

Regard's.
> 0 votes

---
Tags: 404
---


# Question
Title: 2.7 Developer Log Error submit_entry() to shannel_form_submit_entry_end
Getting a Developer log error when I edit an entry using the channel:form.

Deprecated function submit\_entry() called in system/expressionengine/modules/channel/mod.channel.php on line 5291. Deprecated since 2.7. Use Renamed to: channel\_form\_submit\_entry\_end instead.

When I create an entry - all is fine, it is only editing that I'm getting a call to a developer log error.

Any ideas? I've checked to see the modules using submit\_entry and after searching, nothing is showing.

# Answer
> 1 votes
first thing check that all your addons is updated to last version.

go to your database table Tools \> Data \> Sql manger \> mange database tables and check exp\_extensions table to see if any extension used safecracker\_submit\_entry\_XX hooks , if there any check their names and update them to last version.

check it and let me know.

Regard's.

---
Tags: 2.7.0
---


title: expression engine upload file types

text:
# Question
Title: expression engine upload file types
At the moment I can only set this to 'all file types' or 'images only' but would like to specify a small list (.doc, .docx, .pdf) for some documents, is this possible?

# Answer
There is no native way to do what you want. It's either "images" or "all".

If one does not already exist then creating a custom fieldtype that would only permit uploads of a particular type should be possible. Start with the existing file fieldtype and see if you can modify it to do what you need.
> 1 votes

# Answer
you can determinate the allowed file type in EE from this file ./system/expressionengine/config/mimes.php

and be sure that Admin -\> Security and Session Preferences, "Apply XSS Filtering to uploaded files?" set to "yes".

and this will apply to all member groups except Superadmin, superadmin members always can upload all files type.
> 0 votes

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


# Question
Title: How to count member's entries, limited by channel?
I'm trying to find a way to show a simple entry count for the logged in member, which is limited by channel. I would be using this in a conditional to change the action of a link depending on how many entries they've posted to that channel. Something like this:

```
{if member_group == '8' && {MY_ENTRY_COUNT channel="directory"} > 1}{/if}

```

The only plugin I can find is this one: https://github.com/websecret/number\_member\_entries

But it doesn't work right to limit by channel - looks like its channels parameter is setup to list channel ID's instead of short names, but I don't think channels even have IDs.

If it makes any difference I'm using Solspace User, but that only appears to have a simple entry\_count variable that can't be limited by channel.

Anyone know how else to get a count like this that could be used in an advanced conditional?

# Answer
The Number member entries plugin looks like it should do the trick.

Channels do have a channel\_id, but I can't find it in the EE control panel easily. You could count the number of channels down from the top of your Channels list (under Admin \> Channel Administration \> Channels). You could also use the Developer Info add-on to find the channel\_id.

```
{if member_group == '8'}
  {if {exp:number_member_entries:count channels='1'} > 0}
    Yep, there are entries!
  {if:else}
    No entries here.
  {/if}
{/if}

```
> 1 votes

# Answer
I check this plugin it's very useful for me , so I edit it to accept channel short name in channels param.

you can download the new version here:

https://github.com/ahmad-saad/number\_member\_entries

Regard's.
> 0 votes

---
Tags: members, entries, solspace-user, count
---


title: 404 returning to site index

text:
# Question
Title: 404 returning to site index
I just realized that when I go to website.com/faljalsdfkj, it should cause a 404 and take me to the 404 page. I have this same setup on ann older site and it seems to be working correctly, but Can't figure out what's different. I don't have strict urls turned on because I need this setting for a feature.

After viewing this thread:

404 ErrorDocument returns home page incorrectly

it seems that perhaps its my apache configuration? Or is there another setting im missing?

Any ideas would be huge. Thanks!

# Answer
Loading the home page in 404 mode is EE's default functionality. Unless you configure/code otherwise this is just what happens.

Can't you add this to your home page template?

```
{if segment_1 !=""}
  {redirect="404"}
{/if}

```

This assumes you have a template specified as your 404 template in the area of the CP that Alex provided a screenshot of.
> 2 votes

# Answer
First, make sure you have enabled "Strict URLs" and chosen you 404 template in in the control panel.

> **Control Panel Location:** Design \> Templates \> Template Preferences

Take a look at Global Template Preferences in the ExpressionEngine User Guide for more information.
> 2 votes

---
Tags: 404
---


# Question
Title: SuperSearch Results for Entries using Playa displaying Entry ID
When I search through SuperSearch and get a result that uses the Playa field the Entry ID ## of the associated field is incorporated. For instance, I'm searching projects which are associated with a given staff member via Playa. My result comes back "Project Title, \[entry\_id##\] Staff Member" where the entry\_id## is replaced with the actual entry\_id.

Any thoughts? Playa 4.4.5 SuperSearch 2.1.3 EE 2.6.1

Thanks, Drew

# Answer
I don't know if I understand your problem but check this URL and see if it will help you:

http://www.solspace.com/docs/super\_search/third\_party\_support/#pt\_playa

Regard's.
> 0 votes

---
Tags: playa, supersearch
---


# Question
Title: Links created with Structure tags point to wrong environment after DB import from another environment
When I export my DB from one environment to another, all links created with `{structure:page_url_for:{entry_id}}` format try to load the environment URL path from the database I imported from another environment.

If I to go to Admin -\> General Configuration, the URLs and Paths look right (assuming from Focus Lab config setup) and if I just re-save that page, structure links start working again.

# Answer
It appears there is a bug report for this on expressionengine.com. The team is aware of it.

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

Additionally, the support team for Structure has provided me with some beta code to test a way to get around this and it worked. The next version of Structure should be out soon and does not use incorrect environment urls, regardless of the EE bug I linked to.
> 0 votes

# Answer
I've actually run into this issue on a couple of MSM sites in the last couple of weeks.

From what I can gather, at some point the root URL is stored in the 'site\_pages' column in the 'exp\_sites' table, for each site.

I have a PHP script that decodes/encodes and unserialzies/serializes the data, and tells you what to change. Ping me at @degerstrom or pal@felt.no if you need more details.
> 2 votes

# Answer
The issue will be done to the config.php file or the database. The config file will always overwrite the database, so irrelevant of the General Configuration settings within the Control Panel. Also I expect the path in question is set within the template settings, not general config.

Because you're using Master Config chances are you've not set the correct environment variable or path, so it's incorrectly identifying the pathing based on the server - or the staging server hasn't been set up correctly.

Highly recommend using the Deeploy Helper add-on, which will identify any stray paths anywhere in your build - be it config file or database.
> 0 votes

# Answer
The links in Structure will actually not be affected by any configuration settings. I don't think this is specific to Structure, but I might be wrong.

In any case, give this a try: https://gist.github.com/degerstrom/9591099
> 0 votes

---
Tags: structure, focus-lab-master-config
---


title: NSM htaccess generator error EE2.8.1

text:
# Question
Title: NSM htaccess generator error EE2.8.1
I'm running into what looks like an incompatibility for NSM htaccess generator with ee2.8.1

Trying to save entries will result in the following error:

\*Fatal error: Call to undefined function do\_hash() in /home/dev/system/expressionengine/third\_party/nsm\_htaccess\_generator/ext.nsm\_htaccess\_generator.php on line 224\*

While trying to go into the settings returns the following error:

\*Fatal error: Call to undefined method EE\_Javascript::generate\_json() in /home/dev/system/expressionengine/third\_party/nsm\_htaccess\_generator/ext.nsm\_htaccess\_generator.php on line 421\*

Does anyone know of a fix?

# Answer
> 6 votes
actually I don't use NSM htaccess generator , but I can help you with this problem.

first thing update to the last version , if you have the last version and still have this problem you can solve it as following:

about the first one:do\_hash() problem.

replace `do_hash()` function with PHP’s hashing functions like `sh1`

about the second one `generate_json()` :

replace `$this->EE->javascript->generate_json` with `json_encode`

check it and let me know.

Regard's.

---
Tags: htaccess
---


title: Channel Entries rows -wrapping

text:
# Question
Title: Channel Entries rows -wrapping
I am trying to wrap a div () around my channel entries output every 3rd item. So

entry1 entry2 entry3 entry4 entry5 entry5

# Answer
> 2 votes
you can use {switch} or {if} condition with % Operator "Remainder of one number divided by another" like this:

1- `{switch}` variable :

```
{switch="<div>||"}
....Your code....

{switch="||</div>"}

```

2- `{if}` with `%` :

```
{if count=="1" || count%4==0}<div>{/if}
....Your code....
{if count%3==0}</div>{/if}

```

# Answer
> 0 votes
Be aware that the operator functionality was added as of EE v2.7.1. If you choose to use the switch method mentioned here, you actually need to handle it a bit differently to protect your loop from instances in which the number of entries you are loading does not divide evenly by the number of columns you are loading. The most effective way to do with is to add additional switch logic to close the row. You can see this in detail in another EESE post with my answer here:

Adding wrapper markup at intervals within loops (entries, matrix, playa, etc)

---
Tags: channel-entries, css, html
---


# Question
Title: Low Search Form + CE Cache's Static Driver; What's Needed to Make it Work?
I'm using CE Cache's Static driver, which essentially uses EE to generate the first view of a page, and then saves the output to a text file, which is served on subsequent page views; pretty easy to setup, and, super fast.

We have a simple, keywords only, Low Search form in the header of every page on our site. It looks like it includes a couple of fields that might be unique to the user/session/cookie, `XID`, and, possibly, `param`?

When another user comes in and performs a search on a cached page, they're getting an error - "you are not authorized to perform this action."

Is there anything I can do to get the Low Search form working? Any potential "gotchas" to just building a form that will GET to generate the correct URL, e.g. example.com/search/?keywords=widget ?

Currently using EE 2.7.2, Low Search 3.0.3 (I just saw that that's out of date now), and CE Cache 1.10.1.

# Answer
> 0 votes
There are (were) two issues at play here:

**Bug with Relying on XID Would Break Search Form for Users who Didn't Generate Cached Version of Page**

The search form's `XID` getting cached on non-results pages *was* causing trouble, but appears to be resolved upgrading from Low Search 3.0.3 to 3.1.2. I'll attempt to check back in and confirm this, but early testing looks promising.

**Low Search Results with CE Cache Static Driver**

When search results pages are built with a query string (`example.com/search/?keywords=foo`, CE Cache's static driver ignores (rightfully so) query strings.

This can be worked around by using encoded queries which replace the human readable query string `/?keywords=foo` with hashed segment `eyJrZXl3b3JkcyI6ImhlbGxvIHdvcmxkIn0`, which should play nicely with CE Cache's static driver.

In the event that encoded queries are unacceptable, any of CE Cache's non-static methods should work just fine.

---
Tags: low-search, ce-cache
---


# Question
Title: How do you Suppress Core File Modification Notices?
Is it possible to disable the core file modification modification notices/alerts in the control panel?

When we commit updates into version control, the next page load in the CP on our staging server will get the "One or more core files have been altered," and whatever action a user was doing in the control panel (writing an entry, editing a setting, etc.) will be lost.

# Answer
> 0 votes
The underlying issue here was caused by an ExpressionEngine bug that was corrected in version 2.8.0.

---
Tags: notification
---


# Question
Title: Break CE Cache for a Search Results Template when Any Entry Updated?
We're caching search results pages with CE Cache. I'm wondering if there's a way to bust the cache on these pages whenever any entry is updated? We have dozens of channels; I'd rather not specify all of the relevant tags in the control panel and/or template to use the normal cache busting process (e.g. add "search" as a tag to all of the channels when configuring them, or adding all of the different tags to the search results template).

Is there a way to quickly grab the date of the most recently updated entry and use that as part of the `id` parameter in the opening `exp:ce_cache:it` tag, or something? Perhaps some other trick I'm not thinking of?

**Edit** Perhaps the ability to specify `*` as a value for the `tags` parameter would be a cool feature request?

# Answer
> 1 votes
You should be able to simply tag the Cache It tag in your search section with `search`, and then break on the `search` tag in the cache breaking settings for "Any Channel". That way, any time an entry changes (from any channel), your search results will be cleared.

---
Tags: ce-cache
---


# Question
Title: Delete EE's Member Profile Templates to Prevent SPAM, what do you think?
If all my membership functionality is handled on the front end via an addon like User or Freemember, can I just delete EE's built in member profile templates?

What do you think? Would that help prevent spam accounts?

# Answer
The best way I've found to eliminate bot attacks is with the Snaptcha add-on. It's very unobtrusive and supports just about every other third-party user and comment add-on, like Solspace User and Freemember.

If you aren't using EE's Member Profile Templates, it's probably a good idea to hide them. You can't "delete" Member Profile Templates per say, but you can randomize the 'Profile Triggering Word' with a config variable making it impossible to guess. This would prevent spam bots that are trying to exploit the built-in member registration form (index.php/member/register).

Here's an example of this Focus Lab's EE Master Config:

```
/**
 * Member-based settings
 */
$env_config['profile_trigger']          = rand(0,time()); // randomize the member profile trigger word because we'll never need it

```

Here's an example from the NSM Config Boostrap:

```
// Create a random string for the member profile trigger
        'profile_trigger' => '--sdjhkj2lffgrerfvmdkndkfisolmfmsd' . time(),

```

If you wanted to add this directly into your `config.php` file, you could use this:

```
$config['profile_trigger'] = rand(0,time());

```
> 3 votes

# Answer
No, even if you do delete them. People will custom target to whatever signup method you dream of.

Your anti-spam thoughts should be focused more along the lines of: "What can a freshly registered user do that can be considered spam and how can I change that to at least be harder to do in 5 seconds?"
> 1 votes

# Answer
Spambots are definitely targeting the default member/register path for EE. I have a client's site that uses third party member registration add-on for EE, but despite hardening that, we were still seeing lots of spambots signing up on the site.

It turns out they were going right to the default member/register path and registering that way. You can either change the location as above, or do what I did, which is just set up an Apache redirect that goes from member/register to the actual registration form/page.
> 1 votes

---
Tags: members, spam
---


# Question
Title: Are there any ongoing costs for cartthrob & what upgrades do you get?
This is more of a sales question about CartThrob, but as we're unable to get through to their offices at the moment I thought I'd ask here.

Basically we want to know if after a year or so we'll get some sort of un-expected renewal request from mightybigrobot. I think the answer is almost certainly no but need to double check.

Secondly, does anyone know what sort of patching, updates, new versions we're to expect with cartthrob?

# Answer
The fact that you're unable to get through to their company for a sales question should be a red flag, imo.

However, as far as I know, there are no renewal costs involved with CartThrob.
> 2 votes

# Answer
No, there are no ongoing licensing costs for CartThrob. It's a one off purchase for the software.

I think they also offer telephone support packages now which I would imagine would be an annual cost.
> 1 votes

# Answer
They offer paid phone support at $120/hr: http://paidsupport.mightybigrobot.com

For updates, see http://cartthrob.com/docs/pages/change\_log/index.html
> 0 votes

---
Tags: cartthrob, upgrade, bug
---


title: Generate Coupon Codes in CartThrob

text:
# Question
Title: Generate Coupon Codes in CartThrob
I would like to generate a number of single use coupon codes - and judging by the wording at http://cartthrob.com/tour (next to Promotions heading) I can "generate coupon/voucher codes" but I can't see anywhere in the CP to do this.

Is it possible or do I have to manually add each coupon to the channel?

Thanks in advance

# Answer
> 0 votes
I have myself never used it, but could this addon be of some kind of help?

http://devot-ee.com/add-ons/cartthrob-offers

# Answer
> 0 votes
You must first define which channel(s) should be used for your coupons or discounts and set them up with the appropriate field types. Do this in the CartThrob settings menu of your CP.

You can then create the coupons or vouchers as entries in whichever channel you have set to be your discount or coupon channel.

# Answer
> 0 votes
You'll need to create the coupons yourself.

You could also make a single coupon that can be used only 50 times, if that's a viable option.

---
Tags: cartthrob
---


# Question
Title: Cartthrob: Add discount amount to purchased items
I need to add a discount amount to each purchased item entry. I had a conversation on Twitter that indicates that this is existing in CT already but is halfway there. Has anyone accomplished this already?

Here is the twitter conversation I am referring to: https://twitter.com/cartthrob/status/388310009643159554

# Answer
There are two ways you can do it:

1) Create a Discounts channel, and assign it in CartThrob

2) Create a Coupon Codes channel, and assign it in CartThrob

If you do the former, the discounts are automatically applied to each order.

If you do the latter, the user will have to enter a coupon code on the checkout form in order for the discount to happen.

You'll also need to put the HTML in place for the Coupon code to appear on the checkout form something like this:

```
                                <fieldset name="Coupon Code" class="control-group">
                                <div class="field-labels">
                                    <label for="coupon_code" class="clp">Coupon Code</label>
                                </div>
                                <div class="controls">
                                    <input id="coupon_code" class="field-bg clp" type="text" name="coupon_code" maxlength="31" />
                                </div>
                            </fieldset>

```
> 1 votes

---
Tags: cartthrob
---


# Question
Title: CartThrob Customer Subscription Date Changes
CartThrob's site demos and screenshots, unfortunately, don't go into much detail, so I'm turning to this for some answers.

Is it possible in CT to update the subscription renewal date on a customer's order after the fact?

# Answer
The renewal date is determined based on the Last Bill Date, the Interval Units, and Interval Length. All of those variables are editable after a subscription has been created. So while you can't specifically set an exact renewal date, you can modify those fields to get the renewal date you want.

There is also an End date field you can set to terminate all rebilling.

Here's a screenshot that shows all of the editable fields available when you edit a subscription.
> 1 votes

# Answer
The above advice *does not* work if you have Trial occurrences set to 0 (which the Subscriptions documentation tells you to do for a subscription that infinitely rebills until canceled).

There's a bug in the code that causes it to never rebill in this case. Just a word of warning.

Bug report with fix I sent to CT:

If you have a subscription with a "Total Occurrences" set to 0 (for infinite re-bills, as per the CartThrob documentation), setting the "End Date" on the subscription will NOT cause it to expire, and indeed no pending subscriptions are ever returned for any kind of processing, because of the MySQL query in pending\_subscription\_filter() in subscription\_model.php: -\>where('total\_occurrences \> used\_total\_occurrences')

Caveat Emptor, though. They've apparently given up on Subscriptions for now, and aren't selling or supporting it at all.
> 1 votes

---
Tags: ee2, cartthrob
---


# Question
Title: Pagination no longer works in Super Search after EE 2.8 upgrade
Here's an error I am receiving on search results after updating to EE 2.8.1:

```
Fatal error: Call to undefined method Pagination_object::get_template()
in /Users/username/Documents/Projects/myproject/system/expressionengine/third_party/super_search/mod.super_search.php
on line 1161

```

I realize Solspace hasn't confirmed compatibility yet, but if anyone has any workarounds for now that would be great!

# Answer
replace :

```
$this->EE->pagination->get_template();

```

with:

```
$this->EE->TMPL->tagdata = $this->EE->pagination->prepare($this->EE->TMPL->tagdata);

```

**Updates:**

I don't use Super search before, I just tell you what you must change. if you use `$channel->pagination->get_template()` then change it to `$channel->pagination->prepare`

and if just use the same prefix for `->TMPL->tagdata`

Regard's.
> 1 votes

---
Tags: solspace, supersearch, 2.8
---


title: using URL parmater with conditional

text:
# Question
Title: using URL parmater with conditional
Inside this URL there is a parameter:

```
http://localhost/recipe?id=9

```

Is it possible to use this parameter `(id=9)` with a conditional, like a segment? Or to check if there is a parameter inside a URL or not?

# Answer
> 1 votes
You can easily retreive GET and POST variables with the **Mo' Variables** add-on.

Download from Devot-ee
Github repository

For example, if your URL is `http://localhost/recipe?id=9`, you could use this code in your `recipe/index` template:

```
{if get:id == "9"}
  TRUE!
{/if}

```

You can also create default values for variables in the extension settings to test conditionals if no id parameter exists. For instance, if the default value for "id" is 0:

```
{if get:id != 0}
  ID EXISTS!
{if:else}
  No ID here!
{/if}

```

This is useful for handling exceptions like if there is no value in the query string (`/recipe?id=`).

# Answer
> 1 votes
With mo' variables (http://devot-ee.com/add-ons/mo-variables) you can get your get/post vars into early parsed variables you can then use in standard conditionals.

# Answer
> 1 votes
The URL Helper add-on is also worth mentioning, and will give you access to the query string within your templates.

---
Tags: conditionals
---


# Question
Title: EE v2.5.3 Freeform v4.1.3 entries not working
EE v2.5.3 Freeform v4.1.3

Are there any known issues with these versions?

Should these versions be compatible?

Form entry is working ok.

But I can't get the entries tag to work, I've stripped it right back to the basics, reinstalled it, to test I'm using the default 'contact' form and I've set the existing entry to be 'open':

```
{exp:freeform:entries collection="Contact"}

{first_name}
{email}

{/exp:freeform:entries}

```

IF I add an {email} field, it returns the email address of the logged in user within the tags, but nothing else is displayed, no entries.

EDIT: after the first comment, I tried this:

```
{exp:freeform:entries form_name="Contact"}

{first_name}
{email}

{/exp:freeform:entries}

```

With the form\_name param included: '{first\_name}' is displayed plus my email address if I'm logged in. Without the form\_name param included: nothing is displayed.

I haven't found an answer yet, but I found a workaround: I resorted to an embedded db query, it does mean that I have hard coded the fields as the column names from the database, but it works:

```
{exp:query sql="SELECT * FROM exp_freeform_form_entries_2 WHERE entry_id={segment_3}"}

<input type="hidden" name="first_name" id="first_name" value="{form_field_1}"/>
<input type="hidden" name="last_name" id="last_name" value="{form_field_2}"/>
<input type="hidden" name="street" id="street" value="{form_field_8}"/>
<input type="hidden" name="city" id="city" value="{form_field_9}"/>

{/exp:query}

```

# Answer
`collection=""` isn't a parameter on the **exp:freeform:entries** tag in Freeform 4.x. You use `form_name="`" or `form_id=""` instead.

Take a read through the **Freeform 3.x to 4.x Guide** as tags/parameters have changed.
> 3 votes

# Answer
Try this parameter to see if it has any effect.

status="\*"

It might be preventing entries with a status of "pending" which is the default from being shown.
> 3 votes

# Answer
As Anna mentioned, the 3.x to 4.x guide is a helpful place to start. Field variables are also prefixed now:

http://www.solspace.com/docs/freeform/entries/#variables

http://www.solspace.com/docs/freeform/entries/#examples
> 1 votes

---
Tags: solspace-freeform
---


title: Development Cycle

text:
# Question
Title: Development Cycle
I am a long time Drupal Developer, but it looks like I'm going to have to do some EE Dev work.

This question might become clear as time goes on, but wondering what experiences/best practices can be shared with the dev cycle.

In Drupal, I am accustomed to developing on a local MAMP environment; create various templates, CSS, custom modules, Features (that allow database centric functionality to be committed to code), etc. The very few database tweaks that can't be relegated to code via Views or Features are hand manipulated with each "push" of updates and enhancements.

Does this path make sense with EE? My initial impression is that design and development is carried extensively in the database, AND that the database is not very portable.

Looking forward to thoughts, input and experience.

# Answer
I've very little experience with Drupal since 4.x many years ago, tried to get into it at 6.x and 7.x the last being 2 years ago. Ultimately went with ExpressionEngine 2 (had 1.6.x experience in the past for this).

That said here are some thoughts.

Templates - these can be flat files, you can use the administrative control panel to sync between the database and your files. However, as far as I know their settings, such as enabling PHP, have to be configured in the control panel.

Your content basically sits in channel entries. Channels are like the tables, entries are like rows. I don't think there's a generic flow for this between development and production sites.

Add-ons that extend EE whether just in the control panel, for templating, or new field types, are a mix between flat files and being installed in the db (may be more than a simple flag of present/absent & enabled/disabled if they have their own settings or take advantage of hooks).

There's nothing like drush for EE as far as I'm aware. So for both versioning needs and managing your setup, it's all up to you how you want to go about it. There is devot-ee for add-ons and an add-ons like their monitor and dev demon's updater or something to that allow you to compare versions of your add-ons and simplify updating process (haven't used the latter).

templates, frontend stuff, add-ons, and EE itself can all be managed in one regard, but as far as keeping database changes in sync goes I don't think there's even an unofficial community standard kinda thing.

I could stand to be corrected, though!
> 3 votes

# Answer
Let me be 100% clear that I am not even close to an expert on this, but I've recently started using the development workflow described on Krasimir Tsonev's blog in order to enable a local development process.

http://krasimirtsonev.com/blog/article/Deploying-ExpressionEngine-based-site

So in addition to what is already suggested in terms of saving templates as files and using Master Config to set local database settings, Tsonev adds some code to a few system files so that all of your database changes are logged to a separate .sql file, which you can commit with your template changes. You then just need to run the .sql commands on the staging/production server to recreate all the database changes.

Probably worth a look.

UPDATE: Just ran into this plugin last night which appears to do the same thing.

https://github.com/fccotech/ee-db-trace
> 2 votes

# Answer
That which is not portable in the database can be set in the config.php see http://ellislab.com/expressionengine/user-guide/operations/moving.html

You can write a script to set these dynamically based on the current server, that way you can use the same config online or offline. (also the database connection settings will need to match if they vary between the servers)

This way once your setup you can copy the database between servers without worrying about directory and db config mismatches etc.
> 2 votes

---
Tags: module, development, themes
---


# Question
Title: display only if a matrix cell has a certain value
have this table that I want to display only if one parameter set in a matrix cell has a value of 1:

```
{exp:channel:entries channel="{canale_corrente}" limit="1" disable="member_data|pagination|categories"}
                                {formati_prodotti}
                                    {if enable_shop_lnk == "1"}

                                    <div class="small-12 column">
                                        <div class="content-box">
                                            <h2>TITLE</h2>
                                            <p class="subhead">SUBTITLE</p>
                                            <table width="100%">
                                                <thead>
                                                    <tr>
                                                        <td>Formato</td>
                                                        <td>Shop</td>
                                                    </tr>
                                                </thead>
                                                <tbody>
                                                    <tr>
                                                        <td>{codice_formato} - {nome_formato}</td>
                                                        <td><a href="#" class="tiny button radius">BUY</a></td>
                                                    </tr>
                                                </tbody>
                                            </table>
                                        </div>
                                    </div>
                                    {/if}
                                {/formati_prodotti}
                            {/exp:channel:entries}

```

CAPTION:

{formati\_prodotti} is a matrix field

enable\_shop\_lnk is a child field inside {formati\_prodotti} that can be 0 or 1

the problem is that I can't find a way to hide the entire table when there's no records with enable\_shop\_lnk == 0

Also because the enable\_shop\_link is inside a matrix field I can check it only by wrapping it with the matrix field {formati\_prodotti} and if there's more than one entry meeting the criteria I get more than one table!

Any idea!

# Answer
> 1 votes
You can wrap the whole {formati\_prodotti} tag pair in this conditional:

```
{if '{formati_prodotti:total_rows search:enable_shop_lnk="1"}'}
    {formati_prodotti}
        ...
    {/formati_prodotti}
{/if}

```

See http://docs.pixelandtonic.com/matrix/templating/field.html#total-rows

# Answer
> 0 votes
try

```
{if "{enable_shop_lnk}" == "1"}

```

Regard's.

---
Tags: matrix
---


# Question
Title: Sage Pay (Server) throwing error at checkout
I've set up CartThrob and using Sage Pay (server) to process payments. Using the {exp:cartthrob:checkout\_form} tags once billing address details are added and the form is submitted I get the following error:

```
A PHP Error was encountered
Severity: Notice
Message: Undefined property: Cartthrob_sage_s::$tokenhost
Filename: payment_gateways/Cartthrob_sage_s.php
Line Number: 469

```

I cannot find any examples of this issue on the CartThrob forums or here so wondering if there are any ideas how to resolve.

Cole

# Answer
> 1 votes
This was an issue with accepting tokens with a test gateway. This has now been resolved.

---
Tags: cartthrob, payment-gateway, sagepay
---


# Question
Title: unable to access to CP after setting cookie domain
Help! I was just trying to setting the cookie domain inside the CP \> Admin \> Security and Privacy \> Cookie Settins

(as explained here Cookie Settings)

and now I can't login to the CP admin :(

how can solve this big problem? thanks

# Answer
solved, i've hardcoded the config.php with this:

```
$config['cookie_prefix'] = '';
$config['cookie_path'] = '';
$config['cookie_domain'] = '';
$config['user_session_type'] = 'c';
$config['admin_session_type'] = 's';

```

Using an MSM installation this solution works great but the config.php has to have these set afterwards otherwise the CP lockout continues:

```
$config['cookie_domain'] = "subdomain.mydomain.com";
$config['cookie_prefix'] = "myprefix";
$config['admin_session_type'] = 's';

```
> 0 votes

---
Tags: login, admin, cookies, administration
---


title: Moderate members edits

text:
# Question
Title: Moderate members edits
I am using zoo visitor to manage my member profiles.

Is it possible to allow members to edit their profiles but not let the edits post live until they are moderated/approved by the admin?

# Answer
> 2 votes
Natively it would be tough. You could set their member group to have access only to a particular status, but that would take the member entry out your "regular" loop (since it would affect the status on an existing entry and not be doing version control, leaving the previously approved version in place).

Since with visitor members are entries, Better Workflow could do this for you. But it's a lot of functionality to throw at that one issue. Obviously there would be other benefits. But it depends on whether you need the member's previous profile to remain live while the edited version is in review.

Publisher, I believe, would also allow you to do this (one of the cool things there is the change highlighting Publisher can do).

# Answer
> 1 votes
I use Safecracker to let members edit my Zoo Visitor Channel Profiles, I have an additional status called 'Moderate' and use it as a hidden field.

```
<input type="hidden" name="status" value="Moderate">

```

Whenever they update, viola - I know they've edited and can hide their status until moderated. (I also have a cron job that looks for the status of Moderate every morning and it emails me with each entry that requires moderation)

---
Tags: members, zoo-visitor, moderation
---


# Question
Title: Assets, thumbnails not showing up and can't post new images
Just noticed the Thumbnails of previously published posts in the Assets modal window are not showing up anymore and I can't upload images either in new Post.

They worked fine before.

Using Assets 2.2.2 And EE 2.7.2 Cache folder is writable

Thanks in advance for the help.

# Answer
I fixed it by setting the User Session Type to Cookies only.
> 1 votes

---
Tags: assets, pixelandtonic
---


# Question
Title: Channels and entries structure on site with deep hierarchy
I'm trying to wrap my head around the most efficient way to set up entries in EE for my site structure. This is my first EE build, coming from a Wordpress background and I'm looking for opinions on how a more experienced EE dev would approach setting up my site's structure.

The site can be defined as an e-catalog, no e-commerce functionality is present but the site is largely based off the product views. I am using the Structure add-on, and have purchased Playa, Matrix and Stash as well.

Pages needed: 1. Product Category pages - displays links to Product Grid pages 2. Product Grid pages - displays product tiles. Tiles are groupings of products. The tiles must be created by the client in the CP because there are no patterns amongst the tile groupings.

\*There is no singular product entry view. The Product Grids are the the most drilled down view of products.

Initially, I set up channels for Product Categories, Product Grids and Products. I related Product Grids to their respective Product Categories with Playa.

I imported a category of products as individual entries in the Products channel. This is where I'm stuck. I'm not sure if my channel structure is the most efficient and I don't know how to most efficiently create the tiles. I feel like there has to be a better way.

Any thoughts on approach would be greatly appreciated!

# Answer
> 2 votes
I would suggest you use EE categories for your product categories rather than channels. Each product tile is an entry in the products channel, and each tile is assigned to one or more categories which determines which product grid it shows up on. The index/category page is then just a list of the categories in your product categories group, and the product grid pages are essentially category archive pages showing all entries assigned to that category.

---
Tags: playa, channel, structure, entries, content-elements
---


# Question
Title: exp_flash cookie being set for each channel entry
I have a CE tag that seems to be setting the exp\_flash cookie to the entire contents of each entry output within the loop. This leads to an error in chrome, where the header ends up being too large.

Set-Cookie: exp\_flash=a%3A1%3A%7Bs%3A17%3A%22%3Anew%3Agmap\_tagdata%22%3Bs%3A6787%3A%22%0A++++++++++++++++++++++++%0A++++++++++++++++++++++++%7Bexp%3Ace\_cache%3Ait+id%3D%22%7Bauthor\_id%7Dpost%7Bentry\_id%7D%22+url\_override%3D%22user%7Bauthor\_id%7D%2Fpost%22%7D%0A++++++++++++++++++++++++%3Cli+class%3D%22post%7Bif+c\_photo%7D+hasPhoto%7B%2Fif%7D%7Bif+c\_desc%7D+hasEvent%7B%2Fif%7D%22+data-id%3D%22%7Bentry\_id%7D%22+data-author\_id%3D%22%7Bauthor\_id%7D%22%3E%0A++++++++++++++++++++++++++++%3Cheader%3E%0A++++++++++++++++++++++++++++++++%3Cdiv+class%3D%22mTime%22%3E%0A++++++++++++++++++++++++++++++++++++%7Bentry\_date%3Arelative%7D%0A++++++++++++++++++++++++++++++++%3C%2Fdiv%3E%0A++++++++++++++++++++++++++++++++%7Bif+c\_desc%3D%3D%22%22%7D%0A++++++++++++++++++++++++++++++++%3Cdiv+class%3D%22mImage%22%3E%0A++++++++++++++++++++++++++++++++++++%7Bexp%3Ace\_img%3Apair+src%3D%22%7Bphoto\_url%7D%22+rounded\_corners%3D%22all%2C25%22+border%3D%223%7Cffffff%22+height%3D%2250%22++width%3D%2250%22+crop%3D%22yes%22+allow\_scale\_larger%3D%22yes%22+save\_type%3D%22png%22%7D%0A++++++++++++++++++++++++++++++++++++%3Ca+href%3D%22%2Fmember%2F%7Bauthor\_id%7D%22%3E%3Cimg+src%3D%22%7Bmade%7D%22+alt%3D%27%7Btitle%7D%27%2F%3E%3C%2Fa%3E%0A++++++++++++++++++++++++++++++++++++%7B%2Fexp%3Ace\_img%3Apair%7D%0A++++++++++++++++++++++++++++++++

etc etc this repeats for each entry output on the page. Not clear why this would be set, I've toggled extensions and plugins, etc to no end. Anybody know why this might be happening?

# Answer
This turned out to be an issue with EE 2.8, MSM, and google maps for expressionengine. Updated Google maps module to 3.3.5 and all is well
> 2 votes

---
Tags: cookies
---


title: User Edit Permissions in Freeform

text:
# Question
Title: User Edit Permissions in Freeform
I'm trying to decide if Freeform (or Freeform Pro) is a good fit for what I need to do and wondering a couple things about forms I can set up for member us.

For front end edits, can users edit entries that have been approved or can they only view pending? I want to set it up so they can edit entries that have been rejected or are still pending but not once they have been published.

Also can you allow users to edit an existing entry but as pending? Such as submitting edits or extra information on an entry and if approved, that information appears on that particular entry. If allowed is this a feature on free, pro or both?

# Answer
First, you would set up your form to have a status of "pending" so that the Freeform entry has a status of "pending".

Then, for a user to be able to edit these "pending" form entries, use `{exp:freeform:entries}` to first retrieve the entries, then display the Freeform Edit form using `{exp:freeform:edit}` (Note: this tag is a Freeform Pro feature only). For example:

```
{exp:freeform:entries status="pending" /* your other parameters here */}
    {exp:freeform:edit
         form_id="1"
         entry_id="{freeform:entry_id}"
         restrict_edit_to_author="no"
         allow_status_edit="yes"}

      // Your form containing a field for changing the status,
      // if status="" is not defined/hard-coded as a parameter:
      <select name="status" id="status">
         <option value="">Select:</option>
         {freeform:statuses status="not closed|testing"}
            <option value="{status_name}"
         {if freeform:edit_data:status == "{status_name}"}
            selected="selected"
         {/if}>
            {status_label}
            </option>
         {/freeform:statuses}
      </select>

    {/exp:freeform:edit}
{/exp:freeform:entries}

```

Your second question is answered with the above: you could use status="pending" in `{exp:freeform:edit}` to set entries to be "pending", or use a form field to allow the user to change (or not) the entry's status. Again, this is a Freeform Pro feature.
> 0 votes

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


# Question
Title: Parse custom field data in entry_submission_end_hook
What I'm trying to do is parse the custom field data sent to the `entry_submission_end` hook.

Here's what I was able to dissect out of the channel entries module, but what I'm confused is how to instantiate an instance of `Channel` for use by the template parser library.

```
public function entry_submission_end_hook($entry_id, $entry_metadata, $entry_data)
{
    $tag_to_parse = "{page_uri}";
    $channel = new Channel; // do I include mod.channel.php and instantiate this, if so how?

    $this->EE->load->library('channel_entries_parser');
    $parser = $this->EE->channel_entries_parser->create($tag_to_parse);
    return $parser->parse($channel, $entry_data);
}

```

Ideally this should return the URI of the page for the entry saved via `entry_submission_end`.

*Alternatively if there is another way to run logic on parsed tag data from a given entry upon saving or creating said entry I'm all ears.*

# Answer
> 0 votes
Here's what I was able to come up with. I did tap into the channel entries module. This seems excessive since in my scenario it's just taking a single field of text and parsing it but at least it fully implements whatever classes EE has.

I hope this helps someone.

```
public function parse_tagdata($entry_id, $tagdata)
{
    require_once PATH_MOD.'channel/mod.channel.php';

    ee()->TMPL->tagdata = $tagdata;
    ee()->TMPL->tagparams['dynamic'] = "no";
    ee()->TMPL->tagparams['entry_id'] = $entry_id;
    ee()->TMPL->site_ids = array($this->config->item('site_id'));

    $vars = ee()->functions->assign_variables($tagdata);
    ee()->TMPL->var_single  = $vars['var_single'];
    ee()->TMPL->var_pair        = $vars['var_pair'];

    $channel = new Channel;
    $channel->fetch_custom_channel_fields();
    $channel->fetch_custom_member_fields();
    $channel->build_sql_query();
    $channel->query = ee()->db->query($channel->sql);
    $channel->parse_channel_entries();

    return $channel->return_data;
}

```

---
Tags: add-on-development, module, channel, extension
---


# Question
Title: An Error Was Encountered Site Error: Unable to Load Site Preferences; No Preferences Found
Besides database issues what causes this?????

I have not upgraded or moved the site.

I have set the permissions, checked my config.php file and so forth.

Are there any other solutions?

# Answer
> 0 votes
Thanks all. We found the issue! We did check the database and exp sites and all was fine. I am using git to manage a website on a server and git had changed file permissions when we pushed from the development server to the live server. We needed to set permissions on a directory folder to get it to work. Problem averted! Slaves to our machines :(

# Answer
> 2 votes
The only time I've ever seen it is when the settings in database.php were incorrect or there was a problem connecting to the database. Confirm with your host that your DB is still accessible.

---
Tags: error, ee
---


# Question
Title: Can CartThrob send notification emails on wishlist/registry events?
We need to send a notification email to a person who receives an item from their registry.

* Person A: Adds item to registry
* Person B: Finds Person A's registry and purchases an item
* Person A: Receives a notification email informing them "An item has been purchased for you."

While this is one use case, are there any other wishlist/registry events that we can send notifications on? I haven't been able to find any documentation on this and CartThrob seems to have a flexible notification architecture for steps in their other related CartThrob products.

# Answer
Sending an email to Person A from Person B is a completed feature that will be available in the next release of this add-on (along with a few bug fixes and template updates)

There are currently no other notification events though. If you think of any, feel free to post em, we'll add them to the feature request pile.

To answer your next question: The next release is complete. It'll be uploaded sometime in the next several days. Probably on Monday of this coming week.
> 0 votes

# Answer
Chris, I would also be REALLY, very interested in the next release where we have it installed and working, but unable to share or email the wish lists. Is there an update for when the next version will be released?

Also I noticed that Wish Lists, as well as others addons, have been removed from the available products list on the website. Is this temporary?
> 0 votes

---
Tags: cartthrob
---


# Question
Title: How does one get a ‘soft’ carriage return in a Rich Text field?
When entering text in a Rich Text field it is sometimes desirable to have a soft return — ie. a simple line break within the paragraph rather than starting a new paragraph. In many situations (including EllisLab's own forums) a shift-return keyboard combo will give this result — but not in EE's RTE, where it starts a new para.

Typing \<br\> will generally achieve the desired result (although it's clunky and sometimes needs the entry to be submitted more than once before the line breaks registers as behind-the-scenes html). But if clients want an RTE field it's generally because they don't *want* to be typing HTML elements into their text — certainly not to achieve something as basic as a soft return/line break.

I'm sure that it is possible to create an RTE button for this but that process is not particularly simple for non-developers, and really shouldn't be required for such a basic function.

Am I missing something? Or is there really no simple way to insert a line break into a paragraph in the RTE?

# Answer
> 1 votes
Okay, it turns out it’s a bug that manifests when using the RTE in Safari. Switching to Chrome gets rid of the problem (though I'm not 100% sanguine about telling clients that they need to avoid a specific browser if they want to be able to use soft returns).

# Answer
> 0 votes
Hold down the Shift key when you hit Return in practically any text field and you should get a soft carriage return.

---
Tags: rte, richtext, text-formatting
---


# Question
Title: HTTPS BrilliantRetail checkout page not loading stylesheets
I am using the BrilliantRetail e-commerce extension with ExpressionEngine and there is an option to serve up the checkout page using the HTTPS protocol. This is working correctly, however, my HTTPS pages do not show the proper layout because the CSS files are not being served through HTTPS. If I use the inspect window to edit the HTML and change the CSS paths to HTTPS it works fine.

Anyone know how I can resolve this issue? Thanks in advance!

# Answer
In case anyone else runs into this issue, the problem was resolved by removing the protocol from the site URL in the general settings menu.

`http://mysite.com` became `//mysite.com` and now all of the assets are being delivered through the correct protocol depending on what section of the site you are on.
> 1 votes

---
Tags: checkout, secure, brilliantretail
---


# Question
Title: {absolute_count} not working with Google Maps onclick
I have a google map with markers and when you click on an external link, it takes you to a marker on a map. See js fiddle to see the map in action.

The code on the external link looks like this:

```
<p><a href="#map" onclick="myClick(0);"><p>Click me</a>
</p>
<p><a href="#map" onclick="myClick(1);"><p>Click me 2</a>
</p>
<p><a href="#map" onclick="myClick(2);"><p>Click me 3</a>
</p>

```

So a click will take you to the markers 0 1 2 and so forth. The jsfiddle clarifies this. I need those numbers to start at zero so in ee the code looks like this:

```
<p><a href="#map" onclick="myClick({absolute_count});">{entry}</a></p>

```

What I want to do is have that {absoulte\_count} start with the very first entry which will bring up the first map marker, BUT when I click on it, it takes you to the second marker on the map.

I tried being as clear as I could so comment if you have questions about my question. Ques-ception.

Thanks in advance.

# Answer
Have you tried `myClick({absolute_count}-1);` ?

this is needed because {absolute\_count} isnt zero-based and starts at 1

Or you can subtract the id by 1 in your myClick function

```
function myClick(id) {
    id = id-1;
    google.maps.event.trigger(markers[id], 'click');
}

```

There is also an addon http://devot-ee.com/add-ons/mh-index for this.
> 0 votes

# Answer
I'm not entirely certain if the variable will be available in this context but try using {count} instead of {absolute\_count}.

{count} starts from 1.

{absolute\_count} is zero indexed so will always start from 0.
> 0 votes

---
Tags: google-maps, count
---


title: {Structure:page:entry_id} ouput order

text:
# Question
Title: {Structure:page:entry_id} ouput order
I want to output all siblings of an item using the same order as displayed in structure, the following code works but I need to be able to do this dynamically as I can't hardcode the parent id for each page this is required on

```
{exp:structure:entries parent_id="52"} output here {/exp:structure:entries}

```

I then changed the code to this:

```
{exp:structure:entries parent_id="{structure:page:entry_id}"} output here {/exp:structure:entries}

```

and it works, but the output's order is reversed, no idea why this happens, is there anyway to make the order correct, as per the first example?

Thanks!

# Answer
Are you running the latest version of Structure? It should output the list fine in your first example. Start a support thread with us if not.
> -1 votes

---
Tags: structure
---


# Question
Title: Using structure global variables in embeds
I'm trying to create a navigation menu inside an embed, I have the following code in my main template:

```
{exp:structure:entries parent_id="{structure:page:entry_id}"}
  {if channel_short_name == "accordion"}
  {embed="site/template_accordian"}
  {/if}
  {if channel_short_name == "album"}
  {embed="site/template_album"}
  {/if}
{/exp:structure:entries}

```

This works great, however I then have the following inside template\_accordian:

```
<nav id="primary-nav">
  <ul>
    {exp:structure:entries parent_id="{structure:parent:entry_id}"}
    <li><a href="#{url_title}">{title}</a></li>
    {/exp:structure:entries}
  </ul>
</nav>

```

{structure:parent:entry\_id} doesn't seem to output anything, I'm guessing this is due to parsing order or something but can't work out how to achieve what I want to achieve, any ideas?

# Answer
> 0 votes
I don't know if it will work within that embed because of EE's parsing order. You may need to put it directly in the template.

---
Tags: structure, parse-order, global-variables
---


title: Structure Navigation Tree

text:
# Question
Title: Structure Navigation Tree
Is there a way to use the built-in tags available from structure or EE to list parents and their children accordingly? Essentially, something akin to the logic:

```
{exp:structure:entries channel="channel_name"}
    {if structure:child_ids_for:{entry_id} != ""}
        {!-- List all children to this parent --}
    {/if}
{/exp:structure:entries}

```

Also we need to account for third-level URLs.

Effectively, the output we're looking for is something like:

```
Parent 1
|--Child 1
|----Sub Child 1
|----Sub Child 2
|--Child 2
Parent 2
Parent 3
|--Child 1

```

And so forth. Using the `saef_select` drop-down isn't an option.

# Answer
> 1 votes
Are you looking for something like this?

```
{exp:structure:nav override_hidden_state="no" current_class="active" show_depth='1' max_depth='1' has_children_class='yes' show_overview="yes"}

```

The key is in the "show\_depth" and "max\_depth" parameters along with some others on the Structure navigational tags section.

---
Tags: structure
---


# Question
Title: Assets: Wrong Thumbnail After DB Migration
I dumped my production DB and imported it into my DEV environment, but Assets is showing the wrong thumbnails for S3 images. The full images are correct (they display correctly in the templates), it's just the thumbs that are wrong.

I updated the indexes for those Assets sources, but it didn't fix the problem. I also deleted everything in the `/cache/assets` directory, but nope.

* EE 2.7.2
* Assets 2.2.2

# Answer
> 1 votes
1. Delete all of the files inside `system/expressionengine/cache/assets/`
2. Clear your browser cache.

Voilà.

---
Tags: assets, pixelandtonic
---


# Question
Title: How can I display user's total Friend invites without looping through each one?
I'm using the Solspace Friends module, and I'm trying to figure out an easy way to set a badge displaying the users' total friend invites.

The documentation lists a tag: `{friends_total_results}`, but this tag only works inside the `{exp:friends:invites}` loop, which means it gets repeated for every instance of an invite that the loop returns.

Am I missing something here, or is this just simply not possible in this current veriosn?

# Answer
> 0 votes
Inside the tag you can place a conditional. {if count == "1"}{friends\_total\_results}{/if}

so the total only displays once.

Or you could use the query module and run a query against the exp\_friends table and display a single number.

---
Tags: solspace, solspace-friends
---


# Question
Title: Export Calendar .ics not auto-refreshing, event times off
Good Morning,

I want to set up the export calendar function to allow a user to type in a URL into their Google Calendar, then automatically stay up-to-date as new users add to my non-profit's events calendar.

After reviewing document I have altered the example text (see below), but found that whether I download the .ics file directly, or whether I ask Google Calendar to add by URL where the revised text is located (http://mygatewayarts.org/calendar/export), that

1) the link is not active: the calendar does not include the latest information days later.

2) Despite setting the calendar to start today, I see some past recurring events, but certain one-time events do not.

3) Some event times are incorrectly listed.

Would you propose any tips or alternatives to the example text? Is this the best way to go about it?

4) Lastly, it'd be helpful as well if the descriptor text could link to the event detail page.

```
{exp:calendar:icalendar
    orderby="title"
    sort="asc"
    date_range_start="today"
    show_years="5"
    dynamic="off"
}
{/exp:calendar:icalendar}

```

# Answer
While I didn't use this in conjunction with Solspace's Calendar, I've found Easy iCalendar to be a reliable method for generating content in that format; perhaps you can roll your own template using other Calendar tags?
> 0 votes

---
Tags: calendar, export
---


title: HTML entities in Title field

text:
# Question
Title: HTML entities in Title field
I can't figure out where expression engine is changing my title to html entities.

This is specifically for the required title field

Text like: "Test á Character" is being stored as "Test `á` Character" in the database.

The collation on the column is utf8\_general\_ci The collation on the table is utf8\_general\_ci The default\_character\_set\_name for the db is latin1

I have a custom extension that's hooked into "entry\_submission\_end" and it stores all the request vars in a temporary table.

If I submit an entry with text "Test á Character", in my extension, the text is being inserted correctly into my temporary table as "Test á Character" but incorrectly by expressionengine into the main channel table as "Test `á` Character" in the title field.

I'm fairly experienced with diving into the EE code to modify things but I've been unable to locate the source of this issue. I can directly update the db via SQL myself and the characters are inserted properly as well.

This happens both with custom forms and the default expression engine entry editing form.

# Answer
> 3 votes
I figured it out.

in API\_channel\_entries.php, the title was being brought in before insertion like this:

```
'title' => ($this->EE->config->item('auto_convert_high_ascii') == 'y') ? ascii_to_entities($data['title']) : $data['title'],

```

I don't update regularly (we've made a lot of hacks to make EE work for us) so it's likely just my issue but that setting, auto\_convert\_high\_ascii was apparently removed from the config file in some version but at least for the version I have, is still defined as a default in the EE\_Config core file. This means it was being defaulted to true.

To solve the issue I added

> $config\['auto\_convert\_high\_ascii'\] = "n";

To config.php

---
Tags: database, entry, html-entities
---


# Question
Title: EE Not Outputting All Data Using Query, for Data that Has NULL values in a Field
Using the following Query in my template will not output the title of entries that do not have the ci.filename. BUT when running the SQL in MySQL directly, it does produce the results, including the title field.

Strangely if we output custom fields, e.g. field\_id\_198 that is also returned, this DOES output.

So it seems Expression Engine is not outputting the title (and some other data like urt\_title) when ci.filename is NULL, even though its in the MySQL results, but it is outputting other data.

```
{exp:query sql="
    SELECT *, ci.filename AS business_logo
    FROM exp_channel_titles ct
    LEFT JOIN exp_channel_data cd ON ct.entry_id = cd.entry_id
    LEFT JOIN exp_channel_images ci ON ci.entry_id = ct.entry_id
    LEFT JOIN exp_members m ON ct.author_id = m.member_id
    WHERE (
        cd.field_id_202 = '{segment_4}'
        OR cd.field_id_202 LIKE '%|{segment_4}%'
        OR cd.field_id_202 LIKE '%{segment_4}|%'
    )
    AND cd.channel_id = '36'
    AND (m.group_id = 1 OR m.group_id = 5 OR m.group_id = 6)
;"}

<div class="row">
    {title}
</div>

{/exp:query}

```

Removing the exp\_channel\_images JOIN and field WILL output the title in the results, BUT running direct in MySQL produces the exact same results as the first statement.

```
{exp:query sql="
    SELECT *
    FROM exp_channel_titles ct
    LEFT JOIN exp_channel_data cd ON ct.entry_id = cd.entry_id
    LEFT JOIN exp_members m ON ct.author_id = m.member_id
    WHERE (
        cd.field_id_202 = '{segment_4}'
        OR cd.field_id_202 LIKE '%|{segment_4}%'
        OR cd.field_id_202 LIKE '%{segment_4}|%'
    )
    AND cd.channel_id = '36'
    AND (m.group_id = 1 OR m.group_id = 5 OR m.group_id = 6)
;"}

<div class="row">
    {title}
</div>

{/exp:query}

```

# Answer
Adding the specific table to the SELECT ensures it works:

```
SELECT ct.*
FROM exp_channel_titles ct

```

There is no other title being output from the other tables, but I can see exp\_channel\_images does have a title field. I guess EE has issues with the ambiguity even though MySQL outputted them OK.
> 1 votes

---
Tags: query
---


# Question
Title: How do you use HTML5 elements in WYGWAM?
I see that WYGWAM added support for HTML5 elements (section, figure, etc.) in their changelog, but I cannot figure out how to enable or use them. Can someone enlighten me?

# Answer
WYGWAM does not have the ability to add HTML5 elements like `<figure>` out of the box. It appears you only have access to features that come out of the box with CK Editor, even though you could build a "Widget" that would give you the ability to add HTML5 elements.
> 1 votes

---
Tags: pixelandtonic, wygwam
---


# Question
Title: List all entries from particular channel when being already in that channel entry
Well, I have suspected that code below will list all entries from channel `creators`

```
<ul>
{exp:channel:entries channel="creators" orderby="title" sort="asc"}
<li><a href="{site_url}{segment_1}/{url_title}">{title}</a></li>
{/exp:channel:entries}
</ul>

```

but when I'm in any entry from that channel it displays only that particular entry not all from that channel.

So what is my problem?

Thanks

# Answer
> 1 votes
You should add the dynamic="no" parameter. http://ellislab.com/expressionengine/user-guide/add-ons/channel/channel\_entries.html#dynamic

---
Tags: channel-entries
---


# Question
Title: Snaptcha failing if multiple User registration forms on same page
I'm using snaptcha for Solspace User registration forms. Background info here: User registration failing Snaptcha security test every time

There are two registration forms on the page - one for each of two possible member groups you can sign up for. The form you choose will be displayed inside a modal box.

If there's only one form, it works just fine. User who should pass the security test do. But when I add a second user registration form for the second member group, neither form will submit. They always fail the security test.

When inspecting the code, I see that both User registration forms have the same snaptcha field (same ID and value), and I imagine it's the lack of a unique code for each form that is causing the problem.

How can I use Snaptcha successfully when I have multiple User registration forms on the same page?

# Answer
The solution, as posted by Ben in the devot-ee support forums, is to try making each tag unique as follows:

```
{exp:snaptcha:field id="1"}

{exp:snaptcha:field id="2"}

```

That fixed it for me. I now have two user registration forms on the same page and both submit as they should.
> 1 votes

---
Tags: captcha, snaptcha
---


title: Solspace Calendar error after install

text:
# Question
Title: Solspace Calendar error after install
When I installed the calendar plugin, the first thing I noticed was that the channels did not auto install themselves. Can I add them manually?

Also now when adding content to any channel I receive the following once I hit 'publish', \`A Database Error Occurred Error Number: 1064

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 3

SELECT channel\_id FROM exp\_channels WHERE

Filename: third\_party/calendar/data.calendar.php

Line Number: 578\`

Any thoughts?

# Answer
Turns out there was an error with another plugin. Once I resolved that I was able to reinstall Calendar correctly.
> 0 votes

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


# Question
Title: Pre-fill matrix field when creating new entry?
How can I pre-fill a matrix field when creating a new channel entry.

The reason to do this (and why a matrix field is needed) is:

* Data is best entered and represented using a table.
* Unwanted rows can be removed.
* Additional rows can be added.
* To avoid having to re-enter row descriptions that are frequently used.

# Answer
> 12 votes
Adding the following script to the control panel allows one to define a custom state for one or more matrix fields.

The following script can be modified as needed and then copy and paste into your custom field's "Field Instructions" box beneath your custom user instructions!

Many thanks to @MediaGirl for that trick! Ref: How to add a custom JavaScript to the "New Entry" control panel?

```
<script>
$(function() {

// Make sure that this is the publish form
if (!EE.publish)
    return;

// Only proceed when creating a new entry
var entryId = $('#publishForm').find('input[name="entry_id"]').val();
if (entryId != 0)
    return;

function initLabels(id, labels) {
    var addEntryButton = $('#sub_hold_field_' + id + ' .matrix-btn.matrix-add');
    if (!addEntryButton.length)
        return;

    // Need to wait after `document.ready` has finished executing!
    setTimeout(function() {
        var field = $('#sub_hold_field_' + id);

        // Only proceed if matrix is empty
        // Note: This is not the case if a validation error occurs!
        if (!field.find('.matrix-norows').is(':visible'))
            return;

        // Create one row for each label
        for (var i = 0; i < labels.length; ++i)
            addEntryButton.click();

        // Skip the placeholder row for "No rows have been added yet..."
        field.find('tbody tr:not(.matrix-norows)').each(function(i) {
            $(this).find('.matrix-firstcell textarea').val(labels[i]);
        });
    }, 0);
}

// Check that this is an entry of the expected channel field group
if (EE.publish.field_group == 2) {
    // "Custom Parameters"
    initLabels('23', [
        'Lens Type',
        'Focal Length',
        'Manufacturer',
        'Model',
        'Serial Number'
    ]);

    // "Track Information"
    initLabels('17', [
        'Artist',
        'Title',
        'Label',
        'Artwork'
    ]);
}

})
</script>

```

# Answer
> 1 votes
Though slightly different, I was inspired by this to create Matrix Presets which adds the ability to load and save values to P&T Matrix cells. You would be able to load rather than prefill values into the Matrix Cells.

It could be cleaned up but it works on EE 2.7.3 with Matrix 2.5.10, and so far works with basic fields and within Zenbu+Henshu.

https://github.com/ignetic/ee-matrix-presets

Perhaps in a future update, I may add an options replace all fields or add to them.

Give it a try if it suits your needs, but it may prove useful to others.

Cheers

# Answer
> 0 votes
It's not pre filling, but have you thought about using CKEditor templates ? You would create as many code blocks as you would need and all the client would need to do is click the template button and choose the content chunk they want to create.

---
Tags: add-on, custom-fields, add-on-development, matrix, fields
---


# Question
Title: Solspace Facebook Login - Dynamic Return with {segment}
Might be an odd scenario, but i'm looking to use Solspace's facebook Login with a dynamic return by using segments in the url.

Currenttly fbc:login throws an error when I use any {segment} tags in the parameters.

Here's how they say to use the module: {exp:fbc:login permissions="email|publish\_stream|read\_stream" return\_when\_logged\_in="site/home" return\_when\_logged\_out="site/home" return\_to\_register="site/register" return\_on\_failure="site/fail" } {/exp:fbc:login}

Here's what i'd like to do

{exp:fbc:login permissions="email|publish\_stream|read\_stream" return\_when\_logged\_in="{segment\_2}/{segment\_2}" return\_when\_logged\_out="s{segment\_2}/{segment\_2}" return\_to\_register="site/register" return\_on\_failure="site/fail" } {/exp:fbc:login}

# Answer
Using this kind of conditional in a parameter won't work well:

```
return_when_logged_in="{if segment_2}/'{segment_2}'{if:elseif segment_3}'{segment_2}'/'{segment_3}'/{if:elseif segment_4}'{segment_2}'/'{segment_3}/'{segment_4}'{if:else}/{/if}"

```

First, you shouldn't need those single quotes, as this could cause more issues than less.

Also with the above, you're using an **advanced conditional** within an `{exp:...}` tag's parameter. This gets parsed **after** the `{exp:...}` tag, which likely is giving you the error. Always use **simple conditionals** when working with parameters. In this case you could simply try:

```
return_when_logged_in="/{segment_2}/{segment_3}/{segment_4}"

```

However, your return URL may have a number of slashes at the end, eg. `http://mysite.com/template_group/template//`.

A better solution is the following, all using **simple conditionals**:

```
return_when_logged_in="{if segment_2}/{segment_2}{/if}{if segment_3}/{segment_3}{/if}{if segment_4}/{segment_4}{/if}"

```

Notice how all conditionals are simple conditionals. These will parse **before** the `{exp:...}` tag.

This is general EE advice, by the way, so can come in handy with 1st- and 3rd-party tags.
> 1 votes

---
Tags: solspace, facebook
---


title: Expresso Store Promotional Codes

text:
# Question
Title: Expresso Store Promotional Codes
If we have someone using promotional codes in the checkout tag, is there any way to pull out and display what promo code has been used, once applied? I am thinking in the notes section of the promo code area, I could put something informative in there, and once a promo code is used, push this out to the checkout code

# Answer
Yip, `{promo_code}` should do it. It's just a regular order field in that regard.

Update: Looks like you actually want more details about the discount other than just the promo code. In that case, you could use the `{exp:query}` module with some simple SQL like this (inside the checkout tag):

```
select * from exp_store_discounts where id = '{discount_id}'

```
> 1 votes

---
Tags: expresso-store, coupon-code
---


title: Cloning Entries With Matrix Fields

text:
# Question
Title: Cloning Entries With Matrix Fields
I need help with cloning an entry that has matrix fields for photos. Entries are made/edited using Channel Forms. The clone is generated using an extension to the channel\_form\_submit\_entry\_end hook

My Method:
`public function generate($channel_form_obj)
{
 $entry_id = '';
 $quote_required = 0;
 ee()->security->restore_xid();
//I If the form has errors, don't bother
if (!empty($channel_form_obj->errors) || !empty($channel_form_obj->field_errors))
{
 return;
}
// Grab the group ID
$author_group_id = ee()->session->userdata('group_id');
// Forge the group ID - the contractors dont normally have quote authority
ee()->session->userdata['group_id'] = 1;
// Set the roofer's report to lower case before checking for the quote word
$lc_roofer_report = strtolower( $channel_form_obj->entry('roofer_report') );
// Set the order status to lower case before checking for the quote word
$lc_order_status = strtolower( $channel_form_obj->entry('order_status') );
// All repairs requiring further quotes have the word "required" either
// in the roofer's report or the order status. Both entries are made using a slect list
$reactive_category = $channel_form_obj->entry('categories')[0];
if (
 preg_match("/\brequired\b/i", $lc_roofer_report) == 1
 ||
 preg_match("/\brequired\b/i", $lc_order_status) ==
 )
{
 $quote_required = 1;
}
if($reactive_category == 1 && $quote_required == 1)
{
 // Grab the data we need for the quote page and set spawning entry ID so we can find its spawn if we have an edit
 $data = array(
 'title' => $channel_form_obj->entry('title'),
 'field_id_50' => $channel_form_obj->entry('entry_id'),
 'field_id_3' => $channel_form_obj->entry('customer_id'),
 'field_id_37' => $channel_form_obj->entry('customer_reference'),
 'field_id_5' => $channel_form_obj->entry('job_address'),
 'field_id_40' => $channel_form_obj->entry('town'),
 'field_id_30' => $channel_form_obj->entry('postcode'),
 'field_id_27' => $channel_form_obj->entry('roof_type'),
 'field_id_28' => $channel_form_obj->entry('roof_condition'),
 'field_id_32' => $channel_form_obj->entry('job_photos'), // This causes the problem
 'field_id_33' => $channel_form_obj->entry('quote_details'),
 'field_id_34' => $channel_form_obj->entry('materials_and_plant'),
 'field_id_46' => $channel_form_obj->entry('access'),
 'field_id_41' => $channel_form_obj->entry('notepad'),
 'author_id' => $channel_form_obj->entry('author_id'),
 'category' => array(2),
 'field_id_20' => 'Pending'
);
// Set the entry_id to zero in case this is an entry or an edit not previously spawned,
// otherwise ve heff crepp
$data['entry_id'] = 0;
$entry_id = 0;
// If this is an edit, check if it is a re-edit of a previous spawn so we can correct
// the spawned quote
if($channel_form_obj->edit == 1)
{
 $spawning_entry_id = $channel_form_obj->entry('entry_id');
 ee()->db->select();
 ee()->db->from('exp_channel_data');
 ee()->db->where('exp_channel_data.field_id_50', $spawning_entry_id);
 $query = ee()->db->get();
 if ($query->num_rows() > 1)
 {
 // Throw error message - too many spawns
 return;
 }
 elseif ($query->num_rows() == 1)
 {
 // We have a re-edit of a prevously spawned quote
 $row = $query->row_array();
 $entry_id = $row['entry_id'];
 //echo 'Entry ID '.$entry_id.'
';
 }
}
$group_id = $this->EE->session->userdata('group_id');
if (ee()->session->userdata('group_id') != '1')
{
 //Error Can't Post
';
}
else
{
 // OK can post
 $channel_id = $channel_form_obj->entry('channel_id');
 ee()->load->library('api');
 ee()->api->instantiate('channel_entries');
 ee()->api_channel_entries->save_entry($data, $channel_id, $entry_id, $autosave=false);
 }
}
return;
}` This code generates the following warning:
A PHP Error was encountered
Severity: Warning
Message: Illegal string offset 'is\_draft'
Filename: matrix/ft.matrix.php
Line Number: 2373
And the matrix field entries are not cloned.
I obviously do not know how to clone the matrix fields in this situation.
EE is V2.7.3 and matrix V2.5.10 Can anyone point me at how to clone the the matrix fields?

# Answer
Turnes out the $\_POST data for my field has everything I needed, and I used it like this:

Instead of

'field\_id\_32' =\> $channel\_form\_obj-\>entry('job\_photos')

I did:

'field\_id\_32' =\> $\_POST\['job\_photos'\]

Makes me wonder why the channel form object did not have that in the first place?
> 1 votes

# Answer
Have you checked out Max Lazars' MX Cloner? The only thing I noticed when I used it is that it didn't work for me when testing locally as it (for whatever reason) didn't show up in the Extensions area. But worked fine when deployed. So you might or might not run into that.
> 0 votes

---
Tags: matrix, pixelandtonic, channel-form, channel-entries-api
---


# Question
Title: Expresso Store checkout: How to display custom field if checkout contains a particular category of product
I need to show a text area custom field inside the checkout\>details just if the order contains a product with a certain category ID. How to do it?

this is the scenario: for example, in my store i sell prints and illustrations. (prints are shipped by post and illustrations are downlodable only) if the details page (next step after checkout) contains an illustration (category\_id XX) I want to show a text area where customer write down all specs, instructions and comments.

for other products, prints and other common items i don't want to show this custom field inside the checkout page

Please advice me! thank you ;)

# Answer
In the checkout and order tags, you can access the `{items}` loop. Inside the `{items}` loop you can use the `{entry_id}` variable to access entry custom fields and categories:

```
{items}
  {exp:channel:entries entry_id="{entry_id}"}
    <!-- you can access category tags here -->
  {/exp:channel:entries}
{/items}

```

Then inside the channel entries tag you can access the regular `{categories}` loop.

See:

https://exp-resso.com/docs/checkout\_tag.html#checkout\_tag\_variables

http://ellislab.com/expressionengine/user-guide/add-ons/channel/channel\_entries.html#categories
> 1 votes

---
Tags: expresso-store, checkout
---


title: VZ Address Directory

text:
# Question
Title: VZ Address Directory
I'm trying to figure out the best setup for a directory. I'm adding a bunch of stores that have multiple locations so I wanted to set up my entry to have one address field as "headquarters" followed by a matrix of all possible additional addresses.

With this format, Would I still be able to have the directory display all addresses in a list equally? As in if someone was to search for nearby locations, they would see 2-3 headquarters of businesses as well as any relevant secondary addresses?

# Answer
How you intend to search the directory is certainly a factor as far as your channel structure is concerned. Are you browsing only? And by category or geography? Or are you introducing a geolocated search functionality?

No matter how you handle the browse/search itself, you certainly should be able to assign one location as a "headquarters" simply by having a relationship field and within the non-headquarters location entries, relate them to their parent location/headquarters (if that is appropriate to the organizational structure).
> 1 votes

---
Tags: ee2, matrix, fieldtype
---


title: Rewriting urls of templates

text:
# Question
Title: Rewriting urls of templates
I have some templates in a group called 'client area'

they include

```
client_area
  - profile
  - editprofile

```

so these resolve to

```
client_area/profile
client_area/editprofile

```

I want edit profile to resolve to

```
client_area/profile/editprofile

```

without having to create a sub group of proifile. Is this possible?

# Answer
I would do this by using a conditional within the client\_area/profile template.

```
{if segment_3=='editprofile'}
    Embed your edit profile template
{if:else}
    Show the user's profile
{/if}

```
> 1 votes

# Answer
Are you using the latest 2.8.x version of EE? If so, you should be able to use the new native Template Routing functionality to achieve this. If you're on an older version you can use the Resource Router add-on (https://github.com/rsanchez/resource\_router) to do the same thing and save yourself embed overhead.
> 0 votes

---
Tags: templates, url, groups
---


# Question
Title: Solspace: Freeform - attachments not uploading
Freeform: 4.1.2 EE 2.7.0

Trying to upload a file with an entry. So far no success.

I referenced this post

Here is my code:

```
{exp:freeform:form
   form_id="1"
   required="name|email|phone1|experience"
   return="page/thank-you"
   notify_admin="yes"
   notify_admin_template="contact"
   file_upload="Resume Uploads"
   send_attachment="yes"
}

```

I tried this for the input field - it looks right but does not upload the file.

```
<input type="file"{freeform:field:file1 show="1"}

```

So I tried this and it simply creates a text area with no file upload options.

```
{freeform:field:file1 show="1"}

```

I have searched the Solspace documentation, but there are no examples and the file upload code does not help.

I would appreciate any assistance on this.

Thanks.

# Answer
In my template, the field looks like this: {freeform:field:attach\_your\_resume}

First, I would try removing the part of your tag that says "show=1" and just use: {freeform:field:file1}

Second, did you create the field called "file1" (from the freeform admin inside EE) And if so, what filetypes did you set it up to accept?

Also, in Expression Engine, have you set it up to allow those kinds of file uploads? Look in: Content-\>Files-\>File Upload Preferences and look at the Allowed File Types for your file upload location.

Then, if that still isn't working, you may need to look at your mimes.php file which is found inside the Expression Engine core.
> 1 votes

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


title: Zoo Visitor email registration refresh

text:
# Question
Title: Zoo Visitor email registration refresh
iv been trying to setup the email registration form for zoo-visitor when I add in all the credentials and hit submit the form just refreshes with a blank form and the error messages says "**The following field is required: Email**"

```
{exp:zoo_visitor:registration_form return='dashboard' class="form" error_handling='inline' error_delimiters='<span class="alert alert-error">|</span>' autologin='yes' allowed_groups='5'}

    <div class="arrow"></div>

    <input type="hidden" name="group_id" value="5">

    <div class="form-group">
        <input id="trainer_firstname" class="form-control input-lg" name="trainer_firstname" type="text" placeholder="First name" value="" />

    </div>

    <div class="form-group">
        <input id="trainer_lastname" class="form-control input-lg" name="trainer_lastname" type="text" value="" placeholder="Last Name" />

    </div>

    <div class="form-group">
        <input id="trainer_phone" class="form-control input-lg" name="trainer_phone" type="text" value="" placeholder="Phone" />

    </div>

    <div class="form-group">
        <input id="email" class="form-control input-lg" name="email" type="text" value="" placeholder="Email" />
        {error:email}
    </div>

    <div class="form-group">
        <input id="password" class="form-control input-lg" name="password" type="password" value="" placeholder="Password" />
        {error:password}
    </div>

    <div class="form-group">
        <input id="password_confirm" class="form-control input-lg" name="password_confirm" type="password" value="" placeholder="Confirm Password" />
    </div>

     <input class="form-submit" type="submit" value="Register" />

    {field_errors}{error}{/field_errors}

{/exp:zoo_visitor:registration_form}

```

# Answer
> 0 votes
Did you check to see if the member\_email is required in your custom field groups?

---
Tags: forms, zoo-visitor, registration
---