title: P&T Checkboxes not displaying properly

text:
# Question
Title: P&T Checkboxes not displaying properly
I'm having trouble getting my P&T Checkboxes field to display properly.

My field is {job\_type} and it's options are: full\_time : Full-time part\_time : Part-time

This is the code I'm trying to use, but it doesn't ouptut anything:

```
{exp:channel:entries}
  {job_type backspace="2"}{option}, {/job_type}
{/exp:channel:entries}

```

If I change it to just {job\_type}, it outputs the selected value as part of a list; but if I try to use the proper :ul tag, {job\_type:ul}, it doesn't output anything.

I'm using EE 2.5.5, and P&T Checkboxes version 1.0.3.

# Answer
To get the tag pair to work with EE 2.5.5 and PT Field Pack 1.0.3 you need to modify the ft.pt\_checkboxes.php file and add has\_array\_data = true;

```
class Pt_checkboxes_ft extends PT_Multi_Fieldtype {

var $info = array(
    'name'     => 'P&T Checkboxes',
    'version'  => PT_FIELD_PACK_VER
);

var $class = 'pt_checkboxes';

var $has_array_data = true;

```
> 3 votes

# Answer
artmem,

I just tested this. I have a checkbox (pt\_checkbox) with three options. I threw this into a template to test the output:

```
    {exp:channel:entries limit="1"}
<h1>{title}</h1>
    {pt_check}
    {option_name}: {option}<br />
    {/pt_check}
<hr />
{/exp:channel:entries}

<hr />

{exp:channel:entries limit="1"}
<h1>{title}</h1>
{pt_check:ul sort="asc"}
{/exp:channel:entries}

```

and both sets of tags gave me the correct output, as:

Does a very simple test like that work for you? I'm also testing on 2.5.5 and 1.0.3.
> 0 votes

# Answer
Field Pack 2.0.2 requires EE 2.6 at least. Having same issue with EE 2.5.5 and fieldpack 1.03
> 0 votes

---
Tags: pixelandtonic, pt-checkboxes
---


# Question
Title: How do I import images to a File Field using DataGrab?
I am importing data using DataGrab and need to be able to link image files correctly in the File field.

I tried using this for the path to the image file:

> {filedir\_1}myimage.jpg

However, it doesn't work. What is the correct way to do this?

Here are the values I am uploading:

Thanks!

# Answer
I remember running into this and the problem for me was running Synchronize ( Content \> Files \> File Upload Preferences ) for the upload destination. You also have to have previously uploaded the images yourself via ftp, as DataGrab doesn't do that. Here's a good rundown from the developer on images from a forum thread:

> I am currently writing some better documentation on how to import images, but in the meantime, this is the best way to do it:
>
> 1) DataGrab won’t actually copy the images to the new server - you’ll have to FTP them to a valid File Upload directory.
>
> When you have copied the files to the correct place, you’ll need to synchronise the folder from the Control Panels Content \> Files \> File Upload Preferences page.
>
> 2) The images will need in the correct format in the CSV/XML file.
>
> This format is {filedir\_1}your\_image\_name.jpg where the 1 is the id of the upload folder you have copied the files to. You can usually do this with a search and replace in the file.
> 3 votes

---
Tags: file-uploads, import, datagrab
---


# Question
Title: How do I show how many members are in a member group?
I am creating a summary page that shows the number of members in each member group.

I tried the following but it only displays 1 as the result and there are 25 members in this group:

```
{exp:query sql="SELECT count(*) as active_members from exp_members where group_id=9 "}
    {count}
{/exp:query}

```

What is the correct syntax for this?

Thanks.

# Answer
> 2 votes
You have a conflict of names of variables. "count" is a reserved name.

On all modules of EECMS, the current item number of a loop is parsed on the variable {count}, starting on 1. If you code a query that returns, let's say, 5 rows, your result would be "12345".

Your query returns just one row. The loop will be executed once and returns "1". Of course, you just need one row. You are already using another name. So use it:

```
{exp:query sql="SELECT count(*) as active_members from exp_members where group_id=9 "}
    {active_members}
{/exp:query}

```

---
Tags: query
---


# Question
Title: How are we supposed to manage time and respect localization/DST in EE?
**Context**:

I recently setup EE in production and had some templates that were time-sensitive. In these templates I was using JavaScript to countdown to open a feature in case a member accessed the page in advance. The countdown was basically a difference between `{current_time}` and an entry's Date field.

This was my introduction or rather re-introduction to EE's DST. In the `Admin -> Localization Settings` they literally mean your server's time zone and DST settings, not the settings you want for EE.

**Problem I faced:**

The timing was off by an hour. I would see the correct time as desired when punching in the Date field, but the epoch time stored in the database was actually an hour behind. Yet `{current_time}` in a template was perfectly fine.

**Attempted fix:**

My server's time is in UTC and at present DST is not in observance (I just assumed this is somehow automatic), despite changing those settings the Date field would be stored as "UM5" (GMT -5 or EST, the time zone for New York which is what I want) *and still be an hour behind*.

**Temporary fix:**

Reading up on previous discussions I turned off localization for users and set a Super Admin's setting as the master site default. There is no longer an "Honor the Daylight Saving Time setting associated with each weblog entry?" setting, nor does it seem that anything gets stored associated to a channel or entry (please correct me if I'm wrong here), so this feature seems to be gone altogether. This did the trick for me in the sense I could now put a desired time as seen in YYYY-MM-DD hh:mm \[AP\]M format and get stored with the desired epoch value....

**Problems that remains:**

* All previous entries' time are now behind by an hour. That is not a problem for me at the moment, but I probably wouldn't want that to happen. If a content editor or manager punches in a datetime, say, November 18th at 9 AM, that time should never later on become something different, whether 8 AM or 10 AM.
* What if I want to respect users' localization settings? For now they're off and I couldn't yet determine if they're relevant or not.

I found the following post by post by Ryan Masuga (via this blog entry) which seems very useful for dev/staging/production configs, automating enabling/disabling DST, using a config variable instead of a member's settings (difference between `server_timezone` and `default_site_timezone`), but it doesn't seem like it will affect retrofitting these settings onto all previous dates when that is not desired.

I haven't been exposed to how else this might be a problem so I guess for now how do you keep fields that were saved whilst DST was observed the same even while DST is no longer observed?

EDIT::

Here's a code sample similar to what I use for my configuration (credit to Steven & Adrian for the Gist)

(note it's `$config`, not `$conf`, don't know if the latter legacy thing has any effect)

(For timezone codes like `UM5` below see: Code Igniter: Date Helper: Timezone Reference):

```
// @link http://expressionengine.com/forums/viewthread/195956/#922322
$isDst = date('I') ? 'y' : 'n'; // or see discussion below for timezone-specific dst, not sure if it should be done given EE will make up the difference
/* @link https://gist.github.com/3969207
$dateTime = new DateTime();
$dateTime->setTimezone(new DateTimeZone('America/New_York'));
$dateTime->setTimestamp(time());
$isDst = (bool)$dateTime->format('I') ? "y" : "n";
*/
$config['time_format']           = 'us';
$config['server_timezone']       = 'UTC';
$config['server_offset']         = '';
$config['daylight_savings']      = $isDst;
$config['default_site_timezone'] = 'UM5'; // GMT - 5
$config['default_site_dst']      = $isDst;
//$config['honor_entry_dst']       = 'n'; // No longer exists

```

Any new date fields will be entered properly, however, existing fields will be off by one hour. The problem remains. Entries punched in while DST was on will be off by an hour while DST is off, similarly entries punched in while DST was off will be off by an hour while DST is on (albeit the other direction).

**How do we solve the alternating 1-hour off problem?** The discussion on the github gist does not solve this except via manual database queries...

Edit:

ExpressionEngine 2.6 will be removing these DST issues altogether, which makes me wonder about upgrade issues... and we'll have to do with these config variables already in use in a bootstrap... here's to hoping their docs on the matter will be thorough/comprehensive...

# Answer
> 0 votes
**This is resolved in EE 2.6+** by upping the minimum PHP version so they could make use of native stuff for date/time as well as having reintroduced the `honor_entry_dst` setting.

**For EE 2.6+** See: In EE 2.6 how do we set different localization/timezone site-wide than the server's timezone?

**Prior to EE 2.6** there is one \[commercial\] fieldtype add-on I know of that seems to either resolve or ignore EE's timing issues altogether and that is Low Events.

# Answer
> 13 votes
As Steven said, there is a handy workaround to automatically set the current timezone. Elaborating:

Add the following to your `config.php` file (replacing the `America/New_York` timezone with one from this list of supported PHP timezones):

```
var $dateTime = new DateTime();
$dateTime->setTimezone(new DateTimeZone('America/New_York'));
$dateTime->setTimestamp(time());
$isDst = (bool)$dateTime->format('I') ? "y" : "n";
$conf['daylight_savings'] = $isDst;

```

Note this will only work on PHP 5.3+ (which you are most likely already using, unless your host is extremely outdated).

Source: https://gist.github.com/3969207

# Answer
> 2 votes
Here's a solid work around for fixing the DST issues in EE. https://gist.github.com/3969207

# Answer
> 1 votes
I'd like to cross reference the answer I posted here Forcing DST settings for users.

Even once you nail down the users's localization you might still end up with times that are an hour +/- if you are creating an entry with a date field that end up in a different DST state.

The issue is EE has no record of what the DST state was when the entry was saved. This is fine if all you are concerned with is dates that exist in the past but you will have to re-save entries during the new DST state for dates that occur in the future because they'll be +/- 3600 seconds off.

---
Tags: dst, localization
---


# Question
Title: Exp:resso Store - Single Page Donate Checkout
I am attempting to use Exp:resso Store to create a donation form on a single page. Ideally, the user will go to /donate and pick from a select-menu the donation cause (a custom order field), the amount they'd like to donate (which updates the quantity field on a product called "Donation" with a min price of $1), and all of the billing and credit card form fields.

Since, the {exp:store:checkout} tag is not available unless there is an item in the cart, I've setup a form button that adds the product "Donation" to the cart when clicked and has a return to /donate.

However, I can't use a form button for every link to /donate (e.g. a link added in a paragraph that's managed via a WYSIWYG editor).

Is there a better way to go about this?

Appreciate the help.

# Answer
My solution was to add the product form button on the /donate page inside the {exp:store:checkout} {if no\_items} tag, and using jQuery to submit the form when the page loads. This ensures there is always a product in the cart. Then, the user completes the single page checkout form fields with their desired donation amount (which updates the quantity of the "Donation" product), billing info, etc.

```
{exp:store:checkout}
{if no_items}
<!-- Form button to add product id #20 to cart -->
{exp:channel:entries entry_id="20" limit="1"}
    {exp:store:product entry_id="20" form_class="form-donate" return="donate"}
        <button type="submit" name="submit-now" id="submit-now" class="btn">{title}</button>
    {/exp:store:product}
{/exp:channel:entries}
{/if}
...
Billing, CC, etc
{/exp:store:checkout}

```

The jQuery:

```
<!-- Auto submit .form-donate to add product id #20 to cart -->
<script type="text/javascript">
$(function(){
    $('.form-donate').submit();
});
</script>

```

Interested in any other ideas or solutions.
> 4 votes

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


title: Commerce Add-On + FoxyCart?

text:
# Question
Title: Commerce Add-On + FoxyCart?
**Instead of developing something from scratch is there any existing commerce kind of add-on that could speed up integrating FoxyCart and members?** There are no products, codes, categories, or anything else in my EE yet so how that gets put into EE can be completely subjective at this point, too. I haven't really touched anything asides from the Simple Commerce Module in EE 1.6.x.

For those of you not familiar with FoxyCart it basically does not assume anything about your e-commerce, it doesn't hold products, but it does create customers invisibly on its end (you can use their API/DataFeed to communicate from your end and/or to receive updates on their end). It keeps track of transactions and can make recurring subscriptions regardless of your merchant gateway. You provide FoxyCart with all the information based on your cart/checkout, such as products, discounts, coupons, categories, you make it all up (can be done securely so the data can be determined to not have been tinkered with) and FoxyCart will present your user with a cart, checkout, etc. It's completely open-ended so you can make your own user experience as you please.

# Answer
> 1 votes
Personally I would look at creating your own option. I have done it in the past with just custom fields and building out the product links like they have in the FoxyCart docs or you could build a module if you are comfortable with PHP. I was in the acmecart.com (the new modules name from HCC) beta since late 2010 and have not received an updated build in at least a year (I might not be on their list anymore for new beta releases but I just dont know)

# Answer
> 4 votes
You could look at FoxEE by HCC Development ... though they've been quiet as of late, poking around their forum it looks like they might have an update about to ship.

---
Tags: ecommerce
---


title: P&T Assets + Carthrob

text:
# Question
Title: P&T Assets + Carthrob
Has anyone ever tried using P&T Assets as a field with Carthrob? More specifically, I'm looking to sell photos that are located on my Amazon S3 account. Do you think this will work?

# Answer
I think you should be able to do this using the `{exp:cartthrob:is_purchased_item}` tag.
https://cartthrob.com/docs/tags\_detail/is\_purchased\_item/index.html

You could just check whether or not the logged in member has purchased the product, and conditionally display the assets.
> 1 votes

---
Tags: assets, cartthrob
---


title: How to turn off the developer log?

text:
# Question
Title: How to turn off the developer log?
How do I turn off the developer log?

I already checked the **Output and Debugging Preferences** at the **System administration** section in the CMS but there's no option for that.

# Answer
I've created a bug report at Ellislab and Robin Sowell replied with:

"*And yep, I’ll pass along your request re: turning it off.*"

So maybe the feature will be included in 2.6.2
> 2 votes

# Answer
Can you try by setting within config file:

```
$config['log_threshold'] = 0;

```

Sorry, I didn't try it so not sure if would work for you.

===

The "log\_threshold" setting is detailed here in the docs:
https://ellislab.com/expressionengine/user-guide/general/system\_configuration\_overrides.html#log-threshold
> 2 votes

# Answer
I assume you mean the the notice the appears when there are notices for developers, on the control panel home screen?

AFAIK, you cannot disable the Developer Log. But these notices should only be showing to Super Admins.
> -1 votes

---
Tags: ee2, development, developer-log
---


# Question
Title: Cartthrob MSM site adding products from site 1 in site 2 = £0.00
This one is causing me a headache and I am pulling my hair out! Anyone done this before?

I have MSM set up and want to keep site 1 managing all the products. I am then using categories to only show the desired products on each site.

• Products are showing up fine on both sites.
• On site 1, everything is working ok. Products are adding to cart.
• Site 2 adds the product to cart, but it has a zero value.

I have tried:
• If I hard code a price="" in, it works and adds that value to cart.
• I have set up cookies properly for each site and there is no cross contamination there.
• on\_the\_fly on site 2 has the same £0.00 effect - also the entry ID is being picked out
• Check to see if global prices are zero
• plus everything I can think of.

I am presuming that because I have no product mapping in site 2, that it is breaking there. Does anyone know of a way to maybe manipulate the db to show one channel in both sites?

Any guidance would be greatly appreciated as I am now bald.

Thanks in advance.

# Answer
> 1 votes
Apologies if this seem obvious - and it will get more complex if you have price modifiers, etc, then requiring use of an extension hook and more logic - but why not just hard code the price with the price field's value?

```
{exp:cartthrob:add_to_cart_form allow_user_price="y" price="{product_price}"}

```

(This still excludes using the simpler add\_to\_cart tag, which just accepts an `entry_id`.)

# Answer
> 0 votes
Thanks Derek for your response. I had gone down that avenue and the price modifiers was one issue. I also have ad odd set up as there are four channels for different products. So depending on the channel, I have to run a {if} on the pricing. I ran into a parse order problem with this.

I have found that it IS actually something to do with the session being set. Oddly, if I am logged out, the product adds to cart as 0. If I then log in, and take a look at the cart, the price is set correctly.

I am revisiting this now to see how to fix it. Its an odd one!

---
Tags: cartthrob, multi-site-manager
---


# Question
Title: my matrix field with 3 player columns, 2 text columns has stopped responding in edit
By 'stopped working', I mean that the prompt 'no rows exist yet - create the first one' appears, but clicking on it does nothing. Same for the '+' symbol - clicking on it does nothing.

Everything was working up to this point, and I can still add values to other fields for that Channel. I was able to enter values into columns in this particular matrix fields until recently, plus select entries in other columns using the Playa fields. The templates were also successfully checking the Matrix column values.

The Matrix field includes 3 Playa field types and 2 text. Have I just overloaded it?

Also - the site is in development. It's a friend's website and I'm not familiar with the web host. The site is running quite slowly, and there may be a problem with intermittent IP blocking. Could that kind of thing cause just one Channel field (the last field) to not respond?

# Answer
> 1 votes
OK - solved. I caused the problem myself by changing the type of a field that appeared earlier in the same group. I'd changed it from Rich Text to Wygwam. The corruption or whatever was easier to see when I worked in a different version of the browser. Field titles and descriptions of all fields after that field were showing in red, with an underlined rollover state.. Very weird.

As expected, changing that field type back to Rich Text wasn't enough... so I deleted and recreated it. My original Matrix field with Playa and other fields in the columns was just fine after that.

---
Tags: matrix, playa
---


title: Only show distinct entries

text:
# Question
Title: Only show distinct entries
Is there a way to only show distinct entries using the channel entries tag?

For example, I want to create a list of channel entries that have a city field. The list would show the city name, but there are several entries that would have the same city name. If I use the channel entries tag to display the cities, their would be duplicates.

How do I avoid the duplicates?

Thanks for any help.

# Answer
> 6 votes
If you would like to avoid the duplicates while showing only cities, you can use Query module to populate the cities. Like:

```
{exp:query sql="SELECT DISTINCT field_id_xxx AS city_name FROM exp_channel_data WHERE channel_id=x"}

{city_name}

{/exp:query}

```

You need to replace field\_id\_xxx with correct custom field id.

# Answer
> 0 votes
As Bhashkar says, you can use the query module to do this. However to avoid showing duplicates you will need to add a GROUP clause;

```
{exp:query sql="SELECT field_id_xxx AS city_name FROM exp_channel_data WHERE channel_id=x GROUP BY field_id_xxx"}

{city_name}

{/exp:query}

```

This will ensure that each city name is shown only once

---
Tags: channel-entries
---


# Question
Title: Safecracker prefixing directory name to uploaded file
Has anyone had an instance like this?

I have a Matrix field which contains a Safecracker File upload field.

When I upload a file via this (in the regular control panel) the file uploads but the name has the directory prepended to it.

Say the file was called "my\_document.pdf" and was uploaded to a directory named "documents" would be called "documentsmy\_document.pdf".

EDIT: I have actually "fixed" this now but I don't know if my fix will cause problems further down the line.

Looking at ft.safecracker\_file.php I figured that save method was to blame. Towards the end there is a ternary conditional that prefixes the upload directory name to the file. I've changed that line so it doesn't.

Changing: $output = ($data && isset($this-\>settings\['safecracker\_upload\_dir'\]) && $data !== 'NULL') ? '{filedir\_'.$this-\>settings\['safecracker\_upload\_dir'\].'}'.$data : '';

To: $output = ($data && isset($this-\>settings\['safecracker\_upload\_dir'\]) && $data !== 'NULL') ? $data : '';

Has 'solved' the issue for me but I'm unsure as to whether this was an intentional thing to avoid clashes of filenames that are in different directories - I can't really see how that could happen though. It all seems a bit odd.

# Answer
> 1 votes
I have actually "fixed" this now but I don't yet know if my fix will cause any problems further down the line.

Looking at ft.safecracker\_file.php I figured that save method was to blame. Towards the end there is a ternary conditional that prefixes the upload directory name to the file. I've changed that line so it doesn't.

Changing:

```
$output = ($data && isset($this->settings['safecracker_upload_dir']) && $data !== 'NULL') ? '{filedir_'.$this->settings['safecracker_upload_dir'].'}'.$data : '';

```

To:

```
$output = ($data && isset($this->settings['safecracker_upload_dir']) && $data !== 'NULL') ? $data : '';

```

This has 'solved' the issue for me but I'm unsure as to whether this was an intentional thing to avoid clashes of filenames that are in different directories - I can't really see how that could happen though. It all seems a bit odd.

UPDATE: I've seen some weirdness with some Safecracker fields not returning any data (although passing a conditional check to see if they're populated). This could well be related to my hack - although again I am not sure why. The data in these fields was existing prior to my hack and they were working afterwards but suddenly stopped working.

Changing the fieldtype to a regular file field and back to a Safecracker file field *seems* to have sorted it so I am not sure what happened.

---
Tags: matrix, safecracker, file-uploads, filename
---


title: Safecracker - No channel was specified

text:
# Question
Title: Safecracker - No channel was specified
I'm trying to use Safecracker for a job application form so that all applications will be registered as entries in a channel called job\_applications.

So I have this:

{exp:safecracker channel="job\_applications" return="/inside\_town\_hall/administration/human\_resources/career\_opportunities" }

\[some code...\]

{/exp:safecracker}

And yet when I try to view the form, I just get a "No channel was specified" error message... I double-checked (more like fifty-times-checked) the spelling of the channel and all. I even tried another of my channels as a test and none worked. I also tried to replace the 350-or-so lines of code inside the tag pair by a basic "input name="title" type="text"" and "input type="submit" value="Submit"" and it still doesn't work.

I feel like this is probably some really stupid error but I can't think of anything. Is there some setting I have to change to make it accept my channels or something? I'm not really used to ExpressionEngine and SafeCracker so I might be forgetting something basic.

# Answer
> 1 votes
I have run into this before, and here is how I fixed it: If the user filling out the job application is not a member of the site, in Add-ons \> Modules \> Safecracker, you will need to "allow guests to post entries" on that channel (if you don't have a guest member account set up, you will need to create one). Then in your safecracker tag, you need to add logged\_out\_member\_id="3" where 3 is the id of your guest member account.

---
Tags: safecracker, channel
---


title: Embedding templates with conditionals

text:
# Question
Title: Embedding templates with conditionals
I have a basic expressionengine template which I am using to display entries for 2 different channels. I am using an embed to pass different page layouts within the center of the template, this is based on conditionals.

```
{exp:channel:entries channel="dog|cat" limit="1" dynamic="yes"}
  (basic html here)
    {if channel == "dog"}
      {embed="tg/one"}
    {if:elseif channel == "cat"}
      {embed="tg/two"}
    {/if}
  (some basic html here)
{/exp:channel:entries}

```

I have also tried using..

```
{exp:channel:entries channel="dog|cat" limit="1" dynamic="yes"}
  (basic html here)
    {if category_id == "100"}
      {embed="tg/one"}
    {if:elseif category_id == "200"}
      {embed="tg/two"}
    {/if}
  (some basic html here)
{/exp:channel:entries}

```

When loading the final page, the parent template displays fine but doesn't show the appropriate embed or any embed for that matter.

It's probably worth noting that the embeds do not contain any expressionengine code, just html. Could someone please explain what I am doing wrong or the best method to accomplish this?

Thanks

# Answer
Robert!

First of all, let's fix your conditionals.

Conditionals using numbers don't need quotation marks. From docs:

> If you are testing against a word, you should enclose the word in single or double-quotes. If you are testing against a number, then you do not need to use quotes.

So:

```
{if category_id == 100}

```

Even so, this code doesn't work because {category\_id} is available just inside the {categories} variable pair.

The better way to compare the name of a channel is using its short\_name. Usually the name is titlecase or it has special characters. So:

```
{if channel_short_name == "dog"}

```

Now, I suggest you to just use embeds if you really need them. Since you just need HTML on them, try to use a global\_variable, for better performance.
> 4 votes

---
Tags: templates, conditionals
---


# Question
Title: /member URLs getting hammered, locking up server
**Please note: The /member URL has been reconfigured already. The issue is traffic on the non-existent URL.**

I have a client who has been running EE 1.6.1. He recently inquired with me about a large number of failed delivery emails he was receiving in response to emails originating from the server. I recommended we go ahead and upgrade his site to get things current and mitigate any issues.

His site was on a basic Media Temple VE server, so the OS & PHP were outdated. As part of his site upgrade I launched things anew on a Rackspace Cloud server running Ubuntu 12.0.4 and the latest apt-get PHP5.

I did not upgrade the original site. I installed EE 2.6.1 and migrated his templates and content in.

He'd been getting "back door" registrations via the default `/member` URLs for years. Most were trapped in Pending. Some where in Members. All were generating emails to non-existent inboxes, which was the source of all the email he was getting.

**Fast-forward to today:**

We're seeing the emails decrease. However, we're seeing a large volume of requests hitting the new site on the now non-existent /member URLs. `Allow New Member Registrations` is set to `No` and I've changed the `Profile Triggering Word` to a non-default value.

During high-volume episodes of requests on these URLs, we're seeing memory usage spike on the server and the server ultimately locking up. I've resized the server from 512MB to 1024MB (after having to reboot it) to mitigate the issue. Most of the time it's functioning quite well within 512MB (and I recently launched another client's site on an identical server with MSM, who's serving up more pages just fine with 512MB). It's the bombardment of requests on `/member` URLs that are killing the server, and this wasn't an issue on the old site where those URLs actually functioned.

Has anyone dealt with such an issue? Is there away to mitigate this without continuing to throw more RAM at the server or employ edge caching? I have a hard time viewing this as simply a matter of traffic spiking, because we were seeing this volume of hits on the old server. The only difference was that it was able to respond.

I do have `Enable Strict URLs` set to `Yes` and the `/member` URLs are returning EE's 404 page.

I'm going to look at tweaking settings in Apache next. If anyone can recommend any other solutions from experience, I'd love to hear them. The site went down last night at a time that coincided with a regular spike in emails on the old server. The pattern is clear. The server was at the 1024MB RAM size overnight, so even that was insufficient during peak volume.

I have logrotate enabled for the virtual host's access logs and set a max file size of 5MB to keep things in check there. They look to be hitting 10-20MB over the course of a day, most of which is `/member` URLs of various form.

Thanks!

**Update: User Agents that I'm seeing**

Culprit User Agents are consistently:

`Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1;)`

There are a few /member/email\_console/##### requests from:

`Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)`

But they're not the high-volume ones.

**Update 2**

Thanks to @jo\_nnbc's advice, I have the following now. We'll see if this puts a damper on things:

```
Redirect 410 /member

BrowserMatchNoCase "Mozilla/4\.0 \(compatible; MSIE 6\.0; Windows NT 5\.1; SV1;\)" bad_bot
BrowserMatchNoCase "Mozilla/5\.0 \(compatible; Googlebot/2\.1; \+http\://www\.google\.com/bot\.html\)" bad_bot
Order Deny,Allow
Deny from env=bad_bot

```

**Update 3**

After further review, here's what I have in .htaccess:

```
Redirect 410 /member

BrowserMatchNoCase "Mozilla/4\.0 \(compatible; MSIE 6\.0; Windows NT 5\.1; SV1;\)" bad_bot
BrowserMatchNoCase MJ12bot bad_bot
BrowserMatchNoCase Ezooms bad_bot
Order Deny,Allow
Deny from env=bad_bot

```

I've also checked a few of the IPs using whois.sc. They're all from China. I've added the following to my iptables:

```
-I INPUT -m iprange --src-range 120.40.0.0-120.43.255.255 -j DROP
-I INPUT -m iprange --src-range 59.56.0.0-59.61.255.255 -j DROP
-I INPUT -m iprange --src-range 27.152.0.0-27.159.255.255 -j DROP
-I INPUT -m iprange --src-range 216.244.78.160-216.244.78.175 -j DROP
-I INPUT -m iprange --src-range 110.80.0.0-110.87.255.255 -j DROP
-I INPUT -m iprange --src-range 36.248.160.0-36.248.191.255 -j DROP
-I INPUT -m iprange --src-range 219.154.0.0-219.157.255.255 -j DROP

```

# Answer
Are you able to see where they are coming from? Is it coming from random user agents or specific ones? Or is the user agent blank?

htaccess blacklist any strange user agents if that helps. Or block by some country ip addresses for now if it is specific.
> 4 votes

# Answer
I would suggest installing Fail2Ban - it is a process that will monitor your logs and ban (via iptables) IPs that are trying to log in at excessive rates, or otherwise exploit your server.

Linode has a good writeup on how to set it up: https://library.linode.com/security/fail2ban
> 2 votes

# Answer
Add this to your config.php:

`$config['profile_trigger'] = md5(mt_rand());`

This will hash the /member value and is completely unguessable by bots.
> 1 votes

# Answer
EE's 404 page is still an EE/PHP page generation. You might lessen the server load even more with a command like this in your .htaccess file:

```
redirect 301 /member http://pickabaddomain.com

```

That way Apache is telling them to bug off.
> 0 votes

---
Tags: members, apache, memory
---


title: Filter using check boxes

text:
# Question
Title: Filter using check boxes
I have searched everywhere for a solution to this problem but have yet to find one.

I have a form whereby a user can filter Recipes by type and meal time. There are 10 types and 4 meal times. They are all check boxes.

What I need to happen is that when a user selects multiple types/meals they are return with filtered entries.

I have looked into dynamic parameters but it only allows one 'type' and one 'meal time' to be returned and isn't ideal.

I did consider using segments but it would result in a long URL which I would have to use PHP on to separate 'types'/'meals times'. I also considered using POST but it didn't work as expected.

Will I have to resort to Vanilla PHP for this and if so can someone provide a few pointers.

Thanks

# Answer
> 2 votes
Low Search
http://gotolow.com/addons/low-search

Assuming your types/times are categories (which it sounds like they are)...

In your `{exp:low_search:results}` tag, you should use `require_all="category"`. This will make sure the results only match entries with *all* the selected categories.

Your checkboxes should all be named `category[]`.

```
{exp:channel:categories channel="recipes" style="linear"}
  <label><input type="checkbox" name="category[]" value="{category_id}"{if category_id IN ({low_search_category})} checked{/if}> {category_name}</label>
{/exp:channel:categories}

```

# Answer
> 0 votes
Yes, you will have to use PHP. You can create an Extension or Module and an ACTion URL to keep it clean. EE was not designed to handle this much data in an "SEO-friendly" or non-programmatic manner.

---
Tags: filter, checkbox
---


# Question
Title: How do I use a conditional to filter channel results?
I need to be able to display only a subset of channel entries based on membership expiration date.

I am looking to display only those entries where the Expiration Date is less than or equal to today.

Here is the code:

```
{exp:channel:entries channel="member_profiles" group_id="9|10|11|12|13|14|15"  orderby="business_expire_date" sort="asc"}
 {if {business_expire_date format="%U"} <= {current_time format="%U"} }
    <tr class="{switch='odd|even'}">
        <td><a href="/member-reports/profile/{url_title}">{member_business}</a></td>
        <td>{full_name}</td>
        <td>{business_enroll_date format="%M %d, %Y"}</td>
        <td class="expired"> {business_expire_date format="%M %d, %Y"}</td>
    </tr>
    {/if}
{/exp:channel:entries}

```

When I load the page I get the following error:

> Parse error: syntax error, unexpected T\_IS\_SMALLER\_OR\_EQUAL in /home/...

How do I modify the {if} statement to correct that?

Thanks.

# Answer
You should wrap your dates in quotes.

```
{if "{business_expire_date}" <= "{current_time}"}

```
> 3 votes

---
Tags: conditionals
---


title: Exp:resso Store: Min/Max Order Quantity

text:
# Question
Title: Exp:resso Store: Min/Max Order Quantity
I am using Exp:resso Store to manage a shop that needs the ability to set a minimum number of products purchased, and a maximum. For instance, we may require that 4 spoons be purchased, but no more than 24. Any number between those is valid since the spoons do not come in packages of 4.

At first glance, the Store custom field allows us to set a total quantity in stock (next to the "Limit Stock" checkbox), and to set a "Min Order Quantity."

If I set "Min Order Quantity" to 4, the cart will still allow me to add a single product.

Question #1: Why is that?

Question #2: While looking at this, I found several references to "max\_order\_qty" in the code for the shipping module. Is there a way to apply this to a specific product in the cart?

# Answer
That doesn't sound right - can you please email support@exp-resso.com with CP login details so that we may investigate this issue for you.
> 0 votes

---
Tags: expresso-store
---


title: Stash preparse and CE Cache

text:
# Question
Title: Stash preparse and CE Cache
I'm having a hard time wrapping my head around this.

I'm using Stash template partials approach, with the needle/haystack technique for replacing variables in content blocks... with CE Cache over the top.

My template looks like this:

```
{!-- Embed view/layout --}
{stash:embed:layouts:default}

{exp:ce_cache:it id="model"}

  {exp:channel:entries ...}
    {!-- Get video data from matrix field --}
    {cf_page_videos}
      {exp:stash:set name="video-{row_count}" type="snippet"}
        {mx_video}
      {/exp:stash:set}
    {/cf_page_videos}

    {!-- Vars to go in view/layout --}
    {exp:stash:set}

      {stash:title}{title}{/stash:title}

      {stash:content}
        {!-- Parse this so the {video-1}, {video-2} snippets within will work --}
        {exp:stash:parse}
          {cf_page_content}
        {/exp:stash:parse}
      {/stash:content}

    {/exp:stash:set}
  {/exp:channel:entries}

{/exp:ce_cache:it}

```

My view/layout template looks like this:

```
{exp:ce_cache:it id="view"}

  <h1>{exp:stash:title}</h1>
  {exp:stash:content}

{/exp:ce_cache:it}

```

Everything works just fine when CE Cache is **disabled**.
When I enable it, the 'view' cache fragment shows something like:

```
<h1>Page Title</h1>
<p>This is the page content</p>
<p>{video-1}</p>
<p>Some more content</p>

```

If I change `{exp:stash:parse}` to `{exp:stash:parse process="end"}`, then the 'view' cache fragment will look something like:

```
<h1>Page Title</h1>
{d534s5d782yihu542u78fdhs894sh}

```

I don't know what I need to escape or modify to get this working.
Any suggestions would be appreciated!
Thanks

**Update:**
The latest version of CE Cache has some Stash-related improvements.
Updating fixed the issue but introduces a Stash bug.
Also, I need to use `{exp:stash:parse process="end"}`.

I get a PHP error on the first page load, but everything seems to get cached correctly and the subsequent page loads are perfect.
I've taken this up with Mark and will post an update later.

**Update 2:**
Aaron (CausingEffect) has fixed the issues in the latest version of CE Cache.
The above code works perfectly - provided you use `{exp:stash:parse process="end"}`.

# Answer
> 0 votes
This issue is fixed by updating CE Cache to the latest version.

# Answer
> 1 votes
I set up my templates differently from you with regards to CE Cache. I wrap the whole template in CE Cache tags so that includes the embedded layout template too.

Page template

```
{exp:ce_cache:it id="the-template"}
{embed="layouts/index"}
...rest of page...
{/exp:ce_cache:it}

```

and then don't wrap the layouts/index template in CE Cache tags but instead use escape tags for bits I don't want cached.

---
Tags: stash, ce-cache
---


title: MX Grid Lite: image not shown

text:
# Question
Title: MX Grid Lite: image not shown
this is the first time i’m using grid lite (i need it for a gallery)

I’ve the following code

```
<div id="galleria">
          {!-- Grid Lite --}
          {exp:channel:entries channel="galleria"}
            {immagini}

              <img src="{immagine}" />

            {/immagini}
          {/exp:channel:entries}

</div>

```

where {immagini} is the grid lite’s fieldtype , and {immagine} is the grid lite’s column but the content not shown

I’m doing something wrong? Thanks

# Answer
Was a bug in grid lite

today max lazar will fix it
> 1 votes

---
Tags: image
---


# Question
Title: Prevent content editors from adding "$" to field
I'm using CarthThrob and a modify by quantity price field (CartThrob Price - Quantity). What it does:

1-3 = $5

3-9999 = $4

It lets you set a lower price as you buy more. Nice feature, but the people entering the data are adding a $ before the prices. You need to enter just the digits: 5 not $5. If the $ is added it breaks the order total calculations. All kinds of weird stuff happens, mainly the effected products are free.

How can I prevent users from entering the $ value? The setting on the field don't let me choose numeric and the CT docs don't mention this little (Big) problem.

# Answer
If your site is in HTML5, try using patterns. This answer assumes you have template-level control over the form you provide people for the price, as in Safecracker (but you'll have to explicitly code your forms, and NOT use the {display\_field} inside the custom\_fields loop.)

`<input type="text" placeholder="" name="" pattern="[0-9]* value="{cf_name}">`

or perhaps

`<input type="number" etc="etc" pattern="[0-9]*>`
> 2 votes

# Answer
Workaround it with JS - either via a custom accessory or, easier, the CP Add CSS/JS Add-on:

Install the CP CSS & JS add-on from here: http://devot-ee.com/add-ons/cp-css and put this in the settings for Custom JavaScript:

```
if ($('.cartthrobPriceQuantityThresholds').length){
    $('.cartthrobPriceQuantityThresholds input').blur(function(){
        $(this).val( $(this).val().replace(/[$]/g, '') );
    });
}

```

Done.
> 1 votes

---
Tags: cartthrob, custom-fields
---


# Question
Title: Using Stash to set Custom Field based on URL with Freebie
I'm building a multilingual site, which has a fallback to English if the article isn't available in the users selected language. I'm using freebie\_1 to switch the custom field for each language.

I'm still fumbling my way round Stash and guessing the following code should work. However, on the front end I'm only seeing `{cf_news_title_en}`

How can I pass the `{lang}` variable in to the custom field to render correctly?

```
{exp:channel:entries channel="news" dynamic="off"}

    {if "{cf_news_title_{freebie_1}}" != ""}
        {exp:stash:set_value name="lang" value="{freebie_1}"}
    {/if}

    {if "{cf_news_title_{freebie_1}}" == ""}
        {exp:stash:set_value name="lang" value="en"}
    {/if}

    {exp:stash:append_list name="news"}

        {stash:news_title}{cf_news_title_{lang}}{/stash:news_title}
        {stash:news_page_url}{site_url}{freebie_1}/news/{url_title}{/stash:news_page_url}
        {stash:news_intro}{cf_news_intro_{lang}}{/stash:news_intro}

    {/exp:stash:append_list}

{/exp:channel:entries}

{exp:stash:get_list name="news" type="snippet"}
    <article>
        <header>
             <h2><a href="{news_page_url}">{news_title}</a></h2>
        </header>
        {if news_intro != ""}<p class="lead">{news_intro}</p>{/if}

    </article>
{/exp:stash:get_list}

```

# Answer
To make "{cf\_news\_title\_{freebie\_1}}" to work, freebie has to be parsed early.

So, let's create an alternative to this.

If all of the first segments of URLs is code of languages, on your config. php, add this:

```
global $assign_to_config;

if(!isset($assign_to_config['global_vars']))$assign_to_config['global_vars'] = array();

$lang_code = substr($_SERVER['REQUEST_URI'], 1, 2);
$assign_to_config['xml_lang']               = $lang_code;
$assign_to_config['language']               = $lang_code;
$assign_to_config['global_vars']['cv-lang']     = $lang_code;

```

This way, you can use {cv-lang} instead of {freebie\_1}.

By the way, I think you can do all of this without stash.
> 1 votes

---
Tags: stash, multilingual, freebie
---


# Question
Title: Matrix Fields Causing Page to Load Very Slowly
I am running the latest version of Expression Engine (2.6.1) and Matrix (2.5.5).

I created a Matrix field for an Award Winners listing for our website, with 2 fields - the first being Field Pack - Dropdown (for award years) and second being plain text (winner's name). In my actual code, I am pulling out the award winners in a list by year like so:

```
    {if award_list!=""}

        {award_list sort="desc" limit="150"}

            {if award_year=="{prev_row}{award_year}{/prev_row}"}

            {if:elseif award_year=="{next_row}{award_year}{/next_row}"}

            {if row_index!="0"}<br />{/if}<br /><strong>{award_year}  </strong>

            {if:else}

            {if row_index!="0"}<br />{/if}<br /><strong>{award_year}  </strong>

            {/if}

            {if award_year!="{next_row}{award_year}{/next_row}"}{award_winner}{if:else}{award_winner}, {/if}

        {/award_list}

    {/if}

```

This does run successfully, but locks up when looking for the Matrix channel\_entries\_tagdata. This what the template debugging says:

```
(0.084529 / 5.51MB)       -> Class Called: Channel
(0.087144 / 5.65MB)       -> Method Called: entries
(0.139607 / 8.05MB)      Calling Extension Class/Method: Assets_ext/channel_entries_query_result
(0.177234 / 9.17MB)      Calling Extension Class/Method: Playa_ext/channel_entries_tagdata
(0.179309 / 9.20MB)      Calling Extension Class/Method: Matrix_ext/channel_entries_tagdata
(4.989313 / 9.99MB)       -> Data Returned
(4.989540 / 9.98MB)       - End Tag Processing -
(4.989713 / 9.98MB)      Processing Advanced Conditionals
(5.837677 / 10.04MB)      Processing Sub Template: includes/footer

```

I wasn't sure if there was an issue with my if statement, or there is another issue going on with the fieldtype. Any help would be great.

# Answer
How many database queries is your template code generating? If you're not sure, turn on EE's Output Profiler. `Admin > System Administration > Output and Debugging.`

Every time you use the `{prev_row}` and `{next_row}` tags you will be adding an additional database query to your page. This will be compounded as you are using the tags within your matrix loop. So if you're displaying 150 matrix rows you'd be looking at about 450 queries just to display this section of your template.

You could try using PHP in your template, set to input, to save and compare the previous row values instead of using the `{prev_row}` tag. This obviously doesn't work for the `{next_row}` tag but based on your example I don't think you'd need to do this anyway. If you need help grouping the matrix rows under a year heading it might be best to post another question dealing directly with that issue.
> 0 votes

# Answer
the system you've built there seems like it could be a pretty big drain on the system - can you try removing all the if statements to see how quick everything loads? If there's a significant difference, then you might want to think up on a cleaner approach that might save you time.
> 0 votes

---
Tags: matrix, performance, field-pack
---


# Question
Title: What steps do I need to take to remove borked entry from database (channel_titles: yes, channel_data: no)
Before I troubleshoot what caused the problem in the first place (entry made using safecracker form), I'd like to know how to remove the bad data.

EE Version v2.5.2 - Build Date: 20120606\*
Development Environment: MAMP

(Yes, yes, I know. I was soon going to update it to 2.5.5; Now troubleshooting this issue is at top of list.)

**Channel Entry #62, and how it manifests:**

**In the database**:
entry\_id 62 **does exist** in the `exp_channel_titles` table of the database.
entry\_id 62 **does not exist** in `exp_channel_data`

In `exp_channel_data` it goes from 61 to 63. Oh my.

**In the control panel**:
The entry ID, title, author, date, status all appear in table of entries. Upon clicking the title link to edit entry, this message results:

> "You have tried to access a channel that does not exist."

**From the template**:

* On an **index page template** that lists multiple entries in this channel, template calls for `{title}` (and `url_title` in link to individual page) `{author}` And a custom field for a short description: `{showcase_txt_short_description}`
The **rendered index page** displays title, author name, but displays {showcase\_txt\_short\_description} as is.
* Template for individual entry page has more custom fields in addition to title and author. Similar to rendered index page, the rendered individual entry page displays the title, but passes through {unrendered\_custom\_fields\_enclosed\_with\_curly\_braces}
* When I first loaded up that individual page, I got a number of errors. Alas (?) I cannot describe them for you because they magically disappeared when I refreshed the page just now while preparing to compose this question.
Errors were:

+ 3 php warnings
    + 1 error 1064 with a SQL error and details of SQL query, that ended up referencing ft.matrix (yes, there's a matrix field in this particular channel).

**Changes I have made since discovering this error**

Between the time I first encountered this error and now, I updated addons for the site. Among the addons, I updated to the latest version of Matrix, and also pt fieldpack (source:github)

Another thing I did, in the DB: made minor manual correction to table for entry\_id 62 in exp\_channel\_titles. Where versioning\_enabled, it was set to n, (whereas channel preferences for this channel is y), so I changed it to y. (no, that didn't correct error)

So, the php warnings and SQL errors have gone away, but I have something bad in my database.

**Now that you know a ridiculous amount of detail, my question**: What is the best way to get rid of the bad entry #62. Should I just remove the row that contains entry\_id 62 from the exp\_channel\_titles table, or are there other places I should go in order to prune this bad entry out and start again to see what caused it?

# Answer
Your "More Info" comment shows you are on the right track, in looking for other data fragments in the database. exp\_channel\_data contains your custom fields. Several third-party field types have their own table to store information in (like Matrix/exp\_matrix\_data).

You should be safe to remove the row from exp\_channel\_titles. The other tables contain data that is tied to that main entry table, but they are rarely referenced separately. The exact addons/code will determine whether an orphaned entry elsewhere in the database is a problem or not (like some of the geolocation addons), but I am inclined to think it won't be an issue.

By the way, have you looked for other problematic entries? A query like this could be useful:

```
SELECT ct.entry_id
FROM exp_channel_titles ct
LEFT JOIN exp_channel_data cd ON (cd.entry_id = ct.entry_id)
WHERE cd.entry_id IS NULL

```
> 5 votes

# Answer
Here is the process I would follow to isolate the problem a bit more. Looks like that entry 62 is indeed problematic

1. Backup your database (a big dump is enough to allow you to rollback quickly if anything goes horribly wrong)
2. Delete that 62 entry from exp\_channel\_titles
3. If problem persists and you still get a message tied to matrix, try disabling it.

You can always restore everything if needed.
> 0 votes

---
Tags: database
---


# Question
Title: Using hyphens opposed to underscores with in page URLs
Someone told me the other day that Google likes url's with hyphens (e.g. a-page-title) opposed to url's with underscores (e.g. a\_page\_title).

Assuming this is correct is there a way to make Expression Engine use hyphens in it's page url's opposed to the underscores it uses by default?

# Answer
> 4 votes
Admin \> Channel Administration \> Global Preferences \> Word Separator for URL Titles \> Dash

Or, in your config.php file (or your bootstrap equivalent):

```
$config['word_separator'] = 'dash';

```

---
Tags: seo, pages
---


title: Template "Unmatched Relationship Tag"

text:
# Question
Title: Template "Unmatched Relationship Tag"
I'm trying to get a multi-entry relationship field to render in a template using EE 2.6.0, however I'm getting "Unmatched Relationship Tag: "{impact\_stats}"" with template debugging enabled, with it disabled I get nothing with the conditional, without the conditional it just outputs the actual tags and not their contents.

This is the code I'm using, it's contained within a exp:channel:entries loop and all of the entry's tags other than the impact\_stats one is working.

```
{if impact_stats}
<section class="content-stats-listing">
    <div class="row">
        {impact_stats}
        <article class="module-stats note av-fire">
            <h4>{impact_stats:headline}</h4>
            <p>{impact_stats:description}</p>
        </article>
        {/impact_stats}
    </div>
</section>
{/if}

```

Any ideas?

# Answer
Looks like the template parser is *thinking* that your conditional is the opening variable of a pair.

Try this:

```
{impact_stats}
    {if impact_stats:count == 1}
    <section class="content-stats-listing">
        <div class="row">
    {/if}
            <article class="module-stats note av-fire">
                <h4>{impact_stats:headline}</h4>
                <p>{impact_stats:description}</p>
            </article>
    {if impact_stats:count == impact_stats:total_results}
        </div>
    </section>
    {/if}
{/impact_stats}

```
> 1 votes

---
Tags: ee2, templates, relationships
---


# Question
Title: Strange parsing issue after switching from embeds to Low Variables snippets
My coworker and I are baffled by a recent issue that came up when we switched all of our embeds over to Low Variables. The weirdest part is that the issue is happening on his machine, not mine, and we have identical code and database...

So, we have a low variable we called 'low\_snippet\_left\_sidebar' that's set for early parsing, and saved as a file. We're calling it from our template by using just {low\_snippet\_left\_sidebar}.

```
{exp:navee:custom
    nav_title="main-nav"
    start_nav_from_parent="true"
    class="secondary-nav"
    only_display_children_of_selected="true"
    selected_class_on_parents="true"
    parent_selected_class="parent-selected"
    }
    <li class="{class}" data-count="{navee_count}"><a href="{link}" rel="{rel}" target="{target}" title="{title}"><span>{text}</span></a>{kids}</li>
{/exp:navee:custom}

```

And when that renders on the page, it spits out the nav just fine... except before each nav item, there's a stray `d" }` that shows up for some reason... And that just happens to be the end of that long navee tag with parameters on separate lines.

I tested out swapping the last two parameters in that tag, and what ended up happening was the stray characters became `e" }` instead. Weird.

So then we tried making that navee tag all on one line, without having each parameter on its own line, and the problem went away! What is happening here?

How come having line breaks in my tags works on my machine, but not on my co-workers? This issue doesn't arise if we just use EE's Snippets instead of Low Variables...

here is a pic of the nav that gets output, without the errors (we used EE snippet) http://paleosun.com/misc/mahec-secondary-nav-working.png

And here's a pic of the nav that gets output as a Low Variable http://paleosun.com/misc/mahec-secondary-nav-broken.png

Any ideas/hints/clues? I don't think this is a nav-ee related issue, as the same issue is happening wherever we have line-breaks between parameters in tags, in a low variable, and only on my coworkers computer...

Thanks!

# Answer
So, after following a hunch, this is indeed due to the way new lines/carriage returns are handled on some Windows environments.

To fix, open up **base.low\_variables.php**, look up the line that says:

```
array('variable_data' => read_file($file)),

```

And change that to:

```
array('variable_data' => str_replace("\r\n", "\n", read_file($file))),

```

In LV v2.3.1, that's line 355. In the latest version (v2.3.5), it's line 342.
> 1 votes

# Answer
There is an acknowledged bug with EE 2.6.1 where multi-line parameters in templates are broken. I'd guess that you are running different EE versions locally?
> 0 votes

---
Tags: error, low-variables, parse-order, snippets
---


# Question
Title: Avoiding duplicate category names across MSM sites
Quick 'how to' question for everyone around using Categories across multiple MSM sites.

**Here's the situation:**

1. There is a 'master' (MasterSite) site, and 2 other 'sub-sites' (SiteA + SiteB).
2. SiteA and SiteB both have a channel called Events.
3. I'm using the standard Channel Entries tag on the MasterSite to show events from both SiteA and SiteB ... and of course using the site="SiteA|SiteB" parameter.
4. SiteA and SiteB both have an 'Event Category' group setup.

**The issue:**

Everything works fine until I have a single list of category names (for filtering). SiteA has the following categories - Wine, Christmas, Mother's Day. SiteB has the following categories - Wine, Christmas, Father's Day.

When I list them out for filtering, I end up with duplicate names: \- Wine \- Wine \- Christmas \- Christmas \- Mother's day \- Father's day

I can see why this is happening, and where the issues are, and get why it has to work like that ... but I want to remove the duplicates! I can handle the filtering part (as I'm using Isotope I actually only need the category name to do the filtering!).

**So here are my questions:**

1. Can I setup and share a single category group across the different sites?
2. Is there an add-on that handles this issue?
3. Is there a parameter or setting I've missed that 'removes duplicates'?
4. Is there simply a better way to do this?

**What I've come up with:**

1. Use javascript to remove duplicates on the fly.
2. Use PHP to add in all categories into an array, removing duplicates, then list them out.

I'd rather do these things 'by the book' using built-in functionality if possible ... but am open to other suggestions!

Ready... steady... go!

:)

# Answer
I'd do this with Stash. Use `set_list` to store each category and url title into an array, then use `get_list` with `unique="yes"` to remove the dupes:

```
{exp:stash:set_list name="cats" parse_tags="yes"}
    {exp:channel:categories style="linear"}
        {stash:cat-name}{category_name}{/stash:cat-name}
        {stash:cat-url-title}{category_url_title}{/stash:cat-url-title}
    {/exp:channel:categories}
{/exp:stash:set_list}

<ul>
  {exp:stash:get_list name="cats" unique="yes"}
    <li><a href="{cat-url-title}">{cat-name}</a></li>
  {/exp:stash:get_list}
</ul>

```
> 1 votes

---
Tags: categories, multi-site-manager
---


# Question
Title: Using the RTE within my own custom field type
As a learning process, I am developing a field type that will allow me to insert data from multiple text inputs and text area fields (similar to an address field with text fields for address, state, postal code, etc.) So far so good.

I have been using the form\_input and form\_textarea methods from Codeigniter's form helper to generate the fields, but I was wondering if there is a way of implementing the native RTE as another option. Is there some sort of EE helper method to generate the RTE in my own field type's display method?

# Answer
> 2 votes
You can also do this with the rte\_lib:

```
ee()->load->library(array('javascript', 'rte_lib'));

ee()->javascript->output(
  ee()->rte_lib->build_js(0, '.WysiHat-field', NULL, TRUE)
);

$field_output = ee()->rte_lib->display_field('<p>Your text</p>', 'your_field_name', array(
  'field_ta_rows' => 3,
  'field_text_direction' => 'ltr',
  'field_fmt' => 'none',//xhtml or br or none
));

```

# Answer
> 0 votes
OK, Turns out you only need to apply the Wysihat JS on a text area to initialize it (Docs here for the EE/jQuery ported version).

What I did was first check for the installed RTE in the exp\_fieldtypes table, then injected the JS into the CP if it was present:

```
$this->EE->cp->add_to_foot('<script type="text/javascript">$(function(){ $("textarea").wysihat({"buttons" : ["bold","italic","underline"]}); });</script>');

```

Will probably do something cleaner later, but at least it works now :)

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


title: Conditional by field and category

text:
# Question
Title: Conditional by field and category
I'm trying to get this if statement to work, not sure what I'm doing wrong. This is my code:

```
{categories}{if remaining_places_available<1 && category_id==259}<p><strong>Fully booked</strong></p>{/if}{/categories}

```

This is within the channel entries tag. the remaining\_places\_available is a field. Replacing && with AND doesn't work either. It's just outputting {categories} {/categories} on the front end.

Would really appreciate some help.

Thanks, Julie

EDIT: This is my channel entries tag:

```
{exp:channel:entries channel="choices_events" show_future_entries="yes" show_expired="no" disable="trackbacks" orderby="date_time" sort="asc" paginate="bottom" status="open" dynamic="no" parse="inward"}

```

This works fine in my code, and outputs '259' on the correct entries:

```
{categories}
    {if category_id == "259"}259{/if}
{/categories}

```

I just can't get it to work within the other if statement :

```
{categories}{if remaining_places_available<1 && category_id==259}<p><strong>Fully booked</strong></p>{/if}{/categories}

```

# Answer
> 2 votes
First, let me say that "trackbacks" isn't a value of the parameter disable anymore.

Now, let's make your conditionals to work.

I didn't realize until see your code, but looks like just the variables related to the {categories} tag pair are available inside it.

Since, your conditional uses an "AND", we can break it into two parts:

```
{if remaining_places_available < 1}
    {categories}
        {if category_id == 259}<p><strong>Fully booked</strong></p>{/if}
    {/categories}
{/if}

```

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


title: Expr-esso Store - shipping

text:
# Question
Title: Expr-esso Store - shipping
Currently my store installation requires you to press the button 'update cart' to calculate the shipping when at the start of checkout. I don't need anything fancy with the shipping - it just calculates it based on total amount in the basket. Can I get it so that the shipping is automatically calculated when arriving at checkout instead of forcing the user to update the cart?

Thanks

# Answer
> 1 votes
Are you using the `{exp:store:cart}` tag or the `{exp:store:checkout}` tag? Basically the Cart Tag behaves exactly the same as the Checkout Tag. The difference lies in performance - while the Checkout Tag provides a form, and provides options for updating and submitting the cart, the Cart Tag simply displays a cached version of the current cart.

Give the `{exp:store:checkout}` tag a try and this should calculate things automatically for you without needing to update the cart:

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

```

---
Tags: expresso-store
---


# Question
Title: WYGWAM error "The file browser is disabled for security reasons..."
When trying to browse files to upload an image I am getting the error:

*The file browser is disabled for security reasons. Please contact your system administrator and check the CKFinder configuration file.*

I am running old versions, but hope there is a quick solution before having to update this old site. Running:

EE v2.2.1

WYGWAM 2.3.2

# Answer
Make sure you're accessing your CP on the same domain as your site? e.g domain.com/cp and not www.domain.com/cp. Ensure whichever you're using matches that which is set in Admin \> General Configuration.
> 3 votes

---
Tags: wygwam
---


# Question
Title: Textarea seems to be converting plain text to html entities
I have a textarea field (which i'm using to paste some custom CSS for a page) that has no formatting set on it.

However, when I paste the following in;

```
h2 {background-color: #03c7e1;}

```

ExpressionEngine automatically outputs it as;

```
h2 {background-color: #03c7e1;}}

```

It's real confusing and wondered if anyone else had this issue before?

# Answer
Make sure to check the particular Channels preferences

admin \> channel administration \> channels \>

Edit the preferences for the channel in question and look for "Channel Posting Preferences" and in particular "Default HTML formatting in channel entries" - set this to: "Allow ALL HTML". I suspect it may be set to: "Convert HTML into characters entities"
> 1 votes

# Answer
`}` is the HTML character entity for a right curly bracket `}`. It could be that you've forgotten to include a closing curly bracket somewhere in the code you're pasting in and it's being interpreted incorrectly as a result. Check your code in that textarea and ensure all brackets are paired up correctly.

If everything matches up correctly in your textarea field then it might well be in your template where a mis-match is causing the issue.
> 0 votes

---
Tags: text-formatting
---


title: Entry won't update

text:
# Question
Title: Entry won't update
I'm at a loss on this one. I have an entry in my products channel. The status is wide. The entry is showing up on the home page. OK, great.

But now I want to change some text on the entry. I make the change and hit submit. It stays on the form, rather than going to the summary of the entry with the 4 or 5 links at the bottom. And the change doesn't seem to take, because the front end stays the same as before. Plus, when I get out of the update form on the back end, then go back in, the change has disappeared.

I am able to add a new entry. I'm also able to make changes to that entry. But the existing entry won't change.

This is a site I've cloned from another site. The data is from that other site, but it's in a new database, on a new server (cloud). I have followed all instructions for moving sites between servers.

Any help would be much appreciated. (BTW, we're using version 2.5.5.)

# Answer
> 1 votes
I'd double check that the new database credentials have been added to the database.php file and that they are correct for the new host. Deeploy helper can often be useful when moving to a new environment to make sure all the settings are correct for it's new location.

Failing that then have a good check that there aren't in fact any errors on the Publish screen or notifications bar at the top. These can be very subtle and can often be missed resulting in the symptoms that you describe. I've certainly had this before when clients have described the exact same thing only to find that it was due to a subtle error message that wasn't noticed. If that's the case then Mega Error may help to make them a little...less subtle.. :)

---
Tags: channel, entries, updating
---


title: Reordering Assets

text:
# Question
Title: Reordering Assets
Is there a way to reorder assets using the Assets plugin?

I want to allow the client to upload a series of files and then choose which order to display them on the front end.

# Answer
> 2 votes
I don't think it's possible to change the order of items in Assets as this is mainly intended as a global asset management addon and not particularly linked to display in front-end templates. You will probably be better off doing this in a Channel Entry where you pull in your assets and then set things like an order on the output.

Matrix (also by Pixel & Tonic) will help you to do this where you can place each asset in it's own row providing a way to order them. Matrix multi-upload will also provide an easier way for users to upload a batch of files at a time whilst actually creating that entry saving switching back and forth.

Alternatively you could use something such as Channel Images where you're doing much the same thing and pulling in assets into a channel entry with the option to set ordering and various other options before saving.

---
Tags: pixelandtonic, assets
---


title: User module - recommendations

text:
# Question
Title: User module - recommendations
i'm hoping you guys can help with recommendations for the best user management module for my particular problem.

i want to be able to have two levels of user - site admins and members. site admins would be able to view / add / remove members from their designated 'location' only (so I guess a field to identify where they're based would be required). this should all happen on the front end of the site, outside of the EE admin.

i also want to be able to view / filter all users by specific custom fields (for example their location) and if possible export all users to CSV (appreciate this may need to happen outside of the module though...)

There seems to be lots of modules available so before I take the plunge I'm just trying to work out which one is the best fit for me.

Cheers Matt

# Answer
> 1 votes
You may get some of the way there with Profile:Edit or Zoo Visitor in that they abstract out member management to channel entries so you would be able to **READ** members from front-end templates using their module tags along with native EE channel entries tags.

You could possibly **CREATE** members from the front-end too if — in the case of Zoo Visitor for example — you set `autologin="no"`. This should prevent the the person from being assigned a session ID and automatically being logged in as that user. You would need to ensure that you remove any `{if logged_in}` checks in the template.

**UPDATE** would be possible if you pass in the member\_id or the member\_entry\_id of the profile you wish to update as is the case with Zoo Visitor. Profile:Edit will only enable you to update the profile of the currently logged in member.

\[**EDIT 1:** James (below) has mentioned that you can also pass in the member\_id to Profile:Edit to allow you to edit a specific member profile and not just that of the current logged in user.\]

As far as **DELETE** goes I don't think either module will provide a way to do this in the way that you're hoping from the front-end. Profile:Edit doesn't provide this option at all and whilst Zoo Visitor provide a delete tag it can only be used to delete the *currently logged in member* from the front-end for obvious reasons.

You should be able to achieve most of what you want to with both addons if used in the control panel however and being regular channel entries you can assign member groups with varying permissions along with custom member fields. This would be your easiest option but if working from the front-end is essential then it could be worth checking out Open API. It acts as a platform and doesn't provide a ready made solution as soon as you install it so you need to be prepared to get your hands a little dirty in getting in building a CRUD based member management system.

\[**EDIT 2:** Although I've not used the module myself it seems that Solspace User has the ability to both UPDATE and DELETE users along with providing a means for a single Admin user to CREATE users from the front-end. Overall this seems to be your best bet in achieving what you're looking to do.\]

---
Tags: members, module, recommendation-request
---


# Question
Title: Nothing seems to work to successfully remove index.php
No matter what I try, I can't seem to successfully remove index.php. I'm wondering if the host is lacking some setting in the server environment... otherwise the site hosts just fine.

Here's what I've done:

-- Made an .htaccess file containing nothing but the supported method

(http://ellislab.com/expressionengine/user-guide/urls/remove\_index.php.html)

```
<IfModule mod_rewrite.c>
    RewriteEngine On

    # Removes index.php from ExpressionEngine URLs
    RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /index.php/$1 [L]
</IfModule>

```

-- Cleared the "Name of your site's index page" field in General Configuration

-- In system/expressionengine/config/config.php, I've tried setting the $config\['uri\_protocol'\] to each of the alternate configurations.

I'm running EE 2.6.1. Can't seem to figure out what's going on, at all.

The only thing I *can* think of is that I'm running from an IP address type URL, e.g. http://xx.xx.xxx.xx/~sitename, but I don't see why that would affect anything.

Thanks to ALL who take a stab at the answer - this is driving me a little bonkers.

# Answer
As Dylan mentioned, set a RewriteBase, or modify "/index.php" to something like "/~sitename/index.php"
> 1 votes

# Answer
What actually happens when you do this? You said it doesn't work, but do you see 404 pages, white screens, what?

One thing you could try is changing this line:

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

```

to this:

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

```
> 0 votes

---
Tags: htaccess
---


# Question
Title: Can P&T Assets read/use image EXIF data?
Seems like a no-brainer feature to have, specifically regarding the date and location properties of images.

And yes, I know I can use VZ Exif, but for performance reasons, I'd prefer to have that metadata in Assets' DB instead of reading the data from the filesystem every time.

# Answer
I'd just like to point out that, in order to read EXIF data, you must have PHP compiled using --exif-enabled flag, which is not something all hosting parties provide, hence Assets is not sporting this feature, but this is on our list of things to do, probably by using some 3rd party library for this, that parses jpg files.
> 1 votes

# Answer
Yes, you are correct with the plugin "VZ EXIF", all the EXIF data are being fetched for that file dynamically. I couldn't see such any file handling field type which stores EXIF data also.

I think, a field type or module can be developed for it which would be great :).
> 1 votes

# Answer
As far as I know it can. You'll find details in the P&T Assets docs including parameters for `date`, `date_modified`, and `location`.
> 0 votes

---
Tags: assets, image
---


# Question
Title: Stash Get_List outputting additional empty item
I have a client that needs a slider that can either show text, or a "tweet" (using CE Tweet for getting the tweet's info). I'm using Stash, and thought this would be the best way to get there:

```
    {exp:channel:entries
        channel='slides'
        dynamic='no'
    }
        {exp:stash:set_list
            name='home_slides'
            parse_tags='yes'
            parse_depth='2'
        }
            {if slide_type == 'tweet'}
                {slide_tweet type='show'}
                    {stash:list_text}{text}{/stash:list_text}
                    {stash:list_attribution}{user_name}, <a href="https://twitter.com/{user_screen_name}" target="_blank">{user_screen_name}</a>{/stash:list_attribution}
                    {stash:list_cta}<span class="ui-retweet"></span> Retweet{/stash:list_cta}
                    {stash:list_link}https://twitter.com/intent/retweet?tweet_id={id_str}{/stash:list_link}
                {/slide_tweet}
            {if:else}
                {stash:list_text}{slide_text}{/stash:list_text}
                {stash:list_attribution}{slide_source}{/stash:list_attribution}
                {stash:list_cta}{slide_call_to_action}{/stash:list_cta}
                {stash:list_link}{slide_link}{/stash:list_link}
            {/if}
        {/exp:stash:set_list}
    {/exp:channel:entries}

```

This is where I'm outputting the list (simplified slightly):

```
    {exp:channel:entries
    channel='pages'
    limit='1'
    require_entry='yes'
}
    {exp:stash:set parse_tags='yes'}
        {stash:page_title}{title}{/stash:page_title}
        {stash:page_content}
            <section class="slider">
                <ul data-orbit data-options="bullets: false; ">
                    {exp:stash:get_list name='home_slides' prefix='list'}
                        <!-- {list:count} -->
                        <li>
                            <div class="row">
                                <div class="large-12 columns">
                                    <h2><span class="ui-quote"><span class="ui-quote-open"></span></span>
                                        {list_text}<br>
                                        <small class="attribution">{list_attribution}</small>
                                    </h2>
                                    <p><a href="{list_link}" class="btn">{list_cta}</a></p>
                                </div>
                            </div>
                        </li>
                    {/exp:stash:get_list}
                </ul>
            </section>
        {/stash:page_content}
    {/exp:stash:set}
{/exp:channel:entries}

```

Now after my actual entry gets outputted, another "slide" gets put into my template, but all the stash-variables in that list-item are empty. Any idea as to where this emtpy item might come from?

Thanks!

* Steven

# Answer
You're re-wrapping your Stash get\_list in another Channel Entries tag pair where you're also outputting 1. `limit="1"`. So it looks like it will probably be running the Stash list and then acting on the outer loop of the extra Channel Entries tag pair.
> 1 votes

# Answer
Ok, so apparently this is an enormous conflict between `stash:set_list`, switchee and parse-order. The parse order doesn't play nice with the combination of set\_list and switchee, so I refactored it to plain conditionals, causing the unmatched conditional to parse but not return anything, fooling stash into thinking there's another item. Has anyone experienced this before?
> 0 votes

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


# Question
Title: Many-to-many relation (playa?) with additional data
I have a channel called "Courses" and it is using Matrix to have several "Lessons". I use Zoo Visitors, so I have members as channel entries. When a member signs up for a course, I want to follow if he/she completed the lessons of the course. When he/she completes all lessons under that course, then the course also will be marked as completed for this user. I can imagine how this would be done using database tables, but do you think if it can be handled using just channels/matrix/playa? Or module should be developed?

# Answer
> 1 votes
In theory that sounds possible. You'd probably have to create some custom fields in the Member channel (possibly again with Matrix) so you can assign "Courses" and the corresponding "Lessons" to them. You could then include a column for "Status" and indicate whether it's "not started", "started", or "complete". On the front-end you can then use a Safecracker form to change the status once the course has been completed. This could be either a hidden submission or a manual user action to indicate that they've completed the course.

I think the problem would be that in the Member entry you'd need to track Courses and Lessons separately so that each could have a status. I'm not sure that would work in a single Matrix field(?)

No doubt you'd get a better result with a custom module but it would also take considerably longer to put together so it's a tradeoff between whether you can get something to work with what you have (albeit maybe not quite tailored how you would like it in an ideal world) versus the time (and/or cost) it would take to put together a custom module.

# Answer
> 0 votes
I've actually built exactly this. In my Zoo Visitor fields I have the following fields:

* 1x Playa Single Select for "Active Course"
* 1x Playa Single Select for "Active Lesson"
* 1x Matrix, with Playa Single Selects for "Finished Courses"

The next Lesson is selected based on a sort of "id" they all have, which are sequential.

---
Tags: matrix, playa, relationships
---


title: Channel Images: Migrating to CloudFiles

text:
# Question
Title: Channel Images: Migrating to CloudFiles
I have a client that needs to migrate to CloudFiles (currently hosting their assets on their own server). DevDemon indicated that they have a migration-script for current entries, but they are nowhere to be found (tried contacting them over e-mail and Google+), does anyone have a solution for this? They have over 2000 entries with Channel Images, so manual migration would be a PITA.

Thanks!

* Steven

# Answer
> 0 votes
The migration script has been written and already tested by a couple of people. Get in touch so we can send you the updated build.

---
Tags: channel-images, migration, devdemon, cloudfiles
---


# Question
Title: MSM displaying main site when going to second site's domain?
I've installed a new site using MSM but when I hit the domain it's showing the content from our original domain. I'm not sure where to look for this.

# Answer
In your index.php file for the second site (or third or fourth...) there are $assign\_to\_config variables.

From the docs:

```
$assign_to_config['site_name'] = 'domain2_short_name';
$assign_to_config['cp_url']    = 'http://domain2.com/admin.php';
$assign_to_config['site_url']  = 'http://domain2.com';

```

All three should be set properly or it can default to the main site.
> 1 votes

---
Tags: multi-site-manager
---


title: EE 2.6.1 Password not getting reset

text:
# Question
Title: EE 2.6.1 Password not getting reset
I am trying to get the default Password Reset form working. I receive the email in my inbox, as expected, then I am taking to form asking for a new password and to confirm it. I click Submit and I am sorta taking to my index page. I say sorta because I have to refresh the page to actually see the page. Is this possibly why the password is not resetting?

I have tried this in Safari, Chrome and Firefox on the Mac.

Any suggestions?

Thanks,

John

# Answer
Could you check if its related to this bug report https://support.ellislab.com/bugs/detail/19414
> 2 votes

---
Tags: password
---


title: System folder & database.php path

text:
# Question
Title: System folder & database.php path
I moved my system folder above the root and was updating the database.php file and was confused about the correct path for one of the settings.

Should it be:

$db\['expressionengine'\]\['cachedir'\] = '/nfs/c10/h06/mnt/143832/domains/website.org/**html**/system/expressionengine/cache/db\_cache/';

or

$db\['expressionengine'\]\['cachedir'\] = '/nfs/c10/h06/mnt/143832/domains/website.org/system/expressionengine/cache/db\_cache/';

Thanks!

# Answer
> 0 votes
If the root of your site is "/nfs/c10/h06/mnt/143832/domains/website.org/html/", the right option is the second one.

# Answer
> 1 votes
I'd look to make it a little more dynamic (and legible) by using APPPATH:

```
$db['expressionengine']['cachedir'] = APPPATH."cache/db_cache/";

```

You still need to set 777 permissions on the cache/ directory but it will be writable when placed above the webroot.

---
Tags: php, database, path
---


# Question
Title: ExpressionEngine, php and stash - scope problem, please help
I'm hugely grateful for a resource like stackexchange and the really useful posts. I've researched the problem I'm having for a couple of days now and am seriously stuck - so any help is massively appreciated!

I'm using the fpdf to work with a very customised favourites system (uses playa and matrix to have parent and child pages) within EE to generate a pdf of the favourited pages.

I have it working so that i can output the html required for the pdf but I need to get the entire output into a single variable to feed the pdf plugin. I tried using stash append and also stash with php and within an embed but it's not working as expected.

Everything is working except being able to append to a single variable and it being set properly. Within 'output\_pdf' below I have set up a blank stash variable and I want to build up with barrister details within the pdf\_format\_barrister include. It's not working as expected though and the stash call with output="no" in doesn't seem to work at all and is still outputting the code.

I'm not sure how clear I'm being about what I'm tring to achieve but any pointers in retaining a variable and appending it across embeds is what I need really.

output\_pdf (using php and php set to output):

```
// setup a blank stash variable to contain the output for the pdf to be appended in the embdeds
echo '{exp:stash:set name="pdf_string" output="no" parse_tags="yes" trim="yes" save="yes" replace="yes" scope="user"}{/exp:stash:set}';

// THE LOOP
$i = 0;
$num_barristers = sizeof($barrister_person_ids);

while ($i < $num_barristers)
{
    $this_barrister_id = $barrister_person_ids[$i];

        //echo $this_barrister_id."<br/>";

        echo "{embed='includes/pdf_format_barrister' barrister_id='$this_barrister_id'}";

            $j=0;
            while ($j < $num_barrister_faves) {

                //echo "<p>".$barrister_exploded_fave_ids[$j]."</p>";

                echo "{embed='includes/pdf_format_expertise' barrister_id='$this_barrister_id' fave_id='$barrister_exploded_fave_ids[$j]'}";

            $j++;
            }

    $i++;

}

$everything = '{exp:stash:get name="pdf_string"}';

```

pdf\_format\_barrister:

```
{exp:channel:entries dynamic="off" entry_id="{embed:barrister_id}" status="open" disable="pagination" limit="1" channel="barristers_jc|barristers_qc"}

    {exp:stash:set name="pdf_string" output="no" parse_tags="yes" trim="yes" save="yes" replace="yes" scope="user"}
    {exp:stash:get name name="pdf_string" scope="user"}

            <br />
            <div id="pdf-practice-areas"  style="width: 100%; float: left;"> <!-- profile related practice for pdf -->

            <div style="width: 25%; float: right; text-align: right; margin-top: 15px;">
                <img src="{barristers_profile_image}" alt="{title}" title="{title}">
            </div>
            <div style="width: 74%; float: left;">
                <h1 style="display: inline-block;">{title}</h1>
                <br />
                <p>
                {if barristers_year_of_silk}jjYear of Silk: {barristers_year_of_silk format="%Y"}<br />{/if}
                Year of Call: {barristers_year_of_call format="%Y"}<br />
                {if barristers_email!="" OR clerks_email!=""}<a href="{if barristers_email}{barristers_email}{if:else}{clerks_email}{/if}">{if barristers_email}{barristers_email}{if:else}{clerks_email}{/if}</a><br />{/if}
                {if barristers_direct_dial}Direct Dial: {barristers_direct_dial}{/if}
                </p>

            </div>
            {if barristers_featured_quote}
                      <blockquote class="featured-quote" style="width: 50%; clear: both;">
                    {barristers_featured_quote}
                        {quote}
                        {if author_year}<h4>- Chambers & Partners 2012</h4>{/if}
                    {/barristers_featured_quote}
                      </blockquote>
                {/if}
            <h2 class="header" style="clear: both;">Overview</h2>
            {barristers_profile_overview}

            {if barristers_other_quotes}<h2 class="header">Quotes</h2>{/if}
             {barristers_other_quotes sort="asc"}
             <blockquote>
                 {quote}
                 {if author_year}<h4>- {author_year}</h4>{/if}
              </blockquote>
            {/barristers_other_quotes}
            </div>

    {/exp:stash:set}

{/exp:channel:entries}

```

Thankyou very much in advance for any help!

Cheers,

Alex.

# Answer
Just to echo Rob above it would help to fix your code block formatting above to make it more comprehensible, and add comments to explain what you are doing at each step.

I can see a few things in any case that might be a problem.

This recursion is likely to cause problems:

```
{exp:stash:set name="pdf_string" output="no" parse_tags="yes" trim="yes" save="yes" replace="yes" scope="user"}
{exp:stash:get name name="pdf_string" scope="user"}
{/exp:stash:set}

```

Putting embeds in a loop is bad for performance, because each embed creates a new instance of the template parser:

```
$j=0;
while ($j < $num_barrister_faves) {

    //echo "<p>".$barrister_exploded_fave_ids[$j]."</p>";

    echo "{embed='includes/pdf_format_expertise' barrister_id='$this_barrister_id' fave_id='$barrister_exploded_fave_ids[$j]'}";

$j++;
}

```

Mixing PHP and ExpressionEngine tags is, in my opinion, always a bad idea. Besides the basic legibility of your code, EE tags are parsed recursively while PHP is parsed linearly. Confusion is practically guaranteed. It will be more performant and maintainable to write a custom module or plugin to handle the logic and use either the tagdata as the view or load a view to layout your output. Note that you can use Stash programatically if you want to set placeholders or reuse variables elsewhere, e.g. `stash::set($params)`, `stash::get($params)`
> 1 votes

---
Tags: stash, php
---


# Question
Title: Channel entries category tag only showing last category
Within my `exp:channel:entries` tag, I am using the `categories` tag pair to show the categories that the entry is in. However, it is only showing the last category that the entry is in:

```
{exp:channel:entries}
    <h3><a href="{url_title_path='photos'}">{title}</a></h3><br />
    {image_upload}
        <img src="{path}_thumbs/{filename}.{extension}" />
    {/image_upload}
    <a href="{url_title_path='photos/printing'}">Print this photo</a><br />
    Categories: {categories backspace="2"}{category_name}, {/categories}<br />
{/exp:channel:entries}

```

This is the same on both the development and live sites.

There are a number of categories in the database (a couple of hundred), but each entry is only in around 2 or 3 categories. The correct categories are all selected when editing the entry in the admin panel.

# Answer
I've discovered the cause:

The channel entries and categories are added through a web service, and it turns out I missed the `exp_category_field_data` table.

Without anything in this table, only the last category was showing. I've updated the web service to add the categories to this table, and it's working correctly now.
> 4 votes

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


# Question
Title: Object of class EE_Session could not be converted to string in DevDemons forms
I've installed the latest version of DevDemons Forms(3.3.5)

When I navigate to the index page of the Control Panel I'll get the following error.

> A PHP Error was encountered
>
> Severity: 4096
>
> Message: Object of class EE\_Session could not be converted to string
>
> Filename: forms/ext.forms.php
>
> Line Number: 240

I also found a bug report on the Ellislab website related to this problem https://support.ellislab.com/bugs/detail/19469

# Answer
This is something that DevDemon will need to look into as it relates to the Session class constructor where the session\_start hook is being called which corrupts the last call object. Instead of a string it is now returning an object which throws the error. The fix will most likely require a change to grab the last\_call content before loading the session library and append this when returning a value in the cp\_js\_end hook.
> 1 votes

# Answer
For bug reports could you please open up a support request at our site? That is the fastest way to get bug reports fixed/processes.
> 0 votes

---
Tags: php, forms, bug, devdemon
---


# Question
Title: Undefined property session in cp_js_end hook
Currently facing the following error in the `cp_js_end` hook.

```
Undefined property: Javascript::$session

```

it looks like the session class isn\`t loading anymore in EE 2.6+ It whas working in older versions.

Is this a bug, or did EL change the way of loading the session class in some other order?

Example:

```
function cp_js_end()
{
   print_r(ee()->session);
}

```

# Answer
> 1 votes
Just found a way to avoid this problem

I change the hook from `cp_js_end` to the `cp_menu_array` hook.

```
Will work
function cp_menu_array($menu)
{
    print_r(ee()->session)
}

```

Please make sure that you not returning your JS but add your js with to the with `ee()->cp->add_to_foot('<script type="text/javascript"></script>');`

---
Tags: add-on-development, sessions, hook, development
---


# Question
Title: Passing variables to MX Notify via Safecracker
I have a safecracker form for visitors to submit events. I'm trying to capture their email address to use with MX notify ({author\_email}) . Is this even possible?

```
<div id="calendar_saef_edit">
   {exp:safecracker
   channel="calendar_events"
   return="/events/add-event/success"
   logged_out_member_id="2"
   error_handling="inline"
   status="Pending"
   }

     {if error}
                <p class="error">{error}</p>
        {/if}

   <p><strong><label>Your Full Name:</label></strong><br />
   <input type="text" name="full_name" /></p>
    <p><strong><label>Your Email Address:</label></strong><br />
   <input type="text" name="event_email_address" /></p>
     <p><strong><label>Business/Organization Name:</label></strong><br />
   <input type="text" name="business_name" /></p>
   <p><strong><label>Event Title:</label></strong><br />
   <input type="text" name="title" /></p>
   {exp:calendar:date_widget event_id="{segment_5}"}
    <p><span class="label label-info">Hint:</span> If an event is multiple days, change the "repeat" drop-down menu to "Select Dates". Then, click each day that the event is happening. Don't create an event for every single day. </p>

      <label>Event Photo:</label>
      {field:event_photo}

   <p><strong><label>Event Summary:</label></strong><br />
  {field:event_summary}
   <p><strong><label>Event Location:</label></strong><br />
   <input type="text" name="event_location" value="{event_location}" /></p>
   <input type="hidden" id="status" name="status" value="Pending">
    <input type="hidden" id="mbr_email" name="mbr_email" value="{event_email_address}">
    <input type="hidden" id="author_email" name="author_email" value="{event_email_address}">
   <p><input type="submit" name="submit" value="Submit Event" class="btn btn-success" /></p>
   {/exp:safecracker}
</div>

```

# Answer
> 1 votes
nope, it is not possible. Only if modify ext. and add option to parsing custom fields for mbr\_email

# Answer
> 1 votes
While not a free solution, it's possible to do this with Postmaster. Postmaster is highly extendible and provides a rich full-featured API for you to send email for just about anything. Templates can be highly dynamic, and if the desired functionality doesn't exist, just use the API to create exactly what you need.

https://objectivehtml.com/postmaster

# Answer
> 1 votes
Yes it's totally possible simply use {author\_email} in the email "to" field from the Modules/Extention/Settings section of the plugin.

1. Navigate to the Add-ons/extentions/MX Notify Control-\> click on settings
2. "To Email" add {author\_email} *(or what ever the name of the input field used in your safe cracker form)*

That's it !

---
Tags: safecracker
---


# Question
Title: Entry linking 2.1 with dynamic categories
I am using Entry Linking 2.1 to display prev/next entries in the SAME cateogry as the current single entry page.

I cannot get the plugin to recognize the current category unless it is hardcoded. I tried low segtocat and it will not work in the Entry Linking code.

```
{exp:entry_linking entry_id="{entry_id}" link="previous" channel="portfolio" orderby="entry_date" status="Open|Sold" sort="asc" mode="short" category="{segment_3_category_id}"  no_results="cycle"}
<a href="{path={segment_1}/{segment_2}/{segment_3}/{link_url_title}}"><</a>
{/exp:entry_linking}

```

# Answer
> 1 votes
Answer:

```
category="{categories backspace="1"}{category_url_title}|{/categories}"

```

---
Tags: categories, entry, links, entrylinks
---


title: CartThrob Subscriptions module issue

text:
# Question
Title: CartThrob Subscriptions module issue
I 'm using CartThrob Subscriptions module. In this module area, while clicking at "Add Subscription" button, I 'm getting the message "*To create new subscriptions for existing customers, you must already have member data stored with the payment processor. You currently have no payment vaults available for any customers*"

Screenshot is here:

Can anyone help me if s(he) faced such a thing and resolve it. I am really stuck here and couldn't understand what more settings I need to do.

I 'll highly appreciate your help.

Thanks,

# Answer
I believe the user either needs to *purchase* the subscription so they agree to the recurring payment and provide their card details with the transaction or if it's for an existing member then they need to have paid before with a payment gateway which supports the token vault system. These include:

* Authorize.net (CIM)
* eWay (Token Payments)
* Payleap (SCM)
* Sage (Token)
* Stripe

They basically securely store the credit card details in their vaults so purchases can be made at a later date without needing to enter in those CC details again.

It may be that the payment gateway that you're using doesn't support the token vault system or it may be that the customer either hasn't purchased from the store before. In which case you may need to setup a subscription plan and then get them to *purchase* this on the front-end with one of the above payment gateways. That should see future subscriptions go through fine.
> 1 votes

---
Tags: cartthrob
---