# Question
Title: file modal, doesn't act on any search/filtering
**IMPORTANT:** It turned out that this question couldn't really be answered based on the info I had provided, and it wasn't possible for me to provide enough info to make it answerable. Tom provided the best steps for debugging this type of issue in a normal situation so I'm giving it to him, but in my case the issue being that some changes to core that are not released yet, were causing problems in the way that Secure form processing worked. Turning of secure form processing until this issue is remedied was the solution that worked for me.

## The Question:

I'm running the latest version of ExpressionEngine, and I'm a little stuck with a file field. Oh why oh why did I enable that? The issue I'm having is with the file modal that pops up either on adding a file in a file field or the clicking the little image icon by other fields. I can type whatever I want in the search field, or toggle the sorts, but the contents stay the same. Likewise the pagination links don't work:

I know that there are a number of files in that folder with names that begin in 121130. There seems to be no way to navigate around and find the file I want to add so I'm stuck. I'd love any of three types of advice listed in order of usefulness:

1. How can I convert this file field back to a plain input field without losing the path information: {filedir\_11}filename ?
2. How can I debug this issue and figure out how to make it work?
3. How can I manually modify the contents of this file field entry, even directly in the database to get the file I want selected even if the file modal doesn't work?
4. Am I the only one having this issue?

**update:** I had already gone into the inspector and seen that requests were fired off to admin.php (renamed to mcp.php in my case), but I didn't exactly know what a proper query looked like. Tom's Answer contained a helpful screenshot of what a request and response looks like. I find that mine is making queries, but the request seems to maybe be getting redirected and losing the query in the process. Here are some screenshots to illustrate:

Here you see that when I click into the search window it loads two images, then when I type a 1 it fires a request from jquery.js to mcp.php which then seems to get 302 redirected twice before getting a response useless to jquery:

Here is the response for that third request (the others resulted in a 302 so obviously returned nothing) As you can see it is returning html, not json.

So now the issue becomes figuring out where those redirects are coming from. Do I need to look to Apache? I'm not immediately seeing anything there that should be causing this, but it is possible I'm missing something.

**Update 2**: I thought I had this thing licked. I went into my admin.php file and found where I had set a non https link to the control panel in the Multi-Site Manager settings. I know I have a redirect set in apache to redirect all non ssl requests for the control panel through to ssl, so I thought that would get rid of at least one of those redirects… Result: no change.

# Answer
Let's take a crack at (2) first of all, because it seems to me like getting this working using the File FT will require the least mucking about in total. When you use the search box in the file manager modal, an ajax request should fire off back to the CP to look for results:

Is that request firing (see the "network" tab of your web inspector), and if so what does the response look like? It should return a bunch of JSON (even if there are no matching results).

Update your question with the answers to those two questions and we'll go from there.
> 3 votes

# Answer
I admit to not using the field\_type file, primarily because I like having more control over images. I typically either have clients use the file upload button and then entire the name of the file in a text field or use a different field type, like Assets (from Pixel & Tonic).

From testing, at least on my Mac running Mountain Lion and Safari 6.0.2, I'd say there is a a javascript issue. When you type in the initial filter, if it doesn't start limiting the field immediately, I'd look at file synchronization and or javascript as the issue. I've included some troubleshooting steps below, but first…

If you are not too opposed to losing the {filedir\_11}filename, I'd recommend the following:

Assuming most images belong to various sections of your site, and that you store images in associated folders (example: About Section images are stored in /images/about/ ). Then you can just create the appropriate template code:

```
<img src="{domain}/images/{section}/{field_name}" alt="" />

```

For images in content, I've found the file upload under the textarea still works for inserting an image in.

Alternatively, I really do love Assets by Pixel & Tonic. I find it a really great file manager. Others may prefer Channel Images by DevDemon, I haven't used it. If your project can't afford that, but already has the Matrix field type, that also works very well at managing images.

If you really want to get the File field\_type working properly, I suggest…

1. **Turn on Debugging Options**\- if your images aren't separated into multiple directories the issues could just be the amount of time it takes to filter. Even with Assets, I find a directory with over 200 images can take a while to filter. But Assets provides visual feedback that it's still working.
2. **Group Images Into Folders**\- this goes with the above, but the less items per directory the better. A directory of 50 images will always be more responsive that a directory of 300 images, so instead of just using /images use folders like /images/about/, /images/howto/, /images/reviews/, etc.
3. **Review Any Control Panel Modifiers**\- things like 'Responsive CP', Control Panel Themes (I use Nerdery to change pink to blue), etc. It's possible that something is just confusing the File Browser.
4. **Make Sure Image Directories Are Synchronized** \- This is new in EE2, but see: http://ellislab.com/expressionengine/user-guide/cp/content/files/sync\_files.html In the File Upload Preferences, there is a new synchronize option. I believe this creates a database reference for all items in the directory, so javascripts are processed faster. Scanning a file directory can be a bit longer than a MySQL query. It's possible, that once all images are properly sync'd that your keywords filter may start filtering again.
> 1 votes

---
Tags: control-panel, file-uploads, javascript, redirects
---


title: CP Lockout based on IP alone?

text:
# Question
Title: CP Lockout based on IP alone?
I have a client who has found that when one user is locked out of the CP, all others are locked out too. This makes me think that this is based on IP address alone rather than username.

Anybody got any experience with this issue?

Thanks

EDIT IN RESPONSE TO QUESTIONS:

This happened over a weekend so I wasn't online to check the database at the time. However the message received was 'You are only permitted to make four login attempts every 30 minute(s)'. So one user locked triggered this lockout but it affected all other users in his company.

Looking at the check\_password\_lockout() method in Session.php it looks like the check is based on username **OR** useragent. So it would appear that if he locked himself out in a particular browser, all other users on that IP would be locked out if they were using the same browser.

I'm not a security expert in any way, but shouldn't that SQL check be **AND** not **OR**? Any thoughts?

# Answer
> 4 votes
It's normal that EE restricts logins based on IP address. Restricting on user agent wouldn't be much use, because a malicious script could just change the user agent for every request.

That said, the normal EE error message is `You are only permitted to make four login attempts every 1 minute(s)`. You must have increased this from 1 minute to 30 minutes, which is clearly unusable.

In the control panel, go to **Admin** \> **Security & Privacy** \> **Security and Sessions**.

There, you will find the setting: **Time Interval for Lockout**

Set this back to `1`, or if that is still too long for you, even `0.5`.

After changing this session, you probably also want to empty the `exp_password_lockout` table to remove any lockouts currently in effect.

# Answer
> 3 votes
Locked out how? After too many attempts to login or actually blocked because of malicious activity?

If you're blacklisted this is done based on your IP, so that would cause other people on the same network to be blocked too.

– Wouter

---
Tags: login
---


# Question
Title: How best to get a new EE install (including channels/fields) up and running quickly?
I don't use GIT or anything (yet) but am trying to speed up the time it takes to set up a new EE site. I'm finding that I'm setting up a lot of the same channels, custom fields, low variable, etc. So I'm wondering, is it / should it be possible to set up a new site the way I want, export out those tables, then import them to sites afterwards as a jump start?

I tried this, and it worked - sort of. I tried to export out my tables for Low variable groups and low variables. Both imported fine. However, while the groups showed up in the CP, the variables didn't (even though they were in the database).

Anyway, thanks for any thoughts you have about this, or tips/links on accomplishing something similar!

Todd

# Answer
I don't pre-populate channels and fields because my sites tend to be slightly different and sometimes I like to try a different approach to solving the same problem. That being said, what I do can be modified to add channels/fields. I built a default install with a set of free add-ons I use all the time that make development easier (Switch:ee, If/Else, Responsive CP, etc.) I created a DRY config file that only requires a few setting changes when duplicating this site. Once I setup all the add-ons and config files I export a .sql file from Sequel Pro and save this at the root of my default site. When I need a new site I create an entry in my httpd\_vhosts.conf and hosts files, duplicate the directory, import the DB using Sequel Pro, make the necessary changes to my config file and voila, I have a new site up and running.

Now, you could certainly setup as many channels and fields that you believe are common from site to site right after setting up your default install. When you import the DB to your server (in my above case it's a local dev server) the channels and fields come along for the ride. You could also place all these files into git, something I'm learning more about so I can do just that. Carl Crawley did a presentation at EECIConf 2012 that made this process take less than a minute and all managed and updated through git but my manual approach only takes about 5 minutes to go from nothing to a new site.
> 2 votes

# Answer
This largely depends on what you are trying to do. So many of my sites are so different that I wouldn't get much of a time savings by setting up much of anything in the DB for re-use.

However, here are your options in general.

The NSM site genator looks promising and it's all open, but it seems to have been light on activity lately. The last commit appears to have been 5 months ago. Dead project?

http://ee-garage.com/nsm-site-generator

If you do a search for "import" at http://devot-ee.com then you will see a lot of add-ons which you can use to import data in other formats. Because the control panel is the slowest cog in the process, I think creating data in X format using offline tools and then importing that data would save a bunch of time.

You could also just setup add basic items to a bootstrap base install of EE, but again, it's the control panel which slows me down. So, an importer would be faster.

Certain modules from developers such as Solspace provide auto installs to get examples for their add-ons working. This can be quite helpful at times, especially if you have never worked with the add-on before.

Of course, the items which jumps out to me is that you don't know Git. Fix that! By far you will get the most benefit by setting up one base install, copy that to your repo and then clone that repo for each new project.

Also, more and more, developers and clients are expecting to have the development backed up in a version control system. Using Git also gives you more options for fast deployments, and this can save you a lot of time and headaches as well.
> 8 votes

# Answer
Not sure about pre-populating sites with channels etc as every project is different but Made by Hippo posted an article re getting EE up and running quickly, might be useful to you, I've adopted a couple of things like pulling out config file to assets folder.
> 4 votes

# Answer
One way or another you'll have to dip in to git and the best thing is you can accomplish most things with out even touching the terminal.

For example have a local install via MAMP. Setup everything to a point where you feel confortable e.g. channels, fields, categories, snipets, variables and any other settings. Export database as file then create a Bitbucket account (which is free), get Sourcetree, create a repository and connect it to the local install folder via Sourcetree and commit which syncs files. This then becomes your base template for future projects which can be installed in a few minutes.
> 2 votes

# Answer
To populate a new install with dummy content you can use http://squarebit.co.uk/seed.
> 1 votes

---
Tags: config
---


# Question
Title: How to create module tag output 'sub-loop'
I'm trying to do something like the following:

```
{exp:my_tag my-param2="1" my-param2="2"}
    <li>{title}</li>
    <li><ul>
    {my_fields}
        <li>{field_label}: {field_value}</li>
    {/my_fields}
    </ul></li>
{/exp:my_tag}

```

Is it possible to do it with a simple TMPL-\>parse\_variables() or should I put in place something more complex?

# Answer
> 5 votes
The `parse_variables` function handles this natively so there's really no need to complicate things unless you need some additional functionality.

The template class documentation includes some detailed instructions, but basically you just need to add a `my_fields` array to your main array of variable data.

```
$vars['title'] = 'My Title';

$vars['my_fields'] = array(
    array('field_label' => 'Foo', 'field_value' => 'Something'),
    array('field_label' => 'Bar', 'field_value' => 'Something else')
);

$output = $this->EE->TMPL->parse_variables($this->EE->TMPL->tagdata, $vars);

```

---
Tags: add-on, php, module, parsing
---


title: Securing Files uploaded with FreeForm

text:
# Question
Title: Securing Files uploaded with FreeForm
Does anyone know of a straightforward way of securing files which have been uploaded via Solspace FreeForm?

In a nutshell, what I'd like to have is files uploaded to a directory which isn't accessible to the general public, but is accessible once you have logged into the CP as an admin user.

**Edit**: To clarify, Freeform just uses a standard EE File Upload destination and has a link within it's admin screens to view the uploaded file. I've tried creating a Destination which is above root, but that makes the file inaccessible from within the CP as well (unless I'm doing it wrong that is).

**Edit 2**: I seems if you try to access the file via the file manager in the CP it works fine if you have the upload destination above root. What isn't working is the link within Freeform itself. It uses the 'URL of Upload Directory' to link directly to the file. This results in a 404 if the destination is above the root.

# Answer
Have you thought about making upload folder locations above root?

Here is an article about doing just that for Freeform file uploads: Storing file uploads above webroot in EE2
> 6 votes

# Answer
What sort of files do you need to lock down and how much security is required?
Below is a few methods i have used in the past.

**Run it through PHP**
I used a solution a while back when i used htaccess-rules to run every request for a particular dir through a special template and used Php and template-tags to verify that the user was logged in and had the correct permissions.

For added security you could do as @Cem said and store the files above root or just stick with locking them down with htaccess.

Found a quick example of the php code here.

If everything was ok i sent the correct headers and returned the file through php.
One downside of this could be the speedbump when you need to start up php for every single file.
Might work better for simple files than with multiple images on a page.

**Cookies in htaccess**
You could also use htaccess to verify that a cookie has been set and contains the correct value, the cookie could be set from EE.

**Hashing the filename**
Another way to go about it would be to add a unique hash to the filename and store that in the db. That way it would be impossible (see hard) for someone to guess the url to your files.
> 4 votes

---
Tags: file-uploads, solspace-freeform
---


# Question
Title: Best way to layout an employment history field in a safecracker form
I'm looking for some suggestions for the best way to layout an employment history field in a safecracker form. The paper version has a table with the following headers:

* From – To (month/year)
* Job Title
* Name, Address & Telephone Number of Employer
* Reason for leaving

I don't want to create multiple fields for each possible job in the list so I was thinking of going for a single textarea.

Can anyone suggest a nicer way of doing this? Thanks.

# Answer
> 4 votes
Consider using the Matrix field\_type by Pixel & Tonic, see Pixel & Tonic: Matrix This will allow you, the applicant to enter as many rows of like formatted data as needed.

You would define the areas, similar to a table. So the subfields could be: from (mm/yyyy), to (mm/yyyy), position, company, summary, reason for leaving.

The info could be laid out how you like, say something like:

```
  **From       To         Position/Company**
  **Summary/Reason for Leaving**

  05/2012   09/2012     Web Developer, Prince and Stadtler
  Summary: Worked developing photo exhibit section for project specific to user feedback stories.
  Reason for Leaving: Contract Ended
  ...

  01/2012   04/2012     Database Developer, Synchronized Beings
  Summary: Switched company from MySQL to MongoDB.
  Reason for Leaving: Contract Ended

```

The form would place a single instance of the fields to be completed. The applicant, would then select to add more rows, as needed, similar to adding jobs or projects to LinkedIn.

Matrix works well for these types of situations, where there would be an unknown amount of, but similarly formatted responses. It could also be used for a skills field, etc.

# Answer
> 1 votes
The cleanest solution i can think of is to use Matrix from Pixel and Tonic.

Create a matrix field with a field for each of your columns and then use {field:your\_matrix\_field\_name} in your SafeCracker form.

# Answer
> 0 votes
You could use WYGWAM and the templates feature of CKEditor. Each From/To section would be a template segment. Training users on what to click and choose might be a little tricky but it would certainly work for your situation and keep things to one field.

---
Tags: safecracker
---


# Question
Title: Channel entries tag filter based on custom date field
I'm using the JSON plugin from Devotee to write a small API for a third-party.

Another developer (honestly) has added a 'start\_date' custom field for when a particular offer is valid from. The 'entry\_date' field is defaulting to the date the entry is added.

Is there a way of doing something similar to 'show\_future\_entries' but with a custom field? I only want entries to be returned where the start\_date is before today/current\_time.

Here's my simple JSON template code:

```
{exp:json:entries
channel="offers"
search:product_category="Food - chilled-dairy"
show_future_entries="no"
fields="title|offer_start_date|offer_end_date|product_image|product_weight|product_offer_message|
product_offer_image|...snip"}

```

Thanks in advance,
Brett

# Answer
I've struggled with this problem in the past, and there's not really a native way to fix this. There are two third-party solutions that I'm aware of that will give you an easy fix:

**Low Events: http://gotolow.com/addons/low-events**

Provides a wrapper for the channel-entries tag which allows you to do what you set out to do.

**Solspace Date Field Filter: http://www.solspace.com/software/detail/date\_field\_filter/**

This allows you to pick another field for date-based filtering. Different approach, for your ends same effect. This is $10 cheaper then Low's awesome module, and might be a better fit.

I'm sure there are ways to build this yourself with a custom plugin / whatever, but I'm more of a front-end kind of guy, plus: if you can fix this by spending 20 bucks and 5 minutes, to me that's always cheaper then spending an hour or two trying to work out how to fix this :). Hope this helps!

* Steven
> 3 votes

# Answer
The docs have an example of setting the start\_on parameter dynamically. Check here

Does require a bit of php though.
> 0 votes

---
Tags: channel-entries
---


# Question
Title: Calculating a value with Stash and MX Calculator
I'm trying to do some basic math using a Stash Get var and MX Calculator. Any recommendations? I'm sure my lack of understanding of parse order strikes again.

I can get the variable using:

```
{exp:stash:get name='house_starting_price'}

```

But when I try to use it in the MX\_Calculator plugin the value doesn't parse.

```
{exp:mx_calc parse="inward" expression="({exp:stash:get name='house_starting_price'}*.05)"}

```

---

**Based on feedback I've made the following adjustments:**

The stash variable is set like so (note it is in a matrix field):

```
{exp:channel:entries channel="Homes" dynamic="no" limit="1" url_title="{segment_3}" require_entry="yes" disable="categories|category_fields|member_data|pagination"}
                {!-- Go through the elevations matrix but only pull the fields that are from the current community, set with segment_4 --}
            {elevations orderby="elevation_name" sort="asc" orderby="elevation_name" sort="asc"  search:elevation_community="{segment_4}"}
                {!-- Stash the first price as starting price for community --}
                {exp:stash:set name="house_starting_price" match="^1$" against="{row_count}"}{elevation_price thousands_sep=''}{/exp:stash:set}
            {/elevations}
{/exp:channel:entries}

```

I've modified the stash get to use stash:parse:

```
    <br>starting price = {exp:stash:get name='house_starting_price'}
    {exp:stash:parse parse="end"}<br>This is within stash parse: {exp:stash:house_starting_price}

    <br>MX Calculator value: {exp:mx_calc expression="({exp:stash:house_starting_price}*.05"})
{/exp:stash:parse}

```

Here's what's output:

Starting price = 326600
This is within stash parse: 326600
MX Calculator value:

In the output debugger I see:

```
 {exp:mx_calc expression="(M00o93H7pQ09L8X1t49cHY01Z5j4TT91fGfr*.05"})
 {exp:mx_calc expression="(365000*.05)"} <-manually entered 365000

```

---

**UPDATE 2012-12-01**

I've simplified this even more for testing. This takes channel:entries out of the equation all together. I'm finally getting it to calculate but I'm seeing some weird stuff.

```
{!-- Set the mytestvariable --}
{exp:stash:set name="mytestvariable"}645323{/exp:stash:set}
<br>The test variable outside of MX Calculator equals: {exp:stash:get name="mytestvariable"}

    {!-- Use stash:parse to attempt using the stash var within MX Calculator --}
    {exp:stash:parse process="end"}

      {!-- Ensure the varible loads within stash:parse --}
      <br>The test variable within Stash Parse equals: {exp:stash:get name="mytestvariable"}

      {!-- Try to use the stash variable in MX Calculator --}
      <br>The test varible within MX Calculator equals: {exp:mx_calc parse="inward" expression="{exp:stash:get name='mytestvariable'}*.05"}
    {/exp:stash:parse}

```

Output:

The test variable outside of MX Calculator equals: 645323
The test variable within Stash Parse equals: M60o93H7pQ09L8X1t49cHY01Z5j4TT91fGfr
The test varible within MX Calculator equals: 32266.15

Question: Should the second value not equal 645323?
Note: I tried switching all stash gets to shorthand version as well: {exp:stash:mytestvariable}

When I do this I get the following output:

The test variable outside of MX Calculator equals: 645323
The test variable within Stash Parse equals: 32266.15
The test varible within MX Calculator equals:

When I look in the debugger MX Calc is using M60o93H7pQ09L8X1t49cHY01Z5j4TT91fGfr\*.05 instead.

# Answer
> 0 votes
When EE parses a template it looks for tags that are identical, parses the first in the set that it finds and replaces the rest with a cache marker M60o9...

The problem here is simply that you used the identical tag twice, with the second instance being held within a queue (by stash:parse) to be parsed after all template parsing has completed:

```
{exp:stash:get name='house_starting_price'}

{exp:stash:parse process="end"}
    {exp:stash:get name='house_starting_price'}
{/exp:stash:parse}

```

EE therefore never replaces the second instance of the tag with the cached value.

The solution is to simply add the word 'random' to the list of parameters passed to the second instance (and any other instances in the template):

```
{exp:stash:get name='house_starting_price'}

{exp:stash:parse process="end"}
    {exp:stash:get name='house_starting_price' random}
{/exp:stash:parse}

```

Alternatively, the stash variable can be accessed as a placeholder, as it is being used within a stash:parse tag pair:

```
{exp:stash:get name='house_starting_price'}

{exp:stash:parse process="end"}
    {stash:house_starting_price}
{/exp:stash:parse}

```

# Answer
> 1 votes
Looks like you may need to delay parsing of the plugin. Try this:

```
{exp:stash:parse process="end"}
{exp:mx_calc parse="inward" expression="({stash:house_starting_price}*.05)"}
{/exp:stash:parse}

```

The `{exp:stash:parse}` tag is new to the beta version. So you may need to change versions

**Update**

The comma is definitely throwing the calculation off. Set the content to that matrix column to `integer` so the data is standardize. Then I would use JS to format the currency

```
update TABLE_NAME
set FIELD_NAME = replace(
    FIELD_NAME,
    ‘,’,
    ‘’
);

```

---
Tags: stash, parse-order, matrix, mx-calculator, math
---


title: Matrix in Matrix

text:
# Question
Title: Matrix in Matrix
Has anyone ever tried to create a matrix field in a matrix field? (nested matrix)

I have a workshop schedule I'm building and thought this would be the "best" way to create it for multiple days, (initial matrix), and events throughout the day, (nested matrix). I know there isn't a default option for this as far as fieldtypes in a matrix field, but I was curious as to whether or not the universe would implode if attempted.

# Answer
> 10 votes
You might want to give Nolan a try - it sounds like exactly what you're after.

> Nolan enables a very simple matrix style field within a Pixel & Tonic Matrix field

# Answer
> 2 votes
Haven't attempted this, what I have done though is make a Channel for the "events", and then a multi-select Playa-field in the days-Matrix. It's not ideal, I understand, but maybe this would work for you?

# Answer
> 2 votes
Ok,

If this were in EE2, Dom's usage of Nolan would be ideal for what I have. If anyone else runs into an older legacy site that needs the same, here is what I ended up with.

I built a matrix fieldtype with the sub-fields needed for the workshops. I installed SC Category Select and created a category group called workshop days which held nothing more than 'Day 1', 'Day 2', etc.

One of the fields in the matrix field is a SC Category Select field which allows them to select which day the information goes with.

Again, this may not be ideal, but it meets the clients needs of maintaining the workshops on a per entry basis.

---
Tags: custom-fields, ee1, matrix
---


# Question
Title: Have a modal window with yes or no to set a persistent global determining access to template group
I suspect one of you brilliant folks in the EE community will be abel to help me. I need to add a disclaimer-style checkpoint prior to entering a given template group within an EE site. Specifically, it's a medical site with a before and after gallery and some photos in the gallery could be perceived as graphic in nature - and so I want a "visitor beware" kind of selection screen before the user gets into that section. So I'm looking for a way to have the following happen:

1) Upon accessing a give template group path (domain.com/example) a modal window opens with a brief disclaimer allowing the user to choose yes or no to proceed.

2) If yes, the user continues to the template group, if no, they continue to a URL path I designate (probably a placeholder, wherein they would continue to browse the rest of the site and I also give them the ability to reverse their previous no to a yes)

3) the selection that they make in the modal is persistent for, let's say, a browser session. They are still forced to make that same choice the next time they visit the site, even if on the same day, within the browser session.

4) In being a persistent value, the next time they browser to domain.com/example, the rule dictated by their previous selection or yes versus no is enforced. If they clicked yes, they simply access domain.com/example unfettered. If they clicked no, they are routed to the "alternative" landing page wherein they are presented the opportunity to change their mind and select yes.

So I'm guessing this is a javascript thing. I've done something like it, but not in a way that affected routing. It was merely a language selection that then determined whether they were accessing the site via the english or french URL. I've not tried something like there where the selection they make has some influence over what they see within a given template group. I suspect i could repurpose the javascript that was used to perform the language selection, but the behaviour after that was linked to different URLs in the site (domain.com/en/ and domain.com/fr/) whereas in this case, it's all one URL.

Anyone done this before? Advice on how to approach this?

# Answer
If it were me, I wouldn't use JS to handle this, as anyone with JS disabled will be able to get around this stuff. Even using browser cookies could be circumvented, so you really need to think how important is it to see these screens. If having JS and cookies disabled isn't a factor, go with whatever method you this is faster (most likely a jquery solution).

How I would do it would be to customize this add-on.

http://devot-ee.com/add-ons/cookie-plus

Or use this awesome add-on

http://devot-ee.com/add-ons/mo-variables

Really just try to find the best base to start from with the least amount of work to add the desired functionality.

Basically, add a parameter to the setters/getters to handle the redirects. This plugin will do all the cookie work for you, you will just have to manage the redirects.

Using the `{redirect="your/path"}` probably won't work since you will be redirected before the cookie plugin tag is parsed - which is why I would add the redirects to the setters/getters yourself (or have another PHP developer do it).

Really this should be very simple and quick updates if you use that existing module. In my mind, harnessing a pre-built add-on to add the additional functionality would be best - provided there isn't something already in existence. (I have not seen such add-on, so I am not sure if it exists which I why I outline this DIY solution.)
> 3 votes

# Answer
I've always thought that the In Focus photoblog handles this quite well, placing a 'graphic content' overlay on top of flagged images (example). I don't think their approach implements sessions but it would be fairly trivial to set a `show_flagged_images` cookie with jQuery. Removing any other overlays on the page at the same time would also be simple.

This is a slightly different approach to what you're suggesting, but it would be lightweight, easy to implement and is fairly user friendly, as you're not bouncing people from one page to another - overlays can be removed instantly.

Whether or not requiring JS is an issue will depend on your audience.
> 0 votes

---
Tags: javascript, modal
---


# Question
Title: Listed items positioning issue in ExpressionEngine
I have a positioning issue with my in ExpressionEngine. On the following link scroll down to the roster section: click here

I am looping the `li` tags for `<ul class="roster-grid">` I have noticed it loops fine on the few row however begins to misalign on the third row onwards. Does any one know what is causing this problem?

```
<ul class="roster-grid">
{exp:channel:entries channel="roster" dynamic="no" orderby="date" sort="asc"}
                {roster_music limit="1"}
                <li>
                    <a href="#"><img src="{music_thumb}" alt="music" alt="grid-img"></a>
                </li>
                {/roster_music}
{/exp:channel:entries}
            </ul>

```

# Answer
> 2 votes
I did noticed that there are a mixture of image sizes in the grid. Some are `178x182`, `178x183` & `177x183`. This might be causing break in the grid. Try setting a consistant width & height on the images.

Also looks like the `.roster-grid` isn't quite wide enough. I increased the width by one pixel to `534px` and the image jump back. But, this could be do to the inconsistant image dimensions.

---
Tags: templates, tags
---


# Question
Title: Emails not being sent to CC or BCC recipient in Postmaster
I've created a parcel in Postmaster (1.2 beta, build 1.1.99.4), and I want to send a copy of the email to an admin email address (in addition to the intended recipient in the To field).

But when entering a hard-coded email address into the CC (or even BCC) field, I'm finding that the email never gets sent to that hard-coded recipient.

The email does get sent to the recipient in the To field though, and in that email, the hard-coded email address does appear in the CC field. But if I look at the email account for the email address in the CC field, no email is there, or even in the spam folder.

I've used different email addresses but the same thing happens. If I have an email address in the To field, and another in the CC or BCC field, then I'm expecting the email to be sent to two different recipients. But it appears that only one recipient is being sent the email. Can you think what I'm doing wrong here? The email service I'm using is ExpressionEngine.

# Answer
To find out if an email is sent, use the SQL table that stores the responses for all the requests - which is exp\_postmaster\_mailbox. You will be able to check the status to see if it was sent by the server. You can also check the email conents like the sender, recipient, CC/BCC, and even the parsed message contents. This logs will be able to give you an idea if your email was sent.

There are no known issues with the CC/BCC fields at this time.
> 2 votes

---
Tags: postmaster
---


# Question
Title: Importing Fields into Field Editor - how?
I've got Field Editor installed on a new site that I would like to copy/clone fields from an existing site I've built. In the Field Editor CP there's an option to import a field group with a file. This is fantastic, but I can't for the life of me find where to export a field group from an existing site.

The docs for field editor are rather sparse and not helpful in this case.

So is there a way to export field groups from one site to a file and then use field editor to import them into a new site?

New site EE 2.5.3 existing site EE 2.2.2 but scheduled for upgrade to 2.5.3 in the next day or two.

# Answer
You can export one field group at a time in Field Editor while in it's "homepage."
> 2 votes

---
Tags: add-on, ee2, custom-fields, how-to
---


title: Return message: if no results

text:
# Question
Title: Return message: if no results
I am trying to do something which I suspect is quite simple.

I am referencing a channel field to rerun results to populate a series of check boxes. If there are no results I wish to say 'There are no results".

```
{exp:channel:entries channel="sales" disable="categories|category-fields|member-data|pagination" status="open" sort="asc"}
    <label class="checkbox">
       <input type="checkbox" value="{postcode1}">
       {postcode1}
    </label>
    {if no_results}Sorry, No Results{/if}
{/exp:channel:entries}

```

Any thoughts?

Niall

# Answer
You just need to add `require_entry="yes"` as a parameter on your opening `channel:entries` tag and your code should work as expected.

See the documentation on that here.
> 10 votes

# Answer
Any chance you are using this in conjunction with Croxton's ifelse plugin (I see you tagged your question with ifelse)? If so, you need to use the {no\_results}{/no\_results} tag pair instead of the if statement you are using.
> 1 votes

---
Tags: channel-entries, ifelse
---


# Question
Title: Why isn't this snippet + Zoo Triggers working?
I have a set of "category" pages such as:

* Dining (example.com/dining)
* Nightlife (example.com/nightlife)

We are using Zoo Triggers to filter out the categories appropriately. I am using a snippet to insert an icon into the header of each category. This snippet looks like so:

```
{exp:stash:set name="logo"}
    {snippet:masthead_logo}
{/exp:stash:set}

```

The "logo" snippet looks much like this:

```
<div class="logo">
{exp:ifelse parse="inward"}
{if segment_1=='events'}
    <img src="{site_url}images/placeholders/icon-events.png" height="125" width="125"/>
{if:elseif triggers:segment_1=='dining'}
    <img src="{site_url}images/placeholders/icon-dining.png" height="125" width="125"/>
{if:elseif segment_1=='nightlife'}
    <img src="{site_url}images/placeholders/icon-nightlife.png" height="125" width="125"/>
{if:elseif segment_1=='shopping'}
    <img src="{site_url}images/placeholders/icon-shopping.png" height="125" width="125"/>
{if:elseif segment_1=='arts-culture'}
    <img src="{site_url}images/placeholders/icon-arts.png" height="125" width="125"/>
{if:else}
    {exp:ce_img:pair src="{interior_logo}" max="125" crop="no|center,center" fallback_src="{site_url}images/placeholders/member-placeholder-logo.png" allow_scale_larger="yes"}
        <img src="{made}" alt="{title}" width="{width}" height="{height}" />
    {/exp:ce_img:pair}
{/if}
{/exp:ifelse}
</div>

```

As you can see I am testing "dining" for Zoo Triggers segment\_1, which is 'dining' when it parses. However, the conditional is not holding true as it were. In fact, not even the surrounding is passed from the snippet. So I suppose it isn't as much a why isn't this conditional working, but more of a why isn't this snippet working?

# Answer
I tracked the issue down and it was an errantly placed {triggers:entries} tag. Completely my fault, but thankful that I had the answers I received to make me look long and hard at the template.

Thanks all!
> 1 votes

# Answer
In your code above 'logo' is a Stash variable, not a snippet. You would need to access it like {exp:stash:get name="logo"}. You *could* add type="snippet" to the stash:set tag when you set the variable and then access it like so: {logo}; however I'm not sure why you don't just use the original snippet itself: {snippet:masthead\_logo} ?
> 2 votes

---
Tags: stash, snippets, zoo-triggers
---


# Question
Title: Searching multiple channels with Low Search, how do I direct the permalink to the correct template?
Might be having a brain fart on this one, but I'm using Low Search to search two channels and I cannot figure out how to direct them to the right templates. The results display, but I need the link to the entry to go to the correct page...

In Low's example they use this:

```
{comment_url_title_auto_path}

```

which is essentially replicating the permalink feature but without the option to direct it to a certain template. My if statements also don't seem to be working with {if collection=='xx'} either.

# Answer
> 4 votes
If you goto Admin \> Channels Administration \> Channel \> Edit Preferences and set the comment path to the proper URL (i.e. `{site_url}/blog/comments` ) you can use the `{comment_url_title_auto_path}` parameter also. It can be easier then doing conditionals for each channel you might be searching through.

---
Tags: search, low-search
---


# Question
Title: Is there a way to create "peers," as opposed to child/parent relationships?
I'm working on a site that has a workflow in which you might approach the system with one thing (say: an article) or another (say: a person). Articles can have relationships with people, and vice versa.

Normally I would say "make one content type the parent and be done with it," but the required workflow demands that users be able to create the relationship from either direction — a user may want to add a person to the system and relate that person with an existing article, and I don't want them to have to edit every relevant article to create that relationship.

So, you might say, ok: allow either to be the parent — have two relationship fields, and whenever you have to display those relationships, use PHP to filter out any duplicates that might exist.

BUT: what happens when I want to destroy that relationship — not the entries, just the relationship(s)?

I now have to track down every article/person manually, and remove those relationships from each.

It feels like I'm over-thinking this, but I thought I'd ask: Is there a way to create "peer" relationships, one that can be created only once from either peer?

Would this be better handled by something else, like say Categories?

(Now that I'm thinking about it, no categories won't work, because I'd have to go back and add that category to every relevant sibling entry.)

# Answer
Playa from Pixel & Tonic has sibling relationships that might work the way you want them to.
> 4 votes

# Answer
This is not going to be very helpful to you since they have not released it publicly yet but Visitor Plus does exactly what you are looking when it is released. I have done something similar in the past with Tagger but it has the same shortfalls as categories for the most part.
> 3 votes

# Answer
The relationship that you are describing is called a "many to many" relationship model. As you have found, the ExpressionEngine control panel doesn't always handle your needs very well. That's to be expected because every project is different.

What you might need to do is construct a custom entry management interface with Safecracker. This won't replace your control panel, but rather provide a more targeted interface for your users. Playa and Matrix are compatible with Safecracker.

Of course, this is more work, but hopefully it saves work down the road.
> 2 votes

---
Tags: playa, relationships
---


# Question
Title: Is there a better way to direct users after adding/editing an entry?
A thing that annoys me about EE and Structure is that when I add/edit an entry within a channel, I get redirected back to Structure main page. I might want to add another entry, edit another entry in that same channel or edit that same particular entry again.

Always throwing me back to the Structure page is annoying. I feel like I'm clicking around way too much.

Anyone got any good addons or ideas to handle this better? Something that gives you an option to go somewhere after or as you save?

Thanks,

Dave

# Answer
**Deviant** is great for this.

> Deviant allows you to control, globally or on a per-channel basis, where authors land after publishing, updating or deleting entries in the EE control panel.

You can choose to route users to:

* Default Preview
* Publish Form
* Edit Entry
* Manage Entries
* Pages module
* Structure module
* Zenbu module
> 11 votes

# Answer
You can disable Structure’s entry redirection:

Module -\> Structure -\> Module Settings -\> **Redirect to Structure on entry publish/save -\> No**

In addition I use the QuickSave add-on to stay on the edit page when saving an entry (QuickSave settings: **‘Save & Close’ Destination -\> Edit Entries Page**)

SC Publish Redirect is another add-on. But I have not tested it yet.
> 3 votes

# Answer
Well, you can always disable that and use default EE function when you got Preview and you can Publish another entry of the same channel or Edit that entry. You can disable this in Structure Preferences.

About other add-on handling redirects, its something I want to know too :)
> 0 votes

# Answer
If you go to Add-Ons \> Modules \> Structure \> Settings \> Module Settings the second option is "Redirect to Structure on entry publish/save" which you will want to set to "No" in your case to enable the default publish/edit functionality in EE.

If you want to go beyond that you would need to write an extension to handle the behaviors you want. There isn't an existing add-on that I am aware of right now.
> 0 votes

# Answer
I came across this addon that allows you to do specific redirects based on the channel entry being added/updated/deleted. Think it might do the trick.

http://devot-ee.com/add-ons/deviant
> 0 votes

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


title: Custom variable within tag pair?

text:
# Question
Title: Custom variable within tag pair?
I need to restructure the channel entries (I'm trying to group them by one of the channel fields). For example, say I have a list of fruits and each fruit had a color. I'm trying to group these fruits in an associative array by color, like:

```
$fruits['yellow'] = array('fruit_name' => 'banana' ...

```

Once I have this restructured data, I then need to loop over it and output certain mark up.

So far, what I have done is to set `Allow PHP?` to `Yes` and declared an array, built that array within the entries tag pair, and now going to loop through that array and output the markup I need.

This seems messy. Is there a "cleaner" approach?

**UPDATE**

This is how I want to output the data, which I think would be impossible to achieve with an `orderby`:

```
Yellow
 -- Banana
 -- Lemon
 -- Papaya

Red
 -- Apple
 -- Strawberry
 -- Cherry

```

So, I need to loop over the colors, then loop over the fruits within each color. It's a nested array that I need. Using orderby does not give me a nested array.

# Answer
Perhaps you could use the orderby parameter on your custom field, and use PHP to monitor that field, and, each time it changes, perform your custom display behavior?

**Edit 1: Setting up Categories**

It turns out that you should probably be using categories to display your entries. Using your example above, you should setup a Category Group; there are many strategies for managing categories/sub categories; we'll assume you just need a single Category Group called "Colors."

In any event, create the "Colors" category group (Admin \> Channel Administration \> Categories \> \[Create a New Category Group\] \> Name it "Colors" \> Add/Edit Categories \> etc), then, tie it to your channel (Admin \> Channel Administration \> Channels \> Edit Group Assignments \> \[Category Groups\]).

After jumping through those hoops, you'll be able to specify which colors are associated with each entry when editing them.

Once categories are in established, displaying them in a template is straight forward:

```
{exp:channel:categories style="linear"}
  <h3>{category_name}</h3>
  {exp:channel:entries category="{category_id}"}
    <p><a href="{page_url}">{title}</a></p>
  {/exp:channel:entries}
{/exp:channel:categories}

```
> 3 votes

# Answer
As others have noted comments could be the best way to go for you. But if you have valid reasons to use a custom field for fruit colors you can group entries by color with the third-party NSM Channels add-on (AUD $39.95)

This should work:

```
{exp:nsm_channels:group_entries_by
  group_by="custom_field_color"
  }
  <h3>{custom_field_color}</h3>
  <ul>
  {channel_entries channel="fruit"}
    <li>{title}</li>
  {/channel_entries}
  </ul>
{/exp:nsm_channels:group_entries_by}

```
> 2 votes

# Answer
Is there a specific reason you can't use the entries order by parameter to order by that field? I think understanding that would help us answer this question.
> 1 votes

# Answer
You could use Stash to filter by colour on output with match/against:

```
{exp:stash:set_list name="fruit" parse_tags="yes"}
    {exp:channel:entries channel="fruit"}
        {stash:title}{title}{/stash:title}
        {stash:color}{cf_color}{/stash:color}
    {/exp:channel:entries}
{/exp:stash:set_list}

{exp:stash:get_list name="fruit" match="#^yellow$#" against="color"}
{title}
{/exp:stash:get_list}

```

https://github.com/croxton/Stash/tree/dev
> 1 votes

# Answer
Have a look at http://devot-ee.com/add-ons/wb-category-select field type It creates a drop-down of one or more category group.

Also one of the best category plugins around - http://devot-ee.com/add-ons/gwcode-categories you can use it to generate nested or simple list of categories or custom category fields.
> 0 votes

---
Tags: templates, variable
---


title: Can't see root level non-ee php files

text:
# Question
Title: Can't see root level non-ee php files
Weird one - haven't seen this before. Just launched a newly upgraded from ee1 to ee2 site at www.bankofmarin.com. Everything works fine. This is a Structure site and I have strict URLs on to enforce 404 with bad URLs. Works fine.

We need to place some non-ee php files in the root, and they just aren't working. This one https://www.bankofmarin.com/t.php should show the date. Instead I get the 404 page.

Here is my htaccess:

```
# Enable Rewrite Engine
# ------------------------------
RewriteEngine On
RewriteBase /

# Use Dynamic robots.txt file
# ------------------------------
RewriteRule robots\.txt /robots.php [L]

# Force the www - this version will not force www on subdomains, only http://bankofmarin.com
# ------------------------------
RewriteCond %{HTTP_HOST} ^bankofmarin.com [NC]
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]

# Force https - this will only force https on the www site
# ------------------------------
RewriteCond %{SERVER_PORT} 80
RewriteCond %{HTTP_HOST} !^dev\.
RewriteCond %{HTTP_HOST} !^staging\.
RewriteRule ^(.*)$ https://www.bankofmarin.com/$1 [R=301,L]

# Redirect index.php Requests
# ------------------------------
RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
RewriteCond %{THE_REQUEST} !/admin/.*
RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,L]

# Standard ExpressionEngine Rewrite
# ------------------------------
RewriteCond $1 !\.(css|js|gif|jpe?g|png) [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]

```

I thought it might be something in there but its all pretty straightforward. Any ideas?

# Answer
I'm not an .htaccess guru, but we worked with someone to develop a base .htaccess file for use with our clients, and they all contain this

```
## MOD REWRITE BASE
## Checks for file/folder before serving pages in ExpressionEngine
RewriteEngine On
RewriteCond $1 !\.(gif|jpe?g|png|txt)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
#RewriteRule ^(.*)$ http://www.domain.org/$1 [R]
## END MOD REWRITE

```

The goal was to always have EE check to see if there was a file that existed first, then process ExpressionEngine requests and it's been working for us. We just modify the {domain} component for each client.

If I recall, the consultant who helped us with this said that

```
RewriteCond %{REQUEST_FILENAME} !-f

```

checks for the file name first, then

```
RewriteCond %{REQUEST_FILENAME} !-d

```

checks for a directory with said, file, then

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

```

removes the index.php. The remainder is the domain magic.

We've been using that as a base for .htaccess file for over 6-8 years now, it it hasn't failed us.
> 9 votes

---
Tags: php, structure, htaccess
---


# Question
Title: In EE 2.X what replaces the submit_new_entry_end hook?
I'm working on converting an old 1.X extension over to EE 2.X, but my hook was 'submit\_new\_entry\_end'. I can't seem to find a reference to what hook should replace it. My guess is 'entry\_submission\_absolute\_end', but is that right?

# Answer
I would assume so. Instead of asking yourself what hook replaces what hook, ask yourself if this describes the hook you need:

> Additional processing after entry submission, after all processing, prior to redirect.

If so, entry\_submission\_absolute\_end should be the hook you want :-)

You'll get the \_entry\_id, an array of meta data and an array of actual entry data, so you can do pretty much anything with it.
> 5 votes

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


# Question
Title: Lock down/Secure specific sub section in Structure
I have a client's website where they're using Structure addon to hierarchically author content. They now have a need to lock down a particular sub-section of content (could be third level deep). I don't really want to create a set of new templates just for this section, so using the Template Manager to lock down templates to specific user groups is out of the question.

Is there another method by which I can lock down/secure a sub section down to one or more member groups?

Regards Brendan

**UPDATE:** The scope has changed slightly now. This section of the site now needs to be accessible by one of more working groups, but the content they see will be member group specific. May need to consider breaking this out to a specific template group and sub templates instead.

# Answer
You could probably create a custom field to specify if it's locked or not, and then do a conditional redirect in the template if it's locked and the member isn't assigned to the proper group. It's a bit dirty, but it should work.
> 1 votes

# Answer
If you simply need to lock an area down for all but certain member groups then a simple conditional to check the logged in member's group should suffice.

```
{if member_group=="1|3|4"} <-- grant access to anyone in groups 1, 3 or 4
     Display the content
{if:else}
     Show a message indicating they don't have access...or issue a redirect
{/if}

```
> 0 votes

---
Tags: structure, secure
---


# Question
Title: Module development: how to follow OOP best practices
I'm developing an EE module and I want to follow OOP best practices and fulfil the MVC architectural pattern, I have a few questions about how to do this:

* Where should I define a PHP Class for business logic inside a Module?
* What are some examples of existing add-ons that are written in a fully OOP style?

# Answer
If you're looking to stick with CodeIgniter's pattern for OOP (which is very standard) you would have your data methods in one or more models, your view files (for a control panel interface) in a views directory and your two module files (`mcp.*` and `mod.*`) would act as your two controllers.

As such, your directory structure might look something like this:

```
/mcp.addon.php (controller/logic)
/mod.addon.php (controller/logic)
/models/
/models/addon_model.php (data/model)
/views/
/views/index.php (a control panel view file)
/views/settings.php (view file)

```

When an add-on is large or needs some portable logic we tend to write libraries/classes outside of the `mod` or `mcp` files. You don't have to put everything in those controller files if you see a need to do otherwise.

As for an example, you can look at one of our add-ons, Dev Docs, to see code layout. Each add-on "type" (extension, module, etc) is a controller of its own. Then subdirectories contain other code as expected.

https://github.com/focuslabllc/dev\_docs.ee\_addon
> 10 votes

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


# Question
Title: Listing the members/authors who last posted/edited entries in several channels
My members each have their own "PR-room" where all their entries in several channels + their public profiles are collected and shown to the public.

I want a listings page where the 4 last updated PR-rooms are listed. When I ask for the latest entries/edits with the channel:entries tag on multiple channels, I'll get "duplicates", i.e. if a member has posted in both the "News"- and "Galleries"-channel I'll get two listings for the same member/author.

How can I restrict the list to only one result pr. member, regardless of how many channels they've posted in?

# Answer
> 2 votes
You'll probably want a custom query, where you use the `SELECT DISTINCT` statement. I'm not certain how you're creating the PR-Rooms, but something like

```
SELECT DISTINCT m.screen_name, m.member_id FROM exp_members m LEFT JOIN exp_channel_titles c ON m.member_id=c.author_id ORDER BY c.entry_date DESC

```

Might get you started. Be careful with the `LEFT JOIN` vs `RIGHT JOIN`, I didn't test to see which would get you the best results. But basically, a query like this, will get you the member name and their member\_id, based on the descending order of the last channel title they created. The `DISTINCT` limits the results to one return per screen\_name and member\_id.

# Answer
> 0 votes
**EDIT** *I assumed you wanted to make sure you only had a single entry from each of your channels, but on re-reading your question again I see that's not a requirement. My original answer was therefore overcomplicated, but I'm leaving it here in case it proves of use to someone*.

Caveat Lector!

---

So I think the smart way to do this is with Stash and a template partials style approach, as we can grab all the content we need for output and grab the `author_id` we need in one pass of a `{exp:channel:entries}` tag per channel, and use a single `embed` for output.

```
{!-- we need type="snippet" for parse order stuff, and to parse_tags="yes" so we can grab the rendered output for later--}
{exp:stash:set parse_tags="yes" type="snippet"}
  {exp:channel:entries
    channel="channel_2"
    disable="custom_fields|categories|category_fields|member_data|pagination|trackbacks"
    dynamic="no"
    limit="1"
  }
    {!-- grab the author_id for this entry so we can skip it in next entries tag--}
    {stash:channel_1_author}{author_id}{/stash:channel_1_author}
    {!-- stash the actual content that you want to output later--}
    {stash:content_1}
      <li>{title}</li>
    {/stash:content_1}
  {/exp:channel:entries}
{/exp:stash:set}
{exp:stash:set parse_tags="yes" type="snippet"}
    {!-- now pass our author_id with "not" as a param to the second entrieds tag--}
  {exp:channel:entries
    channel="channel_2"
    dynamic="no"
    disable="custom_fields|categories|category_fields|member_data|pagination|trackbacks"
    limit="1"
    author_id="not {channel_1_author}"
  }
    {stash:channel_2_author}{author_id}{/stash:channel_2_author}
    {stash:content_2}
      <li>{title}</li>
    {/stash:content_2}
  {/exp:channel:entries}
{/exp:stash:set}

{!-- use an embed to handle our output (in which all our fresh tasty snippets will now be available--}
{embed="embed/path"}

```

In your embed:

```
<ul>
  {content_1}
  {content_2}
  {content_3}
</ul>

```

Yes you could *probably* do all this with a custom query, but you're going to end up with an unreadable mess and (probably) multiple `embed`s as well due to parse order issues. IMO this way is much cleaner, and makes your intent more readable to the next developer/when you return to your code in 6 months time.

I've been trying to work out if there is a way to do this with only a single channel entries tag for all four entries, but haven't figured it out yet (as we need to make sure we've got 4 entries from unique channels **and** that each is from a unique author too). Because of all those `{exp:channel:entries}` tags make sure you use the `disable` param aggressively and appropriate caching as well.

Alternatively if performance is an issue with this code have a look at the ActiveRecord addon and you may be able to pull what you need with fewer queries using that in place of `channel:entries`.

---
Tags: channel-entries, members
---


title: Struggling with Categories

text:
# Question
Title: Struggling with Categories
I'm new to EE and trying to learn how to use Channels and Categories.

I've created a Channel, then created Channel Fields, then associated the two. I am able to add entries to that channel just fine.

I then created a Categories Group, then created 1 category under that group. Afterwards, I created 3 category fields. They are all Select List field types. The 1 category I created seems to be associated with the 3 category fields automatically.

Then I went into my Channel, under "Edit Group Assignments" and associated the Categories Group.

When I try to add a new Channel entry, the Categories tab has a checkbox for the Category I associated with the Channel. **How do I select the appropriate values from my Select List and associate with with my Channel entry?**

These Select List fields used to be a custom channel field, but because I am trying to "group by" these fields, it seems like I should be using categories.

# Answer
It seems as though you're creating custom fields for categories, when what you need is simply more custom fields for your channel. Category custom fields are for holding information **about that category**, not about individual *channel entries*. When you associate an entry with a category in EE, you are associating it with the singular, canonical values of that category.

Maybe this illustration will help clarify categories in EE:

You might have a **Category Group** called "Fruit". In it, you have categories for Apples, Mangos, Grapes, Oranges, etc.

Then you might add a custom field for that Category Group called "Sugar Content". Now when you go to edit or create a category (Apple, Orange, etc), you have a new field called "Sugar Content" (alongside Category Name, Category URL Title, Category Description, and Category Image). So you enter the amount of sugar **once** for each of your fruits.

Then, you might associate your "Fruits" Category Group with a "Recipes" channel, and every time you you enter a new recipe, you assign it to one or more categories in your Fruits category group. You don't edit the "Sugar Content" custom category field when you're adding or editing your Recipe, because the amount of sugar in each fruit doesn't change per-entry - it's constant.

Maybe that helps?
> 4 votes

# Answer
I think you've misunderstood how these custom category fields work. Each **category** can have unique values for those fields, but not each entry in a channel.

If you need unique values per entry in a channel, you'll want to use channel custom fields. Perhaps check the Playa add-on.

This will allow you to associate one entry with multiple values.
> 3 votes

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


title: New 'Category' Hook or Action?

text:
# Question
Title: New 'Category' Hook or Action?
When adding/deleting/editing a category in the CP, I would like to send that data to Mailchimp (where I ultimately will have the same categories)

How can this be achieved? Using a Action or a Hook? And how?
I'm reading up on making Plugins, Hooks,... but I'm not sure wich Hook I can use and where to place it.

Thanks!

# Answer
> 4 votes
Unfortunately, there is no hook that runs after creating new categories, which is a shame. (You can find a list of available extension hooks here.)

You could try writing an extension that uses the sessions\_end hook, then checks for the various `$_GET` variables that indicate that you just created a new category, but that wouldn't account for times when someone submits the "new category" form and receives errors, nor for when someone creates a new category via the links found on the Publish Form (which are created via AJAX).

So your only alternative I believe is to write a module which does this directly by polling the database (looking at `exp_categories`) and comparing it to your MailChimp categories, then making changes as required. You would configure this using an "action" (which allows you to trigger your method with a URL like `http://mysite.com/?ACT=10`), and setup a cron job on your server to run this acton periodically.

Hope that helps.

---
Tags: categories, add-on-development, plugin, hook
---


title: Freeform 4 sends empty emails

text:
# Question
Title: Freeform 4 sends empty emails
I am currently using freeform version 4.0.6 in EE version 2.5.1

Some of the emails that were send are completely empty (no message body)

Am I the only one that is having this problem? Is there a solution for this problem?

# Answer
I updated Freeform to 4.0.8 which solved the problem.

In v4.0.6 something was wrong with the attachments that should be mailed.
> 3 votes

---
Tags: add-on, email, solspace-freeform, solspace
---


# Question
Title: Channel Entries - possible to search relationship field?
I need a list of all entries filtered by a relationship field. I thought I might be able to use the `search` parameter: http://ellislab.com/expressionengine/user-guide/modules/channel/channel\_entries.html#search-field-name, but it apparently only works on “Text Input”, “Textarea”, and “Drop-down Lists”.

I'm tempted to convert my relationship field to a Drop-down list and figure out another way to make the relationship between my channels. What are my options? Should I be using Category module somehow?

# Answer
> 5 votes
If you use Playa instead of the default relationship type, and make the field Searchable in the options, it will work as if it were a text type. But that doesn't work with the default Relationship fieldtype; you'll have to get Playa.

# Answer
> 4 votes
Just wanted to add that the new version of Low Search allows you to filter entries by relationship (both native and Playa-based). Since Low Search extends the `channel:entries` class, you can pretty much use it as a replacement with the added features. In addition the searching and filtering is much faster as it uses `FULLTEXT` indexes.

Another option as mentioned by adrienne is to use Playa and search the text that's stored in `exp_channel_data`. I'd recommend using the 1entry\_id1 when searching though, because Playa doesn't update the title text that's stored there when the child entry is updated. The `entry_id` is store like `[123] This is the title`, so you could search for `[123]`. Keep the square brackets so that you don't accidentally match something like `[2123]` when searching for `123`.

# Answer
> 0 votes
You don't really say what your trying to accomplish, so I can't say if this is recommended advice, but 'yes'. Yes, it's possible to just use a text field as the basis of a relationship, if you aren't afraid of doing custom queries.

We've done this in a number of situations. Generally, speaking using the relationship field type or Playa works for us, but every once in awhile, a search:in or custom query performs better.

One example, for use, we needed to be able to display all multilingual versions of a publication. The client, produces publications, not all publications are translated, and not all languages are completed when translation occurs, plus occasionally publications are translated into random languages.

So a publication could have an English, Chinese, Spanish, Vietnamese, or Korean version (the five standards), but occasionally may have a Russian, Hmong, or other language translation as well.

We made the relationship field, a text field that already exist, PubID. This field exist to correlate the web version of the publication to the print version, but any version of the publication got the id.

We have six language channels— english, spanish, chinese, korean, vietnamese, and other. We're using a custom query, since the system was set-up pre-search:in days, but basically the query just looks for the current PubID across all six channels, returns the channel name. A subquery is then executed if the channel name is 'other', to pull the results from the specified language field.

So whatever version of the publication a user is viewing, a listing of all the other languages it is available in is provided, and the client doesn't have to keep an updated language list, they just publish the new version, when and if it's ever translated.

So that's a rather long statement to say, 'yes' if the situation warrants it, it is doable, but make sure doing it, makes life easier for the project/client.

---
Tags: templates, channel-entries, entries
---


# Question
Title: Is it possible to allow a member group access to view a channel in the control panel but not publish/edit entries in it
I need to allow a member group to only view some channels (among others) in the control panel but only be able to edit some of those channels.

But as far as I can see there is no way to assign editing permissions per channel, right? I can allow editing for all channels the member group has access to or or nothing.

# Answer
> 2 votes
You can assign which channels a member group can edit using the channel assignment section of the member groups permissions screen. This will restrict the member groups access for posting/editing both in the CP and via stand alone entry forms.

You can also then use the Channel Posting and Editing Privileges controls to determine whether CP users can edit/delete their own entries and view/edit/delete those of others.

However, **it is not possible to make a channel accessible as "read only" for a member group while allowing them editing permissions on another (as I think you are looking to do) using native functionality**. Once you set ""Can edit entries authored by others" for a member group they will have the ability to edit entries in all channels they have access to.

That said, you could still get very close to what you want by either using a custom status group and setting permissions so that editors cannot make entries live even if they can edit them, or by using a custom extension to prevent members of your editor group from submitting entries in your chosen channel. The hook you would want for this is entry\_submission\_start

# Answer
> 2 votes
I believe for that level of specificity, you would need a separate workflow module. I believe BetterWorkFlow by ElectricPutty is possibly what you are looking for.

Generally, in EE, once a channel is accessible, the privileges are closer to all or none. We've set business rules around editing before, but haven't really enforced them with the technology, accept for access. But we've been looking at BetterWorkFlow for a new project, where the client does require more control, and some of the staff wouldn't be inclined to stay within the limits of just business rules.

---
Tags: members, users
---


# Question
Title: How do I get a member login form on the offline template?
We typically demo new EE sites to clients with the site in "offline" mode, which prevents unauthorized access and requires the client to login before they can see anything. Previously we've either directed clients to the CP to login, or, have left the site online and done the authentication via Apache.

**Is it possible to put an EE member login form in the offline template so they can login without having to go to the control panel first?**

I've tried inserting this code into my offline template, but, it appears that the EE tags aren't getting parsed when the site's offline:

```
{exp:member:login_form return="site/index"}
        <p>
                <label>Username</label><br>
                <input type="text" name="username" value="" maxlength="32" size="25">
        </p>
        <p>
                <label>Password</label><br>
                <input type="password" name="password" value="" maxlength="32" size="25">
        </p>
        {if auto_login}
                <p><input type="checkbox" name="auto_login" value="1"> Auto-login on future visits</p>
        {/if}

        <p><input type="checkbox" name="anon" value="1" checked="checked"> Show my name in the online users list</p>
        <p><input type="submit" name="submit" value="Submit"></p>
        <p><a href="{path='member/forgot_password'}">Forgot your password?</a></p>
{/exp:member:login_form}

```

# Answer
It might be easier for you to leave the site online. You can emulate offline functionality by doing this:

1. Create an alternate main index template named something like "home."
2. Create a special "Coming soon" page for your main index template.
3. Create a snippet with these contents:`{if logged_out}{redirect="/"}{/if}`
4. Add the snippet to all of your pages (except the main index template).
5. Add your login form to the main index ("Coming Soon") page.
6. *(Optional)* Link to "/home" instead of "/index" for all of your "Home" links, possibly through the definition of a global variable.

When it comes time to push the site live, you have three things that will have to be done:

1. Move /home to /index
2. Empty the contents of the logged\_out snippet
3. *(Optional)* Change your home links.
> 6 votes

# Answer
I keep my site in online mode, but have the templates restricted to logged in members. When a non-logged in member visits the site they are redirected to a "splash" template with a login form. Once logged in they can see and do everything.

You can set this up in template preferences - It should be just ejnough to redirect the homepage as no-one else should know other links. If you wanted to you could do the redirect on all templates though.
> 7 votes

# Answer
No, you cannot because the offline template is .html and isn't parsed by the EE template engine. Allowing member groups to login when the site is offline is only really available to users who also have CP access.
> 0 votes

---
Tags: templates, members, login, offline
---


title: White Screen of Death Syncing Files

text:
# Question
Title: White Screen of Death Syncing Files
I'm trying to sync my folders using the "Sync" feature in File Manager, but as soon as I press it, then on the next screen, hit Submit... I get the EE White Screen?!

Why would it do this?

It's only recently started doing it, but I've noticed it on a few sites I've deployed.

EE v2.4.0 - Build: date 20120123

# Answer
**A white screen of death normally means that a PHP error has occurred but it's being suppressed**. They should normally be shown if you are logged in as a superadmin but sometimes aren't depending on your config. Here's some things to try to make the error visible:

* Go into your `admin.php` and change `$debug` to `1` instead of `0` (it's under "Error Reporting"). Ideally do this locally or else be sure to turn off after trying it
* Go to Admin ‣ System Administration ‣ Output and Debugging and ensure that Debug Preference is set to 1: PHP/SQL error messages shown only to Super Admins.
* Go to Tools ‣ Utilities ‣ PHP Info and search the page for “display\_errors”. Ensure it is set to On under the Local column. If it is not, your host can help change this setting for you.
* Go into your `admin.php` and change `$debug` to `1` instead of `0` (it's under "Error Reporting"). Ideally do this locally or else be sure to turn off after trying it
* Alternatively inspect the PHP error log file on your server.

If you then see a PHP error, update your question with the details, or if none of this works then update with that info.
> 11 votes

# Answer
Another useful tip that I discovered recently is that you can actually override any `@` suppressed errors via the xdebug.scream config setting. This isn't much use in production environments where you presumably won't have Xdebug installed (and you should be hiding any errors anyway), but if you add the following snippet to your local dev environment's php.ini you'll be able to debug even the most stubborn of white screens:

```
xdebug.scream = 1

```
> 6 votes

# Answer
Something else you might want to look at is the amount of PHP memory. Often times upping the memory limit might help.
> 3 votes

---
Tags: ee2, error, white-screen-of-death, sync, file-manager
---


# Question
Title: What is the maximum number of custom fields you can use in an installation?
I have a fairly large-scale site to build? How many custom fields can I use without running into MySQL database limitations?

# Answer
From the MySQL docs:

"There is a hard limit of 4096 columns per table, but the effective maximum may be less for a given table."

Keep in mind that each field uses two columns, one for field data, another for field type. So divide the maximum column limit by two, and then subtract 3 for the entry\_id, site\_id, and channel\_id columns; which leave you with the possibility of 2046.5 fields.

"Every table (regardless of storage engine) has a maximum row size of 65,535 bytes."

Here are full details: http://dev.mysql.com/doc/refman/5.0/en/column-count-limit.html
> 16 votes

# Answer
Back in the EE1 days I remember some people hitting the limit at around 750 custom fields - usually caused by ambitious Multi-Site-Manager installations. I think they made some improvements in EE2 that may have pushed that a little higher, but either way unless you're using MSM it shouldn't be a problem even for massive sites.
> 2 votes

# Answer
I have maxed out at between 800-900 custom fields per EE install. This is on EE 1.6.7 and is an MSM installation with about 9 sites so not all of those custom fields are for a single site.
> 2 votes

# Answer
I'm guessing you know this but EE adds a new column for all entries with every new field (exp\_channel\_data). So if you had many field groups with many fields this table might hit MySQLs limit, but 2046 ((4096 - 3) / 2) fields is quite extreme and I'd say you need to reconsider your site structure if you need this many! The most I've used is a few hundred, including matrix fields, on a very complex site.

MediaGirl and James have posted the answer, but it's something that shouldn't be an issue.
> 1 votes

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


# Question
Title: Embedding Low Variables within Low Variables i.e. preparse
So I'm taking an existing site and cloning it to use for another site. The thing is the existing site was built a long time ago and has several template insufficiencies including embeds nested 3 levels deep which I would like to fix.

So I've got the header embed now as a low variable which is great. However there are two further embeds within the header that I would like to use as separate low variables just to keep things easy to see in the templates - each of these is a rather large chunk of code.

I've read Low Variables 2.3 totally killed the embed tag and see how that works, however I'm not really passing variables through to the first low variable.

My question is can I do what I want to and if so are there any implications for the future or speed of the site.

exisiting code sample here

```
<header id="header">
    <div class="header-bar">

 A whole bunch of code

        {embed="embeds/_booking-box"}
    </div><!--header-bar-->

More code here

<!-- navigation -->
    {embed="embeds/_nav"}
</header>

```

So in the new template I want to replace those embeds with other low variables - do I need to preparse or not and will it work?

# Answer
> 13 votes
Preparse vars are best used for simple bits of data, not large chunks of code. This is because the Preparse vars are passed along to the variable content by means of a parameter, and large amounts of data (with line breaks, etc...) inside a parameter is never a good idea.

Looking at your example, there aren't any embed variables being passed through the embedded templates. That's a hint that you probably don't need Preparse variables either.

Instead, I'd recommend you create a LV group where you store early parsed template code snippets. Let's call that group 'Snippets'. Inside the group, you add 3 early parsed vars. The first one is the header var, which contains the booking-box and nav vars. All 3 should be early parsed, and the header var should be *above* the other two, so it gets parsed before them. Then all 3 should be parsed just fine.

In conclusion, create 3 early parsed textarea vars in a group in this order, eg.:

* `lv_snippet_header`
* `lv_snippet_booking-box`
* `lv_snippet_nav`

Then in the `lv_snippet_header`, add this:

```
<header id="header">
  <div class="header-bar">
    A whole bunch of code
    {lv_snippet_booking-box}
  </div><!--header-bar-->

  More code here

  <!-- navigation -->
  {lv_snippet_nav}
</header>

```

And then add the above var to your templates in the **variable syntax**: `{lv_snippet_header}`

If you're using the **tag syntax**: `{exp:low_variables:single var="lv_snippet_header"}` then you need to change the reference to the variables inside it to use **tag syntax as well** and you can then disable early parsing, as that's irrelevant for tag syntax.

# Answer
> 6 votes
Taken straight from Low

> Nesting early parsed vars is tricky business. Before the version 2.0.3, there was no predefined order in which the early parsed Low Variables (EPLV) were dealt with, so basically, if it worked, then that's just lucky. :)
>
> As of LV 2.0.3, the EPLV are added to the native Snippets array (and thus parsed) in the order they appear in their group (actually, first by group ID, then by order in the group). This means you have more control over which EPLV are parsed before others.
>
> In your example, you could have a group called Snippets, containing 3 EPLV, say {sidebar}, {sidebar\_content\_1} and {sidebar\_content\_2}. If you want to put the latter two in the first one, you'll have to make sure the order of the vars in the group is this:
>
> * sidebar
> * sidebar\_content\_1
> * sidebar\_content\_2
>
> Then it will work. An order like this will not work:
>
> * sidebar\_content\_1
> * sidebar\_content\_2
> * sidebar
>
> If you're nesting variables across groups, I'd recommend putting them in the same group to have more control over the order in which the EPLV are parsed.
>
> Hope that helps.

---
Tags: add-on, ee2, templates, how-to
---


# Question
Title: Database Queries in Output Profiler Won't Display
With template debugging enabled, clicking the "show" link to display the database queries isn't working.

I suspect this is related to the fact that on all pages of this site there are 7 chunks of content loaded via XHR that pass through the template parser. Because of that, the same ID `ci_profiler_queries_db_1` is used 7 times. Since the code used to show/hide the queries relies on getElementByID, it's unable to determine which of the identical IDs is the intended one.

Is there a solution short of waiting on a core rewrite to use classes and more advanced js?

# Answer
> 5 votes
Ian,

You and Anna/MediaGirl hit on the issue. Currently EE's output class only disables the template debugger and output profiler on responses sent through its own `send_ajax_response()` method (which makes certain assumptions about the response itself.) Hopefully EllisLab will build in some additional ajax response options to the Output class in the future.

**Until that time,** I put together a simple plugin that allows you to surpress the template debugger and output profiler as needed. I'm not putting it anywhere because it's probably somewhat of an edge case. Here's the info:

1. Create a directory called `disable_profiler` in your `third_party` directory
2. Create a file called `pi.disable_profiler.php` in this new directory
3. Here's the code for that file: https://gist.github.com/4206180
4. Add this tag to your templates loaded over ajax: `{exp:disable_profiler}`

You can tweak the code as needed, if you'd rather there be an ajax request logic. I ran this locally with a `$.get()` and `$.load()` jQuery snippet and it seems to work fine. The main/master template keeps the output profiler but the loaded templates do not and thus do not break the master one.

**\[Edit\]**
Per a tweet it looks like there's an add-on that has this behavior among other features. You just install it and it "fixes" this issue for all template requests (per the author's tweet).

Add-on info: http://devot-ee.com/add-ons/ee-debug-toolbar
Tweet reference: https://twitter.com/mithra62/status/276025536717914113

# Answer
> 5 votes
I recently had the same issue where clicking the "show" link didn't show DB query results when template debugging was enabled.

In my case, it was my CSS reset code that was hiding the output. If I remember correctly, "legend" was set to display:none.

You can check your theory about the matching IDs by setting up a blank template and checking to see if the query output appears on that page.

# Answer
> 3 votes
After doing some testing suggested by MediaGirl, I was able to answer with confidence that the root cause in my situation was the multiple calls to display template debugging (via the XHR-loaded content).

Since the code uses IDs to determine what container to show or hide and all 7 of those containers have the same ID, it creates a condition where none of them can be displayed.

I've mentioned this to EllisLab so hopefully they'll address it in a future update.

---
Tags: database, javascript, debugging
---


# Question
Title: Why wouldn't global variable parse correctly with Master Config?
Using Focus Lab's Master Config, I've set a test global variable for production, like so:

```
$env_global['global_test'] = 'test';

```

Then in an embedded template I've dropped in `{global_test}`. Also tried it in a non-embedded template.

In both cases the output, regardless of environment, is this;

```
{global_test}

```

Am I missing something here?

# Answer
> 2 votes
Angie,

I looked through our config code and what you've done *should* work. Can you confirm that you're editing the right environment file to be sure?

I'm reading this from my phone so when I get to my desk later I'll run a few tests to see what's up.

# Answer
> 2 votes
I had this same issue yesterday and the **facepalm moment** was when I realized I had added my variable to config.dev.php when I should have added it to config.local.php.

Are you certain it's not a similar situation?

Perhaps double check the case statements in config.env.php to ensure the matching is working.

---
Tags: config, focus-lab-master-config, global-variables
---


# Question
Title: How to Batch Update Channel Preferences?
I inherited a site with a zillion channels, and every channel has "Automatically Convert URLs to Links?" set to "yes".

Is there a query I can use to update the preferences for all of these channels to "no" at the same time?

EE 2.5.2

# Answer
> 15 votes
The following should work:

```
UPDATE exp_channels SET channel_auto_link_urls = 'n';

```

Backup your DB first though! Always better to be safe.

---

**Update:**

My answer assumes that you know about the Database Query Form. It's located in Tools » Data » SQL Manager » Database Query Form.

---

**Further Update:**

Removed backtick quotes from around table / column names for strange instances where that might cause an SQL error. :-)

---
Tags: mysql, channel-preferences, batch-update, queries
---


# Question
Title: When CE Cache is disabled via the config variable, is there still processing overhead?
I have a current site in development on EE 2.5.3. I'm using the latest CE Cache but have it disabled via the `ce_cache_off` global in my config.

I'm running into some really slow performance in general, most notably refreshing the Structure view.

That view only has 53 queries, which seems normal to me. It's taking upwards of 8 seconds to load, however, and this is at EngineHosting on their Virtual Server Cluster plan that costs $400 a month.

I can't imagine that this is normal and I'm hoping to rule out a server issue. (I currently have a ticket open with EngineHosting and even Greg Aker is going to take a look.)

Does anyone know if CE Cache still does its cache busting and refreshing when disabled via config?

# Answer
> 2 votes
This may be a non issue due to a recent posting by EngineHosting:

http://updates.enginehosting.com/post/37208191032/vsc-performance-impacts

# Answer
> 3 votes
EngineHosting just posted something about that was effecting performance on some VSC clusters, see http://updates.enginehosting.com/post/37208191032/vsc-performance-impacts

But as you say, 53 queries isn't many. Though you may also want to look to see how much memory is used to load the page as well.

---
Tags: add-on, performance, ce-cache, hosting
---


title: Cartthrob: Member Birthday Fields

text:
# Question
Title: Cartthrob: Member Birthday Fields
I'm trying to map member fields in CartThrob, and I'm having trouble with Birthday.

`{customer_bday_m}` displays {customer\_bday\_m}
`{customer_bday_month}` (as shown in docs) displays nothing.

There are no options for the birthday day, month and year fields in the CT settings page.

Am I missing something?

# Answer
> 3 votes
Are you trying to store custom data on member save or checkout? If so, you will need to add `custom_data[custom_field_name]` as the name for the input.

I don't see anything in their docs about birthdays?

You may want to use Profile:Edit along with CartThrob as it can save customer data to your member channel entries automatically.

# Answer
> 0 votes
You might also try the EE's native `bday_m`, `bday_d`, and `bday_y` fields. The documentation only mentions the combined `{birthday}` tag, but the month / day / year values are stored separately in the database and are accessible via `{bday_m}`, `{bday_d}`, and `{bday_y}`.

To use these tags, you must be within `{exp:member:custom_profile_data}`, or you could use an alternative, such as Profile:edit ($49, mentioned by @Siebird above).

I know this answer isn't specific to CT, but it may accomplish what you're after.

---
Tags: members, cartthrob
---


title: Expresso Store: List items on PayPal

text:
# Question
Title: Expresso Store: List items on PayPal
How do I get Store to list individual items and their prices on PayPal? At the moment, the only information which is displayed on the PayPal site is the order number.

Thanks Lee

# Answer
Let me start by saying that PayPal will take your order subtotal and tax rate and want to calculate the tax amount on their own. Normally that wouldn't be a problem but PayPal is notorious for rounding the values wrong which will cause the transaction to fail as their tax calculation is different then what is passed through via Store. So you need to make sure that you run though more test transactions then you normally would to make sure that the rounding issue is not a problem with your site.

**This is assuming that you are using Store 1.6.1:**

While this is not officially supported (I am not sure when or if it will become officially supported) it should do what you need. CI Merchant GitHub Fork will be replacing the system/expressionengine/third\_party/store/ci-merchant/libraries/merchant/merchant\_paypal\_base.php file with the one from the repo. From there you should be seeing your orders data being passed in.
> 2 votes

---
Tags: add-on, expresso-store, ecommerce, paypal
---


# Question
Title: CartThrob Reducing Inventory By a Factor of 2
If someone orders 1x a product at some point between “checkout” and “order\_info” in the sample files with CTv2.2 the inventory of the item gets reduced by double (in this case 2).

Why does it think it needs to reduce the inventory by 2x the ordered amount?

Thanks.

EE 2.5.3 CT 2.2.2

# Answer
> 5 votes
It would appear that there is a bug in CartThrob 2.2 with regards to managing inventory: http://cartthrob.com/forums/viewthread/7374/

# Answer
> 1 votes
I think you need to look at the code you are using for the add to cart bit.

Normally, with CartThrob, you would use {exp:cartthrob:add\_to\_cart\_form} to do the "buy now" bit.

If you look at the docs for this tag pair...

http://cartthrob.com/docs/tags\_detail/add\_to\_cart\_form/index.html

You will see that you can specify a quantity parameter in the tag pair. However, you can *also* add a form field to allow for custom quantities - i.e. you can add more than 1 product at a time to your cart.

I may well be wrong, but I have a feeling you have both the quantity parameter AND a quantity field. Just a hunch. To be honest I don't know what would happen if you did but it's my best guess with the info so far.

---
Tags: cartthrob, checkout, order-info
---


# Question
Title: CartThrob: Modify Credit Cards Listed in Gateways Field
Is it possible to modify the credit cards listed in the `{gateway_fields}`. Or do you have to go through and do a full custom `{exp:cartthrob:checkout_form}` setup?

Thanks.

# Answer
For me I usually just copy/paste the sample HTML code given for that gateway (CT Settings \> Payments) in my checkout template and modify as needed. They also recommend that in the official docs
> 2 votes

---
Tags: add-on, ee2, cartthrob
---


# Question
Title: Redirecting from old Wordpress URLs — getting query strings
I'm migrating the content of a Wordpress blog to EE. The old blog has this URL structure:

```
/news/2012/08/08/2013-schedule/

```

And I need to redirect to this:

```
/news/post/2013-schedule/

```

At the moment I am using this .htaccess redirect:

```
RedirectMatch 301 /news/([0-9]+)/([0-9]+)/([0-9]+)/(.*)$ /news/post/$4

```

But it's resulting in this URL:

```
/news/post/2013-schedule/?/news/2012/08/08/2013-schedule/

```

This is not the end of the world, because I get the right results, despite the extra URL segments, but I'd really rather they went away.

Any help?

FWIW, I'm using the EllisLab-approved redirect method for removing index.php.

# Answer
Few things I'd try first:

1. Have you tried adding the ? to the approved method after index.php?
2. If that doesn't work, have you tried adding ? before /news/post/$4 to see if that changes anything?
3. Check your $config\['uri\_protocol'\] or add it to your config and change from AUTO to one of the other settings (check http://devot-ee.com/ee-config-vars to see the different options)

Any of that help?

**Edit:** I think this is related to an issue I had which was outlined here, hence Option 3: http://ellislab.com/forums/viewthread/202909/#957589
> 3 votes

# Answer
I think your rule is being evaluated at least twice and returns a match twice, once before and once after you do your index.php hiding.

You must be more narrow about what you are matching on. I think this will do the trick:

```
RedirectMatch 301 ^index.php/news/([0-9]+)/([0-9]+)/([0-9]+)/(.*)$ /news/post/$4 [L]

```
> 2 votes

# Answer
This is not marked as answered, did you find a solution? I don't know off the top of my head why this would be happening, but one thing to try would be to put an absolute url instead of a relative one at the destination of your redirectMatch statement. The docs ask for the full URL.

Try replacing that last `(.*)` with `(([\/\w \.-]*)` if a query string is somehow being added internally before reaching that step, that should strip it out by matching only numbers letters underscores dots and hyphens.

You may also want to move that up earlier in your list of redirects, it seems likely that you are getting unexpected input into your redirect. You could turn on redirect logging in Apache to try to get a better sense of what is happening.
> 0 votes

---
Tags: ee2, htaccess, migration
---


# Question
Title: Useless variable when looping channel entries - relationship field
I'm looping through channel entries. When I try to output the value of a relationship field, I seem to be getting some sort of numerical id (it's not the entry id of the current channel or the channel it is related to; I checked). What exactly is that number? How is this number related to the channel it relates to?

Ultimately, I'm trying to change the structure of the data for some other use later on. **So, is there anything in the two channels that are identical so that I can connect the two?**

**UPDATE 1: code snippet**

```
<ul>
    {exp:channel:entries channel="regions" sort="asc" orderby="title" disable="categories|member_data|pagination"}
        <li>{title} - {entry_id}</li>
    {/exp:channel:entries}
</ul>

<?php $formatted_branches = array(); ?>
{exp:channel:entries channel="regions" sort="asc" orderby="title" disable="categories|member_data|pagination"}
    {reverse_related_entries sort="asc" orderby="title" channel="branch"}
        <?php
            $formatted_branches["{participant_status}"]["{region}"]["{parent_company}"][] = array('branch_name' => "{branch_name}");
        ?>
    {/reverse_related_entries}
{/exp:channel:entries}
<?php var_dump($formatted_branches); ?>

```

# Answer
The value is a rel\_id from the exp\_relationships table, which is used as a linking table for all relationships.

Typically you want to use the Relationship tags provided by the Channel Entries loop to work with relationship fields, you should not generally attempt to use them as single variables since they are not generally useful for anything (expect in some special circumstances such as working with custom plugin code).

It looks like you are trying to reference a related entry from inside of a {reverse\_related\_entries} loop - the same issue applies here, the Relationship field itself only returns the rel\_id value - you need to use Channel Entries tag and {related\_entries} to turn this into a usable value.

You could do this by using an embed, for instance, which would load the given entry from the {reverse\_related\_entries} loop, then loop over it's {related\_entries} loop:

**Main template**

```
{exp:channel:entries channel="regions" sort="asc" orderby="title" disable="categories|member_data|pagination"}
    {reverse_related_entries sort="asc" orderby="title" channel="branch"}
        {embed="pages/branch_block" entry_id="{entry_id}"}
    {/reverse_related_entries}
{/exp:channel:entries}

```

**pages/branch\_block** embed:

```
{exp:channel:entries entry_id="{embed:entry_id}" dynamic="off" disable="categories|member_data|pagination"}
    {related_entries sort="asc" orderby="title" channel="branch"}
        {entry_id} - {title}<br/>
    {/related_entries}
{/exp:channel:entries}

```

However, note that using embeds in this way is typically not recommended since it causes nested database calls. If you have a limited number of entries in this relationship however, it's probably okay.

You may also want to consider using Playa instead of the built in Relationships field. It's template tags may be closer to what you expect.

I should also point out that your use of PHP in this template is probably something you want to avoid. It would be a lot better to do this work in a plugin, then package up the results and return it to the template. PHP should never be turned on in templates. I gave a talk on creating simple plugins and wrote up a blog post about it that you may find interesting.
> 2 votes

---
Tags: templates, channel-entries
---