# Question
Title: Upgrading an EE1 site to EE2 with nGen File field
What is the best way to upgrade a site from EE1 to EE2 that is using nGen file field with no EE2 equivalent. This site is also using nGen file inside of Matrix Fields.

# Answer
> 32 votes
The best way to do this is to proceed carefully and make backups of your database at each step of the way. I have previously written a blog post on this, but will elaborate further.

**Step 1:** Before running your upgrade change all ngen field types to text, don't worry the data won't be lost.

**Step 2:** Next upgrade ExpressionEngine as per the official docs and then go back into each field and and change them to the first party file type.

The next step involves a little bit of database manipulation, but it's just copy and paste so don't worry.

**Step 3:** Do make a back up of your database before you proceed just in case.

**Step 4:** This next step depends whether your original nGen file field was in a standard Channel Field, or a Matrix Field.

Now go into your database and Replace “X” with your File field’s ID (you can get that from exp\_channel\_fields), and Y with the upload preference ID that nGen File Field was set to.

(To find your upload preference ID in your control panel, go to Content \> Files \> File Upload Preferences. Choose the ID column on the left that matches the file upload location.)

**4a:** If updating standard Channel Fields, use this query

```
UPDATE exp_channel_data
SET field_id_X = CONCAT('{filedir_Y}', field_id_X)
WHERE field_id_X != ''
AND field_id_X NOT LIKE '{filedir_%'

```

**4b:** For matrix fields run this query instead

```
UPDATE exp_matrix_data
SET col_id_X = CONCAT('{filedir_Y}', col_id_X)
WHERE col_id_X != ''
AND col_id_X NOT LIKE '{filedir_%'

```

X == your Matrix column ID (you can get that from exp\_matrix\_cols), and Y == your upload preference ID.

Credit to Brandon Kelly and Rob Sanchez.

Additionally the same procedure can be used for other add-ons that don't exist in EE2. Convert to text before upgrade and then convert to a new equivalent field type post upgrade if needed.

# Answer
> 14 votes
I asked this same question for a recent EE upgrade. The answer is on Stack Overflow:

https://stackoverflow.com/questions/13041491/expressionengine-1-to-expressionengine-2-upgrade-with-ngen-file-field

The EE2 equivalent field is Safecracker File. Worked perfectly for my upgrade.

# Answer
> 6 votes
I did a lot of different trials trying different methods. In the end no single method is perfect. I've found the thread Brad suggested very useful before.

Whatever method you try, make sure to backup everything twice. What I initially did was create two separate test DBs (one being a copy of the EE1 DB and a separate new EE2 DB) just to test out before the "production" run. Had errors the first couple of tries and then when I was satisfied did the live run.

# Answer
> 4 votes
Take a look at this, I was working on upgrading a EE1 (220+ weblog) instance to EE2 a while back, I shared some of it here: http://expressionengine.com/forums/viewthread/203380/#952561

---
Tags: ee1, ee2, upgrade, add-on, matrix
---


title: Turn off extension in Control Panel

text:
# Question
Title: Turn off extension in Control Panel
I would like to make sure an extension isn't run, via sessions\_end hook, in the control panel.

I'm currently doing this like so:

```
if ($this->EE->input->get_post('D') == "cp")
{
    return FALSE;
}

```

My question: is there a better or prefered method of having an extension only run a hook on the frontend and not in the CP?

# Answer
That should work fine, but you can also check the `REQ` constant (docs) which has the following possible values:

* `CP` \- Control panel requests
* `PAGE` \- Frontend template requests
* `ACTION` \- Module actions, e.g. mysite.com/?ACT=123

For example:

```
if (REQ == 'CP')
{
    return FALSE;
}

```
> 17 votes

---
Tags: add-on, extension, hook, session-end-hook
---


# Question
Title: How would you wrap EE authentication around a custom app?
A client has an EE2 site and wants us to setup a 3rd party app but keep it private to EE members only. How would you extend EE's member sessions to provide single sign on with a 3rd party PHP app?

The app is made up of multiple PHP files and has it's own interface. So, it won't be easy to extract into a custom plugin or module.

We thought about using an iFrame to load the app into an EE page that is for members-only, but it wouldn't be hard to get the iFrame's source URL and hit it directly, bypassing the security.

Now we're considering building a custom module that provides an EE authentication API via action ID. So, we'd create a simple is\_logged\_in() function that is used in the custom PHP app that sends the value of the EE session cookie to our API and the custom module would determine if it's a valid session or not. If it's not a valid session, the custom app would redirect to our EE login page.

Are there any other ideas we should consider?

Assume for this exercise that the app runs on the same server as the EE site.

# Answer
> 3 votes
It's worth bearing in mind that EE has plenty of hooks to make this sort of thing easier - sessions\_end and member\_member\_logout are a couple that would be worth looking at.

Depending on whether or not your app has a built in authentication library it would probably be fairly simple to write an extension that initiates a new session within your app. You'd just need to include the relevant assets and fire off a call to `MyApp::Authenticate($session_id)` when the EE session is created. When the EE logout hook's called you'd clear out your app's session via `MyApp::DestroySession($session_id)`.

# Answer
> 6 votes
Take a look at system/expressionengine/libraries/Auth.php. You should have all the available methods at your disposal to properly create any member session without actually submitting a login form. The ACT would work well I think, provided you pass all the other correct information.

Here is a very minimal example of the proposed process.

```
// Grab the member record using a standard ActiveRecord query
$this->db->where('username', 'some_user');
$member = $this->db->get('members');

// Instantiate the Auth_results, which created the user session
$result = new Auth_result($member->row());

```

# Answer
> 4 votes
I would develop an EE add-on that implements an SSO (single sign on) protocol, like oauth or SAML: http://en.wikipedia.org/wiki/Security\_Assertion\_Markup\_Language

and then have the the 3rd party app authenticate the user using their EE credentials, which would get passed back and forth between EE and the app using oauth, saml, or some other open authentication protocol.

# Answer
> 1 votes
Perhaps you could build a wee API that returns a JSON or xml file for the active user.

Something along the lines of..

**Logged in** True **Username** joe.bloggs **Email** joe.blogs@gmail.com

Have a simple login template that could be popped up if the result of the above was false. Once they login refresh the page and their details would be good as gold. Additionally you could perhaps have the user ID in that file so you can actually connect to the SQL and grab more data that way.

The method I've described is purely hypothetical and I'm not sure if it would work - but it is based on the same basic theory of Facebook Connect.

---
Tags: single-sign-on, security
---


# Question
Title: Accessing a template via AJAX from a template group
I'm trying to access a partial template via AJAX from a template group but I keep getting a 403 forbidden or 404 not found error.

I'm using the great Ajax-include pattern Jquery script from the Filament Group. This script relies on you specifying the html file you want to retrieve from a data attribute in the template; could that have something to do with why I'm getting a 403/404?

I've tried all combinations of paths to the template but still get the same result. I've also tried naming the full path, including the .group, with no success. If I put the HTML file in the root of the site everything works fine.

All templates have been synced and saved as files.

* Path to templates: /assets/templates/default\_site/
* Template group: site.group (default template group)
* Template: footer-resource-menu.html

Template code:

```
<ul>
<li class="dropdown" data-append="footer-form-webmail.html" data-media="(min-width: 50em)">
    <a href="#nowhere" class="dropdown-toggle" data-toggle="dropdown">My Island <b class="caret"></b></a>
</li>
<li>…</li>
</ul>

```

**UPDATE** This was due to the `.htaccess` file being missing from web root.

# Answer
> 8 votes
What is the path to load the template in your browser, through EE (like a normal page on the EE site)? Did you try using that path, too? That would be the one I'd expect to work. You'd want to do this anyway if there are any EE tags in the template, to be sure they get parsed.

If you try to access the URL of a template file directly with the browser you will get a 403 error. The error is given because EE puts a `.htaccess` file in your templates folder that has `deny from all` -- so it prevents templates from being accessed directly, rather than through EE.

So, assuming you are removing index.php, if the partial you are trying to load is the EE template `something.html` which is located in the EE template group `partials.group`, the path to use is `/partials/something`

To test the path is good I would first load it in the browser directly, as one normally would an EE template. If there are no errors, then that path should work with ajax.

---
Tags: jquery, ajax
---


# Question
Title: Adding forms to individual entries where only one or two questions change
A client has requested setting up a channel where they can add forms associated with each entry.

At first Forms from DevDemon looked like a good fit as it has a fieldtype to enable this, but in my case, the forms will be nearly the same for every entry except for one or two questions. For example, every form will capture name, email and phone, but then there will be one or two questions unique to that entry.

So really I need to either be able to save a form for reuse for each entry which can then be modified to include the unique questions, or have a way of defining certain default inputs that apply to every form, and then when the client creates a new form in the CP, the new questions get added to the default set.

Currently it doesn't seem like Forms can do this (saved forms is a feature that may be introduced later) so I'm wondering if there's a way to do this with one of the other forms add-ons?

Or maybe another creative solution?

# Answer
For anyone else following along, it looks like you can do exactly what I want with http://devot-ee.com/add-ons/proform-catchall
> 2 votes

# Answer
What about taking a hybrid approach using FreeForm?

Add a matrix to your channel and allow the editor to define the custom fields. You'd want columns for field labels and field type (dropdown, text, etc) and possibly a third for field options.

Your template will hard code the fields that are common to all forms and loop through the matrix to generate the custom fields.

This article goes into more detail. It's from EE 1.x but the same principles apply.

Also, this article has a nice round up of EE2 form addons.
> 2 votes

---
Tags: add-on, forms
---


title: Database Channel ID Error

text:
# Question
Title: Database Channel ID Error
I've been working on a site for about a year now without issue. There's a good number of channels and entries (about 11/2000+). Within that last couple weeks, I seen something strange happen. The channel ID's in the database seem to be in correct.

An example:

* Vendors channel\_id = 4 in the exp\_channels table
* in exp\_channel\_titles, channel\_id 4 correlates to the title for the blog channel (channel 5).

Has anyone ever experienced this before? I'm trying to go through and fix this, but it's now causing more issues (IE: when you go to a page with a safecracker form it's not pulling in the channel fields for that channel).

Have I completely screwed myself? How can I fix this?

Thanks!

# Answer
> 5 votes
Lucas fixed his issue and I quote:

> I was able to fix this by going through each channel in the CP and re-updating them to be pointing to the correct channel fields.

---
Tags: ee2, database
---


# Question
Title: A conditional for "paginate" loop rendering needed
The "paginate" loop within the channel:entries tag used to render even when no next or previous links would need to render. This seems like it may have been "fixed" in response to a bug report here: http://expressionengine.com/bug\_tracker/bug/11298/.

Unfortunately, this change this leaves no way that I can find to test to see whether pagination is without resorting to PHP in my template. PHP does seem to solve the problem but I wondered if anyone else has a way to do this with native EE code.

# Answer
> 5 votes
This should work:

```
{exp:channel:entries limit="10"}
{if count == 10}
{!-- we actually got 10 so we know there could potentially be more --}
{embed="embeds/paginate" offset="10"}
{/if}
{/exp:channel:entries}

```

And then the paginate embed:

```
{exp:channel:entries offset="{embed:offset}" limit="10"}
{if count == total_results}
YES WE DO HAVE PAGINATION
{/if}
{paginate}blabla{/paginate}
{/exp:channel:entries}

```

Of course, it's superhacky and ugly and you should use AB Pagination instead ;-)

---
Tags: pagination
---


# Question
Title: Exp:resso's Store apply coupon to category only
Does anyone know if it is possible to set up a promo code in Store that only applies to products in a certain category?

I am happy to use an extension (if one exists) to fill the gap if this isn't supported natively.

# Answer
> 6 votes
There are no existing extensions that I'm aware of that can handle this functionality. Currently promo code discounts are applied to a whole order, not individual items.

However, it would certainly be possible to write something in PHP to handle this using the extension hooks.

---
Tags: extension, expresso-store, module, expresso
---


# Question
Title: What is parse order and how does it affect how my template is coded/rendered?
What exactly is parse order and how does it impact my template code and whether I should use embedded templates, global variables, snippets, low variables, stash or any other method that I may not have heard of yet.

Specifically when would I want to use early parsing vs late parsing with Low Variables. Why not just have everything early parsed?

# Answer
> 41 votes
> No one can be told what the Parse Order is, you have to see it for yourself.

Jest aside, parse order is a very tricky subject indeed. My PDF and blog article will help somewhat in grasping it, and some might find my Parse Order Pro sides helpful. But those only are pointers to a more general approach to EE's template parsing.

The point is, EE's parse order is **linear**; things happen after another. The *things* in this case is the replacing of tags and variables. The *happen after another* is the order we speak of. Things in the template are replaced, but can only be replaced if they are *in the template*. When certain tags or variables are put into the template *after* their parsing stage (according to my pdf) has passed, they will remain unparsed. This is the main reason parse order issues exist.

Now, the PDF and blog post only glances at module and plugin tags, but their parse order is intricate in its own. I tried to explain this in my Parse Order Pro slides, starting from slide #88. I could go on with explaining it, but this post might get too lengthy for that. Instead, I'll answer your last question.

> Why not just have everything early parsed?

Main reason: security. The values of early parsed vars can be parsed by EE's template parser, which means they can potentially break the template. This is especially true if the variable type is a text input field or textarea. The user can put anything in there, including tags or even PHP if the template where the variable is present has that enabled. Developers who know what they're doing can use textareas with early parsing turned on (effectively Snippets), sure. But you can hide those, keeping the templates safe from your user's curious little hands.

So, keep your vars as late parsed vars, *unless*:

* You're using them as input for vars or tags
* You're using them in conditionals
* They contain other vars/tags

You could basically say: enable early parsing **if you need the variable content in stages 2 to 8**, leave it disabled if you don't.

Of course, you can also parse Low Variables during the Tags stage (#5), in which case having early parsing enabled is irrelevant.

# Answer
> 15 votes
Fleshing this out further to answer (in part) your question of what is parse order.

Essentially, all parse order is - is the 'order' in which ExpressionEngine takes to process (or parse) each aspect from a page being requested to the completion/render of the page to the browser.

The following is taken directly from Low's Parse Order:

```
Read URI to determine template
 Get template from DB, check permissions & authentication
 Get template from ﬁle
 Return static template
1. Parse snippets / global variables, segment variables and embed variables *
 Parse date string constants
 Parse {template_edit_date} and {current_time}
 If present, get cached template, then go to #7
2. Parse PHP on Input
3. Parse simple conditionals: segment, embed, global variables
4. Assign and parse preload_replace variables
5. Parse module and plugin tags
6. Parse PHP on Output
 Write cache ﬁle
7. Parse advanced conditionals
8. Process embedded templates
Redirect
9. Parse User Deﬁned global variables and others.

```

# Answer
> 12 votes
Here's a link to Low's foundational pdf -- it's got some more detail which can be useful, and it will am sure update as knowledge grows or EE is extended.

http://loweblog.com/downloads/ee-parse-order.pdf

Since he will likely not do it, I'll also give a link where Low discusses parse order in detail, and in relation to his very well regarded Low Variables, which allow you among other things to work positively with parse order.

http://gotolow.com/blog/parse-order-and-low-variables

These are all important topics, because as programmer-experienced person discover on encountering EE, it's not a conventional scripting language. That's very possibly some of its advantage for more pure designers, as was the original intention.

# Answer
> 3 votes
One reason to use late parsing is that early parsing adds *slightly* more overhead in a lot of cases. The usual thought is that if you don't need things to be parsed early, you should leave them late-parsed for performance. That said, it's a *very minor* bit of overhead.

---

It is also possible that you have some Low Variables and you want to use one of them as input *into another one*. In that case, using one early-parsed and one late-parsed would guarantee that they were processed in the correct order.

**Extremely Contrived Example:**

I have some low variables called `{one_fish}`, `{two_fish}`, `{red_fish}`, and `{blue_fish}`, one of which should run on the site at a time. I want to set up which one runs by using another Low Variable, `{type_of_fish}`, which is a dropdown with available options `one`, `two`, `red`, and `blue`.

In this case, I would set `{type_of_fish}` as early-parsed, and all of my various `fish` as late-parsed. Then in my template I can do the following:

`{{type_of_fish}_fish}`

If `{type_of_fish}` is set to `one`, the final output from the template parser will be the *contents* of `{one_fish}`. If it's set to `red`, final output will be the *contents* of `{red_fish}`.

# Answer
> 2 votes
If you're using Low Variable you can create groups to keep your variable in. These groups parse in the order they are listed. I find it helpful to have two groups, one on top called 'snippets early' and another just underneath called 'snippets later'.

---
Tags: add-on, parse, low-variables, parse-order, template-scripting
---


title: Account specific content by subdomain

text:
# Question
Title: Account specific content by subdomain
I'm wanting to use EE2 for a SaaS product where account holders view their instance of the service through a subdomain. I'd like to take advantage of channels that combine similar structured content across all accounts, but have the subdomain help limit the content that is displayed to just that account.

So a structure like this:

* my-ee-site.com/ -\> Marketing site
* my-ee-site.com/settings -\> 404
* account1.my-ee-site.com/ -\> Account 1's publicly available content
* account1.my-ee-site.com/settings -\> Redirect to account specific login page \[logged out\] or account owner's settings page \[logged in\]

I'm considering an accounts channel with a user-editable subdomain mapped to a more permanent account id, that way I can attach more than one member to it. I was also thinking I could also attach this account id to all content during the content creation process so I could easily filter by it (i'd be using safecracker, not through the control panel).

Have you done this before? Are there other routes I should consider?

# Answer
This is doable with EE (assuming you get thumbs up on the legal licence side of things).

You'll need to set up your domain so all (or most) subdomains resolve to a single location. You'll also need to configure apache to listen for traffic for all subdomains for your main domain.

Check out the following articles for details in performing this step: http://www.bybjorn.com/598/ http://net.tutsplus.com/tutorials/php/basecamp-style-subdomains-with-codeigniter/

I would probably write an extension that would check to make sure the subdomain is an valid account, and then add a bunch of global variables for use in templates.
> 5 votes

# Answer
You should probably check that your intended use is permitted under the EE license:

> Restrictions
>
> Unless you have been granted prior, written consent from EllisLab, Inc., you may not:
>
> * Use the Software as the basis of a hosted blogging service, or to provide hosting services to others.
> * Reproduce, distribute, or transfer the Software, or portions thereof, to any third party.
> * Sell, rent, lease, assign, or sublet the Software or portions thereof.
> * Grant rights to any other person. Use the Software in violation of any U.S. or international law or regulation.

I'd drop EllisLab quick line via their contact form to find out.
> 5 votes

---
Tags: ee2, subdomain, saas
---


title: Matrix column with list field type

text:
# Question
Title: Matrix column with list field type
We're integrating a new client site that has a rather unique need. We have a matrix field with two columns. The second column needs to be output in the template in a list format (LI tags). Originally we planned on integrating P&T List for the second column but we found that it doesn't allow carriage returns, which is another requirement.

Here's the template we'll be integrating:

http://www.itistic.com/projects/radiologyassociates/html/radiologists/kedar.asp

We're using Matrix to output custom designations for each radiologist. In the page above, the USF Associate Professor list would be an example of a custom designation. So in our Custom Designations Matrix field we'd have the following columns:

```
USF Associate Professor   |   - Body Imaging
                              - Musculoskeletal

```

.. and here's another example:

http://www.itistic.com/projects/radiologyassociates/html/radiologists/feldman.asp

In this entry, the Cross Sectional Imaging Fellowship would be a custom designation that's input via this Matrix field. You can see here that we need the ability to do line breaks/carriage returns in a single list item.

```
Cross Sectional Imaging Fellowship   |   - Mayo Clinic
                                           Jacksonville, FL
                                           Body Imaging

```

Any options?

# Answer
> 10 votes
Markdown is probably worth considering, although users would familiarise themselves with the two-trailing-spaces linebreak behaviour, which isn't exactly intuitive.

If you're using WYSIWYG fields elsewhere that's also an option. For example, you could easily setup a Wygwam editor config which only has the bulleted list control enabled. That would be crazy-simple and fairly robust, as users aren't going to start screwing around with other controls that might make a mess of the layout.

# Answer
> 6 votes
Not the best though, maybe use 3 columns:

Then do something like the following:

```
<ul>
    {your_matrix_field}
        <h3>{mx_text_title}</h3>

        {if mx_nolan_items}
            <ul>
                <li>
                    {!-- single line so our backspace isn't having to count blank spaces --}
                    {mx_nolan_items backspace='4'}{nolan_item}<br>{/mx_nolan_items}
                </li>
            </ul>
        {/if}

        {if mx_ptlist_items}
            {mx_ptlist_items}
        {/if}

    {/your_matrix_field}
</ul>

```

Make sure you explain in the field directions or via NSM Publish Hints that they should only use the list or the nolan for each row. So only one or the other vs both at once.

# Answer
> 2 votes
Are you using Low Variables? you can put a low variable, which contains a matrix field, inside a matrix and that would theoretically give you the list that you need inside that cell. I haven't tried this myself, but it should work.

Alternatively you could check out Nolan, which lets you have a simple matrix inside a matrix.

---
Tags: matrix, list, custom-fields
---


title: CE Image configuration for MSM

text:
# Question
Title: CE Image configuration for MSM
have an MSM site that I’ve just moved from test to production and we’re white screening on the front-end. I suspected CE Image straight off - commented out my tags and sure enough, the site loaded sans images. I’ve set 128M for CE Image via the config file and then inside index.php we’ve got

```
$assign_to_config['global_vars'] = array(); // This array must be associative
$assign_to_config['global_vars']['ce_image_document_root'] = '/home/user/public_html/msm-site/';
$assign_to_config['global_vars']['ce_image_src_regex'] = array();
$assign_to_config['global_vars']['ce_image_made_regex'] = array();
$assign_to_config['global_vars']['ce_image_encode_urls'] = 'no';
$assign_to_config['global_vars']['ce_image_disable_xss_check'] = 'yes';

```

This works fine on the test server (although we didn’t set the memory limit on test). Interestingly though, the config file editor in the CP is showing ce\_image\_memory\_limit set at 64 and even changing it there isn’t allowed. Where’s it going wrong?

# Answer
> 3 votes
So it turns out to be a server issue where GD support hadn't been enabled in PHP.

Enabled that, kept the same code and we're golden :-)

# Answer
> 5 votes
You need to fill in the array for all of your domains that are part of MSM. I copied this from config.php for a 9 site MSM install and reduced it to just 3 sites to demonstrate:

```
// ce_img stuff here
$config['ce_image_src_regex'] = array(
  '^http://maindomain.com/' => '/var/www/vhosts/maindomain.com/httpdocs/',
  '^http://domain1.com/' => '/var/www/vhosts/domain1.com/httpdocs/',
  '^http://domain2.com/' => '/var/www/vhosts/domain2.com/httpdocs/'
);

```

Once you fill in the correct domains and server paths, you should be good to go.

---
Tags: ce-image, multi-site-manager, config
---


# Question
Title: Distribute images in a custom Control Panel theme?
When creating a custom Control Panel theme, with the help of an override.css file, the easiest way is to make a copy of the default theme's image folder and put that in your theme directory. Then, make changes to the images located in that folder.

If you like to give away or sell a custom theme, how do you distribute the images folder (since I guess all icons not changed by you is licensed by EllisLab) and still make it a easy install?

# Answer
As I understand it, the principle over the override is that you only include files/images and include changes - the rest are inherited from the parent (default) theme.

Therefore, you don't need to include all of EL images with it.
> 1 votes

# Answer
I can't speak to the legality of distributing the images from the default CP theme. I'd say that's a question to pose to EllisLab directly.

But you can add an override.css to piggy-back off the default CP theme styles and images. That's how the NSM Override.css theme works.

Since NSM Override v1.2.0, they store all CSS and images in a separate folder, `themes/cp_themes/nsm_override`. To install it you to only add one line, an @import rule, to the override.css file in the default theme folder:

```
@import url("../../nsm_override/css/screen.css");

```
> 5 votes

# Answer
We use 'Default' as our control panel theme and override it. We keep the same theme on all of our clients sites, and often make improvements and enhancements to it.

To aid with this, we adopt the NSM\_override method of simply importing an external CSS file from override.css but go a step further by actually hosting it elsewhere (in our case a special domain where we keep this kind of stuff).

```
@import url("http://topsecret.com/custom_cp/loader.css");

```

This way it takes seconds to add to a new site and all of our sites get improvements at once.

It's never popped up, but if a client wanted their own bespoke changes we would probably import our loader.css as normal but then continue our overrides below, so for example....

```
@import url("http://topsecret.com/custom_cp/loader.css");

body {
    background: green;
}

```

All of this is a round-about way of saying that you don't need to comply with the EE file structure to manage your custom themes. You can continue to use EllisLab's images by simply referencing their standard location or you can use your own. Because everybody has 'Default' there's no need to re-distribute.
> 1 votes

---
Tags: cp-themes, license
---


title: Add-on Development with Themes and Git

text:
# Question
Title: Add-on Development with Themes and Git
I'm wondering how add-on devs who's add-ons have themes use Git? For example, the way I do things now is to just make my add-ons repo the core folder; eg, securitee or ct\_admin within the third\_party directory will contain the .git folder.

This doesn't work with themes though since those are stored in a completely separate directory and path than the core add-on code.

I was thinking I may need to have a completely stand alone installation of ExpressionEngine for each add-on and just use a .gitignore file to only allow the add-on files. This sounds over complicated though so I'm hoping to avoid this.

Any other ideas?

# Answer
> 28 votes
I always lay my add-ons out to match the directory structure of a default ExpressionEngine install. For example, check out Freemember on github. I think this makes it most obvious for customers downloading the add-on (believe it or not we used to get questions about where to copy the files to).

In Store, my git directory structure looks like this:

* /system/expressionengine/third\_party/store
* /themes/third\_party/store
* /Makefile etc (which I don't include in zip distribution)

I clone this git repo into my Dropbox folder, which sits in `/Users/adrian/Dropbox/Dev/store`

**The final trick is simply to symlink your local EE install to your add-on directory.** For example, (assuming your are using Max OS, Linux, or any other unix-based OS), to create links from my Dropbox folder to my EE install at `~/Sites/storedev`:

```
cd ~/Sites/storedev/system/expressionengine/third_party
ln -s ~/Dropbox/Dev/store/system/expressionengine/third_party/store ./

cd ~/Sites/storedev/themes/third_party
ln -s ~/Dropbox/Dev/store/themes/third_party/store ./

```

Also, since you're using git for add-on development, I highly recommend checking out git flow for managing your different feature branches and releases.

# Answer
> 4 votes
I personally store the addons in a central "code" folder and then symlink the addons' third\_party and themes folder to my sandbox folder. This way the git folder contains both system and themes addon folder.

# Answer
> 4 votes
I set this up by creating a "themes" directory inside my main repo. For instance with ProForm, my directory structure in development actually looks like this:

```
~/public_html/ee/third_party/proform/
__notes/
__static/
config/
docs/
language/
libraries/
models/
plugins/
templates/
tests/
themes/
views/
config.php
ext.proform.php
index.html
mcp.proform.php
mod.proform.php
README
tab.proform.php
upd.proform.php

```

I have multiple directories like this, one for each add-on that I write. Each of these is it's own git repository.

Notice that there is a directory here named "themes". This doesn't actually end up in this location within my produced ZIP files, but is just here to keep everything in one place within the repository.

I create a shared themes directory which contains soft links into each add-on:

```
$ cd ~/public_html/ee
$ mkdir themes
$ cd themes
$ ln -s ~/public_html/ee/third_party/proform/themes ./proform

```

This directory ends up with a single linked themes directory for each add-on.

I then have multiple EE installations, one for each point release that I test with. These go into directories such as

```
~/public_html/ee231
~/public_html/ee252

```

Within each of these, I go to it's system/expressionengine/ directory and create a soft link to the main third\_party directory above:

```
$ cd ~/public_html/ee252/system/expressionengine
$ rm -rf third_party
$ ln -s ~/public_html/ee/third_party ./third_party

```

I then create a link to the themes directory which itself contains the soft links into each add-on:

```
$ cd ~/public_html/ee252/themes
$ rm -rf third_party
$ ln -s ~/public_html/ee/themes/third_party ./third_party

```

This way, I have all of my add-ons 1) in their own repos, 2) with a simple layout including the theme directory and 3) available for easy testing in all my supported EE versions.

**Edit:** I should also note that I use a build script which assembles the actual add-on directories into the expected structure prior to zipping them up - for example, for ProForm this is:

1. Removes all directories that start with \__
2. Moves the root into {zip\_base}/system/expressionengine/third\_party/proform
3. Moves the themes/ directory into {zip\_base}/themes/third\_party/proform

Finally, I also manage all of this using the excellent git-flow strategy. My build script will produce a ZIP file using this logic from any point release tagged by git-flow, and will automatically include reusable libraries or other bits that I need to assemble (such as building static documentation HTML from sources, including ProLib, etc.).

---
Tags: add-on-development, git
---


# Question
Title: EE css template vs. a standard css file?
Is there an advantage/disadvantage to using a EE css template vs a standard css file? I tend to use a css directory that is separate from EE templates. I like using a css preprocessor, and I prefer not to sync my css files through the Template Manger. I am wondering if I am missing some advantage to not using a ExpressionEngine css template?

# Answer
> 27 votes
I'd say you're not missing much at this stage in the game and if you are using preprocessors then even more reason to not use EE CSS templates.

With that said, I could see if you wanted to give your clients access to edit certain colors, for example href colors, then you could build something dynamic which allowed them to edit said colors via GVs, Snippets or Low Variables etc. So the advantage would be the fact that you could use Tags (or PHP even) in a stylesheet template.

Aside from that I'm not seeing much advantages for going that route. Oh, maybe caching; I don't know to be honest on that either because, you have add-ons like Minimee which will minify and cache your css now as well so, not really sure if there are any advantages there any longer either.

# Answer
> 11 votes
Very rarely will I run CSS through EE.

There are times when it's useful as Nate has said but generally it's another load on the template parser that doesn't need to be there.

I also generally keep my 404 page outside of EE as well because it's another db load that doesn't need to be there.

I never edit templates in production either.

# Answer
> 7 votes
The main advantage of using CSS templates over flat files (as Natetronn has mentioned) is the cache busting EE provides. EE adds a version number to the end of the file name automatically and this will flush the CSS out of browser caches each time you update the CSS. This can be highly important if your main audience is sitting behind a corporate firewall as they tend to cache for longer.

I like it as it gives me the opportunity to edit the CSS through the EE cpanel should I need access when I don't have FTP access - such as when I don't have a laptop with me. Yet using Mountee I can still edit it in my code editor of choice.

The other advantage is Versioning, if you have it turned on and are not using a version control system like Git.

# Answer
> 6 votes
I've just used SASS for the first time on a project and I ended up with a bit of a hybrid solution.

I had one main.css stylesheet which was generated by Compass (for all the SASS goodness). This just overwrites the EE CSS template when it generates.

I then had a second stylesheet dynamic.css which was used purely for stuff which the client could edit, such as background images, colours etc. This was a standard EE CSS template. The second dynamic one was pretty sparse, literally only containing the stuff that could be edited and nothing more.

I kept the two files in the location in the EE file structure for no other reason than, if someone was to follow behind me, that's where they'd expect them to be.

Splitting the stylesheets out into two separate ones might be a bit much for most folks, but I get really twitchy when working on massive all encompassing files which have loads of different stuff going off in them. I'd much rather keep things in there own separate box, and then combine them at the end. Which thanks to Natetronn is what Minimee looks like it's going to do for me.

I would be interested to hear if this is a totally dumb way of going about things as it is the first time I've done it, so I'm all ears if there is a much better way.

---
Tags: ee2, performance, css
---


# Question
Title: ExpressionEngine addon script conflicts in MSM sites
What is the best way to manage the ExpressionEngine themes folder with an MSM setup which includes multiple domains?

Currently, I am copying/mirroring the themes folder across all site folders contained in the MSM setup. This tends to work fairly well as long as I set the 'URL to your "themes" folder' and the 'Theme Folder Path' in the Admin section of the CP for each site accordingly, and remember to copy the update files across all domains each time one is added or updated.

My problem is getting a cross-domain access error with js if one of those steps is forgotten or fails. Is there a better way of managing fieldtypes, extensions, etc. where I could keep everything located near the system files and not get these errors when using MSM?

# Answer
I keep my themes folder with the primary domain and then for each sub site set the themes path and url to match that. Everything is working fine for me doing it this way. I've got several 2-3 site MSM installs running like this and one 10 site install without any issues.
> 3 votes

# Answer
This has not been a problem for me, so I'm not 100% sure that this addresses your issue, but I believe you could set up your apache vhosts config (or other web server equivalent) to have the themes folder for all your different domains and sub hosts point to the same actual folder on the server itself. This should avoid any issues with loading up JavaScript from another domain.
> 4 votes

---
Tags: add-on, multi-site-manager
---


# Question
Title: Is there a plugin like Zenbu for the CP members admin section?
We have a client that wants to see member custom fields when looking at the control panel member list (including the "activate pending members" screen).

Is there a plugin similar to Zenbu except for the members section? Are there any other ways to display custom member fields on the member list page?

Note we are **not** using Zoo Visitor or Profile:Edit on this site and would prefer not to add these to an already complicated site unless we really need to.

# Answer
> 4 votes
That would be nice. I haven't seen one.

I often create a frontend admin area to list out members how I want them, and create frontend forms to edit their details.

Sorry, it's the long way. However, it is useful if there are editors that have no need to login into the CP, but need to control the membership side of things.

---
Tags: members, control-panel, admin
---


# Question
Title: CI is not including its PHP files properly?
Has anyone see then before?

```
Warning: set_error_handler() expects the argument (_exception_handler) to be a valid callback in /home/nginx/domains/xxx.com/ee_core/codeigniter/system/core/CodeIgniter.php on line 63
Fatal error: Call to undefined function is_php() in /home/nginx/domains/xxx/ee_core/codeigniter/system/core/CodeIgniter.php on line 65

```

Since last night, all URLs on the site suddenly started returning that message. I can't access the CP, either. From looking at the code in CodeIgniter.php, it looks like the missing functions are all in Common.php, which is included at the top of the file. Any reason CI would be unable to run the included code? (Yes, I checked permissions already....)

Any help is greatly appreciated!

# Answer
> 2 votes
It turned out to be a server problem. The hosting company restarted Nginx and PHP and everything went back to normal. Mysterious.....

---
Tags: codeigniter, php, error
---


# Question
Title: Content field in new entries do not write to the database
I have been experiencing an issue in our UAT environment in regards to new entries. When I publish a new entry, the entry id and the title get written to the database, but the text in the Wygwam field does not. I have to go back into the entry again and paste the content into the Wygwam field and then it will write to the database. Has anyone ever experienced this before? Does anyone have any idea what the culprit could be?

# Answer
Generally the first thing I do when running into an issue with something I have used for a long time which has worked well is to simplify the environment. In this case I would create a test channel with only a Wygwam field (use a preset config rather than a custom config.) If this works then perhaps Wygwam (or more specifically, the JS) is conflicting with another field.
> 3 votes

---
Tags: database, entry
---


# Question
Title: Error when trying to access member profile page
When trying to access a member profile page using the trigger url (e.g. mysite.com/profile) I get the following error:

```
The member profile you requested is currently not available

```

I've checked all the things I can think of. I have seen it once before on a site but given that the normal EE sites I build have very limited membership features (i.e. just the site admins) and I normally turn off member profiles/obfuscate the url I'm at a loss to work out why this is happening.

Has anyone encountered this problem before and found a fix?

# Answer
> 7 votes
If I recall correctly, the trigger itself is not enough - you need to append your action to the last segment

At least, thats what I figured to be the problem when I had this. I had to go to /profiles/login/ and /profiles/profile/ etc and then this worked fine.

Although this could be a bug - but is the way that I've done it.

# Answer
> 3 votes
You do need that last segment to trigger a specific profile and template.

---
Tags: error, members
---


# Question
Title: Separate First Name/Last Name fields in Exp:resso Store Billing Name field?
Is there a way to store separate first / last name fields in the Exp:resso store billing name field?

# Answer
You can use a custom order field for this (although it won't then automatically follow the "shipping same as billing" setting, so you would need to implement that using javascript).

There is also an extension on Devot:ee which does this: Store: Firstname/Lastname

I have not used the extension, but if anyone has perhaps they could post their experience using it here.
> 4 votes

---
Tags: expresso-store
---


# Question
Title: Filtering Member List from Multiple Member Groups?
On a site I took over from another developer, I need to output a list of members from multiple member groups (Staff, Editors, Super Admins) but only one Super Admin member needs to show in it.

The current implementation uses an obscure plugin — it might be a custom add-on as I can't find it via Google — to list members in the Staff and Editors groups. The need to show a single member of the Super Admin member is a new requirement.

If possible, I would like to avoid using an exclude by member\_id approach — that is filtering by a list of member\_ids that I do not want to show. Instead, I would like to include by member\_id, so only that one specified member is listed. So more {if member\_id == ""} and not {if member\_id != "}, but with the need to show all members in the other two groups.

Going that route, as new Super Admins are added (which is very infrequently) I won't have to revisit the project to add yet another member\_id exclusion.

but an include by member\_id, so only a specific Super Admin will show in the list. That way, as new Super Admins are added (which is very infrequently) I won't have to revisit the project to add another exclusion.

Any thoughts?

# Answer
> 8 votes
There are probably multiple ways to accomplish this but the Query module has really become my go-to when there are specialized requirements for the data I want to display, or when there aren't obvious ways to do something with regular EE tags.

Here is an example of what I think you are asking for. Show all the members for a couple member groups (add more if needed) and also for a single suepradmin, selecting that member by id.

```
{exp:query sql=
    "SELECT screen_name, group_title
    FROM exp_members
    JOIN exp_member_groups ON exp_member_groups.group_id = exp_members.group_id
    WHERE exp_members.group_id = 6 OR exp_members.group_id = 7 OR exp_members.member_id = 1"
}
    <li>{screen_name}, {group_title}</li>
{/exp:query}

```

This would output something like

```
<li>Willie Nelson, Super Admins</li>
<li>Johnny Cash, Staff</li>
<li>Merle Haggard, Staff</li>
<li>Doc Watson, Editors</li>
<li>Ralph Stanley, Editors</li>

```

---

**UPDATE**

It's been mentioned in the comments below, and in this answer, that the Query module does not escape data so is unsafe for queries containing user input such as segment data. One of the suggested alternatives is to use the **Active Record** plugin instead, which *does* escape data.

With that in mind, and even though there is no user input in this particular query, here is the same query using the Active Record plugin instead of the Query module:

```
{exp:activerecord
    select="screen_name, group_title"
    from="members"
    join="exp_member_groups"
    on="exp_member_groups.group_id = exp_members.group_id"
    where_in:exp_members.group_id="6|7"
    or_where_in:exp_members.member_id="1"
}
    <li>{screen_name}, {group_title}</li>
{/exp:activerecord}

```

---
Tags: members
---


# Question
Title: What are current realistic, designer-suitable solutions for converting an EE1 site's image galleries to EE2?
As we all know, automatic conversion for EE1 sites were promised but never delivered, and there are sites with very sizable image galleries which have yet to be upgraded because of it.

The baseline has likely been writing an entire new gallery solution using Pixel&Tonic Matrix, but this is a developer-level solution, due to the original Gallery's range of features.

EE's practical intents for designers and web-site owners are a very important part of its abilities, so how do we best serve this?

# Answer
> 7 votes
Chat with the folks at Solspace that will soon have the ability to use http://www.solspace.com/software/detail/importer/ to convert EE 1 gallery to EE 2. I can't remember the full details at the moment but there was a screenshot on twitter just a bit back showing EE 1 gallery to P&T Assets as an import selection could be other options but they are in a better position to share.

Edit: https://twitter.com/reedmaniac/status/263326523803709440

# Answer
> 7 votes
I think the best user-focused solution is actually changing galleries into entries in a dedicated Galleries channel and using Channel Images. You can do the transformation of existing data after your upgrade with some fairly simple SQL, and then going forward your editors would just add images into the Channel Images field in the channel entries.

# Answer
> 4 votes
The short answer is that there isn't a easy solution that will migrate all of the galleries features to EE2, without getting your hands a little dirty in code, other add-ons, or doing some manual migration by writing SQL queries.

Like you mentioned, the Gallery wasn't migrated to EE2, which was either an oversight when EE2 was built or just not a priority.

In the event you don't have a developer to manually migrate galleries for you using raw queries, it seems like the other option would be to familiarize yourself with Matrix or other EE2 gallery solutions, and manually migrate them by hand.

Unfortunately, this seems like choosing the lesser of two evils, but in my experience, those are the two options.

---
Tags: ee2, upgrade, ee2-upgrades, image-galleries, ee1
---


# Question
Title: Native ExpressionEngine Forms w/ Jquery Validate & Watermark Plugins
I'm using the jQuery Validate (https://github.com/jzaefferer/jquery-validation/tree/1.9.0) and Watermark (http://code.google.com/p/jquery-watermark/) plugins in conjunction with ExpressionEngine's (2.4.0) native contact and comment forms.

The validation and watermarking behaviors are working as expected (showing errors inline, on submit, when fields are left blank or filled out incorrectly), however, when the form fields are filled out *correctly* ExpressionEngine itself throws an "x Field Required" error message("Email Field Required" for the Comment Form "Email Message Required" for the Contact) on submit, obviously preventing the forms submission.

One important caveat is that the site, which is not yet live, does not use memberships. So while I *can* submit a comment when logged-in as super-admin, I cannot when testing as a regular "logged-out" user. Meanwhile I cannot send an email via the contact form in either scenario.

I've attempted adjustments to all the moving parts in this set-up that I can think of, without success, and so am left in a situation where I can *either* validate inline with my desired watermarking behavior *or* I can send the forms, not both. The complexity of these 3 interactions seems to *handily* outstrip my capacity to successfully troubleshoot, as I've spent days fiddling to no avail, so any and all ideas by the more enlightened are welcome.

EE comment form code as follows:

```
{exp:comment:form channel="obfuscated" form_id="comment_form" onsubmit="return validate('#comment_form');"}
   <section class="commentformbox" id="commentformbox">

      <input type="hidden" id="subject" class="subject" name="subject" size="40" required value="Comment Form"/>
      <div class="inputbox"><input type="text" id="name" class="name" name="name"/></div>
      <div class="inputbox"><input type="text" id="from" class="from" name="from"/></div>
      <div class="inputbox"><input type="text" id="url" class="url" name="url"/></div>
      <div class="textareabox"><textarea id="comment" name="comment"></textarea></div>
      <input name="submit" class="submitbutton" type='submit' value='Submit Your Comment' style="cursor:pointer;"/>

   </section>
{/exp:comment:form}

```

The hidden fields resolve as follows:

```
<form id="comment_form" method="post" action="http://www.obfuscated/index.php/obfuscated" onsubmit="return validate('#comment_form');" novalidate="novalidate">

<div class="hiddenFields">
<input type="hidden" name="ACT" value="1">
<input type="hidden" name="RET" value="http://www.obfuscated.com">
<input type="hidden" name="URI" value="obfuscated/permalink/obfuscated">
<input type="hidden" name="PRV" value="">
<input type="hidden" name="XID" value="obfuscated#s">
<input type="hidden" name="entry_id" value="7">
<input type="hidden" name="site_id" value="1">
</div>

```

And the validate & watermark call

```
$(document).ready(function(){
$('#name').watermark('Your Name',{useNative:false});
$('#from').watermark('Your Email',{useNative:false});
$('#url').watermark('Your Url (Optonal)',{useNative:false});
$('#comment').watermark('Your Comment'{useNative:false});

$("#comment_form").validate({
     invalidHandler:$.watermark.showAll,
     onfocusout:false,
     rules:{
       name:"required",
       from:{required:true,email:true},
       comment:"required"},
     messages:{
       name:"X",
       from:"X",
       comment:"X"},
       ignore:"#url"
})
});

```

The email contact form is obviously slightly different, and also slightly more troublesome, but I thought I'd just start here for brevity.

I've tried removing other jQuery plugins present on the page, as well as a couple of EE plugins, without success. I have also already looked into solving this using Solspace's Freeform module and its Ajax settings, but as it seemed to require a re-think of some complex styling/behavior already in place I wanted to attempt to resolve this native implementation first, if possible.

Thanks for any help.

# Answer
> 4 votes
> ... when the form fields are filled out correctly ExpressionEngine itself throws an "x Field Required" error message("Email Field Required" for the Comment Form ...

The comment form code that you've posted includes a `from` field, not an `email` field. It seems pretty likely that EE is looking for `$_POST['email']` and then bailing when it can't find it. The jQuery issues might just be a red herring.

---
Tags: forms, jquery, ajax, validation
---


# Question
Title: List of Resources for EE developers and users?
I got this idea from the Russian Language and Usage site. Since "lists of links" are discouraged by the StackOverflow rules, this is a *single question* with a list of relevant resources for folks using EE.

I am answering my own question with a couple of initial resources, and setting that answer to Community Wiki mode. **Please add resources to the single answer** rather than creating separate answers; that way the resources can stay nicely categorized.

# Answer
**ExpressionEngine main website — https://expressionengine.com**

**ExpressionEngine GitHub repo — https://github.com/ExpressionEngine/ExpressionEngine**

**ExpressionEngine official forums — https://expressionengine.com/forums**

**ExpressionEngine Slack Channel — https://expressionengine.com/blog/join-us-in-slack#join-us-on-slack**

---

# Official Documentation

The official documentation is the most thorough resource on EE usage and development and should always be considered first, especially as a novice learning EE.

---

# ExpressionEngine Add-ons

---

# ExpressionEngine Conference and Meetups

---

# Learning Recources

---

# EE Template Examples

---

# Topic Resources

### *Parse Order*

### *Template Partials and Stash*

### *EE URL and Segments*

### *Multilingual Development (i18n)*

### *.htaccess*

### *Optimisation*

### *404 Pages*

### *Configuring EE for Multiple Environments*

---

# Resources for Add-On Developers

### *Tutorials*

### *Presentations*

### *Tools*
> 40 votes

---
Tags: general-knowledge
---


# Question
Title: Previous and Next tags with conditional to display pipe character
This is my template code

```
{exp:channel:prev_entry channel="events"}
    <a href="{path='events/article'}" title="Previous Offer | {title}">PREVIOUS EVENT</a>
{/exp:channel:prev_entry}

{if '{next}' !='' AND '{prev}' !=''}|{/if}

{exp:channel:next_entry channel="events"}
  <a href="{path='events/article'}" title="Next Offer | {title}">NEXT EVENT</a>
{/exp:channel:next_entry}

```

Notice the conditional in the middle **{if '{next}' !='' AND '{prev}' !=''}|{/if}** I've tried every which way to get this pipe character to only display if there are both a next and a previous entry but not if there is only one of them. I've tried AND XOR OR and also checking for != or == but nothing seems to work. I either get the pipe for all results or it never displays.

What is the correct way to get the pipe character to display only if there are both a next and a previous entry.

# Answer
I'm not seeing a "{prev}" or "{next}" variable listing in the EE 2.5.3 docs for channel entries (I'm assuming you're doing this on a single-entry template).

Have you tried using the {paginate}{/paginate} tag pair? (http://expressionengine.com/user\_guide/modules/channel/pagination\_page.html)

I'm wondering if something like this will work:

```
{exp:channel:entries channel="some-channel" sort="desc" limit="1" paginate="bottom"}
{paginate}
    {if previous_page}
        <a href="{auto_path}">Previous Page</a>
    {/if}
    {if previous_page and next_page}|{/if}
    {if next_page}
        <a href="{auto_path}">Next Page</a>
    {/if}
{/paginate}
{/exp:channel:entries}

```
> 5 votes

# Answer
If you want a solution that uses entry linking (rather than pagination as Patrick suggested) then either of these add-ons will allow you to do conditionals based on whether there are next/prev entries or not.

Entry Linking

Advanced Prev Next Entry
> 4 votes

---
Tags: conditionals, template-scripting
---


# Question
Title: What is a client-friendly way to handle multi-part forms with workflow?
I'm looking for some advice on a client-friendly way to create and administer multi-part forms with the caveat that a workflow process is also needed. I know more than one of the forms add-ons for EE offer multi-part forms, and they certainly make form composition/editing simple, but I'm struggling with how I would handle another part of my client's need: workflow. The idea is that the form will be available to a logged in member to complete in parts if needed (i.e. they can come back and edit their form response as many times as needed, saving their progress as they make changes) but once they submit the form for "approval" the form is no longer available for them to edit.

Has anyone attempted this with one of the available forms add-ons? Can one of them do this, or would I be better off looking at Safecracker (recognizing that it will be harder to build the editability of the form itself, but easier to handle the workflow requirement)?

# Answer
> 6 votes
I've used DevDemon's Forms and Solspace's Freeform Pro and they both seem to store the actual form in their own database tables so I'm not sure how you could use SafeCracker with such a set up.

Freeform Pro is what I'd use for a multipart form now, as it has a pretty slick and clean interface (although I have a wish list for this addon) - that said I'd personally try a few of them out.

Where's you'll fall down is on integrating workflow, there's only really Better Workflow but that works on entries - so it wouldn't work with the addon specific tables...

Another addon to look out for if you're using SafeCracker is MX Notifier Control \- you could form a pretty solid entry workflow setup form that - although again, I can't see how it would work with one of the form addons.

# Answer
> 4 votes
Give your entries an status of 'pending' once they are submitted.
Then in your template, only show the form is the status isn't 'pending'.

I haven't tried this using any third party form addons but since you can do this with Safecracker, I'd assume it's possible with a more full-featured form add-on.

# Answer
> 2 votes
I suspect that for forms workflow you might have to write a custom addon. Forms, Freeform Pro, and Proform all have custom hooks that you can integrate with; you could write an extension to allow a logged-in user to save an incomplete form and then return to it later.

If you needed to allow for NON-logged-in users, that might be a little harder; you'd have to do something complicated with cookies.

You could also, depending on your browser requirements, just use Javascript: cookies and the Local Storage API (possibly with a polyfill) could get you everything you needed.

---
Tags: forms, workflow
---


# Question
Title: Is there a way to have "global" Channel fields or liberate a set of fields to multiple Channels?
I remember when I was using EE 1.6.x Brandon Kelly introduced Gypsy. It was amazing.

For EE 2 it seems someone was working on something similar called Drifter but support for it was dropped a while ago.

A suggestion was submitted to EllisLab for Channel Groups, but afaIk there hasn't been any news of that.

If I want to implement some sort of metadata specific to entries but not to channels, e.g. Facebook OpenGraph data, is the only solution at present to manually create Channel field groups and fields per channel??

Is there no contemporary Gypsy-like add-on or Channel Groups feature in the works?

# Answer
Brian removed support for Drifter due to some fairly large bugs which cannot be worked around in ExpressionEngine 2.0. The CMS makes too many assumptions about how field groups work for it to be safe.

I would recommend using something like SEO Lite as a template and modifying it to meet your needs. This extension adds global support for extended fields which appear in their own tab, sounds almost exactly like what you want to do. You'd have to dig into it's PHP and modify the fields of course but it would be better to do this than try to make use of Drifter or similar extensions.
> 6 votes

# Answer
There's https://github.com/iainurquhart/global\_fields which was basically Gypsy reinvented but I'd advise against it.

Anything that fundamentally alters something like this is a recipe for disaster IMO, the number of abandoned Gypsy sites backs that up.

One solution you could use is 1 channel field group with everything you need then use Publish Layouts to hide for fields not needed. Of course doesn't help when you have required fields throughout.

Something like your specific functionality would be better served through another module perhaps?
> 8 votes

# Answer
A colleague and I are actually working on a way to allow fields to be global without some of the headaches of addons like Gypsy or Drifter, but it is going to require core hacks at least in the short term and it is NOT ready for primetime yet. So in the short term, I'd say go with one large field group and use publish layouts, which are much more stable now.
> 2 votes

---
Tags: ee2, custom-fields, gypsy
---


title: More flexible categorization

text:
# Question
Title: More flexible categorization
Everyone knows EE's categories suck. What this question presupposes is, maybe they don't have to. What are the best ways to handle more complex categorization schemes? For example, I am about to start development on a website for a funiture maker. There will be a "products" channel, where each product needs to be categorized in several ways: product line, type of product, room of the house. Those categories will be used in various ways across the site, include generating menus, product listings by the various criteria, related products, and so on. Below are the methods I've used before or am familiar with. Am I missing any? What the are upsides or downsides?

* Use EE's native category groups. Assign more than one group to the channel and instruct the client to select at least one of each type. Use the Category Description field as necessary for display on the landing page or what have you.
* Create a new channel for each group of categories and enter each category as a channel entry. Use relationship/Playa fields to select categories. Obviously this gives me a lot more flexibility with what information I can associate with the category, but the content entry workflow is not great. Also, lots of channels cluttering things up.
* Use Tagger/Taggable/SolSpace Tags. This is great for entering content - you can create a new category on the fly from the edit screen - but very limiting in terms of what data you can associate with a category. No category descriptions as far as I know, although I don't have extensive experience with any of these.
* Create duplicate channels for each category. This only works if you know the categories ahead of time and there are very few of them. The only time I have done this was when I was using Structure and wanted to have a page in the tree for each category. Easy to explain to clients... until they want to add a new category.

Am I missing anything? Is there a better way to handle this? What method does everyone else use?

# Answer
> 10 votes
In the past I've done a bit of a hybrid of the first two options mentioned.

Create a channel for the categories, then create an entry in that channel for each category. Rather than using Playa or a relationship field, as long as the URL title of the category and the URL title of of the entry are the same, it's very easy to access both using the segment variables.

For instance you might have a template `blog/category`, which results in the URL `blog/category/news`

In your template, rather than using the `{exp:channel:categories}` tag pair to access your category meta data, you'd simply use a channel entries pair to display it:

```
{exp:channel:entries dynamic="no" channel="categories" url_title="{segment_3}"}
   ...
{/exp:channel:entries}

```

This would make the page a bit heavier with database queries, but gives you a lot more flexibility in what fields you can associate with a category while keeping the UI for selecting and adding categories very simple for the user.

# Answer
> 2 votes
I think the first two options are your best bet. The last two don't give you the flexibility needed when displaying products based off a segment.

I have done something very similar to your second option w/o Playa. Just mirror the categories as entries and assign that entry the same category (mirrored approach). Then use a extension like Low's Seg2Cat or Litzinger's URL Helper to dynamically display the content.

This doesn't limit what information can be tied to a category (ie. description, 1 image, etc.)

It's not the most efficient, but I've done a true nested URI's category/product that scales nicely with Switchee & URL Helper: https://gist.github.com/4089096

---
Tags: workflow, categories, tags, taxonomy
---


# Question
Title: How can I search channel entries based on related entries, when search:field_name= doesn't apply to those fields?
I want to display all entries from a specific channel that has a specific related entry tied to it. But `search:field_name=` doesn't apply.

# Answer
Have you tried using the query module instead of the channels module? I've done a lot of fancy stuff. You could also try dynamic parameters instead of search.

CreateSean's response is a good way to go through it as well :)
> 5 votes

# Answer
It sounds like using Pixel & Tonic's Playa module might be your best bet. It has tags for pulling entries based on relationships.
> 4 votes

# Answer
I would approach it this way, though I haven't tested this.

I would list out the entry that everything is related to by using the entry\_id paramater and then within that entry use Reverse Related Entries. The code sample in the docs linked should get you there.
> 2 votes

---
Tags: search
---


title: Tiered memberships

text:
# Question
Title: Tiered memberships
I'm currently in the speccing stages of a site and considering ExpressionEngine as an option.

One of the requirements is for "tiered memberships" for instance:

A user signs up as a member with a "Corporate" account This "Corporate" account can have a number of sub-accounts, say for employees.

Has anyone created a system like this within EE before? Is there any kind of add-on that will do this or is it a matter of working with an add-on that shifts members into channels and creating related entries etc.

I'm open to suggestions.

# Answer
> 13 votes
No direct experience doing this, but I'd take this approach initially:

* Each "tier" is a channel entry. You could include things like price, description, etc. here (perhaps this is also a "products" channel used by CartThrob or Store, used to "sell" the tier).
* Use an add-on such as Zoo Visitor or Profile:Edit to create members as channel entries, then use a relationship or Playa field in that entry which links them to a specific tier (I like Playa better for this, as its various :parents, :children, :siblings tags are very powerful).

# Answer
> 1 votes
Haven't done this myself, but did need a sort of multiple "groups" or member "tagging" kind of feature. The easiest way it seems to do this in EE is to expose Channel Categories as a Member field or something similar. There are two commercial add-ons I know of that do this:

IntoEEtive's Member Categories

and

Addon Bakery's Member Categories.

I chose to go with the latter (don't remember why anymore, though). Note that when it displays Categories as a custom Member Field in the Edit Profile page it does not display them the way you arrange them in the Control Panel. It's simply a select or multi-select. Perhaps that could be a feature request. (jQuery Chosen plugin is no longer used as per the documentation screenshots either, you'd have to enable that manually.)

As for relationships between specific members and sub-categories... I don't know. Probably would require custom development?

---
Tags: add-on, members, bestpractice, accounts
---


# Question
Title: Pre-populating SEO lite fields: custom extension advice
I have a client site which utilises the SEO lite module. The client has come back with a feature request which I'm trying to figure out a way to achieve: they want to pre-populate the SEO fields on a number of channels using the title and description channel fields, but then allow the admin user to edit those values before saving/publishing.

*(I know that in my templates I can can fall back to channel field content if the SEO lite fields are empty, this is more about providing a convenience for the client in filling out the SEO Lite fields)*

I'm thinking I can do this by writing a custom extension to inject some JS into the CP on publish/edit forms.

I can write the JS easily enough, but need some advice on the extension side of things.

Questions:

* Is a custom extension the best route?
* Can some one point me towards a good template / existing xtn to use as a basis (ie just injects custom JS into the public/edit view, uses similar hooks etc)?

# Answer
You can pop your JS into the instructions of one of the fields on that form. Will be the quickest solution IMO.

OR you can use this Extension to add custom CSS/JS to the CP: http://devot-ee.com/add-ons/cp-css-js
> 3 votes

# Answer
I could be completely off with this but I wanted to add some JavaScript stuff to the View Members page. MX Cloner had just the bit of functionality I was looking for: Replace a link on the screen with a hover effect given the proper URL and a way to place JavaScript in the CP. This may not be the best or even proper route to go, but it was the most convenient route for me being pretty new and all.

You could easily make a copy of that accessory to pull the defaults from SEO Lite. I haven't used SEO Lite yet so no comment on that.
> 1 votes

---
Tags: add-on, extension, add-on-development, seo-lite
---


# Question
Title: Migrating/duplicating Content/Members from a Production site to Development
(I don't feel this is a duplicate of "Migrating between Development, Staging and Production for a pre-existing ExpressionEngine site" as I'm hoping it's much simpler/specific. Maybe it is a duplicate as I'm not familiar yet with all the nuances as the site is just getting started. If that's the case I would hope detail is provided before being marked as a duplicate. Moreover in the above no particular examples were given for migrating content.)

Assuming no new add-ons and thus tables have been added to either version, say I just want to grab new entries, members, and channel categories from production to development, is there a convenient way to do that? (And changes to existing entries/members or whatever other content?) Or do I just manually export/import from select tables via MySql (does this present problems?)?

# Answer
> 5 votes
If you're just looking for a convenient way to transfer the latest data from one database to another (say from the production database into your development database) then Navicat's data transfer feature is very handy. Though it accomplishes the same thing as the manual export/import you referred to, and will overwrite data not sync it, it's a lot more convenient. It allows you to choose the specific tables you want to transfer or to transfer all of them.

Navicat also lets you save transfer "profiles" for specific transfers you want to perform again so that they can be triggered with only a few clicks. It supports http tunneling as well, making it a handy tool for connecting to servers that do not provide SSH access.

Navicat has another feature that allows you to *sync* the data and/or structure of two databases. I have less experience with this (maybe another answer will address that), but it can be useful if used carefully.

---
Tags: database, migration
---


# Question
Title: What is the difference between a global variable, a snippet and an embedded template?
What is the difference between a global variable, a snippet and an embedded template?

When and where should I be using each of them?

# Answer
> 31 votes
**TLDR;** In general, my preference would normally be to use a snippet, unless I need the variable content to be user editable (eg site email), and to only use an embed when parse order issues or similar necessitate it.

Here's why...

**Snippets:**

Snippets are frequently my first choice for implementing reusable code fragments in EE. They are parsed at a very early stage on each template, making it possible for them to hold dynamic content, ExpressionEngine tags, other variables, PHP, etc.

They are also very lightweight in terms of overhead, in that they don't require another pass of the templating engine in the way that an embed would do. Use a snippet to to reuse dynamic information, but when you don’t need the extra overhead of access control or separate preferences of an embedded template.

It is possible to save snippets out as flat files, but only by using an addon, such as Snippet Sync.

**Advantages**: Fast! can contain dynamic content/tags due to early parsing.

**Disadvantages**: Can't be nested, can't be natively saved as files.

---

**Embedded templates**

Any ExpressionEngine template can be embedded into any other template using the syntax: `{embed="group/template"}`.

As embeds are a separate template, if you want any output from the parent template to be available inside the embed you must explicitly pass variables into it as parameters like so: `{embed="path/template" variable="foo"}`. These which will then be available in your template like so: `{embed:foo}`.

{embed=""} tags are processed after all of the other tags of the original template are processed, this means you can set these parameters with other variables too:

```
{exp:channel:entries channel="blog"}
  {!-- on the last loop through our entries embed a template and pass the output of a tag as a parameter to the embed--}
  {if count == total_results}
    {embed="path/template" my_total="{total_results"}
  {/if}
{exp:channel:entries}

```

According to the EE user guide you should use an embed when:

* You need Embed Variables.
* You need separate PHP parsing preferences from the template this code is being added to.
* You need separate caching preferences from the template this code is being added to.
* You need separate template Access control from the template this code is being added to.
* You need to also be able to access this template on its own directly via the URL.
* You need to edit this content using the flat-file template system. You need to more discretely control which users are allowed to modify this content.

**Advantages**: Allow avoidance of parse order issues. PHP can be enabled for an embed but not for the parent template. Can be nested. Full template permissions control.

**Disadvantages**: Slow, require variables to be manually passed in from the parent template.

---

**User Defined Global Variables**

Global variables* are pretty much the opposite of snippets. They are parsed late in the template parse order , and thus cannot contain other EE tags. though they can be parsed as parameter values for other tags. Normal global variables cannot easily be stored outside of the database (though again, this is possible with some addons).

They are best suited for repeated static string data such as contact email addresses, phone numbers, company registration numbers and the like, though they can also be used for static text, HTML, JavaScript, and other static content that would not affect other tags and variables in your templates.

I frequently use the (free) Republic Variables addon to allow clients to edit global variables via a more friendly UI.

\*The name "global *variables*" is something of a misnomer IMO, as GV's cannot be changed once assigned - ie they are really **constants**.

**Advantages**: minimal parsing cost, easyish for clients to edit.

**Disadvantages**: parsed late

---

**Third Party Alternatives**

There are also a number of excellent third party alternatives which can help reduce the need to use embeds/jump through hoops with the parse order and thus improve site performance, these include:

Mark Croxton's powerful Stash plugin Low Variables, which allows precise control of which variables are parsed late/early (and much more)

If there are others that should feature here add a comment and I will add them to this answer.

# Answer
> 8 votes
All three of these are used for enabling you to not repeat yourself when building sites, but they vary in functionality quite a lot.

**Global Variables** Global Variables are used generally for storing pieces of content that might not be be part of an entry, for instance a contact form email address, a store address, etc. You can not use EE tags within a global variable. Oftentimes I use the Low Variables module to extend Global Variables with additional fieldtypes, creating a great settings area in the control panel for the users.

**Snippets** Snippets are used for storing reusable pieces of templates. The snippet gets parsed before the template they are inside of gets parsed, so you can add any EE tags you like inside a snippet and it'll act just like it's part of the template you put it in.

**Embedded Templates** Embedded templates have the greatest overhead of all of these. They start the template parser again and run independently from the parent template, and just dump the output from the embedded template into the parent template. It's generally a best practice to avoid using embeds as much as is practical, only using them when it's necessary to nest tags that otherwise couldn't be nested.

---
Tags: bestpractice, templates, snippets, global-variables
---


# Question
Title: Custom plugins vs query tags: advantages and implementation
An answer to another question touched on the use of writing custom plugins as a more robust alternative to writing a SQL query in a template via the `{exp:query}` tag.

* What are the advantages/pitfalls of using a custom plugin over the `{exp:query}` tag?
* What patterns should be used to maximise reusability (eg multiple plugins vs single plugin with multiple methods etc)
* How best should custom plugins of this sort be documented before handing off an EE install?

Extra credit for code examples!

# Answer
> 15 votes
The advantage of using a custom plugin (per-project usually) is that you will invariably come up with several small utility tasks to perform during the course of development (not just query-related). It's far cleaner to house these functions under one roof, in one file, rather than sprinkle your templates with custom queries, PHP blocks, and your **/third\_party** folder with a half dozen simple plugins that do one tiny thing.

I would argue strongly in favour of keeping all custom functionality for a site within one package (if not one plugin ... sometimes you'll need an extension as well, and in more complex cases a module). So much less clutter, plus you can use class variables for commonly-used data throughout all of your custom functions (say, an API key if you're making custom API calls, etc).

As for documentation - using the plugin `usage()` function is the way to go for plugins - you can document everything and have it visible right from the Plugins screen in EE. For your extensions and modules, you can use PHPDoc with each function, or just add paragraph-style comments with each function to explain what your code does, and then optionally add EE comments in your templates wherever you call your custom functions so that folks know that it's a) custom, and b) what it does.

The disadvantage of going the custom add-on route would be if you, say, only have a couple of custom queries across your site, and no need for custom helper functions - in which case sticking with the Query module omits any overhead from loading another class (i.e., your custom plugin) needlessly. Plus - no need to write a custom plugin!

# Answer
> 13 votes
It is also important to note that the Query Module *is not safe* if you are allowing any user-entered data. The *only* thing the Query Module does, besides adjusting for pagination if present, is passes the string through to the CI db class (in EE 2.5.3 this is line 181 of `/system/expressionengine/modules/query/mod.query.php` )

`$query = $this->EE->db->query($sql);`

The CodeIgniter documentation specifically states that you should escape your queries using one of the escape functions (see this page: http://codeigniter.com/user\_guide/database/queries.html); however, there is NO escaping being done in the EE core code.

The way around this is to use a custom addon, and ensure that you escape your queries (or use CI's Active Record, which does automatic escaping) within your addon methods.

---
Tags: add-on-development, query
---


# Question
Title: Preferred method for site-specific content in MSM "child" sites?
I'm building a set of sites with MSM and intend to use a "parent" site for the organization to publish most of the common content that will be used for each of the "child" sites. Think of a restaurant with many locations where you want the location-specific information to be embedded into the page content for that location's site, yet the common information is pulled from the parent site.

For a simple example, if you're on a menu page for location A you'll see that location's prices, which may be different from the other locations. Assuming the menu is the same across all of the restaurants, I'd like to use the parent site to create channel entries for each entree and add in all of the common content there, yet have the location-specific price show on each location's menu page.

One simple option would be to create an entry on the child site and add fields for any of the location-specific content items. Then pass those items to the parent site template via embed parameters.

Child:

```
<ul>
{exp:channel:entries channel="entrees"}
   {embed="parent:menu/entrees" url_title="{url_title}" price="{price}"}
{/exp:channel:entries}
</ul>

```

Parent:

```
{exp:channel:entries channel="entrees" site="parent" dynamic="no" url_title="{embed:url_title}"}
   <li>
    <h2>{title}</h2>
      <div class="content">
        <img src="{entree_picture}" alt="{title}" />
            {entree_description}
         <span class="price">${embed:price}</span>
      </div>
   </li>
{/exp:channel:entries}

```

The drawback here is that each entry would need to be added on each child site, which doesn't scale well. In addition, the relationship between child site & parent site would be dependent upon the url\_title being identical, which is error prone.

Any other options?

# Answer
> 6 votes
I would probably use a matrix in the main sites entry with two columns: location and price. One is location and one is price. Fill that in for each location. The location column would need to be a dropdown that the user selects the correct location. The dropdown would be set up so that the value is equal to the site name and the label to the Restaurant name.

In your template you would then do something like this.

```
{price-matrix search:location="={site_short_name}"}
    <span class="price">${price}</span>
{/price-matrix}

```

No embedded templates slowing your site down and more intuitive.

# Answer
> 6 votes
What if you created fields for each location's price for that menu item. Then the field name would be prefixed with the child site's `short_name`.

* `atlanta_item_price`
* `chicago_item_price`
* `seattle_item_price`

Etc.

Then in your child site template, you could use:

`Price: {{site_short_name}_item_price}`

---
Tags: multi-site-manager, embeds
---


# Question
Title: Strange issue with expressionengine and store on a Shared Hosting (OVH)
i've an eccommerce with store on OVH's shared hosting and I often receive this error message when i browse the site:

> Internal Server Error
>
> The server encountered an internal error or misconfiguration and was unable to complete your request.
>
> Please contact the server administrator, postmaster@www.griffando.it and inform them of \> the time the error occurred, and anything you might have done that may have caused the error.
>
> More information about this error may be available in the server error log.

* PHP Version: 5.3
* EE version: 2.5.3
* Store version: 1.6.0

Have anyone else encounter in the same issue? Thanks

edit: Here there's the error log: https://gist.github.com/9d2f2a1f85374c415042

edit2: thank you all guys, now (i don't know why) the error disappear. I didn't change anything

# Answer
The most *common* cause of this error is an issue with your `.htaccess` file. In particular I have run into frequent problems with:

* `DefaultCharset` directives
* `RedirectMatch` directives
* Trying to use `Rewrite` directives on a server that does not have `mod_rewrite` enabled
* Trying to use Apache 1 compression on Apache 2 servers (`mod_gzip` instead of `mod_deflate`)

If you've got any of that in your .htaccess, remove those directives and try again. If not, try removing EVERYTHING from your .htaccess, and add it back in one block of directives at a time until you get the 500 error again.
> 6 votes

# Answer
As a first step, look at your server error logs. Details about what is causing the error will most likely be there.

If this is happening sporadically, I would guess that it has noting to do with EE or Store and everything to do with your hosting environment.

If you don't find the answer in your error logs, your only option is to contact the web host for further assistance.
> 4 votes

# Answer
I did some quick googling on that error, and another possibility is that it's caused by suEXEC. So if suEXEC is installed (e.g. some cPanel servers):

* Check the suEXEC logs on your server (if you have access to them, probably not though if you're using shared hosting).
* Make sure your file and folder permissions are correct. For example on my cPanel server I know the `public_html` folder needs to be owned by `myuser:nobody` and permissions `750`. Everything inside it can be owned by my user and permissions `755`, but I know in the past if I took away the group `nobody` for the `public_html` folder the whole site came crashing down.

If all else fails, try deleting/renaming EE and just try to get a simple index.php file outputting **something**, then work your way up from there until you figure out what is causing the issue.
> 4 votes

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


# Question
Title: How to manually add Content to a Matrix-Row with SafeCracker
I need to use SafeCracker to publish a new entry into a Channel whose Custom-Field-Group exists of only one field — which is a quite large Matrix-field. (Matrix -\> pixel&tonic Fieldtype)

The code look like this (but with much more fields)

```
{exp:safecracker channel='mychannel' return='success' include_jquery='no' datepicker='no'
…
<input type="hidden" name="title" class="title" value="" />
<input type="hidden" name="mychannel-field0" class="field0" value="" />
…
{/exp:safecracker}

```

The fields will get filled through a JavaScript-Datafetcher.

My Matrix-Field is named `{mychannel-entry}` and the first cell is named `mychannel-field0` etc.

How can I tell my form to input the values of my hidden fields into the first/new Row-Cells of a new entry to my channel?

Note: This form only adds new entries, no editing-functions required.

# Answer
> 6 votes
So I haven't been able to test this, but you *should* be able to just manually build your form like so:

```
{exp:safecracker channel='mychannel' return='success' include_jquery='no' datepicker='no'}
  <input type="hidden" name="mychannel-entry[row_order][]" value="row_new_0" />
  <input type="text" name="mychannel-entry[row_new_0][col_id_1]" />
  <input type="text" name="mychannel-entry[row_new_0][col_id_2]" />
  <input type="text" name="mychannel-entry[row_new_0][col_id_]" />
{exp:safecracker}

```

I've assumed above that your full column name in your matrix settings is `mychannel-fieldn`. Is that correct? Edit, the previous, struck through line was incorrect.

Where `col_id_n` is the column\_id of the column in your matrix field - nb this is not the same as the column name - use firebug/dev tools to figure this out as suggested in the blog post linked in the other answer to this qn.

NB. Taken from a similar question in P&T's support forum.

# Answer
> 6 votes
I've done this before - I spoke with Marcus Neto about it and sent him the code for it which he blogged about here

This should give you enough information to do what you need I think.

---
Tags: matrix, safecracker
---


# Question
Title: Outputting Exp-resso Store modifier-options without form-tag
I'm building an XML-feed for publishing my client's products to a third party, and I need to output a list of modifier-options sans the form-tag. I would imagine this to work something along these lines:

```
{product_store_variations:modifier_options backspace='1'}
    {option_name}
{/product_store_variations:modifier_options}

```

This doesn't output anything though. Any thoughts?

# Answer
> 6 votes
You can access most of the basic variables directly through the "Product Details" fieldtype. For example, assuming you named your field `product_details`, you can access the price inside your channel entries tag like so:

```
{product_details:price}

```

However, you can't access the modifiers that way (there is no way for the fieldtype to return variable loops).

To use the standard Product tag without a form, simply add the `disable_form` parameter:

```
{exp:store:product entry_id="123" disable_form="yes"}
    {modifiers}
        <!-- code here -->
    {/modifiers}
{/exp:store:product}

```

Reference: https://exp-resso.com/docs/product\_tag.html#disable\_form

---
Tags: expresso-store, expresso, modifiers, xml
---


# Question
Title: {path=} tag resolving correctly in one channel but not in another
I generally make use of the `{path='xyz'}` tag within my channel entries, for all the usual reasons. However, I've realised that whilst it resolves the URL correctly in one channel (ie. `www.mydomain.com/xyz`) it seems to fail to do so in another (ie. the tag is rendered in the template raw, with the braces converted to HTML entities). I can't see any difference between the two channels’ preferences. Can anyone shed any light on this?

# Answer
This is a bug introduced in 2.5.3 - There's a hotfix here:

http://expressionengine.com/bug\_tracker/bug/18239/
> 7 votes

---
Tags: ee2, channel
---


title: Stash, DRY and redirect

text:
# Question
Title: Stash, DRY and redirect
I'm currently wiring together a site that uses the DRY principle and makes heavy use of @croxton Stash module.

All is working as expected but if I purposefully remove part of the URL I cannot force a redirect as I'm using the URL template to capture the info and embedding (last) a template for display.

I'm using the {if {exp:stash:not\_empty name="my-stash"}} Show the info {/if} to great affect but when I set {exp:channel require\_entry="yes"} AND there is no entry, how do I force a redirect ?

```
{embed="_includes/_layout_equipment"} // The layout template

//Collect all values for all custom fields
{exp:stash:set parse_tags="yes" trim="yes" parse_conditionals="yes"}
{exp:channel:entries channel="equipment" url_title="{segment_3}" require_entry="yes"}
    {if no_results}Has no effect here{/if}

    {stash:title}{title}{/stash:title} // Get title
    {stash:matrix}{matrix}<li>{value}</li>{/matrix}{/stash:title} Get Matrix Pair
    //repeat for all custom fields in the entry - a lot of them
    {/exp:channel:entries}
{/exp:stash:set}

//Need to SET a host of 'stash's' using the master stash vars captured above

{exp:stash:set name="main" parse_tags etc}
    {if {exp:stash:not_empty name="title"}}
    <h1>{stash:title}</h1>
    {/if}
    <ul>
        {stash:matrix}
    </ul>
{/exp:stash:set}

{exp:stash:set name="sidecontent" parse_tags etc}
  //Pull in other Vars declared in the steps above
{/exp:stash:set}

{exp:stash:set name="tab01" parse_tags etc}
  //Pull in other Vars declared in the steps above
{/exp:stash:set}

// Join all the bits
{exp:stash:set name="contentregion" parse_tags etc}
  <div class="abc">
  {stash:my_var}
  <div class="inner">
  {stash:tabs}
  </div>
  </div>
  <div class="abcde">
  {stash:anothervar}
  {stash:morevars}
{/exp:stash:set}

```

Then in the Embed template:

```
<html>
<body>
<div class="content">
{exp:stash:get name="contentregion"}
// By this stage at least one var within this var contains some mark-up - no actual data but a random <div> or <ul>
// ************* WHERE DOES A REDIRECT FIT IF THESE IS NO CONTENT ??? *****//
</div>
<div class="sidecontent">
{exp:stash:get name="sidecontent"}
</div>
</body>
</html>

```

Apologies for confusion but my embed is quite simple due to the varying nature of the content (tabs, optional tabs, accordions, optional accordions and so on)

I've got all this going on and setting {no\_results="redirect"} just fails to trigger

# Answer
> 12 votes
You should be able to implement redirects once you add the Stash `no_results_prefix` parameter. For example:

```
//Collect all values for all custom fields
{exp:stash:set parse_tags="yes" trim="yes" parse_conditionals="yes" no_results_prefix="equipment"}
{exp:channel:entries channel="equipment" url_title="{segment_3}" require_entry="yes"}
    {if equipment:no_results}{redirect="404"}{/if}

    {stash:title}{title}{/stash:title} // Get title
    {stash:matrix}{matrix}<li>{value}</li>{/matrix}{/stash:title} Get Matrix Pair
    //repeat for all custom fields in the entry - a lot of them
    {/exp:channel:entries}
{/exp:stash:set}

```

# Answer
> 0 votes
Put the redirect in the original channel:entries tag so you can use `no_results`:

```
{exp:stash:set parse_tags="yes" trim="yes" parse_conditionals="yes"}
    {exp:channel:entries channel="equipment" url_title="{segment_3}" require_entry="yes"}
        {if no_results}{redirect="404"}{/if}
        {stash:title}{title}{/stash:title} // Get title
        ...
    {/exp:channel:entries}
{/exp:stash:set}

```

EDIT...

Sorry I should have tested first. Try adding parse="inward" to the original stash:set tag - that works for me.

```
{exp:stash:set parse_tags="yes" trim="yes" parse_conditionals="yes" parse="inward"}
    {exp:channel:entries channel="equipment" url_title="{segment_3}" require_entry="yes"}
        {if no_results}{redirect="404"}{/if}
        {stash:title}{title}{/stash:title} // Get title
        ...
    {/exp:channel:entries}
{/exp:stash:set}

```

The alternative would be to put the stash:set on the inside of the channel:entries tag, with the no\_results conditional outside the stash:set block... That works too, however it would prevent you from easily doing the next part where you're calling up those stashed variables and skewering them back together in a different order since the vars will not be set at that point... parse="inward" gets around that I think.

# Answer
> 0 votes
Okay so I must confess to not having tested this, but can you not stash the "result" of the no results tag:

```
{exp:stash:set parse_tags="yes" trim="yes" parse_conditionals="yes"}
    {exp:channel:entries channel="equipment" url_title="{segment_3}" require_entry="yes"}
        {if no_results}
          {stash:no_results}true{/stash:no_results}
        {/if}
        {stash:title}{title}{/stash:title} // Get title
        ...
    {/exp:channel:entries}
{/exp:stash:set}

```

Then parse that to create a redirect (note needs parse\_tag="no"):

```
{exp:stash:set name="redirect" parse_tags="no"  trim="yes" parse_conditionals="yes"}
    {if {exp:stash:not_empty name="no_results"}}
      {redirect="redirect/path"}
    {/if}
{/exp:stash:set}

```

Then push *that* into your embed template:

```
{exp:stash:set name="contentregion" parse_tags etc}
  {stash:redirect}
  <div class="abc">
  {stash:my_var}
  <div class="inner">
  {stash:tabs}
  </div>
  </div>
  <div class="abcde">
  {stash:anothervar}
  {stash:morevars}
{/exp:stash:set}

```

A bit long-winded I know, but might meet your use case?

---
Tags: stash, module, dry
---


title: Testing PayPal Express with Store

text:
# Question
Title: Testing PayPal Express with Store
When using the **paypal sandbox** with store, what do I put in the store settings fields for the paypal gateway?

I have obtained my paypal credentials for running live, but to test with the sandbox, do I have to have another set of credentials for my paypal developer account?

# Answer
I haven't used Store but have used Cartthrob, Membrr (as well as many other ecommerce engines) and wanted to add my thought.

You should have two sets of credentials - your live PayPal account details and your developer account details (sandbox). As far as I know these are completely separate - certainly in my experience I've just used two separate accounts.

You'll need to set up a buyer account in the sandbox that you'll use when you've proceeded to the PayPal payment page.

To test the cart while developing, obtain the API details from your sandbox account and add these to the PayPal gateway in the CP. Once you test the checkout process (I'm assuming this is for PayPal Standard/Express) you'll need to enter the sandbox buyer account details (see above) to test a payment.

As I said, haven't had experience of Store but this seems like a more general PayPal API question.
> 8 votes

---
Tags: expresso-store, settings, paypal
---