title: Adding CKEditor Plugins to Wygwam

text:
# Question
Title: Adding CKEditor Plugins to Wygwam
I'm attempting to add a CKEditor plugin to Wygwam, but the plugin is not showing in the config or editor even after adding it to the extraPlugins config and I have uploaded the CKEditor plugin to the themes/third\_party/wygwam/lib/ckeditor/plugins folder. I am wondering if there is another step, or special configuration to enable CKEditor plugins within Wygwam that I am missing.

# Answer
I had the same issue with the save button which Wygwam removed recently too. It was a bit of a battle but i have it back working now.( the pixel and tonic documentation leaves a lot to be desired on this area)

Ok first of all you need to download the add on from the ckeditor site , in my case it was a save button and I called the folder saveicon with the plugin within in a folder called save ( see the paths below).

Put the folder into /var/www/themes/third\_party/ Then create a folder in /var/www/system/expressionengine/third\_party/ , in my case I called it save. my ext.save.php file is below which you put in the folder you create in third party.

( change it to your own name eg ext.***.php )

In the code below change were I have "save" to your own plugin name and your own file paths

```
<?php if (! defined('BASEPATH')) exit('No direct script access allowed');

class **save**_ext
{
    var $name           = 'Your extension name';
    var $version        = '1.0';
    var $description    = 'discription';
    var $docs_url       = 'URL';
    var $settings_exist = 'n';

    private static $_included_resources = FALSE;

    // Begin calling button functionality and icon
    private $_hooks = array(
        'wygwam_config',
        'wygwam_tb_groups',
    );

    public function activate_extension()
    {
        foreach ($this->_hooks as $hook)
        {
            ee()->db->insert('extensions', array(
                'class'    => get_class($this),
                'method'   => $hook,
                'hook'     => $hook,
                'settings' => '',
                'priority' => 10,
                'version'  => $this->version,
                'enabled'  => 'y'
            ));
        }
    }

    public function update_extension($current = NULL)
    {
        return FALSE;
    }

    public function disable_extension()
    {
        ee()->db->where('class', get_class($this))->delete('extensions');
    }

    public function wygwam_config($config, $settings)
    {
        if (($last_call = ee()->extensions->last_call) !== FALSE)
        {
            $config = $last_call;
        }

        // Check if our toolbar button has been added
        $include_btn = FALSE;

        foreach ($config['toolbar'] as $tbgroup)
        {
            if (in_array('Save', $tbgroup))
            {
                $include_btn = TRUE;
                break;
            }
        }

        if ($include_btn)
        {
            // Add our plugin to CKEditor
            if (!empty($config['extraPlugins']))
            {
                $config['extraPlugins'] .= ',';
            }

            $config['extraPlugins'] .= 'save';
            $this->_include_resources();

        }

        return $config;
    }

    public function wygwam_tb_groups($tb_groups)
    {
        if (($last_call = ee()->extensions->last_call) !== FALSE)
        {
            $tb_groups = $last_call;
        }

        $tb_groups[] = array('Save');

        // Is this the toolbar editor?
        if (ee()->input->get('M') == 'show_module_cp')
        {
            // Give our toolbar button an icon
            $icon_url = URL_THIRD_THEMES.'saveicon/save/icons/icon.png';
            ee()->cp->add_to_head('<style type="text/css">.cke_button__save_icon { background-image: url('.$icon_url.'); }</style>');
        }

        return $tb_groups;
    }

    private function _include_resources()
    {
        // Is this the first time we've been called?
        if (!self::$_included_resources)
        {
            // Tell CKEditor where to find our plugin
            $plugin_url = URL_THIRD_THEMES.'saveicon/save/';
            ee()->cp->add_to_foot('<script type="text/javascript">CKEDITOR.plugins.addExternal("save", "'.$plugin_url.'");</script>');

            // Don't do that again
            self::$_included_resources = TRUE;
        }
    }
}

```

Just be aware that caps matters so use a capital letter for you plugin name where I used it.If this is working properly you should see your extension in the extensions list and you just need to enable it and the icon should appear in the wygwam editor configurations and you can pull it into your toolbar.

( note for some reason when you enable the extension it still shows as disabled in the my list but it is enabled.)
> 2 votes

---
Tags: wygwam, ckeditor
---


# Question
Title: Count and list the consecutive years for 10 years
I would like to know if I can do this using ee or if I have to implement a PHP method. Basically I want a dropdown that lists years from the current year to the next ten years so: 2014, 2015, 2016 ..... until 2024. I want this to obviously change annually without me having to actually add ten years in the list every time it should just loop through.

I know I can get the year using this:

```
{current_time format="%Y"}

```

So are there things I can add or do to this date to get the dropdown I want?

# Answer
Unless it's been introduced in a recent version there is no way to do date arithmetic using native EE tags.

As you say you could do this with a fairly simple bit of PHP which could be added directly to a template or, as is probably better, wrapped up into a plugin. There may well already be something like this available on Devot:ee. For instance, try http://devot-ee.com/add-ons/dt-plugin
> 0 votes

---
Tags: forms, ee, date-format, drop-down
---


# Question
Title: Can I update a customized fieldgroup GUI across multiple channels?
I apply a particular fieldgroup, "Common", to about 15 channels. I've customized my tabs and locations of the fields to make it easier to use. Every time I add a field, it's added to the bottom of the Publish tab, then I move it somewhere else. I don't mind doing this, but I do it times 15 channels, so it gets tedious. Is there any easier way?

# Answer
The simple answer is no. The only reason I am writing more words here is that SE didn't just let me say "no". ;)
> 0 votes

---
Tags: fields
---


title: Wygwam table classes

text:
# Question
Title: Wygwam table classes
In latest version of Wygwam for EE: can I add a custom class to a table without going into view source mode? I am thinking something similar to links, where I can click on the advanced tab and set the class, id, etc. But for tables, there is nothing similar... My clients are not good at viewing or changing source, so this feature would really help if it's available.

# Answer
> 0 votes
This is something I had as well , I have created a custom style for tables which my users added by just adding the name to stylesheet classes under the advanced tab. This is a pain and I contacted pixel and tonic about it and they said it was dropped by ckeditor in the latest version and so it was dropped from wygwam too.

This happened to me before where the save button was dropped by ckeditor/wygwam so i had to bring it into my setup as a plugin as featured here.

Adding CKEditor Plugins to Wygwam

I just haven't got around to see if i can do the same thing for the advanced tab. Also be aware that ckeditor and wygwam have brought back icons and features that were dropped from earlier versions (like the div icon) so it may still be brought back in a future version

---
Tags: wygwam
---


title: Variable SSL and Cookies

text:
# Question
Title: Variable SSL and Cookies
Let's say I have a membership site, and my login page & form are served with SSL: `https://mysite.com/member/login`.

```
<form action='https://mysite.com' method='post' class='login'>
    <!-- login form inputs -->
</form>

```

The user logs in and EE sets a cookie so she remains logged in. It also sets some other cookies to track some other stuff about her. But then the member navigates to my homepage which is **not** served over SSL: `http://mysite.com/`

Are the user's membership cookies now susceptible to being intercepted because they're not being sent over SSL? If they are intercepted, can they be used by a baddie to cause trouble on my site?

Ultimately, should any site with front-end membership functionality use SSL on *every* page, not just pages with sensitive data & forms?

# Answer
> 7 votes
Yes, the cookies are still susceptible to being intercepted. The full set of cookies for matching domains is transmitted by the browser with each page request to that domain, even if the original cookies were set using HTTPS/SSL and the current page is HTTP.

One way around this is by setting the "secure" flag on cookies you set. Any cookies set with the "secure" flag will only get transmitted by browsers when connecting to HTTPS pages. In recent versions of ExpressionEngine there are a few ways to do this. One way is by setting this config variable:

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

```

That'll make sure all cookies set by EE get the secure flag (note: the server must be configured to set the HTTPS environment variable). If you only want to set it for some cookies, you can use the `set_cookie_end` extension hook to put custom logic around cookie requests, making the important ones secure.

Remember that if you use secure cookies for things like the session cookie, cart sessions, etc... those things won't persist in HTTP requests which might lead to some weird UX if you don't account for it in URLs and redirects.

As far as how much trouble bad actors can make with cookies, it depends. With some settings, ExpressionEngine will try to fingerprint session IDs with information like the user agent and other data. This can help because EE won't authenticate a session if the information doesn't match.

The safest approach is to operate over only HTTPS and set all cookies to `secure` (and `HttpOnly`, which EE now does as default). Hardware is very fast with SSL/TLS these days so unless you're running with a lot of traffic or on a complicated setup, you probably won't see much a performance issue.

Let me know if I can provide any other information on this!

# Answer
> -1 votes
.

Why NOT use SSL on every page is a good question? The extra server load is negligible, it makes things much simpler (not detect/re-direct etc) - and it makes the entire site look trustworthy. The main potential disadvantages are if you're using off site assets that are not served over SSL, which will give mixed content warnings.

---
Tags: members, security, ssl, cookies
---


# Question
Title: Store Shipping, Billing & Credit Card Info
I am not sure if this is an appropriate questions for this site - I was just wondering if expresso store automatically saves the user's shipping, billing and credit card details somewhere in the database and at which point (and where) does store save these?

Thanks in advance

# Answer
Store saves the shipping and billing address if they are supplied once the order is submitted. This will show the order details in the CP admin area and you can access it using the `{exp:store:orders}` tags on the front-end. You can see all of the information that store collects about an order by going to the `exp_store_orders` table in the database.

Having said that if you want to link the data the users enters (other then CC details) you will need to goto Store \> Settings \> Order Fields and link them to either member fields you have created or channel fields you created if you are using Zoo Visitor.

Store does not store any CC details on the server at any point except in some cases. Some gateways will allow you to pass back the last 4 digits of the CC number and the expiration dates.

Some gateways allow you to store the users CC details on their servers then create a token which allows you to pass that to the payment gateway provider and they will charge the card through that. Stripe, PayPal Pro, and Authorize.net are all gateways that pop into mind that allow this kind of functionality but as far as I am aware of none of the Store gateways have this feature is enabled by default so you would need to add that functionality to which ever gateway you were using.
> 2 votes

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


title: Is it possible using expresso store?

text:
# Question
Title: Is it possible using expresso store?
I have a requirement and want to check with expresso-store developers whether its possible or not.

Requirements

1. One superadmin who can administer all stores, like adding or deleting a store.
2. Multiple owners can register their own store(s) and should be able to run and maintain their individual store(s). (Like update/publish new products, inventory, sale records, orders, etc)
3. Each owner will be given their own login credentials to manage their stores, products and orders etc.
4. Each store should have a separate URL,for example if my domain URL is www.nisarstores.com,then each store should have a URL like store-1.nisarstores.com,store-2.nisarstores.com etc.
5. Each website will display products related to only that store. For eg. store-1.nisarstores.com will display products only of that store.
6. Orders made on a store should be visible and maintained by respective store admin.
7. The store FE needs to be multi-lingual.

Hope I was clear in explaining my requirement,so please give your feedback whether this kind of requirement is possible using expresso-store or not.

Cheers Nisar

# Answer
> 2 votes
The short answer is no this is not really possible unless you are using MSM or heavily modify the core.

1. This is based upon member groups so someone that is a super admin or has similar privileges should be able to manage the Store settings.
2. Since each store would need to be a MSM site this is not an issue just make sure that each store owner only has access to their MSM site.
3. No problem here this is just default EE membership settings.
4. You would just need to configure your MSM setup properly.
5. Not an issue since store will only display products from the currently active site.
6. Not an issue since orders are site specific.
7. Store does not currently have any support for other third party multi-lingual modules like Publish or Transcribe so you might have a bit of trouble translating things like modifiers, email templates, error messages.

Running a setup like this with using MSM is not an ideal setup in my opinion.

---
Tags: expresso-store, ee2, ecommerce, shopping-cart, simple-commerce
---


title: Webhook no longer working in EE 2.8.1

text:
# Question
Title: Webhook no longer working in EE 2.8.1
I need help with a webhook on a client site which is not working since updating to 2.8.1 and ZooVisitor 1.3.32. When an order is fulfilled in the client's Shopify store it issues a JSON notification instructing EE+ZooVisitor to create/update a member account. Best I can tell Shopify is doing its part but something is no longer functioning correctly on the receiving EE end.

Could this be related to the new XID security requirements? I successfully fixed a form elsewhere on the site by adding the XID hash, but I have no clue where to add that to a webhook without a little guidance.

This was initially set up by an EE developer who has since gone AWOL and left me pretty much stranded. I would greatly appreciate any assistance anyone can offer to get this back up and running ASAP. I’m pretty familiar with EE but my background is primarily on the design side and this is apparently over my head.

# Answer
Solved. Problem was caused by new cross-site request forgery protections in EE. Setting the corresponding webhook action as csrf\_exempt fixed it.
> 1 votes

---
Tags: zoo-visitor, xid
---


title: Export individual ics per event

text:
# Question
Title: Export individual ics per event
I have an event calendar page:

site.com/events/event-calendar

that lists all upcoming events on that one page. Next to each event listing i want there to be an 'Export' button that links to/exports the ics for just that one individual event.

My export button currently links to the 'export' template - a href="export" - with:

```
{exp:calendar:icalendar
    show_days="1"
    limit="1"
    dynamic="off"}
{/exp:calendar:icalendar}

```

but that does not export the ics for the exact event. I have tried playing around with the parameters `date_range_start`, `date_range_end`, `event_id` but can not get it to work. Is it even possible? What do i need to add?

Any help is appreciated!

# Answer
You will want to change your template up

**Export Template:**
**URL: http://mysite.com/events/export**

```
{exp:calendar:icalendar
    event_id="{segment_3}"
    limit="1"
}
{/exp:calendar:icalendar}

```

**Main Template**
**URL: http://mysite.com/events/event-calendar**

```
<h1> Events</h1>
{exp:calendar:events}
    <h2>{event_title}</h2>
    ... Additional Data here...
    <a href="/events/export/{event_id}">Download</a>
{/exp:calendar:events}

```

This will pass the event\_id to your export template properly for each event. As Solspace mentioned in the comments this will **export all occurrence for the event** not just a single occurrence of that event.
> 1 votes

---
Tags: solspace-calendar
---


# Question
Title: Member Import Error - Unable to parse XML
I am trying to import 55 members into a new site. I am using the following format:

```
<members>
 <member>
  <username>myuser</username>
  <screen_name>First Last</screen_name>
  <password type="text">Password</password>
  <email>myname@email.com</email>
 </member>
</members>

```

for the file location I have uploaded the .xml file to the root of the site and listed the name of the file without the server path.

Unfortunately the EE documentation on this topic is woefully thin.

Any suggestions as to what might be missing here?

# Answer
EE's built in Member Importer can be a bit fickle from time to time and the error reporting is.... well it is anything but useful. So I have a list of things that you can try

* Upload the file to the root of your server and try both `../member-import.xml` or `member-import.xml` I have had various results depending on the server environment.
* EE requires `username`, `email`, and `screen_name` to all be unique. This is not only for the members you are importing but existing members in your DB.
* Usernames need to be at least 6 characters (unless you are forcing longer in your config) and can not start with a number.
* If you have any custom member fields setup in your install either make sure that they are all not required or alternatively make sure the required fields are included in your .xml file and that they contain content. For example if `other_app_id` is a required field you need to include `<other_app_id>Something here</other_app_id>` in every record you are importing.
* If your original data was created in Excel and you exported it as CSV file it often creates a funky breaking space that looks like a normal space in most text editors but if you open it in Terminal (Mac) or Notepad Plain Text (Windows) you will see it actually creating a new line. Exporting the original excel file in OpenOffice (Windows) or the latest version of Numbers (Mac) should fix the issue.
* Make sure that your data has been sanitized to remove any special characters that are not valid in XML. From the top of my head I believe they are `&`, `<`, `>`, `"`, and `'`. These characters will have to be converted into XML entities.
> 3 votes

---
Tags: members, import
---


# Question
Title: Solspace Tag and moving tags from one group to another
Is it possible to move some tags from one tag group to another or I need to add them manually and then delete if from exiting group?

Thanks

# Answer
You could have a look at the exp\_tag\_entries database table, in particular the tag\_group\_id column and make manual modifications, it's not recommended without having backups ready and knowing what you're doing.

The best and safest way would indeed be to delete the tag in the Tag CP, then recreate it from an entry form in a Tag custom field assigned to your new tag group. **Note**: when deleting the tag, this tag won't be associated to any entries anymore.
> 1 votes

---
Tags: solspace-tag
---


title: Control Panel PHP Error

text:
# Question
Title: Control Panel PHP Error
I am getting the following error when I go to the My Account section in the CP and click on Edit Profile. It's preventing me from saving my updates.

A PHP Error was encountered Severity: Notice Message: Undefined offset: 0 Filename: cp/myaccount.php Line Number: 349

**EE 2.7.2**

**Modules:**

Calendar 1.8.6

Channel Images 5.4.12

Forum 3.1.13

Facebook Connect 2.1.3

Freeform Pro 4.1.3

Importer 2.2.3

Mailing List 1.0

Pages 2.2

Postmaster 1.4.7

Super Search 2.1.3

User 3.4.5

Wygwam 3.2.1

**Extensions (not listed in Modules)**

Matrix

Playa

Resource Router

Stash

**FieldTypes (not listed above)**

CKI Member List

VMG Chosen Member

# Answer
Line 349 is trying to get the first result from the query to get the member\_data for that user. It appears as if you will see this error any time you try to edit a member that does not exist.
> 0 votes

---
Tags: control-panel
---


title: REST addon error?

text:
# Question
Title: REST addon error?
I'm trying to use http://devot-ee.com/add-ons/rest. In a few of my pages, I am getting this error when I enable debug mode:

A PHP Error was encountered

```
Severity: Warning
Message: strtotime() expects parameter 1 to be string, array given
Filename: rest/pi.rest.php
Line Number: 351

```

The relevant part of the code in `pi.rest.php` is this:

```
// Format dates to unix timestamps
elseif (isset($this->EE->TMPL->date_vars[$index]) and ! is_numeric($child))
{
    $child = strtotime($child);
}

```

I've tried outputting the value of `$child` before the `strtotime` call, and I see:

`array(1) { ["profile_name"]=> string(18) "John Doe" }`

The output is the array representation of the JSON string I expect to be returned to me.

Any ideas what be causing my issues?

**UPDATE 1:**

One of the problems exist when the REST tags are called from inside:

```
{exp:low_search:results
   {if embed:query}query="{embed:query}"{/if}
   collection="forum_topics"
   disable="categories|category_fields"
   limit="25"
   paginate="bottom"
   orderby="date"
   sort="desc"
}

```

When I replace that with just `{exp:channel:entries}` (and remove the `query` param, and replace `collection` with `channel`), the problem is gone. So, it has something to do with Low Search???

**Update 2:**

The other place where this add-on is having issues is when it is inside of:

```
{exp:friends:mine
    member_id="CURRENT_USER"
    reciprocal="y"
}

```

**Update 3:**

I did a `var_dump` in the part of the code that encounters the error. `$this->EE->TMPL->date_vars` has the value `array(1) { [0]=> string(10) "entry_date"}`. `$index` is `int(0)`. And `$child` has the array that I need.

# Answer
ExpressionEngine has had some updates to do date localization and relative dates. The particular line from the core that is causing your issue is `Line 4166` in `expressionengine/libraries/Template.php`.

There are a number of solutions here for your problem.

Ideally line 349 should check to make sure it is a string as well because `strtotime` will only work as expected with a format string.

```
isset($this->EE->TMPL->date_vars[$index]) && is_string($child) && !is_numeric($child))

```

Additionally it could utilize a different tag parameter as well on line 65.

```
$format = $this->EE->TMPL->fetch_param('response_format', 'xml');

```

Either of these changes should do the trick for this scenario, personally I would do both.

If you have a response that comes back as a numeric string it will still try to process it as a date if you don't change the template tag.

I believe the reason you are seeing it only with the `low_search` tag is because you are triggering date processing with the `orderby="date"`.
> 1 votes

# Answer
EE 2.8 will consider any tag variable that contains "format=", "timezone=", or ":relative" a date variable. Do you have any tags within your exp:rest tag pair that contain any of those phrases? For example, these made up variables would be considered date variables: `{foo format="%Y"}`, `{bar timezone="America/Chicago"}`, and `{oldest:relative}`.
> 1 votes

---
Tags: channel-entries, templates, add-on, addons, rest
---


# Question
Title: Is there a way to include jQuery after a Channel Form?
I'm currently creating a Channel Form that has a file field. Because of this, ExpressionEngine wants to include their Javascript and their version of jQuery (version 1.7.2).

In my wrapper template, I already include jQuery right before the close of the body tag (as per best practices at the time of writing). However, including jQuery creates collision errors and the file field has errors (won't allow me to delete files that are already uploaded and doesn't display the upload button.

I can add the parameter of include\_jquery="no" to the Channel Form, which stops ExpressionEngine from loading their version, but the file field still doesn't work at this point.

If I move the inclusion of jQuery in my wrapper template to before the Channel Form (I put it in the head tag), it works correctly, which is what EllisLabs suggests doing. The problem is that I would prefer to leave jQuery at the bottom of the page, so that it doesn't block loading anything else.

Is there any way to keep jQuery at the bottom of the wrapper template, while also being able to use File Fields in Channel Forms?

---

As a minor note: the file field will also only work if you're using a slightly older version of jQuery (\< 1.9), as it currently calls the .browser property, deprecated in 1.9

# Answer
I've had this same problem. I solved it by simply using `{if segment_1 == "abc"}` statements to not include my jQuery on any page (segment) that had Channel Forms loading it's own jQuery.

You can also overwrite the jQuery file that EE/Channel Form includes with your version of jQuery -- I have found EE's version to be slightly different to what I download from jQuery.com
> 3 votes

---
Tags: safecracker, file-uploads, jquery
---


# Question
Title: Trouble with Zoo Visitor checkboxes in a Low Search
I am looking to do a search of a few Zoo Visitor fields that are comprised of checkboxes. This was something I was working on a few months ago and I picked this project back up this week. I am having two different issues and I'm not sure if they are Zoo Visitor or Low Search issues so I figured I would post here to start.

The first issue has to do with the checkboxes themselves. I have three checkbox fields with anywhere from 10 to 50 options. Each option is listed on its own line as specified in "Multi-Select Options" within the channel field settings. A few of the options have commas in them and I'm not sure if that's an issue.

When I go to display these fields within my search, the checkbox fields all behave in very strange ways. All the fields in the low search form follow the same format every time:

```
<fieldset>
  <legend>Fieldname</legend>
  <div>
    <span class="label"></span>
    <div class="group">
        {exp:channel:entries
          site="default_site"
          channel="zoo_visitor"
          status="not closed"
          disable="categories|pagination"
        }

        {mbr_fieldname}
          <input type="checkbox" name="{item}" value="" /> {item}<br /><br />
        {/mbr_fieldname}
        {/exp:channel:entries}
    </div>
  </div>
</fieldset>

```

For two of these fields, some of the checkboxes being displayed have multiple values combined into one value. That is, instead of there being two separate checkboxes for Value 1 and Value 2, one checkbox will contain BOTH Value 1 and Value 2 together. Another one of these fields has multiples of the same value wjthin the list. For example, Value 3 might show up twice for no apparent reason. These values are also not in the order listed when I created the field. I even checked in the database and all the data looks to match what I entered properly the first time. To test this issue further, I created a new checkbox field this evening called testcheckboxes. When I tried to display this new field like so:

```
        {exp:channel:entries
          site="default_site"
          channel="zoo_visitor"
          status="not closed"
          disable="categories|pagination"
        }

        {testcheckboxes}
          <input type="checkbox" name="{item}" value="" /> {item}<br /><br />
        {/testcheckboxes}
        {/exp:channel:entries}

```

No entries show up whatsoever.

The second issue has to do with the checkboxes that DO show up. If I try to check off any of these boxes and search, no member results are found even if I know a particular member has these boxes checked off. The checkbox fields are marked as searchable and the results page has a status="not closed".

I'm hoping to be able to unravel this problem soon but I'm really not sure where to go from here. Any help would be greatly appreciated. Thank you.

# Answer
> 9 votes
# Generating the checkboxes

Take a good look at what you're trying to achieve, and what you're actually doing. You want a list of checkboxes that contains all options for a given Checkboxes field. So, for example, say your `mbr_fieldname` contains 3 checkboxes for primary colors. In that field's settings, you've added the three colors in the `Multi-Select Options` setting, so in your publish form, that would look like this:

```
[ ] Blue
[ ] Red
[ ] Yellow

```

Each entry (member, in your case) is assigned one or more colors, which you can loop through using the `{mbr_fieldname}{/mbr_fieldname}` variable pair. So, this code:

```
{exp:channel:entries ... }
    {mbr_fieldname}
        {item}
    {/mbr_fieldname}
{/exp:channel:entries}

```

...will loop through each **entry** and display each color **for that entry**. It will not display *Blue Red Yellow*, which is what you would be after. Just add a `{title}` to it, and you'll see.

So, if you just want to display the **options** rather than the actual entry values, don't use the Entries tag. Instead, either hard-code the options in your template, or use **Low Options**, which was created specifically for that purpose. With that, you can generate the list of checkboxes like this:

```
{exp:low_options:mbr_fieldname}
    {options}
        {option:value}
    {/options}
{/exp:low_options:mbr_fieldname}

```

Which brings me nicely to your second issue: the filter that doesn't work.

# Filtering entries based on those checkboxes

You want to only display entries based on the option that was checked. How would you achieve this *without* a form or Low Search, but just using the channel:entries tag? You'd use the `search:my_field` parameter, like so:

```
{exp:channel:entries channel="zoo_visitor" search:mbr_fieldname="Red" ... }

```

That means you're going to have to use Low Search's Field Search filter. And as per **How Parameters Work in Low Search**, that means using an input field with `name="search:mbr_fieldname"`.

However, the Checkboxes field allows multiple values, so you want to be able to include multiple values, too. Not a problem, Low Search caters for that, too. So, you end up with this (using proper `<label>`s instead of the `<br>`s):

```
{exp:low_options:mbr_fieldname}
    {options}
        <label>
            <input type="checkbox" name="search:mbr_fieldname[]" value="{option:value}">
            {option:label}
        </label>
    {/options}
{/exp:low_options:mbr_fieldname}

```

Note the `[]` in the `name` attribute and actually setting the `value` attribute, too.

---
Tags: low-search, zoo-visitor, checkbox, channel-fields
---


title: Batch Uploading & Watermarking?

text:
# Question
Title: Batch Uploading & Watermarking?
One of the things we are excited about with expression engine is that watermarking images when uploading is so easy for admins. Unfortunately we have also discovered that files can only be uploaded one at a time. I know that there are plugins that can manage batch uploading but does anyone know if any of them also offer a watermarking feature as well?

# Answer
> 5 votes
Channel Images can do that and a lot of other neat stuff: http://www.devdemon.com/documentation/channel-images

# Answer
> 5 votes
The CE Image plugin has a watermark functionality (and much more), check 'watermark' on this page: http://www.causingeffect.com/software/expressionengine/ce-image/user-guide/parameters

---
Tags: file-uploads, plugin, image
---


# Question
Title: Embed variables aren't correctly parsed in the low search result parameters
Embed variables aren't correctly parsed in the low search result parameters

I have this code for my low search results.

```
{exp:low_search:results
{if embed:author_id}author_id="{embed:author_id}"{/if}
...
{if embed:query}query="{embed:query}"{/if}
}
...

```

Seems simple enough. However, when I outputted the `$data` values in my `low_search_pre_search` hook, I get this

```
array(
['embed:author_id}author_id'] =>
...
['embed:query}query'] =>
)

```

Why did it parse the parameters that way?

# Answer
As I told you earlier today, this is **not a Low Search issue**, but a conditionals parsing issue. If you turn on Template Debugging, you'll see the opening tag just before it is actually executed. It will look something like this:

```
{exp:low_search:results {if embed:author_id}author_id=""{/if} ... }

```

*That* is what's executed, and what EE uses to set the internal `ee()->TMPL->tagparams` array, which in turn is used by Low Search.

But if you change the tag to a native Channel Entries tag, *you will see the same effect*; ie. the unparsed conditional.

Turns out that **if an embed variable isn't set**, that conditional is treated as an **advanced** conditional, and therefore parsed **after** the tags, making them unsuitable to use to set/hide parameters like that.
> 4 votes

---
Tags: low-search, embeds, parameters
---


# Question
Title: Relationships: Show other fields in list for Relationship field when creating an entry
When creating entries, is there any way to configure a Relationship field, so that in the list displayed on the entry form, you see more than just the data from the Title field? Could I have it include data from other fields, especially custom fields?

Background: I have a channel called "Portfolios" which has a Relationship field called "Site Projects." My site works such that a client can enter a bunch of entries in the Projects channel, then create Portfolio entries where they can pick multiple Projects in the Relationship field (Site Projects) to be displayed in a list on the main website.

The problem is that the client entered all the data and there are TONS of entries in the Projects channel. So many that it's hard to tell much about them merely from their titles. They asked if I could set EE up so that when they are entering Portfolio entries, the list for the Relationship field of Site Projects would show data from another custom field or two, as well (like "Project ID" and or "Launch Date") so they know exactly what they are selecting.

# Answer
In the past I used the Title Master add-on (http://devot-ee.com/add-ons/title-master) - and basically created an entry title that had more info in it (channel name in my case due to multiple channels with like-named entries).

I wouldn't use Title Master at the moment as it doesn't look to be keeping up with EE well, but possibly the approach could be done using MS Title Control instead: http://devot-ee.com/add-ons/mx-title-control.
> 0 votes

---
Tags: channel-entries, relationships
---


# Question
Title: How To Retrieve & Preload Users Credit Card Details
Currently I am offering on-site payment with a credit card using PayU's Enterprise API for order checkout. What would be the best way to actually retrieve and preload the credit card fields for returning users?

It is recommended that the merchant website does NOT store the user's credit card details. Is there perhaps any other possible way to achieve this?

# Answer
Let me first start by saying **you should not store users' credit cards data on your servers under any circumstance.** True PCI compliance is super expensive to initially setup and to maintain.

Having said that I am not familiar with PayU's API but I can speak from other payment gateway experience. If your payment gateway supports the feature you will want to implement a token system. This basically works in a few steps:

1. The user goes through the checkout process and enters CC details on your site and opts to save the CC number for future purchases.
2. Depending on the API either you will need to create a token on your end through js/php and pass that along or you send the CC details to the payment gateway and they create the token and send it back to you for storage.
3. When a user comes back in the future you will need to transmit the token over to them and they will process the order as normal.

That is a fairly simple explanation of the steps but should be a good starting point. I know of a few gateways that support this Stripe (doc example), Authorize.net, & PayPal Pro (PayPal's Reference Transactions API).

The Store support team can chime in if I am wrong but I don't think that any of the default gateways support using Tokens currently and I imagine you will have to write an extension and your payment gateway extension to allow Store to handle this properly.
> 4 votes

---
Tags: ee2, payment-gateway, payu
---


title: Invalid payment method

text:
# Question
Title: Invalid payment method
I am getting "Invalid payment method" error from Store, even though the payment method I have set on the for is a valid and activated payment method configured within Store.

In this case, I am using the Stripe payment method, with:

Name: Stripe Short Name: stripe

My tag looks like this:

```
    {exp:store:checkout
        next="cart/confirmation"
        return="cart/confirmation"
        form_class="lj-form lj-same-addresses"
        require="name|address1|region|country|postcode|payment"
        payment_method="stripe"}
      ...
    {/exp:store:checkout

```

What could be causing this error to show up?

**Edit:** After some investigation, somehow it appears that the payment method is being changed to "manual". Still digging.

**Edit 2:** Okay, the manual issue and the "Invalid payment method" were caused by using some sample code that had the manual payment method thing hard coded as a hidden input.

Now what's happening instead is that I'm sent back to the checkout page without any error appearing. I have inline errors turned off.

**Edit 3:** Traced this down to an API error from Stripe. It returned the following error, but with inline errors off, Store did not display it.

```
{
  "error": {
    "message": "Your card was declined. Your request was in test mode, but used a non test card. For a list of valid test cards, visit: https://stripe.com/docs/testing",
    "type": "card_error",
    "code": "card_declined",
    "charge": "ch_1ZMhyw6xhWwp3R"
  }
}

```

So in this case I used one of their recommended test cards and it worked, but that doesn't solve the problem with Store, which is that it doesn't appear to display error messages returned from (some?) APIs in some cases. I had to hack a call to show\_error() into Merchant\_stripe\_response::\__construct to get it to show up:

```
elseif (isset($this->_response->error))
{
    $this->_status = self::FAILED;
    show_error($this->_response->error->message);exit;
    $this->_message = $this->_response->error->message;
}

```

Here's a link to my full template: http://pastebin.com/5zrnQvJN

# Answer
> 2 votes
Thanks for the detailed info.

Correct - setting `payment_method=""` in your tag simply adds a hidden field to your form, and if you have another hidden field in your template that would override the POST data.

With regards to the error message, even if you aren't using `error_handling="inline"` in your checkout tag, you still need to use `{error:payment_method}` somewhere in your template to display errors from the payment gateway. This is because payment gateway errors work slightly differently (they may not show up until the customer is returned from an off-site gateway, so it would be inappropriate to display the EE error page with a "back" button as this would break the checkout flow). We're looking at ways to make this variable behave the same as regular errors, but for now you should have it in next to your payment fields on the final page of the checkout.

Adding `{error:payment_method}` to your template should remove the need for the edit you made above - can you try that?

# Answer
> 0 votes
What you can also try is to use the {exp:store:payment} tag instead of the {exp:store:checkout} tag..

---
Tags: expresso-store
---


title: EE Version Number Error on version 2.4

text:
# Question
Title: EE Version Number Error on version 2.4
I downloaded a current copy of my production database into my development environment. Both the production and development environments are **EE v2.4.0**. When I logged on to the control panel I received the following error message:

> An unexpected error occurred attempting to download the current ExpressionEngine version number. Please visit your Download Account to verify you are on the current version. If this error persists, please contact your system administrator

What is EE checking to determine this? How do resolve it.

---

### UPDATE

My apologies to all readers. It is not EE 1.4 but it is EE2.4. My apologies to all respondents.

# Answer
> 3 votes
You will want to open up your CP and navigate to Admin \> System Preferences \> General Configuration and scroll down to New Version Auto Check and set that to "No". From the EE1 docs:

> **New Version Auto Check**
>
> Enabling this feature will cause a message to be displayed in the Control Panel when a new version of ExpressionEngine is available. It will not automatically download and install a new version.

The reason that you are getting the error is because in EE1 the update script was looking for an xml file on http://expressionengine.com but since EllisLab unified their offerings into the http://ellislab.com domain name it broke things like this. Once you disable the new version check in the CP the error should disappear and there is nothing wrong with getting the error other then it being a pain to see it all the time.

Having said that you are fairly far behind 1.7.3 I think was the last EE1 version and we are currently at 2.8.1 I think with EE2.

# Answer
> 0 votes
A proviso on this answer , it applies to expression engine 2 + , im not sure about EE 1.4 as its so old but its worth a look anyway

Go and edit yourconfig file in /system/expressionengine/config/ .

The first item in the config items list is

```
$config['app_version'] = "281";

```

281 in this case referres to expression engine 2.8.1 which i am running. If you are getting that warning your version of expression engine is different from the value in this config item .To fix it and get rid of the warning just change the value to match the version of EE you are running.

---
Tags: ee2, database
---


# Question
Title: Issue displaying specific category entries
I'm trying to create a native EE blog to move away from wordpress but the native categories are proving to be quite difficult. I've got the listing of categories showing, but directing them to their category template shows all channel entries and not just the category specified in the url. Code is below.

```
{exp:channel:categories channel="blog" style="nested" class="categories"}
    <a href="{path='blog/index'}">{category_name}</a>
{/exp:channel:categories}

```

The click action works as desired and brings you to a url string

```
domain.com/blog/category/category_name

```

Category headings work fine

```
{exp:channel:category_heading channel="blog"}
    <h1>{category_name}</h1>
{/exp:channel:category_heading}

```

Displays "Category Name"

But then the actual categories do not display. It's as if there's simply no entries matching this category.

```
{exp:channel:entries channel="blog" disable="members|pagination" related_categories="yes" custom_fields="yes" dynamic="no" status="Open" sort="desc"}
    <article class="blog-article">
        <figure><img src="{blog_image}" alt="{title}"></figure>
        <div class="blog-details">
                <p>By: {author} <a href="{url}" target="_blank"><i class="icon-twitter"></i></a></p>
                <p> <i class="icon-time"></i> {entry_date format='%F %d, %Y'}</p>
                <p> <a href="{page_url}"><i class="icon-comments"></i> {comment_total} Comments</a></p>
            </div>
            <h1>{title}</h1>
            {intro_text}
            <a href="{page_url}" class="magenta">Read More</a>
    </article>
{/exp:channel:entries}

```

# Answer
> 1 votes
The issue above was solved by changing the dynamic setting. Originally the setting was

```
{exp:channel:entries channel="blog" disable="members|pagination" related_categories="yes" custom_fields="yes" dynamic="no" status="Open" sort="desc"}

```

Changing dynamic="no" to dynamic="yes"

```
{exp:channel:entries channel="blog" disable="members|pagination" related_categories="yes" custom_fields="yes" dynamic="yes" status="Open" sort="desc"}

```

Solved the problem.

---
Tags: categories
---


# Question
Title: PHP string fun does not evaluate unless var is used elsewhere in template
I'm trying to use the PHP String fun plug-in to evaluate whether a current entry belongs to a specific channel and then show/hide a register prompt depending upon that. So I have a snippet:

```
{sn_content_channels_closed} = "content_guides|content_videos|content_white-papers"

```

Then the channel in question is "content\_white-papers", however the template code below fails to return TRUE 'unless' I place the {channel\_name} variable somewhere else in the template in addition to here:

```
{if '{exp:phpstringfun function="substr_count" par1="{channel_name}"}{sn_content_channels_closed}{/exp:phpstringfun}'=='1'}

```

Of course I could do that but I'd like to understand why this doesn't work, Parse order... EE WTF... something else?

# Answer
ugh, I came across what looks like the same thing a while ago: plugin value in a template conditional

It's really odd. You could try ifify: http://devot-ee.com/add-ons/ifify

... though these days I think I'd attempt this more cleanly using Stash's `get_list` with `match` `against` parameters.
> 1 votes

---
Tags: conditionals, phpstringfun
---


# Question
Title: Autofilling existing logged in Expresso Store customer information in checkout fields
Is there some way that when an existing customer is logged in and places something in their cart, that it would autofill their billing information from their existing data, instead of having to re-fill in that information?

# Answer
My billing/shipping fields are coded like this and the info is autofilled:

```
<div class="field {if error:billing_phone}error{/if}">
    <label for="billing_phone">Phone *</label>
    <div class="controls">
        {field:billing_phone}
        {error:billing_phone}
    </div>
</div>

```

OR, as per the **Checkout Tag "Billing Details" docs**, you can code like this:

```
<input type="text" name="billing_name" value="{billing_name}" />

```
> 2 votes

---
Tags: expresso-store, expresso, users
---


# Question
Title: Printing Order Summary in Expresso Store
Does store generate a printable order summary for customers? Anyone do this with any success. Customer wants a "print invoice" button on the order summary page, and I'm not sure how to go about that. I tried using the HTML/CSS email that goes to the customer (that would print nicely), but of course, when I put that in a template called "invoice" and link to it from the Order Confirmation page, it doesn't parse any of the customer/order variables.

# Answer
> 2 votes
Take a look at the **Orders Tag**:

The order\_hash should be present in the "success" page URL as a segment and you can grab that and pass it to another template with a link like this:

```
<a href="/checkout/print/{segment_3}">Print Invoice</a>

```

Then in your "Print" template use the following to get your invoice data:

```
{exp:store:orders order_hash="{segment_3}"}
    {if no_orders}
        {redirect='404'}
    {/if}
    <!-- display order details here -->
{/exp:store:orders}

```

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


# Question
Title: How to get a CDN to work with ExpressionEngine
I've run into this problem before, and took an alternate route. Basically, I'm using MaxCDN to deliver my images/fonts/js/css. To do this I set a global variable to point to the cname for my cdn url (i.e. http://cdn.mysite.com/). The problem is I'm getting all kinds of

> No 'Access-Control-Allow-Origin' header is present on the requested resource.

Errors? I've tried the various .htaccess methods to alleviate this, but nothing seems to work?

Here's what I currently have, which is just the recommended settings from MaxCDN, with the index.php removal for EE:

```
<IfModule mod_rewrite.c>
############################################################################################
#Section 1
RewriteEngine On
IndexIgnore *
Options +FollowSymLinks -Multiviews -Indexes
############################################################################################
# ----------------------------------------------------------------------
# CORS-enabled images (@crossorigin)
# ----------------------------------------------------------------------
# Send CORS headers if browsers request them; enabled by default for images.
# developer.mozilla.org/en/CORS_Enabled_Image
# blog.chromium.org/2011/07/using-cross-domain-images-in-webgl-and.html
# hacks.mozilla.org/2011/11/using-cors-to-load-webgl-textures-from-cross-domain-images/
# wiki.mozilla.org/Security/Reviews/crossoriginAttribute
<IfModule mod_setenvif.c>
  <IfModule mod_headers.c>
    # mod_headers, y u no match by Content-Type?!
    <FilesMatch "\.(gif|png|jpe?g|svg|svgz|ico|webp)$">
      SetEnvIf Origin ":" IS_CORS
      Header set Access-Control-Allow-Origin "*" env=IS_CORS
    </FilesMatch>
  </IfModule>
</IfModule>
# ----------------------------------------------------------------------
# Webfont access
# ----------------------------------------------------------------------
# Allow access from all domains for webfonts.
# Alternatively you could only whitelist your
# subdomains like "subdomain.example.com".
<IfModule mod_headers.c>
  <FilesMatch "\.(ttf|ttc|otf|eot|woff|font.css|css)$">
    Header set Access-Control-Allow-Origin "*"
  </FilesMatch>
</IfModule>

# Removes index.php from EE
RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L,QSA]
# If 404s, "No Input File" or every URL returns the same thing
# make it /index.php?/$1 above (add the question mark)
</IfModule>

```

Unfortunately, I'm still receiving the errors? If I change my sites "site\_url" within the EE config to point to my CDN, and then use {site\_url} it works, but this breaks other things for obvious reasons.

The other thing I found interesting is if I use the Minimee EE module, and set the URL to the cdn, the js and css can be served via the CDN and I don't have problems. However, the caveat here being, any images that point to the cdn within the css files also receive an error.

# Answer
> 1 votes
So it turned out the problem was an ajax call within one of my scripts. I was under the assumption it was image related as the images were the only items receiving an error, they were also not loading. Fonts were loaded, and it *appeared* as though the scripts were loading fine as well.

After removing all the scripts and adding them back one-by-one I was able to pinpoint that it was an ajax call causing the issue.

After adjusting my script I was able to make everything work as expected. The above .htaccess worked fine.

---
Tags: ee2
---


# Question
Title: Varying image compression by upload destination
Is there any way to set a specific level of jpeg compression and vary that according to the upload destination? I'm trying to work out how best to integrate EE's native image upload features with the soon-to-be-standard **picture** element, and in particular to make use of the *compressive images* technique. This method involves saving retina images at maximum compression/minimum picture quality, generally resulting in smaller file sizes than those of non-retina resolutions saved at a more 'normal' compression level.

The problem comes when EE performs any sort of resizing, because it resaves the jpeg at a fairly high quality (level 9 out of 10, I think), which completely undoes the file size benefits of an image originally saved using the *compressive images* method. So either the client must create the retina image at a size that requires no resizing by EE (not very end user-friendly, and doubly-unwieldy if you need more than one size of retina image), or one must do away with trying to use the compressive images method.

I know that CE Image can adjust the compression on the fly, but AFAIK it does so on the image tag itself, which won't mesh very well with the picture element syntax (you'd need to apply CE Image's 'quality=""' parameter to the source srcset attribute of the Picture element… I think). So the only way around it would seem to be to establish separate upload destinations (or specific image-manipulation sub-destinations) that have their own specified compression level.

So I upload a big image, say 1700px wide, to the upload destination *blog\_images*. The max width for the destination is set to 1200px and maximum compression (quality = 0) -- this becomes my retina image. There is also an image manipulation set for that destination that resizes the image to a width of 600px and saves it with normal compression (quality = 9). That becomes my non-retina image. Of course I can imagine various further image manipulations with different compression levels -- mobile size retina and non-retina images, for example.

Is this varying of compression levels possible any way?

# Answer
> 1 votes
There is no native way, and I have not seen anything in the 3rd party market. I would make a good FR - I can see just being able to set the compression level on each image manipulation.

# Answer
> 2 votes
CE Image can output just a URL to a manipulated image. Meaning that it could compress the image on the fly (if the image hasn't already been compressed on a previous page load), and can still output the image's URL where needed. CE Image has a quality= setting for jpg images, and uses filters to optimize png images automatically when possible.

Additionally, CE Lossless can be enabled to take the compression with CE Image even further. Between jpegtran, jpegoptim, optipng, pngout, pngcrush, smushit, and pngquant, those images can be squeezed pretty tight. For example, jpegtran strips all image metadata, provides lossless optimization via Huffmann compression, and changes the images to progressive.

By default, CE Lossless will also compress images as they are uploaded to EE (but that can be disabled in the config).

The smush.it driver for CE Lossless can be used without even having to install anything on the server.

Disclaimer: I'm the author of the CE Image and CE Lossless add-ons.

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


# Question
Title: Cartthrob payment gateway (Worldpay) callback gives "the action you have requested invalid post back"
Using Cartthrob 2.4 and EE 2.7, paying via Worldpay, returns this message:

```
the action you have requested is invalid

```

My guess is its the new security introduced for POST requests, that require a new XID set, so does anyone know how to deal with this for external websites like Worldpay submitting call backs?

Thanks

# Answer
> 3 votes
We have fixed this with a couple of changes, seems Cartthrob has a couple of issues...

1) Based on this post XID POST from third party we added the we added 'csrf\_exempt' =\> 1 into the database for the payment\_return\_action in the Cartthrob exp\_actions table. We do not know if this helped, but seems like we should do it. Carttrhob does not add this in when installed or updated.

2) Next issue the callback URL to enter into Worldpay was not working, http:// or , so we managed to find out this URl should be http://ourdomain.co.uk/themes/third\_party/cartthrob/lib/extload.php/worldpay\_redirect, so we entered that into Worldpay and that works, almost....

3) The callback page showed an error along the lines of "Cartthrob detected an incorrect system folder path, update the system folder path in Extload: extload.php". Or something along those lines. It seems Carttrhob assumes our system folder will be called system. For security we renamed it. Why on earth Carttrhob does not use the setting in EE index.php, and there is no instruction about this, so we updated our system folder path in third\_party/cartthrob/lib/extload.php and now it all works OK.

So I guess 3 issues needed to be fixed to get Carttrhob Worldpay to accept payments.

# Answer
> 0 votes
We were able to get this working by following point 1 above using CT2.4 with EE2.7.2 with the PayPoint.net gateway (https://github.com/dmlogic/ct\_paypoint)

# Answer
> 0 votes
I'm having similar issues with Sagepay and getting nowhere fast (frustrating lack of support!). However, I thought I should add that you can edit extload.php with your custom system name (and location) - so you don't have to stick with 'system'

# Answer
> 0 votes
Due to the new EE security preventing forms being submitted without an XID (therefore third party gateways can't submit POST notifications), we now use this in our config.php file for Payment Gateways

```
/*
|--------------------------------------------------------------------------
| Disable CSRF for Sagepay
|--------------------------------------------------------------------------
|
| This will disable CSRF for Sagepay Request, so payment will work
|
*/
if(stripos($_SERVER["REQUEST_URI"],'/themes/third_party/cartthrob/lib/extload.php/sage_s') !== FALSE)
{
    $config['disable_csrf_protection'] = "y";
}

```

---
Tags: cartthrob, security, xid
---


title: CartThrob Sage Pay error

text:
# Question
Title: CartThrob Sage Pay error
Working with CartThrob and SagePay on a site and get the following error at checkout (after submitting card details):

> HTTP Status Code: 500 HTTP Status Message: The request was unsuccessful due to an unexpected condition encountered by the server. Error Code : 5006 Error Description : Unable to redirect to Vendor's web site. The Vendor failed to provide a RedirectionURL.

Have set up a Valid IP with SagePay. Note this is for dealing with token payments (in recurring subscriptions) and is checking against a test gateway.

# Answer
Due to the new EE security preventing forms being submitted without an XID, third party gateways can't submit POST notifications. The csrf protection needs to be disabled. To prevent disabling the security feature globally, we use this in our config.php file for Payment Gateways:

```
/*
|--------------------------------------------------------------------------
| Disable CSRF for Sagepay
|--------------------------------------------------------------------------
|
| This will disable CSRF for Sagepay Request, so payment will work
|
*/
if(stripos($_SERVER["REQUEST_URI"],'/themes/third_party/cartthrob/lib/extload.php/sage_s') !== FALSE)
{
    $config['disable_csrf_protection'] = "y";
}

```

More information here:

Cartthrob payment gateway (Worldpay) callback gives "the action you have requested invalid post back"
> 1 votes

# Answer
When you post through to Sage Pay from your site Sage Pay will process the transaction for you and feedback the results of the AVS/CV2 checks that have been performed by the card issuer. At this point we will send you a notification post containing these results, your site must then send through an acknowledgment that this POST has been received and letting Sage Pay know how you wish to proceed. You will need to include three fields within your acknowledgment, these are listed below with their descriptions.

* **Status** \- Alphabetic, Max 20 characters. This field can have multiple responses.

+ OK – Send this if you successfully received the notification Post from Sage Pay. Send this unless an error occurs during notification.
    + INVALID – send INVALID if the details you received in the post from Sage Pay were consistent with expectations for this Transaction but you do not wish to accept the transaction. The RedirectURL must still be provided, and Sage Pay will still redirect the Customer back to your site, but the transaction will NOT be settled with the bank. Only send this result if you want to cancel the transaction.
    + ERROR – An error has occurred during your Notification processing. The Sage Pay system will check for a RedirectURL, and if one is provided the Customer will be redirected to your site, but the transaction will NOT be settled with the bank. Only send this result if you want to cancel the transaction and report an ERROR to Sage Pay.

Please Note: OK statuses will allow the transaction to settle and money to move into the Vendor account. INVALID or ERROR responses will prevent the transaction from settling, so the customer will not be charged. You should send OK in all circumstances where no errors occur in validating the Notification POST, so even if Sage Pay send you a status of ABORT or NOTAUTHED, you should reply with an OK and a RedirectURL that points to a page informing the customer that the transaction did not complete.

* **RedirectURL** \- Alphanumeric, Max 255 characters. This is a fully qualified URL (including http:// or https:// header) to which you’d like the customer redirected on completion of the transaction.

Please Note: If you wish to pass parameters back to your own site (such as the session id or transaction code), these should be included in RedirectURL.

* **StatusDetail** \- Alphanumeric, Max 255 characters. This should be human-readable text providing extra detail for the Status message. If Status is not OK, state what is wrong with the Transaction and why you are rejecting it.

If you are receiving an error message and are sending through the correct fields and responses please check you clear your response buffer to remove any header code, comments or HTML. The Sage Pay Server is expecting “Status=” to be the first characters in the response. If it does not see these, it treats the response as though it is an error and fails the transaction.

Please also note that all POSTs must be communicated through ports 80 and 443.

If you are receiving a 5006 error message this would suggest that we are having trouble understanding the information that is being passed to us at this point.
> -2 votes

---
Tags: cartthrob, sagepay
---


# Question
Title: Expression Engine Plugin for Changes Log
Is there a way or a plugin that keeps a log of who changed what for pages and templates \[and other things if possible\]?

# Answer
I found that Audit Pro does the job! Thanks though
> 2 votes

# Answer
There are a couple options available for tracking changes in content:

Better Workflow and Publisher

These do not work for templates, though. I would suggest using Git to track template changes.
> 0 votes

---
Tags: plugin, developer-log
---


# Question
Title: Store order_discount Not Showing In Next Step
Using store, I am creating a multi-step checkout process. The first form is displaying the products in the cart page, second is shipping details form and third is my credit card/payment page.

On my first form the user is allowed to enter a promo code. This refresh the page and displays the `order_discount` correctly, but when going to the next step, it seems as if the `order_discount` tag resets to R0.00. what could be the problem?

# Answer
Check your browser's developer tools network tab to see exactly which fields are being submitted.

My guess is that when the customer clicks through to the next step of the checkout, you are either submitting two `promo_code` fields, or submitting a blank `promo_code` field (which would reset the discount back to $0).
> 1 votes

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


# Question
Title: Error 1096 - No Tables Used - CodeIgniter
I am trying to use one of stores hooks to insert data into the database when displaying the success page after paying online for an order and I get the following error:

```
Error Number: 1096
No tables used
SELECT *

```

This is the function I am calling on the `store_order_complete_end` hook from store:

```
public function store_order_complete_end($member_id) { // hook
    try {
        // generate coupon code
        $coupon_code = 'FLK-' . mt_rand(100000000, 999999999);

        // generate coupon code until code is unique
        while ($this->check_coupon($coupon_code)) {
            $coupon_code = 'FLK-' . mt_rand(100000000, 999999999);
        }

        //-----------------------------------------------------
        // -- inserting into table exp_channel_titles --
        // retrieving the next available primary key value
        $entry_id = ee()->db->insert_id();

        // array containing the data that will be inserted into the database
        $titles = array(
            'entry_id' => $entry_id,
            'site_id' => 1,
            'channel_id' => 8,
            'author_id' => $member_id,
            'ip_address' => null,
            'title' => $coupon_code,
            'url_title' => strtolower($coupon_code),
            'status' => 'open',
            'entry_date' => strtotime('now')
        );

        // insert coupon into table exp_channel_titles
        ee()->db->insert('exp_channel_titles', $titles);
        //-----------------------------------------------------

        //-----------------------------------------------------
        // -- inserting into table exp_channel_data --
        // array containing the data that will be inserted into the database
        $data = array(
            'entry_id' => $entry_id,
            'site_id' => 1,
            'channel_id' => 8,
            //'field_id_44' => $assoc_product,
            'field_id_45' => $member_id
        );

        // insert coupon into table exp_channel_data
        ee()->db->insert('exp_channel_data', $data);
        //-----------------------------------------------------
        /// setting the return value if successful
        $this->returndata = true;

        // returning the data
        return $this->returndata;
    } catch (Exception $err) {
        // returning the exception if any
        return $err;
    }
}

```

Referenced function:

```
public function check_coupon($coupon_code) {
    try {
        // selecting the coupon code field
        ee()->db->select('title');

        // building the conditions
        $query = ee()->db->get_where('exp_channel_titles', array('title' => $coupon_code, 'channel_id' => 8));

        // retrieving the data into a variable
        $result = $this->EE->db->get()->result_array();

        // return true if the coupon exist
        if (!empty($result)) {
            return true;
        }

        // return false if the coupon does not exist
        return false;
    } catch (Exception $err) {
        // returning the exception if any
        return $err;
    }
}

```

# Answer
Try changing this line:

```
$query = ee()->db->get_where('exp_channel_titles', array('title' => $coupon_code, 'channel_id' => 8));

```

To this:

```
ee()->db->where('exp_channel_titles', array('title' => $coupon_code, 'channel_id' => 8));

```
> 2 votes

---
Tags: expresso-store, ee2, error, codeigniter, activerecord
---


title: Removing segments

text:
# Question
Title: Removing segments
I have a products section as follows with a global header that outputs category fields into the meta info and page content:

domain.com/products/ (All top level product categories listed) Template= /products/index

domain.com/products/category/entries/ (Lists the products within current category) Template= /products/entries

domain.com/products/category/list/ (Lists the subcategories for any top level categories that have them) Template= /products/list

domain.com/products/detail (Shows the entry for the product) Template= /products/detail

I'd like to combine index, entries and list into 1 template at index and am trying to do by using a conditional:

{if segment\_2==""} ...shows all top level product categories (This works) {if:else} ...show products within current category specified by segment 2 of URL (can't get this to work) {/if}

# Answer
> 2 votes
Within the products/index template:

```
{if segment_2 == ""}
    Display all top level product categories
    CURRENT TEMPLATE IS /products/index - so would embed another template?
{if:elseif segment_3 == "entries"}
    Lists the products within current category
    {embed=products/entries}
{if:elseif segment_3 == "list"}
    Lists the subcategories for any top level categories
    {embed=products/list}
{if:elseif segment_2 == "detail"}
    Shows the entry for the product
    {embed=products/detail}
{if:else}
    404!
{/if}

```

But, I would recommend that /products/details/XXX is an ugly URL for the customer and for SEO purposes. You can actually do away with this and assume the product url\_title directly at segment\_2, then rely on the {if no\_results} tag to capture the 404. So from the above example, replace this:

```
{if:elseif segment_2 == "detail"}
    Shows the entry for the product
    {embed=products/detail}
{if:else}
    404!
{/if}

```

...with just this:

```
{if:else}
    Shows the entry for the product
    {embed=products/detail}
{/if}

```

...and then in the products/details template:

```
{exp:channel:entries
    status="not Closed"
    channel="products"
    dynamic="no"
    url_title="{segment_2}"
    require_entry="yes"
    track_views="one"
    disable="member_data|pagination"}
    {if no_results}
            EMBED YOUR 404 TEMPLATE HERE
        {/if}
...

```

> **NOTE:** An edit was made to the above answer stripping out quotes and curlies from the conditionals e.g. it was:
>
> ```
> {if:elseif "{segment_3}" == "entries"}
>
> ```
>
> So the amended answer is correct if you're using the latest version of EE (possible v2.9 onwards), but historically with older versions I've encountered numerous issues with conditional parsing if the segment or value is not defined ( `{if:elseif segment_3 == "entries"}` gets parsed as `{if:elseif == "entries"}` if segment\_3 has no value and generates parsing errors. Hence the need to wrap in quotes and define as EE variables.

You can be even more smart with the URLs and do away with all the identifier segments ("entries", "list" and "details"), where you utilise the no\_results tag pair for product details, no results conditional assume the listing, then on the listing detect if it's a top level category or sub category, or if it's a no result, then display 404. If you decide on this path, you'll probably need low2seg and GW Code Has Children.

---
Tags: categories, url, low-seg2cat
---


# Question
Title: Stash - a variable that was set is not showing the correct value
I have this code, setting some information to stash variables

```
{exp:rest parse="inward" ...}
    <h2>foo_1 in exp:rest = {foo}</h2>
    <h2>bar_1 in exp:rest = {bar}</h2>
    {exp:stash:set name="foo_1"}{foo}{/exp:stash:set}
    {exp:stash:set name="bar_1"}{bar}{/exp:stash:set}
{/exp:rest}

{exp:rest parse="inward" ...}
    <h2>foo_2 in exp:rest = {foo}</h2>
    <h2>bar_2 in exp:rest = {bar}</h2>
    {exp:stash:set name="foo_2"}{foo}{/exp:stash:set}
    {exp:stash:set name="bar_2_2"}{bar}{/exp:stash:set}
{/exp:rest}

```

The code above outputs

```
foo_1 in exp:rest = -35.2286
bar_1 in exp:rest = 173.9478
foo_2 in exp:rest = 0
bar_2 in exp:rest = 0

```

...but retrieving them returns nothing. The code below

```
<h1>foo_1="{exp:stash:foo_1}"</h1>
<h1>bar_1="{exp:stash:bar_1}"</h1>
<h1>foo_2="{exp:stash:foo_2}"</h1>
<h1>bar_2="{exp:stash:bar_2}"</h1>

```

outputs

```
foo_1=""
bar_1=""
foo_2=""
bar_2=""

```

# Answer
It's a parse order issue, your setting stash inside outer tags then trying to retrieve outside the order, i'd probably do this:

```
{exp:stash:set parse_tags="yes"}
{stash:results}
{exp:rest ...}
    <h2>foo_1 in exp:rest = {foo}</h2>
    <h2>bar_1 in exp:rest = {bar}</h2>
    {stash:foo_1}{foo}{/stash:foo_1}
    {stash:bar_1}{bar}{/stash:bar_1}
{/exp:rest}

{exp:rest ...}
    <h2>foo_2 in exp:rest = {foo}</h2>
    <h2>bar_2 in exp:rest = {bar}</h2>
    {stash:foo_2}{foo}{/stash:foo_2}
    {stash:bar_2}{bar}{/stash:bar_2}
{/exp:rest}
{/stash:results}
{/exp:stash:set}

```

Then grab the vars like:

```
{exp:stash:get name="results"}
  <h1>foo_1="{stash:foo_1}"</h1>
  <h1>bar_1="{stash:bar_1}"</h1>
  <h1>foo_2="{stash:foo_2}"</h1>
  <h1>bar_2="{stash:bar_2}"</h1>
{/exp:stash:get}

```

OR simply this may work too (add parse to the get function):

```
{exp:rest parse="inward" ...}
    <h2>foo_1 in exp:rest = {foo}</h2>
    <h2>bar_1 in exp:rest = {bar}</h2>
    {exp:stash:set name="foo_1"}{foo}{/exp:stash:set}
    {exp:stash:set name="bar_1"}{bar}{/exp:stash:set}
{/exp:rest}

{exp:rest parse="inward" ...}
    <h2>foo_2 in exp:rest = {foo}</h2>
    <h2>bar_2 in exp:rest = {bar}</h2>
    {exp:stash:set name="foo_2"}{foo}{/exp:stash:set}
    {exp:stash:set name="bar_2_2"}{bar}{/exp:stash:set}
{/exp:rest}

{exp:stash:parse process="end"}
  <h1>foo_1="{exp:stash:foo_1}"</h1>
  <h1>bar_1="{exp:stash:bar_1}"</h1>
  <h1>foo_2="{exp:stash:foo_2}"</h1>
  <h1>bar_2="{exp:stash:bar_2}"</h1>
{/exp:stash:parse}

```
> 1 votes

---
Tags: stash, parse-order
---


title: Control Panel remains Unstyled

text:
# Question
Title: Control Panel remains Unstyled
**Disclaimer**: I have already read and implemented the solution found in the ExpressionEngine 2.8.1 user guide.

**My Problem**: Control Panel is unstyled when viewed from any computer other than the server.

**My Setup**: Turned an old computer into a DIY server in my apartment, running Ubuntu Server. LAMP. Using the free core version of Expression Engine with the idea that I will create a proof of concept, then encourage my employer to buy it for the company's website needs.

**Getting to the Issue**: The server works. Expression Engine installed successfully and I can create channels, groups, etc. When I access the Control Panel from the server computer (in my apartment) everything shows up fine. *But when I access it over the internet at work the Control Panel becomes unstyled. No CSS, no theme, just a lot of unstyled text.*

**Have You Tried Turning it Off and On Again**: As mentioned, I already tried the suggested solution of moving cp\_theme folder into the system folder, then restarting the server. Nothing changed. I have searched all over for any other solutions and have come up empty.

Please help me! How do I get the css and themeing back to my Control Panel so I can work on the website whilst away from home?

Thank you very much for your time and assistance!

# Answer
Every time I've seen this behavior it's due to 1 or 2 reasons:

**Issue#1:** The URL and server path to the 'themes' (or renamed themes folder) is incorrect one too many or too less "/" can do it. The fact it works from the server and not any other computer tells me that your paths may be absolute rather then relative. To check : inspect the CP page in whichever browser you're using from 'remote' PC (not server) and look for CSS files that are 404'ing or any other errors. If errors found, JS issues will also come into play.

**Issue#2:** Uploaded files can become corrupt, upload all content to themes folder once again - you can ignore updating 'third\_party' - to be safe, download the entire zip from EllisLabs to make sure your downloaded file isn't corrupt.

**------UPDATE-----**

There is a setting in the CP

Or you can some manual config settings to /system/expressionengine/config/config.php

**-----END UPDATE-----**

Finally are you running any config master items?
> 1 votes

---
Tags: php, css, cp-themes, stylesheets, cpanel
---


# Question
Title: Stash - {exp:stash:is_empty} or {exp:stash:not_empty} is not working properly
I have this code. Inside the stash tag pair, there is a loop that gets a list of author\_ids based on certain conditions

```
{exp:stash:set name="author_ids" trim="yes" parse_tags="yes" parse_vars="yes"}
    ...
    {!-- TODO: Loop --}
    ...
{/exp:stash:set}

```

I outputted the code below for debugging purposes

```
<h2>exp:stash:author_ids - [{exp:stash:author_ids}]</h2>
<h2>{exp:stash:not_empty name="author_ids"}</h2>
<h2>{exp:stash:is_empty name="author_ids"}</h2>

```

The interesting thing is that this is the output for when I have a list of author\_ids...

```
exp:stash:author_ids - [175|176|]
1
0

```

...and this is the output when there wasn't any author id that was set

```
exp:stash:author_ids - []
1
0

```

This is strange.

In both cases, why does the empty functions of stash return the same result for both cases when its apparent that in one case, the value is empty and the other is not empty?

# Answer
I've tested this in the latest version of Stash on EE 2.8.1 and can't replicate your problem - it works fine for me.

Is there anything else in your template that could be causing it? Are you using the most up to date version?
> 1 votes

---
Tags: stash, parse-order
---


title: Comments Display Error

text:
# Question
Title: Comments Display Error
I have followed the EE 2.8.1 docs to create user comments to be displayed against the relevant channel entry on a singular page, as suggested.

However, the comments from the whole channel overall are being displayed and not just the relating entry itself.

Below is my code if anyone can help?

```
<div class="left-col-pages full-width">
  <h2>Job Applications</h2>
<hr>
  {exp:channel:entries channel="jobs" orderby="title" sort="asc|desc" limit="1"}
  <h3>{vacancy}</h3>
    {exp:member:custom_profile_data}
    {if photo}
    <img src="{photo_url}" alt="{author}" width="60" height="60" class="right"/>
    {if:else}
    <img src="{site_url}images/member_photos/image-member-placeholder.gif" alt="No Image" width="60" height="60" class="right"/>
    {/if}
  {/exp:member:custom_profile_data}
    <p>{vacancy} for {company}, {area}</p>
  <div class="clearfix"></div>
<hr>
  {/exp:channel:entries}
   <!-- Show Applications -->
   {exp:comment:entries channel="jobs" orderby="name" sort="asc|desc" limit="2000" dynamic="no"}
   {if photo}
   <img src="{photo_url}" width="60" height="60" alt="{author}'s photo" />
   {if:else}
   <img src="{site_url}images/member_photos/image-member-placeholder.gif" alt="No Image" width="60" height="60"/>
   {/if}
   <p><small>{comment_date format="%d.%m.%Y"}, {name}</small></p>
   <p>{comment}</p>
   {/exp:comment:entries}
  <hr>
</div>

```

This is placed as an embed should that make any difference?

Thanks in advance Scott

# Answer
> 1 votes
It's the `dynamic` parameter.

If you set it to `no`, EECMS will not filter the comments to the entry on URL.

```
{exp:comment:entries channel="jobs" orderby="name" sort="asc" limit="2000"}

```

---
Tags: comments
---


title: Logical branching with FreeForm Pro?

text:
# Question
Title: Logical branching with FreeForm Pro?
Has anyone done forms with logical branching in FreeForm? Something like, if somebody selects "Other" from a radio group, show + require an "Other" text field? If there are any examples that'd be a great help.

Or is FreeForm not the right place to start for something like this? Thanks for any ideas.

# Answer
> 2 votes
DevDemon's Forms add-on (http://www.devdemon.com/expressionengine-addons/forms) allows you to have conditional fields which only show if a previous field contains a particular value.

See their video on Vimeo for a demonstration (http://vimeo.com/45418039).

# Answer
> 1 votes
I've done similar over the years and by far the best practice is to ask the variables up front in a faux form. Once the variables are answered load the appropriate and ACTUAL form, where you can GET the default fields (name,address etc) from initial form.

I have also used javascript to hide/show content but obviously doesn't have any fall back with JS disabled and getting around Freeforms 'required' setting means removing it via JS - can be consuming to wire together.

There is nothing native with any form solution from EE or Solspace or others as far as I'm aware.

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


title: Freeform Pro & ExpressionEngine

text:
# Question
Title: Freeform Pro & ExpressionEngine
I'm getting a large number of spam from one of my contact forms and not sure how I can reduce this using Freeform Pro.

I've tried using the default CAPTCHA but I can't get that to work. Is there a way I can not allow HTML in the textarea element in my form?

Does anyone have any good examples or tips to help me reduce it?

Thanks

# Answer
> 2 votes
I bought and installed SNAPTCHA when I encountered that kind of issue - worked brilliantly. Easy to install and worth every penny of its really reasonable $14 price tag.

# Answer
> 1 votes
There's a free add-in called "Freeform Anti-Spam" - which adds a honeypot field which can help cut down spam a bit. And you can have it check against blacklists to cut out spammers.

It's free. It's here: http://www.vayadesign.net/software/freeform-antispam (Devot-ee link for reviews and other stuff: http://devot-ee.com/add-ons/freeform-anti-spam)

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


# Question
Title: Can't get my conditional to work inside a Playa field
I want to insert a simple exception, using an "if" statement, into the flow of my Playa field's output. But it's not working. Can I get help?

Here's the code that works:

```
{prac_area_contact_people backspace="3"}
<a href="/people/bios/{url_title}"><nobr>{exp:tagstripper:stripAllTags}{people_first_name} {person_last_name}{/exp:tagstripper:stripAllTags}</nobr></a>,
{/prac_area_contact_people}
{/exp:channel:entries}

```

`prac_area_contact_people` is the name of my Playa field.

I want to add some content to the end of the anchor tag in the 2nd line of the sample above, ONLY when the `person_last_name` field is equal to a certain value.

So I did this:

```
<a href="/people/bios/{url_title}/{if person_last_name == 'pollack'}professional_liability{/if}">

```

The goal is that when the `person_last_name` field is `pollack` it adds on the extra segment in the URL. But the thing fails. What am I doing wrong?

# Answer
> 0 votes
That should work as you have it, unless something else is parsing the conditional before Playa can get to it. Try using Playa’s `var_prefix` param to prevent that:

```
{prac_area_contact_people backspace="3" var_prefix="person"}
    <a href="/people/bios/{person:url_title}{person:if person_last_name == 'pollack'}/professional_liability{/person:if}">
        <nobr>{exp:tagstripper:stripAllTags}{person:people_first_name} {person_last_name}{/exp:tagstripper:stripAllTags}</nobr>
    </a>,
{/prac_area_contact_people}

```

# Answer
> 0 votes
The conditional you are looking for is as follow. You have to parse the variable into a string because of the parse order of the playa field.

{if "{prac\_area\_contact\_people}" == "pollack"} Content {/if}

That should work.

---
Tags: playa, conditionals
---


# Question
Title: How to add items to cart (with cartthrob) via ajax after an ajax login?
So right now I have a scenario where I want 4 fields to add some products to the cart (these are called Device ID, each one represents one product that needs to go to the cart), so here's the code where I added the add\_to\_cart\_form:

```
<div>
                <div class="device">
                    {exp:cartthrob:add_to_cart_form entry_id="device1" price="9.95" shipping_exempt="yes"}
                        <p class="device-id ">Device ID</p>
                        <input class="deviceInput" type="text" name="device1" placeholder="Device Id" />
                    {/exp:cartthrob:add_to_cart_form}
                </div>
                <div class="device">
                    {exp:cartthrob:add_to_cart_form entry_id="device2" price="9.95" shipping_exempt="yes"}
                        <p class="device-id ">Device ID</p>
                        <input class="deviceInput" type="text" name="device2" placeholder="Device Id" />
                    {/exp:cartthrob:add_to_cart_form}
                </div>
            </div>
            <div>
                <div class="device">
                    {exp:cartthrob:add_to_cart_form entry_id="device3" price="9.95" shipping_exempt="yes"}
                        <p class="device-id ">Device ID</p>
                        <input class="deviceInput" type="text" name="device3" placeholder="Device Id" />
                    {/exp:cartthrob:add_to_cart_form}
                </div>
                <div class="device">
                    {exp:cartthrob:add_to_cart_form entry_id="device4" price="9.95" shipping_exempt="yes"}
                        <p class="device-id ">Device ID</p>
                        <input class="deviceInput" type="text" name="device4" placeholder="Device Id" />
                    {/exp:cartthrob:add_to_cart_form}
                </div>
            </div>

```

Then, after that, there are two possible cases:

#1. The user wants to create a new account and add the items to the cart, in this case the items are added correctly and the user only needs to be redirected to the create account form.

#2. The user wants to log in to an existing account, and here's where I'm having problems. The problem is exactly when I'm not logged in and I want to log in, then the items are not added to the cart, the user logs in correctly and is redirected to the right page but the cart has no items on it.

This is the code I'm using to log in:

```
$(document).ready(function() {
        $('form#login-form').ajaxForm(function(arg1, arg2, arg3){
            $("#login-error").hide();
            var response;
            try{
                response = JSON.parse(arg1);
            }catch(e){

            }
            if(response != undefined && response.success == false){
                $("#login-error").show();
                return false;
            }else{
                $("div.device div input[name=XID]").val(response.XID); //thing I tried to work with the add, just adds one item
                submitCartItems();
                window.location = "/purchase/cart"
            }
            return false;
        });
    });

```

And this is the code I'm using to submit the items to the cart:

```
function submitCartItems(){
        $("input.deviceInput").each(function(){
            if(!$(this).val())
                return;
            var form = $(this).closest("form");
            $(form).ajaxForm(cart_form_options);
            $(form).submit();
        });
    }

```

As you can see in a comment in the Login function, I used this to try to play a bit with the XID in the hidden inputs for each add\_to\_cart\_form, the thing is it worked but just for one item, doesn't matter if I try to add all 4 items, only 1 gets added to the cart:

```
$("div.device div input[name=XID]").val(response.XID);

```

So the question is, is there a way to add the items to the cart via ajax request AFTER the login is done, or, is there a guest session/login session involved in the cart managing that's affecting the items being added to the cart?

# Answer
> 0 votes
What I would suggest you do to get that code to load into the template after login is successful, is do a $('div.add2cart').load('path to template with code'); then run your JS to add items to cart after the html loads with the new session information on a logged in user.

---
Tags: cartthrob, login, jquery, ajax, shopping-cart
---


# Question
Title: Deleting thousands of spam Members (not Pending)
I have a site where I forgot to turn off member authentication and it got hit with over 100,000 spam members over a couple of weeks before we caught it. Now they're all full Members so the SQL to delete Pending members doesn't help.

SQL isn't my forte, but from what I've been able to piece together I think this might do the trick, can anyone say if I'm missing anything?

```
DELETE exp_members, exp_member_data, exp_member_homepage FROM exp_members
INNER JOIN exp_member_data
INNER JOIN exp_member_homepage
WHERE exp_member_data.member_id = exp_members.member_id
AND exp_members.member_id = exp_member_homepage.member_id
AND exp_members.group_id = 'x'
AND exp_members.group_id = 'x'
AND last_visit = 0

```

Trying to delete those members who've never logged in.

# Answer
> 0 votes
After backing up your Database i'd run this Query for each one of those tables:

Delete * from myTable where group\_id = 'group\_id\_2\_delete' AND member\_id not in (#,#,#,#); \<\<\<\< Members ids you don't want to delete

---
Tags: ee2, members, spam, delete
---


# Question
Title: Displaying Category Name and Channel Entry Data with Query Module
I have a SQL query set-up to display a list of entries based on the category ID found in the third segment, but I'm having a hell of a time trying to display the category name that goes along with it. This is what I have that's currently working:

```
SELECT
    cd.field_id_19 AS song_number,
    cd.field_id_20 AS song_title,
    cd.field_id_21 AS song_artist
FROM exp_channel_data cd
LEFT JOIN exp_category_posts cp
ON cd.entry_id = cp.entry_id
WHERE cp.cat_id = {segment_3_category_id}

```

I know I have to add a JOIN with the exp\_categories table in order for the exp\_category\_posts.cat\_id to retrieve cat\_name, but have not been successful in working it out.

Any help would be greatly appreciated.

# Answer
> 0 votes
This plugin will give you all of that functionality that you can pass into a channel entries tag. http://gotolow.com/addons/low-seg2cat

Example:

```
{exp:channel:entries channel="channel_name" category="{segment_3_category_id}"}
      {count} of {total_results} of the entries associated with that cat.

      {segment_3_category_name}
{/exp:channel:entries}

```

Hope this helps!

---
Tags: query, mysql, sql, query-module
---


# Question
Title: Calculate Shipping Cost In Expresso Store
Using the store tags for displaying the various items and values for the orders, how would I be able to calculate the shipping cost according to the user's delivery/billing address entered during the checkout process? As the user is checking out, I need to update a sidebar with all the costs, including the shipping cost for which I am using the store tags.

# Answer
> 1 votes
There is a module out there that will integrate with the USPS API and calculate that shipping for you.

http://devot-ee.com/add-ons/expresso-store-usps-shipping

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


title: Pixel and Tonic Playa direction

text:
# Question
Title: Pixel and Tonic Playa direction
I am a channel called products

I need to relate a product to other products

I edit the product say PRODUCT 1 and assign 5 other products to be related to that product PRODUCT 2 PRODUCT 3 PRODUCT 4 PRODUCT 5 PRODUCT 6

Is it possible that when I go to edit one of the related products PRODUCT 2 that its know its related to PRODUCT 1 and it will be displayed/selected in the playa field automatically?

Thanks

# Answer
> 2 votes
What you're describing is reverse relationships. Playa has no such field for the publish page, but it is possible to get the reverse relationship in the templates with the {exp:playa:parents} tag.

---
Tags: playa
---


# Question
Title: Unable to load the requested class: cache
I recently moved a site from local to staging and when I go to the front end or the back end (CMS) it throws this error...

```
Unable to load the requested class: cache

```

Carl Crawley tried to help me via Twitter (https://twitter.com/madebymayo/status/476274119097733120) by suggesting that it is quite possibly that my .gitignore file is blocking anything to do with cache...

So I checked the .gitignore file and there is no reference to any cache files.

I'm using Tower & Beanstalk to run git and deploy. Is there anything *default* in these two that is causing a file not to upload.

**Is there anyway of knowing which file it needs, so I can just manually upload it?**

I'm running EE 2.8.1 and **I did notice they added something to do with *cache* in this version. So maybe thats it. Is there anyway of disabling this?**

http://ellislab.com/expressionengine/user-guide/optimization/caching.html#caching-drivers

EDIT: I changed the cache from file to dummy. I also reuploaded ALL the files via FTP without any Gitignore files interfering with the transfer. I still get this error. Is it something on the server I could change?

Thanks!

# Answer
/system/codeigniter/system/libraries/Cache/Cache.php Has the Cache class - Check this file is on the staging server, also check the permissions.

I've often had similar issues where it's related to case sensitivity and differing servers (my local not being case sensitive, the public servers are) - so also check that the folder and file are in the correct Case.

One key difference with the Cache class compared to any other class is that it's in a sub folder with the name "Cache" (note capital) - but a file search shows all references using the correct case :(

No - there's no way to disable it as it's a core class and will still be referenced.
> 3 votes

# Answer
For me it was my .gitignore file was set to ignore all 'cache/' folders which must be case sensitive.

Changing to explicit paths fixed the issue once I redeployed.
> 2 votes

---
Tags: error, cache
---


title: Cannot get captcha to work

text:
# Question
Title: Cannot get captcha to work
I'm trying to use the new channel form captcha functionality, and I never get the fields displayed, apparently because the {if captcha} conditional always fails. However, like one of the blog posts I saw, when I take the conditional off, I do get a display of the {captcha} image.

I have followed the instructions and have Allow Guest posts set to yes, Guest Captcha set to yes, And I yave Use TrueType Font set to Yes and that font is there in the {site\_url}/images/captchas directory. I just re-affirmed for the second time that my images/captchas directory is set to 0777, although that may not be valid as it's a Windows server. I don't know how to check the GD library, but every other aspect of EE seems to work fine.

I am not able to see any evidence of GD library. As it's a windows server, I'm not sure where to look. Anyone know where in the GUI, or elsewhere, I can see that?

# Answer
If you can see the CAPTCHA sometimes then you don't have a problem with permissions or the GD library.

Are you logged in to the site/CP when you *can't* see the CAPTCHA? There is a setting to show CAPTCHAs only to users that aren't logged in.
> 2 votes

---
Tags: captcha, ee
---


# Question
Title: Entries with structure:child_ids_for:XXX not bringing up any results
I've got an entry tag here that isn't brining in any results whatsoever:

```
{exp:channel:entries entry_id="{structure:child_ids_for:43}" fixed_order="{structure:child_ids_for:43}"}
  //Content
{/exp:channel:entries}

```

However, if I call the structure tag and place it between a pair of `<p>` tags:

```
<p>{structure:child_ids_for:43}</p>

```

The result is: `<p>48|44|49|50|51|52|53|54|55</p>` so that is definitely working correctly.

If I then copy the piped ID list and swap `entry_id="{structure:child_ids_for:43}"` for `entry_id="48|44|49|50|51|52|53|54|55"` everything works as intended.

I'm not sure what the difference between those two code segments are. Can anyone help at all?

Thank you.

# Answer
> 4 votes
The `{structure:child_ids_for:XX}` tag is parsed very late, after plugin tags have parsed. In other words, too late to be used as a tag parameter. The channel:entries tag will receive the unparsed structure tag. You will have to use an embed to get around this:

```
{embed="your/embed" entry_ids="{exp:structure:child_ids entry_id='43'}"}

```

And `your/embed` template:

```
{exp:channel:entries entry_id="{embed:entry_ids}" fixed_order="{embed:entry_ids}"}
  //Content
{/exp:channel:entries}

```

---
Tags: channel-entries, structure, entryid
---


title: Video file Uploading

text:
# Question
Title: Video file Uploading
Does anyone know what file format for videos Expression Engine will allow to be uploaded? I tried MP4 and WMV neither one is working via the upload screen

# Answer
> 1 votes
You can edit mimes.php to add the mime type that you need. It is located

> system/expressionengine/config/mimes.php

For a complete list of mime types that you can add to that file go here: http://www.sitepoint.com/web-foundations/mime-types-complete-list/

---
Tags: ee, video
---


title: How many entries for a given category?

text:
# Question
Title: How many entries for a given category?
Given a category (not the category group), is there a way to get the count entries assigned to that category? I'm hoping for a native EE solution. This seems to suggest that there isn't one: Anyone know of a plugin to show Category count?. Can I do this in EE only?

# Answer
Here is a plugin that will give you the desired result you need without a custom query.

http://devot-ee.com/add-ons/entries-number
> 2 votes

# Answer
I think the simplest and quickest solution if no one wrote a plug-in already would be:

```
{exp:query sql="SELECT COUNT(entry_id) AS cat_count FROM exp_category_posts WHERE cat_id=1"}{cat_count}{/exp:query}

```

Note: Untested.

Obviously replace the cat\_id value with the category ID you want to count entries for. :)

If you don't have the category ID in the URL, but have its category\_url\_title:

```
SELECT COUNT(entry_id) AS cat_count
FROM exp_category_posts AS cp
JOIN exp_categories AS c ON cp.cat_id = c.cat_id
WHERE c.cat_url_title = "{segment_X}"

```
> 1 votes

---
Tags: categories, category-group
---