# Question
Title: Ideal server setup for EE (PHP Handler, Opcode Cache)
Edit: *Question Clarification:* Amongst other things, **what do people believe to be the ideal PHP 'Handler' for EE?**

We've decided to take the plunge and get another VPS for some of our production sites. Our current server is running suPHP so we can't install APC (according to the host).

So my question is, for performance, how should we ask them to set up our server?

We will keep our old server for development, so we don't want it to be massively different, and they are suggesting FastCGI so that they can install APC, but is FastCGI good/bad/bad for EE?

We also will be running a couple of Laravel3 and 4 on the new server, so if there are any additional recommendations, please tell me.

I wish I wasn't such a sysadmin noob, but after Tim Mahoney's talk at EEUK, we want to make sure we get the server set up right from its beginnings.

Thanks!

# Answer
> 5 votes
In my experience suPHP tends to have a small negative impact on overall performance, and either FastCGI or mod\_php (DSO) will run faster with less resource use, specifically CPU use. FastCGI uses noticeable more memory than DSO, but on the other hand is arguably 'more secure' than DSO for a multi-site environment. For securing DSO, mod\_ruid2 might be an option to consider; I've not actually used it yet but I've heard that it provides similar security advantages as suPHP with better performance.

As for opcode caches, you won't be able to run APC with suPHP. I consider APC to be essential for EE sites; without it a blank template will use 10Mb of memory, with it enabled that falls to 3Mb or so. Eaccelerator is also a perfectly decent option (if you use DSO) that seems to be stable with EE sites, but of course if you're using something like CE\_Cache then having APC available is going to provide you with another driver option for caching.

To avoid the unnecessary overhead of running static assets through Apache I usually setup Nginx as a reverse proxy, so that only PHP requests are passed through to Apache. If you use cPanel, Nginx Admin is an easy way to do this.

Finally, you will need a firewall for your server; for cPanel CSF is the obvious choice, and it also provides extremely useful tips on securing your hosting environment.

# Answer
> 7 votes
Thanks for listening to my talk and staying awake. It really is crucial to get a good base setup and thanks for reaching out to us for advice.

Key mods we use suPHP, EAccelerator, Deflate, File Cache, MemCache, FastCGI (and some other non-cache related mods) and EE works very fast. Not sure on APC but I cannot imagine there being much difference.

The key will be the DB config and Disk speed as everything runs from the DB or sometimes cached files. Caching a bit of PHP probably wont make much difference but EE Debug can tell you that if you were to benchmark the two options suPHP and APC. You can then make a decision before production.

We did have a client in the US using server side cache and combined with EE had some profound effects. They were changing PHP in templates and it didn't change on the front end. Clearing EE cache wouldn't make a difference so if you start to get this and are using a server side caching system, try turning it off. I believe this was a third party system though.

Good luck with the setup, nothing like a nice new server to play with.

This was interesting http://redmine.lighttpd.net/projects/1/wiki/docs\_performancefastcgi ... and if you are thinking about APC on a VM http://chrisgilligan.com/wordpress/how-to-configure-apc-cache-on-virtual-servers-with-php-running-under-fcgid/

Cheers

Tim

---
Tags: server, apache, hosting
---


title: prevent URL category segment

text:
# Question
Title: prevent URL category segment
I have this tag:

```
{exp:channel:categories show="2" style="linear" channel="foto" show_empty="no"}
     <a href="{path='fotografie/studio'}">{category_name}</a>
{/exp:channel:categories}

```

This results in the url: `domain.com/fotografie/studio/C2` I don't want `C2` to show up in the url how do I prevent this?

# Answer
> 1 votes
This has to do with "Global Channel Preferences" (admin \> channel admin \> global preferences) having "Use Category URL Titles In Links?" set to no. When you set it to yes, the default behaviour will be to insert your category url indicator (which you control in the same spot), followed by the category url title (as in /category/category\_url\_title).

At least, that would be the typical default behaviour of the channel categories tag pair. You can certain override that a number of ways, both within the channel categories loop and the channel entries loop.

---
Tags: url, categories
---


title: Outputting relationship data

text:
# Question
Title: Outputting relationship data
I have the following channel setup:

* Activity
* Location

Activity has a field called "activity\_location" which is a relationship to the Location channel.

Looking at the relationshop documentation here: http://ellislab.com/expressionengine/user-guide/modules/channel/relationships.html

I should be able to do the following:

```
<ul>
      {exp:channel:entries channel="activity" dynamic="no"}
        <li>{title}
        {activity_location}
          {activity_location:title}
        {/activity_location}</li>
      {/exp:channel:entries}
 </ul>

```

This should as far as I can tell output the Activity title and the Activities location as well, however it's simply outputting the {activity\_location} which the locations article id, like so:

```
Theatre by the Lake 1 {activity_location:title} {/activity_location}

```

Is the expressionengine documentation incorrect or am I doing something wrong?

Cheers!

# Answer
As pointed out by Derek, the documentation has changed for 2.6 and I was running 2.5 I've now updated and everything's working fine.
> 0 votes

---
Tags: relationships
---


# Question
Title: Member custom profile data not outputting correctly
I've created a custom member field called "member\_code", I'm trying to output this code but it seems to only ever output the code from the first member in the system, even when I use the member\_id="3" parameter. My code is as follows:

```
{exp:member:custom_profile_data}{member_code}{/exp:member:custom_profile_data}

```

No matter which user I login as it's always outputting the first users details, any ideas? I'm running expressionengine 2.6.1

# Answer
Seems you have to wrap {exp:member:custom\_profile\_data} around {exp:channel:entries} instead of placing it inside!
> 1 votes

# Answer
You can use put the code for fetching member data within embedded template and can pass member id as embed variable like:

```
{embed="temp_grp/temp_name" member_id="{member_id}"}

```

Within the template "temp\_grp/temp\_name" put the tag of custom profile data:

like:

```
{exp:member:custom_profile_data member_id="{embed:member_id}"}{member_code}{/exp:member:custom_profile_data}

```
> 2 votes

---
Tags: members, custom-fields, member-details
---


# Question
Title: Display Currently Selected Category Inside Safecracker Form
How do I display the currently selected category for the channel entry inside a Safecracker form?

I tried:

```
{categories}
    {if checked}
       {category_name}
    {/if}
{/categories}

```

I also tried `{if checked != ''}`, and the same with `{selected}` instead of `{checked}`.

Any ideas?

# Answer
> 1 votes
I got it to work by using an embedded template:

The main template:

```
{exp:safecracker
    channel='mychannel'
    url_title='{segment_3}'
    return='site/success'
}

    {!-- Safecracker Fields --}

    {embed='site/entry_category' entry_id='{entry_id}'}

    {!-- More Safecracker Fields --}

{/exp:safecracker}

```

The embedded template (site/entry\_category):

```
{exp:channel:entries
    channel='mychannel'
    entry_id='{embed:entry_id}'
    disable='member_data|pagination|custom_fields'
    limit='1'
}
    {categories backspace='2'}{category_name}, {/categories}
{/exp:channel:entries}

```

This works because embedded templates are parsed after module tags (like Safecracker). So EE loops through the Safecracker tag and performs all the functions inside it, then, when it's done, it loads the embedded template and processes the tags inside *that*. So the two don't interfere with each other and I get my entry's selected categories.

# Answer
> 1 votes
Have you tried something like this:

```
<select name="my_field_name" id="categories" >
    <option value="option_value" {if my_field_name == "option_value"}selected="selected"{/if}>option_name</option>
</select>

```

So you break it out a little more then can through in conditional checking on each option value.

# Answer
> 0 votes
The `{checked}` variable is either empty or contains `checked="checked"`. to check it in a conditional you have to check that it is not empty, and because it contains quotes the conditional needs to be in single quotes. The following should work:

```
{categories}
  {if '{checked}' != ''}
     {category_name}
  {/if}
{/categories}

```

# Answer
> 0 votes
I just encountered a similar situation where I'm in a safecracker tag pair and want to output the selected categories of the entry. GDmac's comment above solved it perfectly, thanks GDmac (I had tried {if {selected}} to no avail.)

---
Tags: safecracker, categories, conditionals
---


title: Assets "count" variable

text:
# Question
Title: Assets "count" variable
I looked through the docs and wasn't able to find a count variable to see what file you are in using a field tag. For example, I want to detect when the first file is being looped though my custom field.

{custom\_field} {if count == 0}foo{/if} bar {/custom\_field}

# Answer
> 5 votes
The count variable is 1-indexed so you need to do {if count == 1}{/if} to get the first in a loop.

---
Tags: global-variables
---


# Question
Title: Delete all cached files and refresh in one strike
Is it with Ce Cache possible to delete all cached files in one strike and have them immediately regenerated?

/David

# Answer
> 1 votes
For the first part of your question you could use CE Cache's Clean tag {exp:ce\_cache:clean} http://www.causingeffect.com/software/expressionengine/ce-cache/user-guide/tags .

To recreate all the cache I think you would need to trigger a crawler to go through your site, maybe based on your sitemap, or cron job that does the same.

---
Tags: ce-cache
---


# Question
Title: Using P&T Select Dropdown field without updating to EE 2.6
I need to use the Select Dropdown included in Pixel&Tonic's FieldPack, but I can't install FieldPack without updating EE to 2.6, which I can't do now. Is there an older version I could use? I searched P&T's website, but older versions don't seem to be available there. I don't need the whole FieldPack, really, only the select dropdown.

# Answer
> 1 votes
The old Field Pack is still up on github: https://github.com/pixelandtonic/pt\_field\_pack

# Answer
> 0 votes
Give P&T a shout directly by email and I'm sure they've have an archived file for you.

---
Tags: pixelandtonic, field-pack
---


# Question
Title: Managing file upload locations with http and https
I've got a file upload location that needs to serve files via http in the public part of the website, and serve files via https in the private part of the website and in the control panel (to avoid getting security warnings).

How can I handle this in EE?

Here's how I'm currently specifying file upload locations in the config.php file:

```
/* File Upload Preferences
-------------------------------------------------------------------*/
$config['upload_preferences'] = array(
  1 => array(
    'name'        => "Uploads",
    'server_path' => "${_SERVER['DOCUMENT_ROOT']}/uploads/",
    'url'         => "http://${_SERVER['HTTP_HOST']}/uploads/"
  )
);

```

# Answer
Try using the protocol neutral implementation, so

```
/* File Upload Preferences
-------------------------------------------------------------------*/
$config['upload_preferences'] = array(
  1 => array(
    'name'        => "Uploads",
    'server_path' => "${_SERVER['DOCUMENT_ROOT']}/uploads/",
    'url'         => "//${_SERVER['HTTP_HOST']}/uploads/"
  )
);

```

Basically, this should allow either protocol to specified. The actually spec is called **'Protocol-Relative'** you can read about it.

IE6 have some issues with JS being loaded by URLs without protocol. And IE8- downloads css twice, if they don't have protocol. But you're fine to use them on images and other files.

This not work on EECMS 2.5.2, but now it's fixed.
> 3 votes

---
Tags: file-uploads, config
---


# Question
Title: About to go ape - Changing email/username in Profile:Edit
I don't know what is going on with the guys over at MightyBigRobot, but I am getting extremely frustrated that I can't get an answer to this issue. I have a client withholding payment until this basic feature is working.

I have "Email as Username" enabled in Profile:Edit, but when a user updates their email address, it does not carry over to the native EE Member Username field so they cannot log in using their new email address, they have to continue to log in using their old one.

Can anyone give me some direction on how to get this working? I've emailed them, posted on their support forums and get nothing in return.

Thanks in advance for any help you can provide! :-)

```
{exp:profile:edit return="account/profile/updated" class="validate"}
   <div class="row-fluid">
     <div class="span6">
       <label>E-Mail Address *</label>
       <input type="text" class="span12" name="email" value="{email}" required />
     </div>
   </div>

   <hr />

   <p><a href="{path='account/password'}">Click here to change your password</a></p>

   <hr />

   <div class="row-fluid">
     <div class="span6">
     <label>First Name *</label>
     <input type="text" name="member_first_name" value="{member_first_name}" class="span12" required />
     </div>

     <div class="span6">
     <label>Last Name *</label>
       <input type="text" name="member_last_name" value="{member_last_name}" class="span12" required />
     </div>
   </div>

   <div class="row-fluid">
     <div class="span6">
       <label>Company *</label>
       <input type="text" name="member_company" value="{member_company}" class="span12" required />
     </div>
   </div>

   <div class="row-fluid">
     <div class="span6">
       <label>Address *</label>
       <input type="text" name="member_address" value="{member_address}" class="span12" required />
     </div>
   </div>

   <div class="row-fluid">
     <div class="span5">
       <label>City *</label>
       <input type="text" name="member_city" value="{member_city}" class="span12" required />
     </div>

     <div class="span4">
       <label>State *</label>
       {exp:cartthrob:state_select name="member_state" selected="{member_state}" class="span12"}
     </div>

     <div class="span3">
       <label>Zip *</label>
       <input type="text" name="member_zip" value="{member_zip}" class="span12" required />
     </div>
   </div>

   <div class="row-fluid">
     <div class="span6">
       <label>Phone Number *</label>
       <input type="text" name="member_phone" value="{member_phone}" class="span12 phone" required />
     </div>
   </div>

   <hr />

   <input type="submit" value="Update" class="btn btn-success" />
{/exp:profile:edit}

```

# Answer
**SUCCESS!!!!!!**

```
Admin > Security and Privacy > Security and Sessions > Allow members to change username

```

was set to NO! Changed it to yes and voila! Erghh.

Simple fix but should be documented somewhere!

Hope this helps someone out there!
> 3 votes

# Answer
This is working fine for me... Are you running the latest version of P:E?

Also, what does your login form look like? On my P:E login form I'm using

`<input type="text" name="username">`

and then on my P:E edit profile form I'm using

`<input type="text" name="email">`

the same as your code block.

Edit to add, I've tested using EE 2.5.5 and P:E 1.0.8, so not the most recent versions myself.
> 0 votes

---
Tags: cartthrob, profile-edit, mightybigrobot
---


# Question
Title: Reason why site_url would work in template, but not current_url?
I have the following code using the {site\_url} variable, like so:

```
<div class="g-plusone" data-annotation="inline" data-width="300" data-href="{site_url}">

```

However, when I changed the variable to {current\_url}, it doesn't work.

```
<div class="g-plusone" data-annotation="inline" data-width="300" data-href="{current_url}">

```

Any idea why one standard global variable would work and not the other?

Thanks!

# Answer
> 0 votes
`{current_url}` was only included in EE 2.5.4 so if it's older than this then that will be why it doesn't work. An alternative approach would be to either use {site\_url} followed by segment variables (not too clean) or use one of the many plugins which address this shortfall prior to 2.5.4.

Personally I quite like URL Helper as it has many useful utilities wrapped up into one handy package. It fills a lot of small holes in EE's URL handling.

---
Tags: templates, global-variables
---


# Question
Title: Exp:resso Store - Field Instructions - How do I edit this?
Field Instructions Instructions for authors on how or what to enter into this field when submitting an entry.

I would like to add field instruction to the "Total Stock" or "Limited Stock" field so my client will know what to enter into this field.

Were do I accomplish this, I don't see any store fields listed in the Channel Fields Admin area.

# Answer
> 1 votes
The Store field type is one single field so you can't edit individual field labels inside unfortunately. It is done this way for ease of use as most of the inner fields are fairly self explanatory. Hopefully 'Limit Stock' will make sense to most users and once they've entered one product they'll know the drill.

# Answer
> 0 votes
You would first need to add a Store fieldtype to what ever channel that you want to have Store products in.

You will need to simply add any instructions to the "Field Instructions" on the fieldtype settings page.

---
Tags: expresso-store, custom-fields, expresso
---


# Question
Title: Any reason the Pages Modules would not keep my assigned uri?
It will not keep the uri that I type into the field in my entry. When I go back into the entry, it is back to the example/pages/uri. I have used module on this site in the past, I had uninstalled it and now re-installed it. Could this be a problem?

# Answer
It's worth ensuring that the Pages module is properly installed (Addons \> Modules | Status: Installed). Also, it's worth trying Addons \> Modules \> Run Module Updates in top right corner of the page.

Other than that ensure that the Pages module is configured correctly in Pages \> Module Configuration. Ensure that you've set the default blog and template to use.
> 0 votes

---
Tags: module, url, pages
---


# Question
Title: When selecting channel entries, only select entries in just the top-level category
I have a channel with entries in categories and subcategories. I want to output a list of only the entries that are not in the subcategories. Is there a way to do an "only A" or "A & not anything else" type of selection?

# Answer
> 2 votes
I'd look to use GWCode Categories. You have the same control over inclusions and exclusions but a whole load more on top. `excl_cat_id` and `excl_cat_id_children` could be useful here if the categories are relatively fixed and you know their IDs.

# Answer
> 1 votes
Try Dandy Cat. it allow really crazy stuff on categories.

# Answer
> 0 votes
You can use the

```
category=""

```

parameter.

You can exclude all child categories

```
category="not 2|14|16"

```

or specify all parent categories

```
category="1|3|4"

```

Check out the docs: http://ellislab.com/expressionengine/user-guide/modules/channel/channel\_entries.html#category

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


# Question
Title: URLs in MSM subsites are still using index.php in them
Is there any chance anyone has ever come across urls in subsites in MSM sites using index.php in them

I am using a .htaccess file in each subfolder for that site which tries to get rid of the index.php so when you try to access the raw url in the site it says 404 not found error. When you type index.php before the url to the page, it loads it pretty well and works fine but from the navigation elements with structure when you click the page nav it just goes to the url without the index.php and says 404 page error.

What I would like is to have no index.php in the url and it to go to the right page instead of saying 404 page error.

Does anyone have an idea?

Cheers, Mark

# Answer
When adding another sub site in EE with multisite manager it is important to note that you need a .htaccess file in the root of the sub directory along with the index.php and admin.php too.

This .htaccess file needs to be super simple and use the following conditions to work:

```
<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>

```

An make sure in the sub sites global preferences that you take the index.php out of the configuration for the sites index too.

And thats what worked for me :)
> 1 votes

---
Tags: multi-site-manager, htaccess, url, 404, php-errors
---


# Question
Title: Can I use Stash inside Third Party Module Tags?
in the examples of Stash and every other similar plugin I always see the variables being set inside the channel:entries tag. But what if I need to set a tag inside the tag of another module? Like for example Solspace's Rating module? Have a look at the code below:

Here I'm trying to set a Stash variable...

```
{exp:rating:stats}
  {exp:stash:set name="rating"}{overall_rating}{/exp:stash:set}
{/exp:rating:stats}

```

Here I attempting to output it...

```
{exp:stash:get name="rating"}

```

But this isn't working with Stash or the String plugin which I also tried.

It seems like I can only set variables inside the channel:entries tag. Is this true? Is there no way to store variables for later use inside third party module tags such as Solspace's Ratings?

# Answer
> 0 votes
Yes anything's possible when you get your head around parse order. There are several different ways of doing this, but generally I find it easiest to always put Stash on the outside of other tags (regardless of whether they're third party or not):

```
{exp:stash:set parse_tags="yes"}
    {exp:rating:stats}
        {stash:rating}{overall_rating}{/stash:rating}
        {stash:something-else}{another_thing}{/stash:something-else}
    {/exp:rating:stats}
{/exp:stash:set}

Rating: {exp:stash:get name="rating"}

```

---
Tags: stash, module, variable
---


# Question
Title: Safecracker return param with created entry id
I have a safecracker form where I need the user to create a new entry. When the form is submitted I want the return address to include the newly created entry id, but I can't figure out how via the documentation.

I have tried:

```
{exp:safecracker channel="submissions" return="submission-complete/ENTRY_ID" include_jquery="no" safecracker_head="no"}

```

And:

```
{exp:safecracker channel="submissions" return="submission-complete/{entry_id}" include_jquery="no" safecracker_head="no"}

```

Anyone know how to do this?

```
    $('form#publishForm').ajaxForm({
        dataType: 'json',
        beforeSend: function() {
            status.empty();
            var percentVal = '0%';
            bar.width(percentVal)
            percent.html(percentVal);
        },
        uploadProgress: function(event, position, total, percentComplete) {
            var percentVal = percentComplete + '%';
            bar.width(percentVal)
            percent.html(percentVal);
        },
        success: function(data) {
            var percentVal = '100%';
            bar.width(percentVal)
            percent.html(percentVal);
window.location.href = "/submission-complete/"+data.entry_id;
        }
    });

```

# Answer
As you mentioned within you comment that you are submitting the Safecraker form with AJAX. The Ajax submission returns JSON data which have entry id also. So you can redirect with JavaScript with success function like:

```
window.location = "/submission-complete/"+data.entry_id;

```

Take a reference from here: http://ellislab.com/expressionengine/user-guide/modules/safecracker/examples.html#ajax-driven-entry-form
> 2 votes

# Answer
I don't think you can since the entry ID won't be created until AFTER the form is submitted.

What you might be able to do is return to the *latest* entry from the logged in user, will should be the entry they just submitted via Safecracker.
> 0 votes

---
Tags: safecracker
---


# Question
Title: Populating an admin multiselect with channel entries
I am trying to work out how to populate an admin multiselect menu from entries within another channel.

Basically I just want to allow my client to be able to add new values to the multi-select without giving them access to all the channel fields.

I thought the 'populate from another channel field' would work but it doesn't seem right.

Any ideas?

Thanks Martyn

# Answer
Could you see MX Select Plus: http://devot-ee.com/add-ons/mx-select
> 1 votes

---
Tags: channel-entries, control-panel, fields, multiselect
---


title: Postmaster CRON notification

text:
# Question
Title: Postmaster CRON notification
I'm new to postmaster. I've been using MX Notify to do some basic notifications. However, I'm looking to to send a "reminder email" that will trigger a CRON timer of +3 days after a initial email is sent. Is this possible with Postmaster? I haven't wrapped my head around how hooks, parcels, etc should be aligned yet. Thoughts?

# Answer
This is definitely possible with Postmaster. You would setup two parcels. The first would be the immediate email. Don't worry about sending this email later. Create a new Parcel (or duplicate) and set that second Parcel to send in the future using the relative date field. You can set it to "+3 days" and it will recognize it and put the email in the queue for the appropriate time.

Then you just use the Ping url provided in the CP and setup a CRON job to ping it at your specified interval. You could also use the Notifications API, but this is much more advanced and probably overkill for what you need.

If you have any more questions or feedback you would like answered privately, feel free to email support\[at\]objectivehtml.com.
> 1 votes

---
Tags: postmaster, notification, cron
---


title: Strange anchors added to end of urls

text:
# Question
Title: Strange anchors added to end of urls
My EE build is appending these strange anchors to the end of all pages. It's not actually causing any problems, but want to send to the client and want to understand why.

http://s168070.gridserver.com/community/#.UZ5IgqvFQrU

Any tips!?

# Answer
Do you have ShareThis on those pages? It appends silly looking hashes like that to the URLS
> 2 votes

---
Tags: url
---


# Question
Title: Creating a 404 page for ExpressionEngine
How do you create a 404 page for Expression Engine? Does anyone have any tips or links to documentation or articles that cover this subject? Any help will be appreciated.

# Answer
> 4 votes
You might read this article Guide to 404 Pages with ExpressionEngine

It would help you great.

# Answer
> 0 votes
That article is definitely handy, but it is not recommended that you Run PHP (security risks, can't cache templates, etc...) in your templates. So I definitely would not do that. In order to pass the appropriate HTML headers look at:

\[http://devot-ee.com/add-ons/http-header\]\[1\]

You would simply add: `{exp:http_header status="404"}` to your 404 template.

Hope that helps as well.

NB - if you throw this error via {if no\_results} - as you normally do maybe? - you get 404 headers without needing PHP or an addon... see http://ellislab.com/expressionengine/user-guide/modules/channel/channel\_entries.html#if-no-results

---
Tags: 404
---


# Question
Title: Playa 4.4.2 MSM - No entries exist for this related channel
After upgrading to Playa 4.4.2 on ExpressionEngine 2.5.5 (Big client and quite reluctant to update to 2.6 until any issues are ironed out) we started getting "No entries exist for this related channel" messages on all fields that linked content from different sites through MSM.

# Answer
> 1 votes
After looking through the source I found that changing lines `1762` and `1805` to

```
'site_id' => (isset($this->settings['sites']) ? $this->settings['sites'] : null)

```

Solved this issue for now.

# Answer
> 1 votes
For Playa 4.4.3, the lines to update in ft.playa.php is 1888 and 1931.

Old:

```
'site_id' => (isset($this->settings['site_id']) ? $this->settings['site_id'] : null)

```

New:

```
'site_id' => (isset($this->settings['sites']) ? $this->settings['sites'] : null)

```

---
Tags: playa, multi-site-manager
---


# Question
Title: Control Panel Redirect Loop After 2.6.1 Update
I just updated from EE 2.5.1 to 2.6.1, and now I get a redirect loop error when I try to access the control panel via `admin.php`.

I cleared my cookies (and started testing in incognito mode to be safe), cleared my .htaccess file, and I added cookie variables to Master Config:

```
$env_config['cookie_domain'] = '';
$env_config['cookie_path'] = '';
$env_config['cookie_prefix'] = 'kg_' . ENV;

```

But that didn't fix the problem. What else should I try?

# Answer
> 2 votes
See if you were bitten by this bug: http://support.ellislab.com/bugs/detail/19378

---
Tags: control-panel, redirects, updating
---


title: Auto login via email / newsletter

text:
# Question
Title: Auto login via email / newsletter
I'd like to send customers an email with a link to their (private) profile/account page.

This link should contain login credits so they can click to go to their profile page and log in at the same time.

How can I add login info to a url?

# Answer
> 0 votes
You can use the add-on LogMeIn to do this exact thing. All it needs is the username to feed into the template. You can achieve that in a variety of ways, some being more secure than others.

The most direct (not so secure) method would be to do the following:

1) Create a template, for example `profile/logmein`, and put the LogMeIn tag in it like this: `{exp:logmein:now username="{segment_3}"}`

2) Then have the email you send include a link to the logmein template with their username in the last segment: site.com/profile/logmein/username

Once the user hits that page it'll redirect them to wherever you have that set up.

It's really too simple.

# Answer
> 0 votes
In the admin, if you go to the page of the user (members -\> view all -\> \[select desired user\]) You can copy the url of that page and send that to them. This allows them to log in and go directly to their account page.

As far as automatically logging them in, that is dangerous and would be a big security concern. You should never automatically log someone in via and email link. But if you are willing to try you need to enable html in your emails (not all clients support it) and you would have to make hidden inputs to tie directly to your cp. (please do not do that though)

Edit: I do not believe that you can tie a form directly to the login of EE. There are session keys for the form that are for authentication to check that you are in a browser and on that specific page.

# Answer
> 0 votes
Expressionengine logs you in by checking your username and password in the database and then creating a session (a cookie and a corresponding database entry).

It would be pretty simple to add another field in the members table and create a GUID for each member that you use to identify and authenticate the member. You can create either an EE plugin or a CI or raw PHP script that provides a landing page that accepts the GUID as a url parameter and performs the pseudo login. You can then send the url with the GUID via a mailmerge, mailchimp or whatever to your users.

I'm sure you know, but you should do your own risk analysis to be sure that this method is secure enough. Make sure whatever group these members are in doesn't have control panel access etc.

---
Tags: members, email, login
---


# Question
Title: Can't add file when publishing to a channel. The modal window don't open up
Using version 2.5.3 and no third party add ons, just some of the natives.

I can upload files/images using the file manager without a problem. It's just when I try to publish in channel the modal pop up won't show when clicking.

I'm logged in as super admin.

I've tested this with different computers and with different browsers.

The upload folder should have proper settings. Tested to sync folder.

BUT A modal do show if there are no files in the directory, saying "You have no files.."

So the modal system seems to work, just not properly. I'd really appreciate some input on this.

# Answer
Usually, when I've had CP issues like this, a simple re-uploading of the original EE themes folder clears things up. There may be a corrupt file in there somewhere.

What happens after you do that?
> 1 votes

---
Tags: channel-entries
---


# Question
Title: Why am I getting 404 error page on subpages on my test site sitting in subfolder of my live site?
I have created a test version of my site in a subfolder of my live site.

The root of my live site is in /public\_html and my test site is in /public\_html/test.mydomain.com.

I have set up a dns record for the subdomain to point to the subfolder.

I have copied the database and linked the test site to the test database.

I have edited the entries in the config file as follows. If the main site entry is:

```
$conf['tmpl_file_basepath'] = "/usr/www/users/capeto/system/template_files";

```

... the test site entry is:

```
$conf['tmpl_file_basepath'] = "/usr/www/users/capeto/test.mysite.com/system/template_files";

```

The homepage of my test site displays fine,but none of the subpages. I am getting a 404 on all of them. For example the page http://test.mysite.com/about/ returns a 404 page.

In the template debugging code it says:

```
(0.001131) Template group and template not found, showing 404 page

```

Any idea what I am doing wrong?

# Answer
Do you have an .htaccess file in the test.mysite.com/ directory too? You will need one if you are removing index.php. You can try going to http://test.mysite.com/index.php/about to see if this may be your issue.
> 1 votes

---
Tags: ee1, config, 404
---


# Question
Title: make thumbnail view the default with native file manager
My client has complained that when they want to choose an image for a channel with an image filed they are given the list of file names by default.

They would find it more intuitive to show the thumbnail view by default rather than need to change the dropdown.

# Answer
> 2 votes
Open up ee\_filebrowser.js and search for the first instance of a("#dir\_choice").val(). Immediately after that add this:

```
; a("#view_type").val('thumb').change();

```

Make sure you include the leading ;.

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


# Question
Title: Using an EE date tag with formatting in php code
I'm using some php code (output parsing) in a template, between {exp:channel:calendar} tags. I have a line assigning the value of a custom date field to the php variable %endDate. Then, I need to test if {date} is equal to this $endDate variable. But if I use {date} alone it just takes the string "{date}" instead of its actual value, and I think that's because that tag requires a format parameter, so now I'm tryng this:

if ("{date format="%U"}" == $endDate)

but, obviously, this gives me a php syntax error and just screws up half of the template... Any idea what syntax I should use to do this?

# Answer
I just tested this:

```
{exp:channel:entries limit="1"}
{title}<br />
{entry_date format="%U"}<br />
<?php
$compare_date ="1123581363";
echo $compare_date." - compare date<br />";
$e_date = {entry_date format="%U"};
echo $e_date." - E date<br />";
if ($compare_date > {entry_date format="%U"}) {echo "I am Greater than";} else {echo "I am Less than";}
?>
{/exp:channel:entries}

```

Template set to php on output.
> 1 votes

# Answer
First of all your code `if ("{date format="%U"}" == $endDate)` isn't correct and you couldn't compare the a PHP variable with EE variable with EE's IF condition due to parsing stage.

The variable {date format="%U"} will work if you are have "date" as Date type field and it will return seconds since the epoch.

You can try the condition code like: `if ("{date format="%U"}" == "<?php echo $endDate; ?>)` make sure the "PHP Parsing Stage" is selected as "Input". But I am not sure if it would work properly for you as you are putting the condition within channel entry tag and where assign the value for PHP variable $endDate.
> 0 votes

---
Tags: php, tags, date, calendar
---


# Question
Title: Exclude random entry from another entry tag
I'm trying to load a random channel entry on page landing, while excluding that entry from the navigation to view more in the sidebar.... Here's what i want to do, but I'm not sure how to make this work...

```
{exp:channel:entries
  channel="success_story"
  dynamic="no"
  orderby="random"
  limit="1"
}
{content}
{/exp:channel:entries}

<ul>
{exp:channel:entries
  channel="success_story"
  entry_id="not (entry_id from above)"
}
<li>{title}</li>
{/exp:channel:entries}
</ul>

```

# Answer
> 2 votes
You can do this using an embed.

```
{exp:channel:entries
  channel="success_story"
  orderby="random"
  dynamic="no"
  limit="1"
}
{content}
{embed="group/embed" eid="{entry_id}"}
{/exp:channel:entries}

<!-- Then create the group/embed template (call it whatever you want) and put this -->
<ul>
{exp:channel:entries
  channel="success_story"
  entry_id="not {embed:eid}"
  orderby="random"
}
<li>{title}</li>
{/exp:channel:entries}
</ul>

```

You could use Stash too, but maybe for another day. :)

# Answer
> 1 votes
Here's a Stash way:

Stash the channel entries. The order doesn't matter.

```
{exp:stash:set_list name="entries" parse_tags="yes"}
  {exp:channel:entries channel="success_story"}
    {stash:id}{entry_id}{/stash:id}
    {stash:title}{title}{/stash:title}
    {stash:content}{content}{/stash:content}
  {/exp:channel:entries}
{/exp:stash:set_list}

```

Output one entry randomly and stash the ID.
Use `parse_tags="yes"` to be able to nest an `{exp:stash:set}`.

```
{exp:stash:get_list
  name="entries"
  orderby="random"
  limit="1"
  parse_tags="yes"
}
  {content}
  {exp:stash:set name="random_entry_id"}{id}{/exp:stash:set}
{/exp:stash:get_list}

```

Output everything *except* the random entry.
You can control the order here using the `orderby` param.

```
<ul>
{exp:stash:get_list
  name="entries"
  orderby="date"
  match="#^(?!{exp:stash:random_entry_id}$).*$#"
  against="id"
  parse="inward"
}
  <li>{title}</li>
{/exp:stash:get_list}
</ul>

```

---
Tags: channel-entries, random
---


# Question
Title: Determine which channel the user came from and display information accordingly
I'm currently working on an EE site (2.5.5) and I currently have a setup in place where there are next/prev buttons displayed on the singular view templates for articles (Two channels: Articles & Interviews). The buttons link you chronologically from entry to entry spanning across channels which is great.

```
{exp:channel:entries channel="articles|interviews|travelling_tips"}
{exp:entries_list per_page="1" entry_id="{entry_id}" entry_series="{embed:all}"}
  {if previous_entry_title}
    <a class="content-nav prev" href="{previous_entry_channel_url}view/{previous_entry_url_title}">Previous Entry: {previous_entry_title}<span></span></a>
  {/if}
  {if next_entry_title}
      <a class="content-nav next" href="{next_entry_channel_url}view/{next_entry_url_title}"><span></span> Next Entry: {next_entry_title}</a>
  {/if}
{/exp:entries_list}
{/exp:channel:entries}

```

And the embed from the articles/view template (also interviews/view template):

```
{embed="embeds/related-articles"
    entry_id="{entry_id}"
    categories="{categories backspace='1'}{category_id}|{/categories}"
}

```

Where I'm running into a problem is when the client has a very specific set of criteria on how these buttons work.

If a user uses the search field and then clicks on an article from the search results page, she wants the next/prev buttons to only click through THE SAME channel bringing up more relevant stories. Currently in the search results if you click on an article it will take you to the articles/view template.

My question is how would I best approach this? Would have have to make some sort of new view like search/view to display that article?

Thank you for your time! If I need to rephrase, please let me know.

EE 2.5.5 Entries List 4.2.2

# Answer
> 1 votes
I though a lot about this, but the only solution I found will cause another issue that you'll have to fix too.

You'll have to add a segment as marker to you URL. For example, add 'search-results' to the links of all entries on search results pages. Since, I've never used Laisvunas Entries List, I'm gonna use the default tags on my sample code. The idea is the same.

On the single entry page:

```
{embed="embeds/related-articles" channels="{if last_segment == 'search-results'}{channel_short_name}{if:else}articles|interviews|travelling_tips{/if}" from-search=""}

```

You should put this inside exp:channel:entries tag.

If you prefer to put the next/previous links outside exp:channel:entries, you don't need to use an embed. Use a snippet, instead, and grab the current channel from a segment or using a segment and a conditional.

On the embed template:

```
{exp:channel:next_entry channel="{embed:channels}"}
    <p>Next entry: <a href="{channel_url}/view/{url_title}{if last_segment == 'search-results'}/search-results{/if}">{title}</a></p>
{/exp:channel:next_entry}

{exp:channel:prev_entry channel="{embed:channels}"}
    <p>Previous entry: <a href="{channel_url}/view/{url_title}{if last_segment == 'search-results'}/search-results{/if}">{title}</a></p>
{/exp:channel:prev_entry}

```

Of course, this will cause a problem. Your site is gonna have duplicated content: "{channel\_url}/view/{url\_title}" and "{channel\_url}/view/{url\_title}/search-results" points to the same page.

To avoid SEO issues, you have to specify the canonical links for this pages without the '/search-results' segment. There are some useful tips about canonical links in this article, too.

I'm sorry. This is the only solution I can think about.

# Answer
> 0 votes
Good job getting the channels to play nicely with each other.

The simplest way to do this might just be to create two templates. One for Articles and the other for Interviews. "/view/article/\[entry\] and /view/interview/\[entry\]". You could use snippets inside if you wanted to manage that content in the same place.

When you search you might have to do something to differentiate the two channels like:

```
<a href="/view/{if channel == "article"}article/
                {if:else}interview/
                {/if}{url_title}"> View</a>

```

This saves you from having to custom write a lot of tests and use other plugins

---
Tags: related-entries
---


# Question
Title: Output Channel Entry {status} to Lowercase Slug
Is there a **documented** (core) way to output the status as lowercase? What if the status is two words - is there a way to output the status with a hyphen?

i.e.:

Status name in Control Panel: **In Progress**

```
{status}

```

Would output:

```
in-progress

```

If there isn't a documented way, could you suggest a solution?

# Answer
If you're unable to write your own PHP for it, you can use the add-on Streeng to wrap around `{status}` in your template with the slug parameter.

```
{exp:streeng slug="yes"}{status}{/exp:streeng}

```
> 0 votes

---
Tags: status
---


# Question
Title: ExpressionEngine 1.7 user & group permissions setting
Does EE 1.7 have a setting where I can have an arthor and editor? I would like to set roles where an author submits a blog post and an editor gets an email confirmation to edit and publish. Is that possible or is there a plugin I can utilize?

# Answer
> 2 votes
Using the native member group settings, you can definitely create these two groups and set their permissions accordingly. I strongly recommend downloading the EE 1.7 docs in the top right corner of the EE online User Guide.

Control Panel Location: Admin \> Members and Groups \> Member Groups

Once you create the member groups, edit their permission related to the current weblogs.

There's a section called "Control Panel Administrative Privileges" with a subsection of "Can administrate weblogs and weblog preferences".

That should get you going.

---
Tags: members, ee1, admin
---


# Question
Title: No longer able to login to the control panel
I'm having trouble logging into a site I'm building. I get no username/password errors when I try to login, but the cp login screen persists. exp\_cp\_log shows that I'm logged in.

EE 2.6.1

The last thing I did before I logged out was enable structure(3.3.8), although I'm not sure if that's the culprit.

Things I've tried:

1. clear cache
2. restart
3. different browsers
4. cleared the exp\_sessions table
5. turned on dubug

No luck trying these solutions out either:

Login page returns to the login page, doesn't log me in?

Any ideas?

# Answer
> 0 votes
I know Structure has updated (version 3.3.10) since EE 2.6 was released. Try updating Structure and see what you get.

If that doesn't work, could it be that you've been bitten by this bug? Give the fix a try. https://support.ellislab.com/bugs/detail/19334

---
Tags: structure, login
---


# Question
Title: Get child_ids for parent and top pages in Structure
I need to check the child IDs for a parent or top page in a conditional. However, Structure natively only provides `{structure:child_ids}` and `{structure:child_ids_for:XX}` globals. How can I rig up `{structure:child_ids_for:top}` and/or `{structure:child_ids_for:parent}` functionality?

*(Question first posed this question on Twitter.)*

# Answer
Combining the native global tags seems to work:

```
{structure:child_ids_for:{structure:top:entry_id}}
{structure:child_ids_for:{structure:parent:entry_id}}

```
> 1 votes

# Answer
I really wish I could get this to work inside a conditional... I can get it to render a list of child ids when used on it's own but within a conditional it doesn't work. Ideas?
> 0 votes

---
Tags: structure
---


# Question
Title: In expresso-store is there a way to create a "Wishlist" or a saved cart that could be different from the checkout cart?
Looking to have the "add to wishlist" functionality in expresso-store. This is basically just a saved shopping cart for the user. The distinction is that it's not the cart that gets purchased in the checkout process. Any ideas?

# Answer
> 1 votes
There is nothing built in but you could use something like Shortlist or Solspace Favorites to allow users to create list of items for future.

---
Tags: expresso-store
---


title: Assets Uploading Fails

text:
# Question
Title: Assets Uploading Fails
This is very similar to Matrix File Upload not displaying contents of directory, upload silently fails

I've just begun to work on an existing MSM site.
I set up some new upload directories, added them to my bootstrap array.

I had the faded upload button, etc. When I updated my indexes, it returned to normal but the upload still just silently failed.

I updated Assets to the latest version because I read in the changelog "Failed uploads now display a proper error message."
Upon trying the upload again, I had to laugh... the alert simply said "undefined".

When I try to upload to an *existing* upload directory, I can't upload either, but the error says: "Could not upload the file - server returned an unexpected response. Please check the server settings."

In my web developer toolbar, the network tab shows a 200 OK POST to `?folder=35&ACT=36&qqfile=test.jpg`. ACT36 in my DB is Assets\_mcp/upload\_file.

All the folders have 777 permissions.
I believe all the file paths are correct because I can *see* files in Assets, I just can't upload.

What am I missing?

# Answer
Needed to make sure my /system/expressionengine/cache/ directories were writable.

Checking the AJAX response in the web developer toolbar showed me a PHP error saying it couldn't write to the file.
> 1 votes

---
Tags: assets
---


# Question
Title: input:custom_modifier_name with exp:store:product_form
I am using the product\_form tag to add multiple items to the cart at one time. I am passing a category per product to a custom\_modifier\_name but the value is not being carried over into the cart/checkout.

```
{exp:store:product disable_form="yes" entry_id="{embed:entry_id}" input:finish="Finish"}
{exp:channel:entries parse="inward" entry_id="{embed:entry_id}" dynamic="no"}
<div class="product-add-ons mix{categories} {category_url_title}{/categories}">
<h2>{title}</h2>
<h2>{price}</h2>
<input type="hidden" name="items[{entry_id}][entry_id]" value="{entry_id}" />
<input type="text" name="items[{entry_id}][item_qty]" id="textfield" /> Qty
{modifiers}
{if modifier_instructions}<p class="instr">{modifier_instructions}</p>{/if}
{if modifier_type == 'var' OR modifier_type == 'var_single_sku'}
<!-- select -->
<select id="{modifier_input_name}" name="items[{entry_id}][{modifier_input_name}]" style="visibility:hidden">
<option value=""></option>
<option value="{option_id}">
{option_name} {if price_mod_val} ({price_mod}) {/if}
</option>
{/modifier_options}
</select>
{if:else}
{modifier_options}
<input type="text" name="items[{entry_id}][{modifier_input_name}]" />
{/modifier_options}
{/if}
{/modifiers}
<input type="hidden" name="items[{entry_id}][finish]" value="{categories}{category_name}{/categories}" />
</div>
{/exp:channel:entries}
{/exp:store:product}

```

Everything else works great except for my custom modifier. I have tried using it in and outside of the {modifiers} tags with no luck either.

Any help would be greatly appreciated! Cheers!

Danielle

# Answer
When you are using the product\_form tag you need to move `input:finish="Finish"` to the `{exp:store:product_form input:finish="Finish"}` tag instead of on the `{exp:store:product}` tag
> 1 votes

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


# Question
Title: Exp-resso Store Custom Payment Gateway / Sagepay Form
On the Expresso Store documentation it says that making custom payment gateways is dead easy, but i cant find the documentation on how to do so. Does anyone know where i can look / have any info?

Also i am going to be integrating using Sagepay Form. This is different from Sagepay server and direct. I assume i need to code my own custom gateway and that is not anything else available that i may have missed?

# Answer
I wouldn't say it's dead easy. If you're experienced with PHP it's certainly possible - how easy it is depends on the particular gateway.

I'm not familiar with Sage Pay Form, and it's not supported out of the box with Store, so yes, to support it you would need to code a custom gateway. In the end you might find using one of the existing and supported Sage Pay gateways easier and much faster.

Store's payment library is open source (you can see the code here: CI-Merchant). There are no guides describing exactly how to write a new payment gateway, because each one is different. Basically you will need to copy the code one of the existing gateways, and go about amending it based on the API documentation from your payment gateway.
> 0 votes

# Answer
I have now built my own.

I just modified an existing payment gateway that was not in use.
> 1 votes

---
Tags: expresso-store
---


# Question
Title: Using Exp:resso Store for workshop registrations
A client is looking for a lightweight e-commerce system to sell a couple digital products, as well as workshop registrations.

Exp:resso seems like a good fit, but I'm not sure how to capture each registrant's details. Would I use the 9 custom fields available to the checkout tag? Would I roll my own?

The flow essentially would be: select a workshop (product), select a quantify (number of registrants), enter their names and titles, checkout, send a receipt.

I'm aware of moreEvents but I'd like to keep this as simple and native to EE as possible.

Thanks!

# Answer
You can either use the custom order fields, or you can store the name with the product (make it a text modifier so people enter it when they add the item to their cart.

The advantage of using product modifiers is that the customer would be able to add multiple "tickets" to their cart, each under a different name. If you use custom order fields then there is only one set of fields per order.
> 0 votes

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


# Question
Title: Why don't new registrations show up in members
I just can't get the Freemember registration form to work. I'm using the default form from the docs:

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

    <p>
        <label for="email">Email</label><br />
        {field:email}<br />
        {error:email}
    </p>

    <p>
        <label for="password">Password</label><br />
        {field:password}<br />
        {error:password}
    </p>

    <p>
        <label for="password_confirm">Confirm Password</label><br />
        {field:password_confirm}<br />
        {error:password_confirm}
    </p>

    <p>
        {field:accept_terms} <label for="accept_terms">Accept Terms</label><br />
        {error:accept_terms}
    </p>

    <p>
        <input type="submit" value="Submit" />
    </p>

{/exp:freemember:register}

```

The form sends but nothing happens. I'm not sure what to even do to get this to set up and work properly. Do I need certain settings I'm missing in member preferences? When I use the default EE member/registration form it works just fine.

EE 2.6.1 Freemember 2.2.2

# Answer
> 5 votes
There is most likely an error being thrown but not being displayed. A few things to check...

Double check that it's installed correctly and listed in Addons \> Modules.

Then ensure that you have set your encryption key in `system/expressionengine/config/config.php`.

The next thing to try would be to remove `error_handling="inline"` so you can see any errors that are returned on form submission.

You're also including `accept_terms` in your registration form. In Members \> Member Preferences, look for "Require Terms of Service". It could be worth setting this to 'No' to test with. You could even try removing that from your form if you set this 'No'.

Does any of that help to shed any light on things? Are there any errors returned?

---
Tags: freemember
---


# Question
Title: 301 redirect url without / to end with /
im trying to correct some URL's that dont have the / at the end,

for example, expressionengine created the url without the / however, im trying to redirect whereas all my URls are consisten with the / at the end.

problem is I already have ranking on the non / urls and now showing up duplicate content with urls listing the / at the end.

what kind or redirect 301 should I do.

ive tried this with no luck.

redirect 301 /products/item http://www./products/item/

it wont work in my .htaccess file.

any sugestions

# Answer
> 1 votes
A 301 (permanent redirect) is the best option and if you want to do it across the board on your site then try this in your .htaccess file:

```
<IfModule mod_rewrite.c>
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/|#(.*))$
  RewriteRule ^(.*)$ /$1/ [R=301,L]
</IfModule>

```

This will append the forward slash onto directories but not filenames and set it as a 301.

You can also use `rel="canonical"` on existing links which works similarly to a 301 in terms of search engine indexing.

---
Tags: htaccess, redirects
---


# Question
Title: Enable Strict URLs triggers 404 on search results
Wonder if anyone else bumped into this issue using Structure & Low Search. Enabling strict URL's results in a 404 on search which {segment\_2} triggers.

The 404 rule looks for the template name which won't be there as Structure doesn't work like that, so how can I tell the search module what the template name is?

Low suggested using Freebie, but before I delve into yet another add-on to patch an add-on I was hoping to find a solution here:-)

Low Search code:

```
{exp:low_search:results query="{segment_2}" status="not closed" disable="categories|member_data"}
{if count == 1}
<p class="">
{if low_search_keywords}You searched for <strong>{low_search_keywords}</strong>{/if}
and we have found <strong>{absolute_results}</strong> matches.
</p>
{/if}{/exp:low_search:results}
</div>
{exp:low_search:results query="{segment_2}" status="not closed" disable="categories|member_data"}
<div class="entry">
{if page_url != ''}
<a href=" {page_url}"> <h4>{title}</h4></a>
{if:else}
<a href="{comment_url_title_auto_path}"> <h4>{title}</h4></a>
{/if}
<p>Found in <a href="{comment_url_title_auto_path}" class="red"> {low_search_collection_label}</a>.</p>
<p>{low_search_excerpt}</p>
</div>
{paginate}
<p>Page {current_page} of {total_pages} pages {pagination_links}</p>
{/paginate}
{if no_results}
<p>
Sorry, your query did not return any results.
Check your spelling or try a different search term.
</p>
{/if}
{/exp:low_search:results}

```

Running EE 2.5+ & all add-ons up-to-date

# Answer
Unfortunately there wont really be an easier way than with Freebie. It's designed for this very purpose when you need EE to ignore certain URL segments and comes in very handy when dealing with Structure because of the way it deviates from EE's native URL handling.

In the case of both strict URL handling and Structure you definitely need to break those URL segments.
> 2 votes

---
Tags: structure, low-search, 404
---


# Question
Title: How can I use Low Search to filter entries by their entry_date, using a datepicker?
I have read a few different posts on how to filter search results using a custom date field, and on using a range of dates as well. However, I need to filter my results by the native entry\_date. I have tried a multitude of things from using date ranges, trying to use exact parameters and more. This is my latest markup:

**Search Tag**

```
{exp:low_search:form collection="albums" query="{freebie_3}" result_page="/daily-photos/results/" form_class="internalSearch photoSearch" secure="no"}
      <input type="text" placeholder="MM/DD/YYYY" class="searchDatepicker text search"/>
      <input type="hidden" id="actualDate" name="search:entry_date">
      <button type="submit" class="searchBtn" aria-hidden="true" data-icon=""></button>
{/exp:low_search:form}

```

**Results Tag**

```
{exp:low_search:results  query="{freebie_3}" limit="15" paginate="bottom" paginate_base="/daily-photos/results/"}

```

**Datepicker Javascript**

```
$('.searchDatepicker').datepicker({
        altField: "#actualDate",
        altFormat: "yy-mm-dd 12:00 'PM'",
        dateFormat: "mm/dd/yy",
        gotoCurrent: true,
        maxDate: "+0d"
 });

```

You can see where I was trying to resolve a suspected timestamp issue by adding a default timestamp in the javascript. My thinking was to have a default timestamp as shown and then in the search, setting the range for the entry\_date to be from yy-mm-dd 12:00 AM to yy-mm-dd 11:00 PM, but I haven't been able to achieve this, and I'm not sure if there's just something basic I am overlooking? I am using Low Search in several other places across the site, so I'd like to be consistent and use it for this scenario. My search results just return all entries with no filtering.

I am running EE 2.5.5 and Low Search 2.2.1. Thanks for looking!

# Answer
> 0 votes
You'll need to target the native `start_on` and `stop_before` parameters to filter entries by Entry Date; check the EE docs here. So, instead of using `search:entry_date`, use this:

```
<input type="hidden" id="actualDate" name="start_on">

```

That will give you all entries with an entry date equal to or greater than the given date. If you want to limit the results to a certain day, you'll also need to define a `stop_before` field.

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


title: Completing Order - Expresso Store

text:
# Question
Title: Completing Order - Expresso Store
I have built a custom gateway for sage pay form.

The plugin gathers all the data from Store and then posts it off to sagepay in an encrypted string.

User than completes payment on the the sagepay website before being posted back to a specified success URL with an encrypted string attatched. When the string is decoded you can view the order status.

How do i notify cart that the order has been paid for and to log it as complete?

# Answer
> 1 votes
You should take a look at other gateways which handle this situation, for example Paypal Express:

https://github.com/expressodev/ci-merchant/blob/master/libraries/merchant/merchant\_paypal\_express.php

When you build the purchase request, you need to tell the gateway to return the customer to `$this->param('return_url')`. For example, in Paypal this involves:

```
$request['RETURNURL'] = $this->param('return_url');

```

This URL will look something like:

```
https://example.com/index.php?ACT=123&H=abcdef123456

```

This is a special EE action URL, which is passed through to Store. Store looks up the payment hash to see which gateway requested the payment, then automatically loads that gateway, and calls `purchase_return()`. So you need to implement that method on your gateway class:

```
public function purchase_return()
{
    // do something here
}

```

Inside the `purchase_return()` method you should check `$_GET` or `$_POST` for the encrypted string that the gateway sent back to you. Here is another good example of decoding a response and returning the appropriate reply:

https://github.com/expressodev/ci-merchant/blob/master/libraries/merchant/merchant\_dps\_pxpay.php#L62

Basically, if the transaction is successful you should return something like:

```
return new Merchant_response(Merchant_response::COMPLETE, $response_message_from_gateway, $transaction_id_from_gateway);

```

If the response failed, return something like:

```
return new Merchant_response(Merchant_response::FAILED, $response_message_from_gateway, $transaction_id_if_there_was_one);

```

Then Store will know to update the order accordingly, and will either mark the order as complete and redirect the customer to the success page, or send them back to the checkout to try again.

# Answer
> 1 votes
I think you should just need to make sure your custom driver extends `Merchant_driver` (or in the case of SagePay, possibly just extend `Merchant_sagepay_base`).

Then I think you just need to make sure you're returning the request at the end of the method for the Merchant Lib and Store to deal with.

```
return $request;

```

---
Tags: expresso-store
---


# Question
Title: Exp-resso Store - Getting Shipping Details - Custom Payment Gateway
I have built my own custom payment gateway. But how do i get the shipping values in PHP processor?

For example you can get the billing address line 1 using this

$this-\>param('address1')

How do i get the shipping address1 ?

# Answer
> 2 votes
Store doesn't actually pass the real shipping address through to the gateway (normally payment gateways don't need to know about the delivery address). If it's required, you could just copy the billing address there. Otherwise, you will need to edit `store_payments.php` to pass through the shipping details so that you can use them. As you can see in the existing Sage Pay gateways it just uses the billing address.

# Answer
> 0 votes
You'll see an example of this in merchant\_sagepay\_base.php of the merchant lib. On or around line 80 you'll see the request for billing details:

```
$request['BillingFirstnames'] = $this->param('first_name');

```

and below a foreach loop for shipping where this is mapped up but *Billing* is replaced by *Delivery*:

```
// shipping details
foreach (array('Firstnames', 'Surname', 'Address1', 'Address2', 'City', 'PostCode',
    'State', 'Country', 'Phone') as $field)
{
    $request["Delivery$field"] = $request["Billing$field"];
}

```

Just be sure that in that function you're returning the request:

```
return $request;

```

---
Tags: expresso-store, payment-gateway
---


# Question
Title: Location in comment tag not being output
I have this code and it should output the location (I have checked that it exists in Expression Engine comment admin) but it doesn't output the data. I have look everywhere for a solution but nothing is indicating why the location is not being output. (Using EE 2.6.0)

```
{exp:comment:entries sort="asc" status="open" limit="20"}
                <article class="recipe-comment">
                    <div class="recipe-comment-author"><strong{location}</strong> Review by {name}</div>
                    {comment}

                    <p class="recipe-comment-post-date">Posted on {comment_date format="%j%S %F %Y"}</p>
                </article>
            {/exp:comment:entries}

```

# Answer
> 1 votes
Looks like you didn't close your `<strong>` element. You need this:

```
<strong>{location}</strong>

```

---
Tags: comments
---


title: Wygwam Content Elements conflict

text:
# Question
Title: Wygwam Content Elements conflict
I have field group with Wygwam and Content Elements. When I select Wysiwyg field in Content Elements, the Wygwam stops working, that is, buttons are not shown.

* EE: 2.6.1
* Wygwam: 2.7.1
* Content Elements: 1.3.1

here is screenshot http://screencast.com/t/GML5I1TNhXG

# Answer
Content Elements and Wygwam are not currently compatible. The CE devs did contact us and we're working with them on that compatibility; but it isn't available yet.
> 1 votes

---
Tags: custom-fields, wygwam, content-elements
---


# Question
Title: Show full shipping region name in email confirmation Expresso Store
On the email confirmation in Expresso Store, can I have the full {shipping\_region} name displayed rather than the three letter short code?

# Answer
You will want to use `{shipping_region_name}` to display the region name or `{shipping_country_name}` to get the full country name.
> 1 votes

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


title: Comment Form Custom Form Field

text:
# Question
Title: Comment Form Custom Form Field
Is it possible to add custom form fields to the EE comment form? What I would like to do is to require people to be logged in members to post but allow them to comment anonymously.

If I add a checkbox with a "Reply Anonymously" option it doesn't record the checkbox state in the exp\_comments table.

# Answer
You cannot use custom fields in the comment form but you can repurpose any of the **native fields** to use as needed.

You might look at repurposing the "location" or "url" field and passing your value to that column in the database..
> 1 votes

# Answer
Sweet, after checking Devot-ee (why didn't I look there first) I found a recent addon called 'Custom comment fields' (http://devot-ee.com/add-ons/custom-comment-fields) which allows you to add some simple custom fields (Text input, Textarea, Safecracker File) to EE comments module posts. I then used this as a way to add the ability for logged in users to specify if there wished to post a specific comment anonymously.

I added a new custom field using this addon called {comment\_anonymously} and then set this as a checkbox field in the {exp:comment:form}

```
<label>
    <input type="checkbox" name="comment_anonymously" value="y" />
    Post my comment anonymously
</label>

```

Then in the {exp:comment:entries} loop, I used a conditional on the custom comment field to display the users name or not:

```
Posted by
{if '{comment_anonymously}' == 'y'}
    Anonymous
    {if logged_in_group_id == '1'}
        (<em>{name}</em>)
    {/if}
{if:else}
    {name}
{/if}

```

Note that I've also placed in a conditional for if a Super Admin is looking to show the users actual name for easy verification.

Cheers Brendan
> 1 votes

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


# Question
Title: Converting FF Checkbox Group to native or P&T checkboxes
I'm converting an EE 1.x site to the latest 2.x version and have run into a problem where FF Checkbox Groups were used which stored their data as a serialized array whereas both the native and P&T checkbox fieldtypes aren't.

What are my options for upgrading/changing the data?

# Answer
Have you tried (after making a backup) changing your FF Checkbox fieldtype to the P&T one? It's been awhile since then so I did double check, and found this post confirming that is all that should be needed.

If that isn't working, can you confirm what versions you're going to and from?

Thank you!

-Lisa, P&T
> 1 votes

---
Tags: ee2-upgrades, pt-checkboxes, checkbox
---


# Question
Title: Remove category Group Name from Low Search select
As per the title. I have categories set up like this example:

Group Name: Amps Children: Pre \> Power \> Integrated

Then using:

```
   <select name="category:Amps[]">
  {exp:channel:categories channel="sound" style="linear" category_group="2"}
    <option value="{category_id}">{category_name}</option>
  {/exp:channel:categories}
   </select>

```

How do you exclude the Group Name and just bring back the children in the rendered select dropdown? Otherwise on submit it will bring back ALL results if nothing is selected.

TIA

# Answer
You could use GWcode Categories instead, you do get much more control over the category output.

```
   <select name="category:Amps[]">
  {exp:gwcode_categories channel="sound" depth="2" show_empty="no"}
    <option value="{cat_id}">{cat_name}</option>
  {/exp:gwcode_categories}
   </select>

```

^ This is a mock up, not actual code.
> 1 votes

---
Tags: low-search
---


# Question
Title: Expresso-store: How do I diaplay the quantity of a specific product in the cart?
Having already added 10 of product *foo* to the cart, I later return to the *foo* product page - how can I display how many *foo's* are already in the cart?

Thanks for any ideas Lee

# Answer
> 1 votes
You would use `{qty_in_cart}` variable as seen in the docs https://exp-resso.com/docs/store/product\_tag.html#qty\_in\_cart

---
Tags: expresso-store
---


title: Safecracker forms fail PCI DSS

text:
# Question
Title: Safecracker forms fail PCI DSS
On our site we have a number of front-end Safecracker forms. Also, our website needs to be fully PCI DSS compliant and in order to achieve this, we have to use a scanning tool provided by our Merchant Bank to ensure that any vulnerabilities are fixed before they will supply us with a PCI DSS compliance certificate.

When we scanned our website, all of the safecracker forms came up with the following similar warning;

> Description: CGI Generic Cross-Site Scripting (quick test)
>
> Synopsis: The remote web server is prone to cross-site scripting attacks.
>
> Impact: The remote web server hosts CGI scripts that fail to adequately sanitize request strings with malicious JavaScript. By leveraging this issue, an attacker may be able to cause arbitrary HTML and script code to be executed in a user's browser within the security context of the affected site. These XSS are likely to be 'non persistent' or 'reflected'.
>
> See also : http://en.wikipedia.org/wiki/Cross\_site\_scripting#Non-persistent http://www.nessus.org/u?9717ad85 http://projects.webappsec.org/Cross- Site+Scripting
>
> Data Received: Using the POST HTTP method, SecurityMetrics found that :
>
> * The following resources may be vulnerable to cross-site scripting (quick test) :
> * The 'RET' parameter of the /product-registration CGI :

```
/product-registration [RET=<IMG SRC="javascript:alert(104);">]

-------- output -------- <p> </p>

<form id="publishForm" method="post" action="<IMG SRC="javascript:alert( 104);">" enctype="multipart/form-data" > <div class='hiddenFields'> <input type="hidden" name="ACT" value="108" /> ------------------------ Other references : CWE:79, CWE:80, CWE:81, CWE:83, CWE:20, CWE:74, CWE:442, CWE:712, CWE:722, CWE:725, CWE:811, CWE:751, CWE:801, CWE:116, CWE:692, CWE:86

```

Another example of vulnerability with the same form is as follows;

```
-------- output -------- <p> </p>

<form id="publishForm" method="post" action="509" src="http://www.exampl e.com/exploit509.js" enctype="multipart/form-data" > <div class='hiddenFields'> <input type="hidden" name="ACT" value="108" /> ------------------------ /product-registration [return_url=/product- registration/sent&RET=509" sr c="http://www.example.com/exploit509.js&XID=]

-------- output -------- <p> </p>

<form id="publishForm" method="post" action="509" src="http://www.exampl e.com/exploit509.js" enctype="multipart/form-data" > <div class='hiddenFields'> <input type="hidden" name="ACT" value="108" /> ------------------------ Other references : CWE:79, CWE:80, CWE:81, CWE:83, CWE:20, CWE:74, CWE:442, CWE:712, CWE:722, CWE:725, CWE:811, CWE:751, CWE:801, CWE:116, CWE:692, CWE:86

```

> Resolution: Restrict access to the vulnerable application. Contact the vendor for a patch or upgrade.
>
> Risk Factor: Medium/ CVSS2 Base Score: 4.3
>
> AV:N/AC:M/Au:N/C:N/I:P/A:N

I was wondering if anyone else has come across this before with ExpressionEngine and Safecracker forms? And also, what the fix(es) might be?

As mentioned in a reply below, I do have the 'return' and 'return\_url' parameters set for the form.

Thanks.

# Answer
> 1 votes
Security scans are a joyous thing. And often return "false positives". Unfortunately in the PCI world, they don't care. It looks like the scanner is referring to the return parameter and being able to inject something into the hidden field. I just checked and SC adds a return parameter of the current page if you don't supply one. So the hidden field is still there.

Can the scanner provide more info, i. e. what it tried to inject? What was returned to it? That may give you a bit more to go on.

I don't believe EE comes close to making any such claims of being PCI compliant.

I would suggest looking at the SC module and see if you can find where it processes the return parameter. Maybe there you can see what you need to add to scrub the return parameter.

Not sure, but you may find your self going down the line of all the hidden parameters as you continue scanning.

---
Tags: javascript, security
---


# Question
Title: Installation of MSM not working on localhost / server
I have just tried to install Multiple Site Manager (MSM) both on my local MAMP server and on the database.

I have copied the files required, and turned on the MSM setting in General Configuration.

However, whenever I go to "Edit Sites", I get the following error:-

The website encountered an error while retrieving

```
http://localhost:8888/soundhalo-blog/admin.php?S=390e647927cdde75544e6e3c9e258cf84f8cce2b&D=cp&C=sites&M=manage_sites.

```

It may be down for maintenance or configured incorrectly.

Can anyone help me out as to why this is showing up? I get the same error on the server as well.

# Answer
> 1 votes
Have you set up the admin.php and index.php files in the sub-sites? Its sounds like it could be something to do with the paths to the system folder.

What happens when you visit the subs sites? Do you get an error saying things are configured properly?

Do you have a custom config file running at all? have you got the site turned off?

I have found that when these things happen, that is usually the paths that are wrong. I haven't seen the error you are receiving before.

Do you have admin.php in the root of soundhalo-blog? Have you renamed that file?

I'm sure you've probably read all this, but if you follow the instructions here, you should set it up fine.

http://ellislab.com/expressionengine/user-guide/cp/sites/index.html

Let me know how you get on.

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


# Question
Title: Limiting query module results by member group_id
I am trying to limit the following query by the member's group id, but having some difficulty with the join statement.

This query works fine:

```
{exp:query sql="SELECT count(*) as member_count, m_field_id_6 as state
FROM exp_member_data WHERE m_field_id_6 != ''
AND m_field_id_9 = 'USA'
GROUP BY m_field_id_6 ORDER BY m_field_id_6 ASC
"}
  {state} ({member_count})<br />
{/exp:query}

```

But I am struggling with how to limit by group\_id:

```
{exp:query sql="SELECT count(*) as member_count, m_field_id_6 as state
FROM exp_member_data WHERE m_field_id_6 != ''
AND m_field_id_9 = 'USA'
JOIN exp_members ON exp_members.member_id = exp_member_data.member_id
WHERE exp_members.group_id='5'
GROUP BY m_field_id_6 ORDER BY m_field_id_6 ASC
"}
  {state} ({member_count})<br />
{/exp:query}

```

The end result would be a directory of members grouped by state. I've maxed out my query knowledge, thank you for any assistance or suggestions.

# Answer
You can try this query:

```
{exp:query sql="SELECT count(*) as member_count, m_field_id_6 as state
        FROM exp_member_data
        JOIN exp_members ON exp_members.member_id = exp_member_data.member_id
        WHERE m_field_id_6 != ''
        AND m_field_id_9 = 'USA'
        AND exp_members.group_id='5'
        GROUP BY m_field_id_6 ORDER BY m_field_id_6 ASC"}
    {state} ({member_count})<br />
{/exp:query}

```

Plz share if ORDER BY is also working fine.
> 2 votes

---
Tags: members, query, sql
---


title: Cannot create channel field

text:
# Question
Title: Cannot create channel field
After upgrading to EE 2.6.1, i now try to create a new channel field, but instead get this SQL error:

```
A Database Error Occurred
Error Number: 1064

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') ORDER BY `screen_name`, `username` ASC' at line 4
SELECT `member_id`, `group_id`, `username`, `screen_name` FROM (`exp_members`) WHERE `in_authorlist` = 'y' OR `group_id` IN () ORDER BY `screen_name`, `username` ASC

Filename: fieldtypes/relationship/libraries/Relationships_ft_cp.php
Line Number: 163

```

Anyboy knows how to correct this?

# Answer
It seems that no member group is selected as "Include Members in PUBLISH page multi-author list?". Go to Control Panel -\> Members -\> Member Groups. Click on "Edit Group" next to Super Admin. Now make sure the "Include Members in PUBLISH page multi-author list?" is "Yes".
> 2 votes

---
Tags: ee2, custom-fields, mysql
---


# Question
Title: EE custom function to return State Name rather than abbreviation
I have a channel for communities that stores community\_name as the 2 letter abbreviation since it is part of the mailing address.

I am trying to build a filtered search but want to display the complete state name rather than its abbreviation.

Where in EE do you put helper functions? In CI, I would just add a file in the system/helpers folder that would hold all of my sitewide functions ( like formatPhone ).

Once I know where to place this very simple function, I also need to know how to display it. Right now I am using `<span class="community_state webcam-caption">{community_state}</span>` but that would, of course, be the abbreviation.

Thanks in advance, Jon

# Answer
Jon,

In EE you can develop a small plugin to display the complete state name. You can have a guide from http://ellislab.com/expressionengine/user-guide/development/plugins.html

For example, you can have plugin tag as `{exp:custom_plugin community_state="{community_state}"}`

and the plugin code would be like:

```
class Custom_plugin
{
    public $return_data = "";
    public function __construct()
    {
        $community_state = ee()->TMPL->fetch_param('community_state');
        ########
        Code or query to fetch complete state name with $community_state as $complete_state_name
        ########
        $this->return_data = $complete_state_name;
    }
}

```

I hope, it would help you.
> 1 votes

---
Tags: templates
---


# Question
Title: Carthrob price modifier wont show price in cart
I am using Carthrob with the price modifiers fieldtype.

In the add to cart form everything works as it should. However, when I add an item to the cart, I can't get the price to display, and the cart total is all out of wack.

I have done a variety of tests but can't figure out the issue. Can anyone take a look at the following code and see if I am missing something really obvious?

I have the following code for my add to cart form:

```
{exp:cartthrob:add_to_cart_form return="enter/checkout"}

    {exp:cartthrob:item_options entry_id="{entry_id}" }
        {select id="purchase-submissions-select" class="standard required"}
            <option {selected} value="{option_value}">{option_name} {price}</option>
        {/select}
    {/exp:cartthrob:item_options}

    <input id="purchase-submissions-submit" type="submit" value="Submit" />

{/exp:cartthrob:add_to_cart_form}

```

and this as a test in my cart:

```
{exp:cartthrob:update_cart_form return="/index.php/basket/"}
    {exp:cartthrob:cart_items_info}

        {item_option:fees} - {price} - {quantity}<br />

        {if last_row}
            {cart_total}
        {/if}

    {/exp:cartthrob:cart_items_info}
{/exp:cartthrob:update_cart_form}

```

P.S I have seen the other thread with a similar problem, and have checked and its not the same issue (i.e no dollar symbols in with the price).

Thank you.

# Answer
> 1 votes
Have you got your cookies set up in admin/config? I've been going through a similar issue.

Also, check to see if your server I've and computer time are pretty close. It old be that your sessions are a bit lost.

I ran through these: http://cartthrob.com/docs/pages/troubleshooting/#add-to-cart-problems

You may well have seen this already.

Are ou using msm at all? Or Stash?

Lastly, it's a long shot, but add parse="inward" on your item\_options. It could be that it's not parsing right.

---
Tags: cartthrob
---


title: Blog on subdomain MSM

text:
# Question
Title: Blog on subdomain MSM
My client wants a blog set up in EE. However, from an SEO standpoint he heard that having your blog on a subdomain is better. A) What is the validity to this request and B) Would I have to use MSM in order for this to be managed all from the same admin? Thanks for any recommendations!

# Answer
> 1 votes
> A) What is the validity to this request

I don't think having a subdomain for blog is better for SEO. Rather than, I always prefer to have SEO friendly URLs for the blogs like yoursiteurl.com/title-of-your-blog which can easily achieved by Pages module.

> B) Would I have to use MSM in order for this to be managed all from the same admin?

Yes, you have to use MSM for this to be managed all from the same admin. For the MSM you domains or subdomain will be hosted at same server. See more from here http://ellislab.com/expressionengine/user-guide/cp/sites/

# Answer
> 0 votes
I agree with the above answer. I've not read anything about a sub domain being more powerful.

I might suggest just setting up the URL structure domain.com/blog/title.

This vs.

blog.domain.com/title - there is no real difference. I can't imagine the search engines ranking one over the other. If you are going to do a huge amount of blogging and article writing, then you may want to split this.

We do a fair bit f SEO, and not heard of this. I'd be interested to hearing what others have experienced.

---
Tags: multi-site-manager, subdomain
---


# Question
Title: Assets not retrieving URL for second site
My situation: I have 3 sites (2 photoblogs, 1 start page). The 2 photoblogs use Assets to manage the images and CE Image to make the thumbnails.

My problem: on the start page i use (this is a simple example just to get the URL from assets in their respective entries for all sites):

```
{exp:channel:entries channel="fotoblog" site="site1|site2" limit="1"}
 {fotoblog-imagens limit="1"}{url}{/fotoblog-imagens}
{/exp:channel:entries}

```

**{fotoblog-imagens} is an Assets field**

Only site1 returns the URL. Site2 doesn't. If i erase Site1 from the site field, it now returns the URLs for the Assets in entries on Site2. Tried var\_prefix but results are the same. Any tips?

# Answer
I think what you'll need to do is add site\_id="site1" to your assets loop.

{exp:channel:entries channel="fotoblog" site="site1|site2" limit="1"} {fotoblog-imagens limit="1" site="site1"}{url}{/fotoblog-imagens} {/exp:channel:entries}

I think that should get it working.
> 1 votes

---
Tags: multi-site-manager, assets
---


# Question
Title: Create variable to be used in conditional in an Extension
I am creating an extension for Cartthrob. What I need it to do is not allow the customer to complete their order if there are a certain number of certain products in the cart (there are three products that they can only buy a total of 8 across all three, but two products that they can buy any number of).

I have the extension set up on the cartthrob\_update\_cart\_end to check the items currently in the cart. I was hoping to set a variable (global?) that I could use later on in the checkout template in a conditional. Setting a global variable like this DID NOT work for me:

```
$this->EE->config->_global_vars['test_var'] = "test var";

```

When I try to output the variable as {test\_var}, it only outputs the variable name (it wasn't parsed). This would most likely be a parse issue, but since this is an extension I thought parsing wouldn't matter.

Some pseudocode I was thinking:

1. Update cart hook calls my function in ext.limit\_items.php.
2. My function counts up all the products and sets a variable "item\_count\_passed" to either true or false.
3. My checkout template loads. Within the template is the following conditional: {if item\_count\_passed} then show checkout form, else show message.

Is this possible/is there a better way to do this? I am saying this is not specific to Cartthrob since I am just asking how to set a variable in extension code that can be used in a conditional in a template.

Thanks!

Edit: I realize that I am probably looking more for a session variable and not a global variable.

Edit #2: Just to be clear, the root question is: How can I set a variable in an extension that I am writing that would be available in a template, particularly within a conditional?

# Answer
You should be able to use CartThrob custom data for this in your extension:

```
$this->EE->cartthrob->cart->set_custom_data('item_count_passed', $item_count <= 8);

```

Then in your template:

```
{exp:cartthrob:checkout_form}
{if custom_data:item_count_passed}
{if:else}
{/if}
{/exp:cartthrob:checkout_form}

```

You might also want to call this in the cartthrob\_add\_to\_cart\_end hook.
> 0 votes

---
Tags: cartthrob, add-on-development, extension
---


# Question
Title: Not all Structure URL's are parsed from Wygwam
If our client selects a structure managed page from the Wygwam link tool, the URL doesn't always parse, resulting in the occasional `{page_XX}` instead of the full URL. However if I drag the page that is getting link to around in the Structure tree, and place it back to where it belong the URL is updated.

I suspect this might have something to do with the Transcribe+Structure combination, as there are still a few small bugs here and there with that collaboration, but I can't tell for sure.

I'm on EE 2.5.5, Structure 3.3.8 and Wygwam 2.7

Any ideas?

# Answer
> 1 votes
I can say that it doesn't relate to Transcribe. I have a site where randomly some (but not all) the links set with the Wygwam Structure link browser outputs {page\_XX} like you are describing. We are not using Transcribe.

I am also on EE 2.5.5, I was on Structure 3.3.8 (now on 3.3.10), and Wygwam 2.7 (now 2.7.1).

I'm not really sure if the upgrade to Structure or Wygwam has fixed the issue. I don't have a way to reliably reproduce it. But I have seen the issue, and am also concerned.

Hopefully that helps figure things out.

---
Tags: wygwam, structure, pixelandtonic, transcribe
---


# Question
Title: Channel Type dropdown not showing all channels
I have 2 channels that are both linked to the same category and status group. However, I tried changing/editing the status from the "options" tab after I published my and only one (the current channel that is assigned to the entry) of my two channels are listed. Is there a setting I missed somewhere to allow all of channels to display here or is this not allowed to change after the page is saved?

http://dl.dropbox.com/u/1739837/Screenshots/dw.png

I'm using Structure which may be causing an issue? Thoughts?

# Answer
As Derek says, only channels with the same field group settings will be shown in that dropdown.
> 1 votes

---
Tags: channel, structure
---


title: Hide a table column if

text:
# Question
Title: Hide a table column if
I've got a compound Matrix/tabular data/conditional situation I'm trying to figure out. I have a table displaying a matrix of credits for various people with columns for Year, Project, Role and Awards. In several cases a particular person may always have the same Role. In a some cases a particular person may have no awards. In each case, that Role and/or Awards column is unnecessary. I would like to use a conditional statement that will:

1. Determine if all the entries of the Role column are the same and if so, hide that column including the column header.
2. Determine if all the entries of the Awards column are empty, and if so, hide that column including the column header.

I can write a conditional on an entry by entry basis to exclude the table cell if it is empty, but that doesn't remove the column, even if they're all empty, because the header is still hard coded.

I've looked into using Stash, https://github.com/croxton/Stash#expstashset\_list-tag-pair but wanted to know if there was a simpler method.

This is an example of a page where both the Role and Awards columns would be hidden. http://toddao.css-staging.com/talent\_detail/joe-barnett

Here is the simplified code

```
{exp:channel:entries channel="creative_talent" dynamic="yes" limit="1"}
        <table>
        <tr><th colspan=4>Selected Credits</th></tr>
        <tr>
        <th>Year</th>
        <th>Project</th>
        <th>Role</th>
        <th>Awards/Nominations</th>
        </tr>
        {credits}
        <tr>
        <td>{Year}</td>
        <td>{Project}</td>
        <td>{Role}</td>
        <td>{Awards}</td>
        </tr>
        {/credits}
        </table>
{/exp:channel:entries}

```

Any advice would be appreciated.

Thanks

# Answer
The item number 2 can be done using the exp:channel:entries and an embed:

```
{embed="template_group/.table" has_awards="{exp:channel:entries channel='creative_talent' limit='1'}{credits search:awards='not IS_EMPTY' limit='1'}yes{/credits}{/exp:channel:entries}"}

```

Sadly, this doesn't work for number 1. So, I used query module for both. In my sample code, roles are on col\_id\_26 and awards are on col\_id\_25. Just replace by the IDs you need.

```
{embed="template_group/.table"

    multiple_roles="{exp:query sql='SELECT row_id FROM exp_channel_titles
    JOIN exp_matrix_data ON exp_channel_titles.entry_id = exp_matrix_data.entry_id
    WHERE url_title = '{segment_2}'
    AND col_id_26 != ''
    GROUP BY col_id_26
    LIMIT 2' limit='2'}{total_results}{/exp:query}"

    has_awards="{exp:query sql='SELECT row_id FROM exp_channel_titles
    JOIN exp_matrix_data ON exp_channel_titles.entry_id = exp_matrix_data.entry_id
    WHERE url_title = '{segment_2}'
    AND col_id_25 != ''
    LIMIT 1'}yes{/exp:query}"
}

```

I used row\_id just to get something from the query.

On your embed:

```
{exp:channel:entries channel="creative_talent" limit="1"}
    <table>
        <tr>
            <th colspan="{if "{embed:has_awards}" AND "{embed:multiple_roles}"}4{if:elseif "{embed:has_awards}" OR "{embed:multiple_roles}"}3{if:else}2{/if}">Selected Credits</th>
        </tr>
        <tr>
            <th>Year</th>
            <th>Project</th>
            {if {embed:multiple_roles} > 1}<th>Role</th>{/if}
            {if "{embed:has_awards}"}<th>Awards/Nominations</th>{/if}
        </tr>
        {credits}
            <tr>
                <td>{Year}</td>
                <td>{Project}</td>
                {if {embed:multiple_roles} > 1}<td>{Role}</td>{/if}
                {if "{embed:has_awards}"}<td>{Awards}</td>{/if}
            </tr>
        {/credits}
        </table>
{/exp:channel:entries}

```

It Isn't a simple answer, but your need isn't simple either.
> 1 votes

---
Tags: matrix, conditionals, table
---


# Question
Title: Nesting a Matrix variable type inside textarea variable (Low Variables)
I've got a variable set up as a 2-col Matrix for easy editing of days/hours (for being open). I'm wanting to nest this in another variable, that contains the mark-up for this snippet (so-to-speak). I have early parse enabled the Matrix var type but within the `{lv_footer}`, it just returns the code as a string from the "nested" var `{lv_hours}`. Anyway I can have that parse before the `{lv_footer}` is parsed?

Here is code in the lv\_footer (saved as file):

```
<div class="hours">
    <h3>Hours:</h3>
    <dl class="hours">
    {exp:low_variables:pair var="lv_hours"}
        <dt>{day}</dt>
        <dd>{hours}</dd>
    {/exp:low_variables:pair}
    </dl>
</div>

```

# Answer
> 2 votes
I'm pretty sure this has to do with the way Low Variables parses nested variables. You may need to add both of these variables to the same group and in the right order for them to parse correctly: `{lv_footer}` should be above `{lv_hours}` in the same group

> ### Nesting
>
> \[cue Inception music\] So, there are three stages at which a Low Variable can be parsed:
>
> 1. As early parsed global variables using the variable syntax (stage 1)
> 2. As tags, single or pair, using the tag syntax (stage 5)
> 3. As late parsed global variables (the default) using the variable syntax (stage 9).
>
> Looking at these stages, you can always nest variables upwards: 2 in 1, 3 in 1, and 3 in 2. As noted before, you can also nest 1 in 1, but only if they are in the same group and in the right order. Theoretically, you can nest 2 in 2, but that might cause your brain to melt. Nesting 3 in 3 won’t necessarily break things, but it can lead to unexpected results. Nesting 1 in 2, 1 in 3, or 2 in 3 will never work.

More on the parse order

# Answer
> 2 votes
If you look at the Nesting quote Siebird posted, you'll also need to know what the different stages (1, 5 and 9) mean.

**Stage 1** is for **early parsed global variables**: Low Variables with early parsing *enabled* and in *variable* syntax: `{lv_my_variable}`

**Stage 5** is for **tags**: Low Variables using the *tag* syntax: `{exp:low_variables:single var="lv_my_variable"}` *Note: Early Parsing has no effect when using the tag syntax!*

**Stage 9** is for **late parsed global variables**: Low Variables with early parsing *disabled* and in *variable* syntax: `{lv_my_variable}`

This means, for your example, that you have 2 vars that are nested. One of them, `lv_hours`, needs the *tag* syntax, and therefore is parsed at *stage 5*. So if you want to nest it inside `lv_footer`, you need to parse that one in *stage 1*: make sure you use *variable* syntax and that early parsing is *enabled*.

---
Tags: add-on, matrix, low-variables
---


# Question
Title: v2.6.1, Structure, Multiple Relationships - How do I render the page URL?
I am using v2.6.1 and the new multi-relationships feature. I am also using Structure. My question is, how do I get the structure URL inside of the new relationships tag. So lets say my related entries field name is "related\_news", how could I populate the hyperlink URL?:

```
{related_news}
    <a href="{related_news:page_url}">{related_news:title}</a>
{/related_news}

```

# Answer
I haven't used that new feature, but it would be the same as the Pages module since we store our data in the same place.
> 2 votes

---
Tags: structure, relationships
---