title: Delete Member without deleting comments

text:
# Question
Title: Delete Member without deleting comments
Is it possible to be able to delete a member without deleting his/her comments for posterity purposes such as retaining it for forums and the like?

# Answer
If you're comfortable with SQL, you can update the database to *change* the member\_id on the comments to one that's not being deleted. So, you could create a 'past member' member, and then update the comments to use the member\_id of the 'past member'. This will disconnect those comments from the members you want to delete.

Other options:

Save a backup of the database, and then delete the member and their comments. If you ever want to see the old comments, run a copy of the site against the older database.

Don't delete the members at all, but move them into a member group that has no privileges.
> 7 votes

# Answer
To answer your direct question, it is not possible to delete a member and keep their comments using EE's native process of deleting members. Deleting a member from the control panel will delete the comments. I believe you can elect to have entries/comments moved to a different member.
> 0 votes

---
Tags: members, member-management, delete
---


# Question
Title: Having issues with $config['debug'] = "1" and environments
I currently have environment variables in my config.php file to deal with databases but on the last couple of project I've had to turn on debug on more than one occasion. I added $config\['debug'\] = "1"; to my db environment variables in config.php but it doesn't seem to work as I had expected (i.e. switching debug = 0 to 1 in index.php, which does work by the way). I would love to have debug turned on for all my development and staging environments but off for the live site. Any suggestions? Should I comment out the debug in index.php? Any other areas that might overwrite this variable in config.php?

Current Environment variables for the database and debug values:

```
/* Environmental Variables
-------------------------------------------------------------------*/
switch ( $_SERVER['HTTP_HOST'] ) {

    // local
    case 'site.dev' :
    $db['expressionengine']['hostname'] = "";
    $db['expressionengine']['username'] = "";
    $db['expressionengine']['password'] = "";
    $db['expressionengine']['database'] = "";
    $config['debug'] = "1";
    break;

    //staging
    case 'staging.site.dev' :
    $db['expressionengine']['hostname'] = "";
    $db['expressionengine']['username'] = "";
    $db['expressionengine']['password'] = "";
    $db['expressionengine']['database'] = "";
    $config['debug'] = "1";
    break;

    // production
    case 'site.com' :
    $db['expressionengine']['hostname'] = "";
    $db['expressionengine']['username'] = "";
    $db['expressionengine']['password'] = "";
    $db['expressionengine']['database'] = "";
    $config['debug'] = "0";
    break;
}

```

# Answer
If you are going to set it in config.php (instead of index.php or admin.php), you have to set it to 2 instead of 1.

```
$config['debug'] = 2;

```
> 2 votes

# Answer
I'd guess it's being overwritten later down in your config file... Remove that instance & the setting should work.
> 0 votes

---
Tags: config, debugging, configuration-variables
---


title: cartthrob_on_authorize

text:
# Question
Title: cartthrob_on_authorize
I am having an issue with the cartthrob\_on\_authorize developer hook. I use the hook to carry out some additional processing to the customer order. One such process is to set an order status based on what was ordered. In order to do this, I use the following code:

```
ee()->order_model->update_order($order_id, $new_status);

```

Where `$new_status = array('status => "Processing");`

This is where it gets a little bit confusing. We use Sagepay Server as our offsite payment processor. The code above works perfectly if the customer successfully checks out first time. However, if their first attempt fails (ie they cancel the initial transaction or enter the wrong card details) and then successfully complete the transaction shortly afterwards, the order status defaults to `Complete`

Has anybody experienced this issue before?

# Answer
> 3 votes
I've not seen that before. Odd one! Take a look here at sample code for setting status from that hook. Maybe it will provide some direction.

https://github.com/CartThrob/extension-change\_product\_status

In theory, sagepay should hit the callback url on payment complete (extload.php) and POST it the payment status flag (Y,C etc) which CT then interprets into the status to set the entry to.

---
Tags: cartthrob, sagepay
---


title: Anchor tags removing hash tag in URL

text:
# Question
Title: Anchor tags removing hash tag in URL
I have a long page with 5 anchor tags. The pull down menu is /boxoffice/season#1, /boxoffice/season#2, /boxoffice/season#3, etc.

However when I go to the menu and click on the link it works for about one second and then it pops back up to the top of the page.

I can see the URL change in the address bar from /boxoffice/season#1 to just boxoffice/season. It auto removes the #1.

Is this an EE thing for some other conflict. Looking for some ideas.

# Answer
Sounds like a JS conflict to me. This shouldn't be anything related to EE.
> 1 votes

---
Tags: url
---


# Question
Title: How to output a checkbox group to email in hard code
I have a form, that has 2 sections where you can select multiple checkboxes and I have not figured out how to get those checkboxes to show up in the email. Here is what the checkboxes look like on the form:

I have the locations and characteristics saved in a checkbox group in the back in of Freeform Pro. There is a label and value assigned to each option. My code looks like this:

```
                                    <tr>
                    <td style="text-align: left; font-weight: bold;"><b>Location Preference (check all that apply)</b></td>
                </tr>
                <tr>
                    <td style="text-align: left" width="300" bgcolor="#efeff0"><label>Great Bend </label><input name="great_bend" value="Great Bend" name="support[]" type="checkbox" id="great_bend"></td>
                </tr>
                <tr>
                    <td style="text-align: left" width="300" bgcolor="#efeff0"><label>Hays </label><input name="hays" value="Hays" name="support[]" type="checkbox" id="hays"></td>
                </tr>
                <tr>
                    <td style="text-align: left" width="300" bgcolor="#efeff0"><label>McPherson </label><input name="mcpherson" value="McPherson" name="support[]" type="checkbox" id="mcpherson"></td>
                </tr>
                <tr>
                    <td style="text-align: left" width="300" bgcolor="#efeff0"><label>Hutchinson </label><input name="hutchinson" value="Hutchinson" name="support[]" type="checkbox" id="hutchinson"></td>
                </tr>
                <tr>
                    <td style="text-align: left" width="300" bgcolor="#efeff0"><label>Colby </lable><input name="colby" value="Colby" name="support[]" type="checkbox" id="colby"></td>
                </tr>
                <tr>
                    <td style="text-align: left" width="300" bgcolor="#efeff0"><label>Wichita </lable><input name="wichita" value="Witchita" name="support[]" type="checkbox" id="wichita"></td>
                </tr>
                <tr>
                    <td style="text-align: left; font-weight: bold;">Desired Characteristics of Your IDEAL Firm<br /><span style="font-weight: normal; font-size: .9em;">Please check your top three characteristics</span></td>
                </tr>
                <tr>
                    <td style="text-align: left" width="300" bgcolor="#efeff0"><label>Compensation and benefits </label><input name="benefits" value="benefits" name="idea_characteristics[]" type="checkbox" id="benefits"></td>
                </tr>
                <tr>
                    <td style="text-align: left" width="300" bgcolor="#efeff0"><label>Networking / Future job opportunities </label><input name="networking" value="networking" name="idea_characteristics[]" type="checkbox" id="networking"></td>

                </tr>
                <tr>
                    <td style="text-align: left" width="300" bgcolor="#efeff0"><label>Client Size </label><input name="client_size" value="client_size" name="idea_characteristics[]" type="checkbox" id="client_size"></td>

                </tr>
                <tr>
                    <td style="text-align: left" width="300" bgcolor="#efeff0"><label>Firm Location </label><input name="location" value="locations" name="idea_characteristics[]" type="checkbox" id="location2"></td>
                </tr>
                <tr>
                    <td style="text-align: left" width="300" bgcolor="#efeff0"><label>Opportunity for travel </label><input name="travel" value="travel" name="idea_characteristics[]" type="checkbox" id="travel"></td>
                </tr>
                <tr>
                    <td style="text-align: left" width="300" bgcolor="#efeff0"><label>Experience in variety of industries </label><input name="experience" value="experience" name="idea_characteristics[]" type="checkbox" id="experience"></td>
                </tr>
                <tr>
                    <td style="text-align: left" width="300" bgcolor="#efeff0"><label>Opportunities for internal advancement </label><input name="advancement" value="advancement" name="idea_characteristics[]" type="checkbox" id="advancement"></td>
                </tr>
                <tr>
                    <td style="text-align: left" width="300" bgcolor="#efeff0"><label>Work / Life balance </label><input name="balance" value="balance" name="idea_characteristics[]" type="checkbox"></td>
                </tr>

```

I tired a few different things as you can see in the code. But, so far nothing has worked. How can I get this to work properly?

# Answer
> 1 votes
Make sure {idea\_characteristics} is also in your email notification template.

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


title: Solspace calendar display event details

text:
# Question
Title: Solspace calendar display event details
I'm trying to display a list of my solspace calendar events, with all the event fields that I have. This is my code:

```
{exp:calendar:events orderby="event_start_date" sort="asc" date_range_start="today" show_months="12" dynamic="off"}
    <p>{event_location}</p>
    <p>{event_summary}</p>
{/exp:calendar:events}

```

I don't know whether I'm doing something really silly but my event location and summary won't show. There's definitely content in these fields and the solspace examples says you can add these fields in the the exp:calendar:events tag so I'm not sure what I'm doing wrong?

# Answer
> 1 votes
Not sure why but I had the whole thing wrapped in {exp:calendar:calendars} tags? I've removed them and now it works fine.

---
Tags: solspace, solspace-calendar
---


# Question
Title: Error on Content Entry Submit in EE: Control Panel Giving JSON Responses in the Browser
I am running into an odd issue when submitting content entry forms in the EE CMS. Whenever I submit a form I see this response in my browser:

I am not sure what is causing this issue but it seems like an error. Any ideas?

---

EE v2.7.2
Calendar
CartThrob Pro
CT Admin
Freeform
Structure
Wygwam
Matrix
Freebie
And a couple more smaller plug-ins and extensions.

# Answer
I've seen this before as well and it seems to be something that can happen with Media Temple hosting when FastCGI is enabled. It looks like you're using MediaTemple so I'm guessing that's your issue.

There are a couple threads in the EE Forums about this:

And a warning about ExpressionEngine and Fast CGI in the Media Temple Knowledge Base

The fix is to edit the PHP settings for that domain inside your Media Temple hosting control panel.
> 5 votes

---
Tags: ee2, control-panel
---


# Question
Title: How to add a Favicon to an ExpressionEngine website?
I'm new to ExpressionEngine and was wondering if anybody could help me?

I added the code: in the header in the home index through the Design -\> Templates -\> Edit -\> Site -\> index. I then uploaded the favicon.ico to the root folder using GoDaddy's FTP.

Is there anything I missing, because it's not working?

Thanks in advance.

# Answer
There's not one way to do this with EE. It all depends on your code.

You should find the section (or sections) of your site templates that have the meta tags. Then add your favicon tag there too. To make sure you have the correct path to the favicon, open the favicon link in your browser.

Example: `<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />`
> 3 votes

# Answer
If you have favicon.ico in your website root folder--i.e., so the favicon's URL is http://yoursite.com/favicon.ico, then you do **not** need to include a link to it in your HTML header. Browsers will automatically try /favicon.ico when they find no link in the header (and, some will try /favicon.ico even when do find a link in the header…).

However, if you do want to include links in your HTML header, and you can just use plain-old HTML, like:

```
<link rel="SHORTCUT ICON" href="/favicon.ico">
<link rel="icon" href="/favicon.ico">

```

Note that many browsers cache the favicon, and if they don't find it at first, they won't necessarily pick-up any code or image changes, right away. You can clear your browser cache, or try a different browser, to see the change.

I find that Chrome is actually pretty good at picking-up changed favicons.
> 3 votes

---
Tags: file-uploads
---


title: Freeform Entries for single use

text:
# Question
Title: Freeform Entries for single use
I've built a pretty standard-fare Freeform contact-form, but have spiced things up a bit. The `entry_id` from the JSON-response is used to fetch someone's name and e-mail, which I run through an underscore template and parse out to the user (something along the lines of "Thanks John Doe, we'll get back to you shortly on johndoe@gmail.com).

Now, I understand that this is potentially a *huge* security risk, as all freeform-results are available through a public json-endpoint (in my case `/api/response/{entry_id}`).

How would I go about securing this? Ideally I'd just want the system to only be able to do this once... Is there a way to set that up in Freeform?

Any input would be greatly appreciated!

Thanks!

# Answer
Assuming you're submitting the form via ajax and updating the content of the existing page(?), you could skip the complication of fetching the Freeform entry data and instead take the name and email address values directly from the DOM (the input elements) instead of the POST data, then inject them into the thank-you message content.

If you're using jQuery you could use the `beforeSend` method to store the values and display them in the `success` method.
> 1 votes

---
Tags: solspace-freeform, json
---


# Question
Title: Solspace's Date Field Filter - can it do date headings?
I've started using Solspace's *Date Field Filter* plugin. Is there any way to make the plugin show yearly headings? Something equivalent to EE's {date\_heading display="yearly"}, which doesn't work with the plugin.

I've got a list of awards that I want to break up by date on a single page, e.g. 2013 winners, 2012 winners, etc.

The current work-around is to set the entry date as the award date, but I'd rather not do it that way (for a variety of reasons).

# Answer
*Date Field Filter* works with the `{exp:channel:entries}` tag, so the native use of {date\_heading} in {exp:channel:entries} should apply here. See the EE documentation. However, {date\_heading} is for **entry\_date**, not a custom Date field.

How about PHP for this then? Basically, display a heading when the first occurrence of a year is encountered, and store it in a PHP array to avoid displaying the same year again.

```
<?php $heading = array(); ?>
{exp:channel:entries /* your other parameters here, including Date Field Filter parameters */}

    <?php if( ! isset($heading['{my_date_field format="%Y"}']) ) :?>
        <h2>{my_date_field format="%Y"} winners</h2>
        <?php $heading['{my_date_field format="%Y"}'] = '{my_date_field format="%Y"}'; ?>
    <?php endif ?>

    // Your other code

{/exp:channel:entries}

```
> 1 votes

---
Tags: solspace, date, filter
---


title: Serial Number Registration Lookup

text:
# Question
Title: Serial Number Registration Lookup
I have a client that wants to setup a system that they can upload serial numbers for their products for warranty information. Then users can submit their serial number on the front-end and it would check against what was entered to see if that serial number is valid.

I'll use Solspace's Importer to allow them to upload the data to the website and build a Safecracker form for visitors, but what do you guys think would be the best way of comparing what serial numbers are valid and checking that against what the visitors enter?

There are many approaches I could take with this and wanted to hear your thoughts first!

Thanks again!

# Answer
> 1 votes
It is depended what do you want to do and how secure it must be. If just check it by s/n - make custom from,

```
<form action="/site/sn_check/" method="post">
    First name: <input type="text" name="firstname"><br>
</from>

```

then, using Mo’ Variables, get \_POST value what user is entered and make request using Query module

```
{exp:query sql="SELECT entry_id FROM exp_channel_data WHERE field_id_10 = '{post:sn}' "}
  {entry_id}
 {if no_results} Sorry, is no s/n here! {/if}
{/exp:query}

```

# Answer
> 0 votes
Assuming the product data (including serial number) is now imported as channel entries, how about using either the {exp:channel:entries} tag with the search:myfield="" parameter, or EE's native search form?:

http://ellislab.com/expressionengine/user-guide/modules/search/index.html

Alternatively, if you're looking for more power in your search form, Solspace's Super Search module would allow you to search your channel entries for a serial number entered in a search form:

http://www.solspace.com/docs/Super\_Search

---
Tags: safecracker, solspace-importer
---


# Question
Title: Possible to reassign a member entries to a member of a different member group?
I created a member and member group specifically for the purpose of holding any deleted members data. Basically, when I delete a member, all its entries and comments would be reassigned to the aforementioned member.

However, when I tried deleting via EE Control Panel Admin, I noticed that the aforementioned member is not in the select dropdown of members to reassign to.

After a quick check, it seems to me that the choices in the select dropdown are the ones in the same member group as the member we are deleting.

Is there a way to circumvent this? If not, what is the purpose of this rule?

# Answer
You right, the system is choose members from user group: *"expressionengine/controllers/cp/members.php"* line 677 (EE 2.7.2).

```
$group_ids = $this->member_model->get_members_group_ids($damned);

```

In case if you will delete multi users from multi groups, it will show you users from multi groups.

Reason? As I think same group, same rights to do the same actions. Showing all groups is make more complicated requests or you will get too big list of members. For most sites this strategy is better.

You case is really exception. And tell the true - I can't find explanations for your requirements.

*update*

possible solution:

1. hack the core (where you can do this I indicate at beginning)
2. make alternative module for delete member
3. change member group before delete
4. if you want always assign to the same users - make ext. for hook member\_delete (it is just a couple lines).
5. create new user in the same group
6. send message to EllisLab and check if they decide to change this practice
> 1 votes

---
Tags: members, delete
---


title: 'Dots' in the url_title

text:
# Question
Title: 'Dots' in the url_title
Is there any way of forcing EE to remove 'dots' from the url title? As in an entry called "thiscompany.com" I want the url title to be thiscompanycom because other things depend on not having dots and it generally is bad practice to have it in the url (browser gets confused)

I tried this in the config file:

$config\['permitted\_uri\_chars'\] = 'a-z 0-9~%:\_\\-';

but the system won't override what seems to be a code ignitor default.

So my question is, where do I override this in the CI core if necessary, or some other way of doing it?

# Answer
1. You can use any ee add-ons which can create url\_titles from another field (for example - MX \*Title Control) + somethink like low\_replace to remove dot's.
2. You can replace it on JS level, you can use Foreign Character Extension
3. You can make your own ext. using entry\_submission\_start hook.
4. If you decide to hack core: \expressionengine\helpers\EE\_url\_helper.php, line 59 function url\_title, after

```
$trans = array(
                '&\#\d+?;'              => '',
                '&\S+?;'                => '',
                '\s+'                   => $replace,
                '[^a-z0-9\-\._]'        => '',
                $replace.'+'            => $replace,
                $replace.'$'            => $replace,
                '^'.$replace            => $replace,
                '\.+$'                  => ''
            );

```

just add new line

```
 $str = str_replace('.', '' , $str);

```
> 6 votes

---
Tags: url-title, codeigniter
---


# Question
Title: Stash saving on :get and :set performance benefits?
I'm still trying to fully wrap my brain around Stash's cacheing system.

From the docs it seems that both :set and :get have the parameters `save`, `scope`, `replace`, and `refresh`.

Is there a benefit to using both?

I had thought that perhaps saving on set could be used to store raw data and saving on get could be used to store formatted data. So for example:

```
{exp:stash:set_list name="products" parse_tags="yes"
 save="yes" refresh="60" replace="no" scope="site"}
    {exp:low_variables:pair var="lv_products"}
        {stash:prod_image}{image}{/stash:prod_image}
        {stash:prod_url}{link}{/stash:prod_url}
        {stash:prod_title}{link_title}{/stash:prod_title}
    {/exp:low_variables:pair}
{/exp:stash:set_list}

```

And then:

```
{exp:stash:get_list:nested name="products"
 save="yes" refresh="60" replace="no" scope="site"}
{if count == 1}<ul>{/if}
    <li><a href="{other_prod_url}">{other_prod_image} <b>{other_prod_title}</b></a></li>
{/if count == total_results}</ul>{/if}
{/exp:stash:get_list:nested}

```

In a more "real world" example. I have a rather complex drop-down navigation that is built off nav:ee but includes low variables with playa, and matrix to create "mega-dropdowns" I stash each bit of data individually, but then also tried to stash the entire generated menu with the page uri as a context.

Is this a correct/beneficial "layered caching" approach? Or am I missing something here? :)

# Answer
For the `{exp:stash:get}` tag `save` is only used with `dynamic="yes"` when retrieving dynamic values from $\_POST, $\_GET or segment arrays.

For your menu it only makes sense to stash the parts of your menu as separate lists if you are re-using those values elsewhere. Otherwise, just wrap the tags that generate the menu with a `{exp:stash:set}` with the `output` parameter set to yes so you don't need to `get` it:

```
{exp:stash:set name="main_menu" save="yes" scope="site" replace="no" output="yes" refresh="0"}
[various expensive tags that generate the menu]
{/exp:stash:set}

```

If this is a main menu then it would be wasteful to cache a unique instance for each page URI. If you need the menu markup to change to display an active state - based on the value of `{segment_1}` for example - then enclose the relevant conditionals with `{stash:nocache}` tag pairs to escape them from caching.
> 3 votes

---
Tags: stash, performance, caching
---


title: Get category name from related entry

text:
# Question
Title: Get category name from related entry
I've got a entry called "town" with a native relationship field, the field name is "parks" and it relates to a channel of entries of parks! Each "Park" has a category too.

In my template i'm showing my "Town" entry and i want to display the related "park" and it's category.

But, i don't seem to be having much luck with it.

My code is as follows:

```
{exp:channel:entries dynamic="off"}
{parks}{categories}{category_name}{/categories}{/parks}
{/exp:channel:entries}

```

But i've also tried:

```
{parents field="parks"}{categories}{category_name}{/categories}{/parents}

```

I'm sure i'm just being a cretin here, any help would be lovely, cheers :)

# Answer
You need to prefix the categories loop with the related field name like this:

```
{exp:channel:entries dynamic="no"}
    {parks}{parks:categories}{category_name}{/parks:categories}{/parks}
{/exp:channel:entries}

```

This is to allow you flexibility to display the parent entry's categories too, so it's quite handy.
> 4 votes

---
Tags: relationships
---


# Question
Title: How to show next/prev links for specific category
I have an artists page where i want to show next/prev from that artist How to do that in Expression Engine? Also: The artist is a child of a parent, and i only want the child(artist id) not parent category id. The {exp:channel:next\_entry/prev\_entry} tag is outside of my {exp:channel:entries} tag

This works:

```
                {exp:channel:next_entry category="12" }
                     <a href="{path='portfolio/project'}">Next Project</a>
                {/exp:channel:next_entry}

                {exp:channel:prev_entry category="12" }
                     <a href="{path='portfolio/project'}">Previous Project</a>
                {/exp:channel:prev_entry}

```

And this gives 12 as result because of some previous coding:

```
                  <? echo $artistid ?>

```

So i thought this would work:

```
                {exp:channel:next_entry category="<?php echo $artistid ?>" }
                       <a href="{path='portfolio/project'}">Next Project</a>
                {/exp:channel:next_entry}

                {exp:channel:prev_entry category="<?php echo $artistid ?>" }
                     <a href="{path='portfolio/project'}">Previous Project</a>
                {/exp:channel:prev_entry}

```

Why doesn't it work?

# Answer
Looks like a parse order issue: http://loweblog.com/downloads/ee-parse-order.pdf

You can use an embed or probably also **Stash**. I can't tell you how with Stash but here's how with an embed:

---

In main template, change the next/previous code to:

```
{embed="includes/prevnext" id="<?php echo $artistid ?>"}

```

> *** update "includes/prevnext" to your actual template name.

---

Then in the "includes/prevnext" template, use:

```
 {exp:channel:next_entry category="{embed:id}" }
   <a href="{path='portfolio/project'}">Next Project</a>
 {/exp:channel:next_entry}

 {exp:channel:prev_entry category="{embed:id}" }
   <a href="{path='portfolio/project'}">Previous Project</a>
 {/exp:channel:prev_entry}

```
> 1 votes

---
Tags: next-prev
---


title: Detecting field type in templates

text:
# Question
Title: Detecting field type in templates
Is there a way to capture the field type in the template?

Say I have a wygwam field named {copy-seg} and I want to apply a class of wygwam to that container.

Normal:

```
<div>{copy-seg}</div>

```

Needing:

```
<div class="wygwam">{copy-seg}</div>

```

# Answer
The field type data is not accessible in typical template tags, like `{exp:channel}`. Typically, you have to use the field **names** for your conditions, e.g.:

```
<div class="{if copy-seg}wygwam{if:else}{/if}">{copy-seg}</div>

```

or

```
{if copy_seg != ''}
<div class="wygwam">
{copy-seg}
</div>
{/if}

```
> 1 votes

---
Tags: ee2, templates, fieldtype
---


# Question
Title: channel entries tag seems to run before my module function
The {exp:bmi\_favorite:list\_ids entry\_type="recipe" site\_id="1"} outputs 18|19 to be passed to the entry\_id parameter. It does not work, unless I manually add the 18|19 into the entry\_id, like entry\_id="18|19". That leads me to believe my module function (list\_ids) is running after the exp:channel:entries tag. Is it possible to run list\_ids first, without having to tweak the settings for the template the code is in?

I also tried changing the single quotes to double quotes and that did not change anything.

```
{exp:channel:entries
    channel="recipes"
    entry_id='{exp:bmi_favorite:list_ids entry_type="recipe" site_id="1"}'
}

    <h2>{title}</h2>

{/exp:channel:entries}

public function list_ids()
{
    $entry_type = $this->EE->TMPL->fetch_param('entry_type', false);

    if($entry_type == false)
        return 'Please provide valid entry_type';

    $site_id = $this->EE->TMPL->fetch_param('site_id', '1');

    $where_data = array(
        'site_id'       =>  $site_id,
        'user_id'       =>  $this->EE->session->userdata('member_id'),
        'entry_type'    =>  $entry_type,
    );

    $query = $this->EE->db->where($where_data)->get('bmi_favorite');

    if($query->num_rows == 0)
        return false;

    $i = 1;
    $output = '';

    foreach($query->result() as $row):
        $output .= $row->entry_id;
        $i++;

        if($i <= $query->num_rows)
            $output .= '|';
    endforeach;

    return $output;
}

```

UPDATE: I added parse='inward' to the end of my list\_ids template tag, that did the trick, but I'd like it to do that without the user having to put parse='inward' themselves, is that possible or the user will always have to append parse="inward" onto my module tag?

# Answer
> 4 votes
If you add `parse="inward"` to your channel entries tag parameters, it will force module tags inside your parameters to be parsed before the channel entries tag.

---
Tags: channel-entries, add-on-development, php, module
---


title: Exclude ?URL redirect from site 404's

text:
# Question
Title: Exclude ?URL redirect from site 404's
I'm administering EE site with forum. On the forum, there are many redirects in the form of http://domain.com/?URL=http://third-party-site.com/page.html

Recently, Google started returning 404 for my site if the page on third-party site (which I can't control) does nit exist. What should I do to avoid that, except for blocking "?URL" urls in robots.txt (especially having in mind that the links existed always, but started returning errors just recently, EE version has not been updated)

# Answer
> 1 votes
You can do this in your htaccess

```
RewriteCond %{QUERY_STRING} URL [NC]
RewriteRule .* - [R=404,L]

```

And, EE will return a 404 error code. BUT, EE seems to always return the page that says *To proceed to the URL you have requested, click the link below*. It won't return your 404 template that you've set in EE (EE seems to give that ?URL parameter precedent over its 404 template processing.)

So, I'd worry that the above is not enough to right things with the Google index, and I'd throw the stronger 410 "Gone" error, instead--plus route it to a static error page outside of EE:

```
#optional, show a static file as an error document
ErrorDocument 410 /410.html
#
RewriteCond %{QUERY_STRING} URL [NC]
RewriteRule .* - [R=410,L]

```

*EDITED: "Gone" is status code 410 -- corrected, above*

I think Google (and other search engines) recognize that people who know how to throw 400 errors aren't kidding, and so those "gone" resources can be removed from the search index right away ;-)

---

Note that, if you don't use EE for your 404 page--e.g., you instead have `ErrorDocument 404 /404.html` set in your htaccess pointing to a static page, then the original example of throwing a 404 will totally circumvent EE, and show your static 404 error page.

# Answer
> 0 votes
One option is to add `<meta name=”robots” content=”noindex, nofollow”>` to the forum header so none of the pages on the forum are indexed. You can do that here:

> themes \> forum\_themes \> default \> forum\_global \> meta\_tags.html

---
Tags: redirects, seo, .htaccess
---


# Question
Title: Is it possible to resize a ce-image with max values and fill the gaps with a background color?
I am trying to resize images (logos) to a max of 150px width and 150px height. Since these images differ greatly in original width and height I would like to center the generated image and then fill the gaps with a background color.

What I would like to end up with is a 150px x 150px image every time with logo centered... is this possible with CE Image?

Here is my current tag.

```
{exp:ce_img:pair src="{logo}" max_height="150" max_width="150" crop="no"}
    <img class="media-object" src="{made}" height="{height}" width="{width}" alt="{title}" />
{/exp:ce_img:pair}

```

# Answer
Yes, there's an example on the CE Image docs (common solutions, option 2 - watermark) - essentially you need a blank image file that you can stretch as a watermark behind the resized graphic. Something like this (derived from the example on that page):

```
{exp:ce_img:pair src="{logo}" parse="inward" max="150" crop="yes"}
    {exp:ce_img:single src="/images/white_spec.png"
watermark="{made}|0,0|100|center,center" width="150" height="150" crop="yes" allow_scale_larger="yes"}
{/exp:ce_img:pair}

```
> 2 votes

---
Tags: ce-image
---


title: Mistyped URLs sending me to blank pages

text:
# Question
Title: Mistyped URLs sending me to blank pages
My original EE setup had it where if you mistype a url (eg. www.site.com/carrers) it is set to load in an empty template. Just recently, if you mistype URLs, you get a blank page of nothing.

Any ideas as what's going on and a remedy?

EE 2.6.1

# Answer
> 1 votes
Solved: My template caching system interfered with page generating. My dev environment didn't have the cache working, so it appeard that the templates were working...

---
Tags: 404, blank-screen
---


# Question
Title: EE Switch within Matrix tag pair not working
I'm struggling to get the native switch function of EE to work at all when it's used inside my matrix tag pair, It's simply ignoring it. Could anyone offer any advice? Thanks

Here's my gist: https://gist.github.com/anonymous/7689336

Thanks

# Answer
Matrix field has his own {switch} tag, so channel {switch} tag (is it what you mean by "native switch function" ?) will be not working inside Matrix pair.
> 1 votes

---
Tags: matrix, switch
---


# Question
Title: Low Search - How to specify a default filter for {exp:low_search:results}?
Based on the documentation, `{exp:low_search:results}` has a `default:parameter` param.

Lets say that I have a channel `foo` that has relationship field `y` where the entries have entry\_id `1`,`2` or `3`

Can I make `{exp:low_search:results}` default the search to filter for `y`?

Does at least one of the code below work?

```
{exp:low_search:results
   default:y="1"
}

```

or

```
{exp:low_search:results
   default:y[]="1"
}

```

or

```
{exp:low_search:results
   default:child:y=""
}

```

or

```
{exp:low_search:results
   default:child:y[]=""
}

```

# Answer
> 1 votes
Your third example should work. It's the regular parameter name, prefixed with `default:`. The parameter name for the (child) Relationship filter is `child:field_name`, so the default version becomes `default:child:field_name`. Applied to the Results tag, this becomes:

```
{exp:low_search:results default:child:field_name="1|2|3"}

```

**Note:** The square brackets `[]` *only apply to input fields in your Form* and only for *multi-valued attributes*. It *never* appears in either parameter names of an EE tag or variable names.

**Square brackets are only used in the `name` attribute of `<input>`, `<select>` or `<textarea>` HTML elements.**

---
Tags: low-search
---


title: DevDemon Updater ajax request error

text:
# Question
Title: DevDemon Updater ajax request error
For a while now I have been unable to use DD Updater because of this error:

```
Warning!
Our test AJAX request failed! We sent an AJAX request to but the response was   invalid.

```

I don't recall if the error started when I upgraded the module or when I moved to a different host, regardless I'm using EE2.5.5 and I have upgraded to the latest version of updater today (3.2.9) with no success. I tried changing several settings and nothing changed, can anyone point me in the right direction? The ajax response is blank btw.

Thank you.

# Answer
> 1 votes
First of all, check if

* URL to the root directory of your site
* URL to your 'themes' folder

is setup correct in *EE \> Admin \> General Configuration*

If you will not found any error inside this settings, you need to open chrome inspector and check what exactly happens. On tab Network you will able see the ajax request (url & headers) + results. Possible something wrong with your .htaccess and you have multi redirection as example.

For example it is can happen if your CP is on domains with www., but request is going to domain w/o www..

---
Tags: ajax, devdemon, devdemon-updater
---


# Question
Title: Passing an embed variable in a parameter of a tag
I don't think that the parse order would make this code below work

```
{exp:channel:entries
  entry_id="{embed='common/.get-entry-id-based-on-some-complex-logic'}"
}

```

Is there a way to make embed tag be parsed first before the `{exp:channel:entries}` is parsed?

If not, what are alternative ways to this(Snippets can't be used if in this case if I am not mistaken)?

# Answer
Why not do it the other way around, where the template being loaded is what actually contains the complex logic? Then you can embed the rest of the template, passing the `entry_id` via an embed parameter.

Alternately, write a simple plugin which performs your logic and returns the `entry_id`, then put your Channel Entries tag inside of that plugin tag pair (related example here).
> 3 votes

# Answer
Have you tried adding a parse="inward" to your channel:entries tag?

If that doesn't work, you could possibly use stash to set an entry\_id variable as a result of your complex logic, and then use that stash var in your channel:entries tag.

eg (very loosely)

```
{exp:stash:parse}
    {complex_block}
        {exp:stash:set name="my_entry_id" type="snippet"}{value}{/exp:stash:set}
    {/complex_block}
{/exp:stash:parse}
...
{exp:channel:entries entry_id="{my_entry_id}"}

```
> 0 votes

---
Tags: embeds
---


title: Wygwam source button

text:
# Question
Title: Wygwam source button
i'm using the wygwam editor and i'd like to use the source button/option with my admin account. but the source button should not be visible/usable for other members.

any idea how to do that?

thanks!

# Answer
Wygwam Super Admin Source does exactly what you need.
> 2 votes

---
Tags: wygwam, admin
---


# Question
Title: Anyone experiencing intermittent Submit fail and redirect to CP dashboard/home? (ee 2.7.2)
On several different installs I'm finding that when I finish editing an entry and hit **Submit**, the submission **sometimes** completely fails and I am redirected to the Control Panel home page.

I'd like to stress that in all cases I **remain in a logged in state** so it seems to be a different issue than the OP was raising in the EllisLab forum thread at How to stop CP timeouts completely – although I note that some of the commenters in that thread are citing the same behaviour as I am describing here.

I have 3 different installs where this is happening, each with a different mix of add-ons from lots and lots to effectively none.

At first I thought it was to do with the security warning interjecting on a 2.6.1 install, but now that is updated and yet it's still happening.

And just now, it's happened to me while working on a **local** 2.7.2 install in which the only add-on installed is Wygwam. But Wygwam is currently not being used on any fields, so the active number of add-ons on the entry that just failed to submit is zero.

That said, as I'm concluding that I probably don't need Wygwam at all on that install I shall disable it and see if this weirdness happens again.

Anyone else got this kind of thing going on? Because it's not good and it's understandably bugging my clients on the live installs.

# Answer
> 3 votes
It's an XID issue/bug that is known to EL and slated to be corrected in the next release. A fix until then is posted: https://support.ellislab.com/bugs/detail/19920#12050

# Answer
> 0 votes
This happens to me on all my recent installs. Here is a thread that may help you. I just found this, and will be trying the couple things they recommend:

Save issue: Submitting entry edits redirects to control panel top?

---
Tags: control-panel, error, database-error
---


# Question
Title: Save issue: Submitting entry edits redirects to control panel top?
**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 having an issue in my ee2 install in which most often when I edit or create an entry in the control panel and click submit, the control panel homepage is loaded and the content is not saved. If I hit back in my browser and resubmit, the change is saved on the second try.

Has anybody else seen this, and does anyone know what the fix is likely to be?

# Answer
> 5 votes
I'd start by disabling all third party extensions, as an errant one of those is probably the most likely cause. You can do this globally in `config.php` by setting:

```
$config['allow_extensions'] = 'n';

```

If this fixes it, set this back to `'y'` then disable your extensions in the CP one by one until you find the cause.

It's also worth checking that there are no JS errors on the publish/edit page (using your browser console). If there are these can normally be traced to a custom fieldtype, or some other addon. If you find one and can't debug it yourself post it here.

# Answer
> 0 votes
It's an XID issue/bug that is known to EL and slated to be corrected in the next release. A fix until then is posted: https://support.ellislab.com/bugs/detail/19920#12050

---
Tags: ee2, control-panel
---


# Question
Title: SWITCH - How to show quantity of switched ON rows?
I need to show how much rows in the entry have "ON" state. I could not find any tag in documentary.

# Answer
If you're looping channel entries you could add a second loop to grab the "On" entries...

```
{!-- first loop to display entries --}
{exp:channel:entries channel="mychannel"}
  {title}
{/exp:channel:entries}

{!-- second loop to grab 'on' entries --}
{exp:channel:entries channel="mychannel" search:your_switch_field="ON"}
  {if count == total_results}
    {total_results}
  {/if}
{/exp:channel:entries}

```
> 1 votes

---
Tags: field-pack
---


# Question
Title: Filter by entry_id parameter in exp:store:search tag
`{exp:store:search}` doesn't appear to allow you to filter by `entry_id` in the same way `{exp:channel:entries}` does.

I've written a plugin that will return only entries that meet advanced category criteria which works great (it returns them as a piped string of entry\_ids).

However I need to pass that into `{exp:store:search}` in order to take advantage of your order by price feature.

Any guidance is appreciated.

# Answer
The Store search tag is actually a wrapper for channel entries, and does exactly that - it generates a list of entry IDs and passes them through, which is why it can't accept a list of entry IDs itself.

What I suggest you do instead of using the a Store search tag is simply order them yourself in your SQL statement. All you need to do is add

```
JOIN exp_store_products on exp_store_products.entry_id = exp_channel_entries.entry_id
ORDER BY exp_store_products.price ASC

```

Then pass them into the channel entries tag using the fixed\_order="1|2|3" parameter (instead of entry\_id=""). It works exactly the same but will preserve the order of entry IDs you pass in.
> 1 votes

---
Tags: expresso-store
---


title: Filtering playa and stash by categories

text:
# Question
Title: Filtering playa and stash by categories
I am trying to filter a list by category, with each staff member listed beneath it. Here is my code:

```
{exp:channel:entries channel="offices" entry_id="23" dynamic="no"}
{office_staff}
    {exp:gwcode_categories entry_id="{entry_id}" style="linear" entry_count="yes" parse="inward"}
        {exp:stash:append_list name="city1_staff_{cat_id}" save="yes" scope="site"}
            {stash:title}{title} - {cat_id}<br/>{/stash:title}
        {/exp:stash:append_list}
    {/exp:gwcode_categories}
{/office_staff}
{/exp:channel:entries}

{exp:channel:categories channel="staff" style="linear"}
<h2>{category_name} - {category_id}</h2>
<ul>
    {exp:stash:get_list name="city1_staff_{category_id}"}
        <li>
            <h3>{title}</h3>
        </li>
    {/exp:stash:get_list}
</ul>
{/exp:channel:categories}

```

The categories are listing properly, and looking at mustash, it looks like the lists are being generated correctly, but for some reason the stash get\_list isn't populating in the second code block. I am sure it is something simple, but its got me going in circles. Maybe someone has a clear view of it?

# Answer
Top of my head, its a parse order thing. Try wrapping your exp:categories tag with

```
{exp:stash:parse process='end'}{exp:categories}...{/exp;categories}{/exp:stash:parse}

```
> 2 votes

---
Tags: categories, stash, gwcode-categories
---


# Question
Title: Allowing script/form tags in RTE (WysiHat)
I was wondering if there was any way of being able to edit the WysiHat settings to allow script/form tags to be entered into them. We have a client who has a third party widget which require JS, and a PayPal form which he wants to be able to put on his site, and move around using the default RTE. However whenever he pastes them in code view and returns to content view, they get stripped.

I've added textarea and rte to skip\_xss\_fieldtypes in Channel\_form\_lib (line 3155) but it's still doing it when swapping between code and content view. If anyone could give me a hand on how to fix this without resorting in switching to a third party WYSIWYG, that would be great.

Thanks, Jon

EDIT: Just did some further investigation, when pasting a script tag in code view and then submitting (without switching it back to content) it comes through fine. However when you then go to edit the entry again, it initialises as content view and the script tag disappears, could this be because the script tag isn't a visible element by default?

Also when pasting a form in and switching back to content view, the form tags get stripped. I thought this might have something to do with the fact that you're already inside a form tag so it's stripping the tags it sees as being unnecessary. Then when you hit submit it's trying to validate the fields that're pasted in (if they have required set, it won't let you submit).

Seems like this might be a bigger issue than just switching a setting over, but I appreciate any useful comments that are left.

# Answer
> 1 votes
Sounds like a perfect user case for krea elements: http://devot-ee.com/add-ons/content-elements

You could have a 'script' field as a separate entity and arrange it before/after any other fields required.

---
Tags: rte, xss
---


# Question
Title: Can't achieve conditional within Playa using {count}
I'm trying to apply a class of odd or even based on the count within a playa field. My website is for a company with 13 branches & 15 products. Not all branches sell all products so I have created a Products channel & an Offices channel and used Playa to add relevant products to each office.

What I'd like to happen is for a class of odd or even to be applied to the opening div that will make the products display either two or three across, depending on the count.

What's actually happening is that no matter what my count, the first div always gets applied as odd and the rest as even. I've tried total\_count but that won't even apply the right class to the first div. Am I doing something fundamentally wrong or is this just not the right approach to take?

```
{exp:playa:children field="office_products"}
            {if {count} == "1|3|5|7|9|11|13|15"}
                <div class="product odd">
            {if:else}
                <div class="product even">
            {/if}
                <div class="insurance_type">
                    <div class="product_image">
                        {exp:ce_img:pair src="{product_logo}"}
                                <img src="{made}" alt="{title}" width="{width}" height="{height}" />
                        {/exp:ce_img:pair}
                    </div>
                    <h2>{title}</h2>
                    {exp:ce_str:ing truncate="88"}<h3>{product_short_intro}</h3>{/exp:ce_str:ing}
                    {exp:switchee variable="{segment_3}" parse="inward"}
                        {case value=""}
                            <a href="#" data-reveal-id="myModal_{url_title}" class="button">Get A Quote</a>
                        {/case}
                        {case value="services"}
                        <a href="{site_url}offices/{segment_2}/services/{url_title}" class="button">More Information</a>
                        {/case}
                    {/exp:switchee}
                </div>
            </div>

            <div id="myModal_{url_title}" class="reveal-modal small">
              <h2>Get a {title} Quote</h2>

                {exp:forms:form form_name="quote_now" display_error="inline"}
                    {forms:fields}
                            {forms:field}
                    {/forms:fields}
                {/exp:forms:form}

              <p></p>
              <a class="close-reveal-modal">×</a>
            </div>
        {/exp:playa:children}

```

# Answer
Switch is the correct way to do this, on a related note the new Modulus operator introduced in 2.7.1 can also help in similar cases. \[http://ellislab.com/blog/entry/the-modulus-operator\]\[1\]
> 1 votes

# Answer
Try **switch** instead:

```
{switch="<div class='product odd'>|<div class='product even'>"}

```

Or **nth-child CSS selector** if you need this for styling:

```
.product:nth-child(odd)
.product:nth-child(even)

```
> 0 votes

# Answer
Changed approach on this slightly. What I wanted to happen was that for an odd count the first row would have two columns, second row would have three and then keep going like that so that I don't end up with a single product on its own at the bottom. By using a combination of switchee and count this is the code i'm using that gives me the result I need.

```
{exp:playa:children field="office_products"}
            {exp:switchee variable="{total_results}" parse="inward"}
                {case value="1|3|5|7|9|11|13|15"}
                <div class="product odd{count}">
                {/case}
                {case value="2|4|6|8|10|12|14"}
                <div class="product even">
                {/case}
            {/exp:switchee}
                <div class="insurance_type">

                    {exp:switchee variable="{segment_3}" parse="inward"}
                        {case value=""}
                            <a href="{site_url}offices/{segment_2}/services/{url_title}">
                                <div class="product_image">

                                    {exp:ce_img:pair src="{product_logo}"}
                                            <img src="{made}" alt="{title}" width="{width}" height="{height}" />
                                    {/exp:ce_img:pair}
                                </div>
                                <h2>{title}</h2>
                            </a>
                            {exp:ce_str:ing truncate="88"}<h3>{product_short_intro}</h3>{/exp:ce_str:ing}
                            <a href="#" data-reveal-id="myModal_{url_title}" class="button">Get A Quote</a>
                        {/case}
                        {case value="services"}
                            <a href="{site_url}offices/{segment_2}/services/{url_title}">
                                <div class="product_image">
                                    {exp:ce_img:pair src="{product_logo}"}
                                            <img src="{made}" alt="{title}" width="{width}" height="{height}" />
                                    {/exp:ce_img:pair}
                                </div>
                                <h2>{title}</h2>
                            </a>
                            {exp:ce_str:ing truncate="88"}<h3>{product_short_intro}</h3>{/exp:ce_str:ing}
                            <a href="{site_url}offices/{segment_2}/services/{url_title}" class="button">More Information</a>
                        {/case}
                    {/exp:switchee}
                </div>
            </div>

            <div id="myModal_{url_title}" class="reveal-modal small">
              <h2>Get a {title} Quote</h2>

                {exp:forms:form form_name="quote_now" display_error="inline"}
                    {forms:fields}
                            {forms:field}
                    {/forms:fields}
                {/exp:forms:form}

              <p></p>
              <a class="close-reveal-modal">×</a>
            </div>
        {/exp:playa:children}

```
> 0 votes

---
Tags: playa, pixelandtonic, count
---


# Question
Title: Safecracker: how can I reliably alter the return value on form submit?
I've inherited a project where the developer used a trick that's worked for me before: use JavaScript to modify the value of Safecracker's hidden return element prior to submitting the form, gaining control over where you'll land after the form is submitted.

Except it's not working with this EE 2.6.1 install; despite this working with EE 2.5.5, and the fact that I can easily modify the return element's value, the form submits and leaves me at the page specified in the Safecracker return parameter.

Here's what we'd like to happen on this school site:

* teacher composes a new class blog post
* teacher chooses "Submit" or "Submit and Email to Parents"
* if choosing "Email to Parents", resulting page should be `/mail_classblog_confirm/`, which loads up the last teacher blog post, previews it as an email, and has the teacher confirm that it should be sent out

What actually happens: either submission lands back at `/classes/{freebie_2}`, which is specified in the `{exp:safecracker}` return parameter.

```
<h3>New Post</h3>
{exp:safecracker channel="class_blog" return="/classes/{freebie_2}" include_jquery="no"}
    <label>Title:</label>
    <input type="text" name="title" style="width: 98%;">

    <label>Update:</label>
    {field:bl_content}

    <button type="submit" class="btn btn-primary">Submit</button>
    <button type="button" class="btn btn-primary btn-mail">Submit and Mail to Parents</button>

    <script>
        $('.btn-mail').click(function(){
            for ( instance in CKEDITOR.instances )
                CKEDITOR.instances[instance].updateElement();

            if ($('input[name="return"]').length > 0) {
                $('input[name="return"]').val('/mail_classblog_confirm/');
            } else {
                $('form#publishForm div.hiddenFields').append("<input type='hidden' name='return' value='/mail_classblog_confirm/'>");
            }

            $('#publishForm').submit();
        });
    </script>
    <a class="btn btn-cancel" style="float: right;" href="#">Cancel</a>
{/exp:safecracker}

```

Ultimately I have two questions:

1. If I'm absolutely positive that the JavaScript is manipulating the return input element correctly (I can watch it happen in Chrome's inspector) prior to submitting the form, how is it even possible that this could fail?
2. Is there a better, more reliable way to control where the user ends up based on which submit button they've chosen?

# Answer
> 2 votes
I know it's a bit old but for someone looking to change some parameters (like the return value) on submit by JavaScript - the reason it's not possible is that EE uses the meta tag which is an encrypted string containing some of the information. So, to change the value you would need to recreate that encryption. Look in the file Channel\_form\_lib.php for more information.

# Answer
> 2 votes
Matt, two options for you.

1) Easy: pass a segment variable to the safecracker form, then use 2 if statements (rather than an if else) to set the return values you need. That means youll need two different links pointing to the safecracker form.

2) More work: create an extension and use the safecracker hook - channel\_form\_submit\_entry\_end to redirect to the required page. safecracker hooks. Maybe you could use a hidden input value, pick that up in the post then redirect to it.

Edit: Solution 1: like this. on the page that links TO the safecracker form create 2 links.

`href="template_group/template_name/submit"`

`href="template_group/template_name/submit-email"`

And in your safecracker template...

`{exp:safecracker
secure_action = "yes"
secure_return = "yes"
channel = "browse"
include_jquery = "no"
status = "{embed:status}"
{if segment_3 == "submit"}
return = "some/path"
{/if}
{if segment_3 != "submit"}
return = "another/path"
{/if}
}`

---
Tags: safecracker, forms, javascript
---


# Question
Title: Cartthrob: confirmation email sent but member not registered
I'm having an issue on a site running EE v2.5.5 and Cartthrob 2.3.6. The vast majority of users are able to register no problem. However, some users intermittently go through the registration process, receive a confirmation email, but when they try to login they get the error: The existing username and/or password you submitted are not valid.

When you check in the backend of the site the member is not registered. I can't for the life of me find any pattern. I thought it might be something to do with people registering from work, where companies have some kind of excessive caching on their servers which is confusing EE somehow.

If anyone has experienced something similar please feel free to share the pain, and even better a solution!

# Answer
So we think we finally found the answer. The previous developer was setting some javascript when a user was registering that was posting the email address to another area of the db. This was causing some issues with certain versions of IE.
> 0 votes

# Answer
I can't offer a specific fix, but I would make sure you have the most recent version of EE, CartThrob and Profile:Edit installed to eliminate bugs in the code.
> 2 votes

---
Tags: members, cartthrob, profile-edit
---


# Question
Title: The action you have requested is invalid
I am using EE 2.4

Dummy signup: http://tensports.zeecdn.com/test-login-native.php

When I click on register it gives me an error **The action you have requested is invalid.**

I am submitting a form with *action ="http://tensports.zeecdn.com/ee/index.php/register/login-signup"*

Can I get some guidance on this?

In case if you want to refer the code :

```
<form id="signupForm" action="<?php echo $STATIC_URL;?>ee/index.php/register/login-signup" method="post">
    <input type="hidden" id="form_status" name="form_status" value="signup">
    <li class="emId remReg"><a href="javascript:void(0);" onClick="javascript:validate_signup();"
        class="acLogin">Register</a>
    </li>
    </ul>
</form>

```

my template:

http://codepad.org/eaKqsvTJ

# Answer
You will get that error if you have secure forms enabled, and you submit a form without including a valid XID in the post.

More here: http://ellislab.com/blog/entry/putting-the-secure-in-secure-mode-forms

Add this to your form:

```
  <input type="hidden" name="XID" value="{XID_HASH}">

```

You can disable secure forms in your config, although this is not recommended:

```
$config['secure_forms'] = "n";

```
> 7 votes

---
Tags: ee2, members, error, forms
---


# Question
Title: Relationship field - {count} of type, and {total_results} of type
I have a relationship field which contains a number of different pieces of content.

Each piece of content has a type property.

Is there anyway I can count the number of each of the types that is included in the relationship.

For example. 3 Product related items, and 2 Showcase related items.

I need to be able to get the {total\_results} of each type.

This is what I'm trying to do...

```
 {if "{related:panel_type}" == "products"}

      {if "{related:count}" == "1"}
        <ul class="p">
      {/if}
        // do stuff
      {if "{related:count}" == "{related:total_results}"}
        </ul>
      {/if}

    {/if}

  {if "{related:panel_type}" == "showcase"}

      {if "{related:count}" == "1"}
        <ul class="s">
      {/if}
        // do stuff
      {if "{related:count}" == "{related:total_results}"}
        </ul>
      {/if}

    {/if}

```

So at the moment {total\_results} is equal to 5 so my ul is not getting closed properly.

Does anyone have any ideas how I can get around this problem.

I would like to keep my markup inside the exp:channel:entries loop, and ideally use only one loop.

Any help, greatly appreciated

# Answer
Faffing about with loop counters is quite unpleasant and inelegant... these are the kind of problems you run into when your data-fetching is tightly coupled to your data-output. Instead put Stash to work. Here's how:

```
{!--  ============================================
STORE THE DATA into dynamic stash lists using context.
Avoid the temptation to put any markup here.
================================================== --}

{exp:channel:entries ...}
    {related}
        {exp:stash:append_list name="related-items" context="{related:panel_type}"}
            {stash:the-title}{related:title}{/stash:the-title}
            {stash:a-custom-field}{related:a-custom-field}{/stash:a-custom-field}
        {/exp:stash:append_list}
    {/related}
{/exp:channel:entries}

{!--  ============================================
ASSEMBLE THE MARKUP and OUTPUT THE DATA
================================================== --}

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

    {if {exp:stash:not_empty name="related-items" context="products"}}
        <h2>Related Products</h2>
        <ul class="p">
           {exp:stash:get_list name="related-items" context="products"}
             <li>{the-title} | {a-custom-field}</li>
           {/exp:stash:get_list}
        </ul>
    {/if}

    {if {exp:stash:not_empty name="related-items" context="showcase"}}
        <h2>Related Showcase</h2>
        <ul class="s">
           {exp:stash:get_list name="related-items" context="showcase"}
             <li>{the-title} | {a-custom-field}</li>
           {/exp:stash:get_list}
        </ul>
    {/if}

{/exp:stash:parse}

```

If you were using a separate view template for your layout you wouldn't need the final stash:parse tag, but if you're setting and getting in the same template it helps to avoid parse order issues. (Full explanation and tutorials here: http://www.jamessmith.co.uk/articles/expressionengine-stash-tutorials)
> 2 votes

---
Tags: relationships, count
---


# Question
Title: Display low search results under category headings
I hope you're all well.

I have built a new website in EE and I'm using Low Search for a filtering system. It is set up as a series of checkboxes which allow the user to choose the categories they wish to view, and upon hitting search they're shown a page of results. This is all working perfectly fine, however I need to make an adjustment to the results page.

At present a user can filter any categories, for example;

* Category 1
    + Category 1 child 1
    + Category 1 child 2
    + Cateogry 1 child 3

If the user ticks Category 1 it will select all the child items so the results page contains all the entris from these four categories (including the parent). Is it possible to display these on the results page as so (assuming the user has chose to display all categories):

**Category 1:** Result 1, Result 2, Result 3

**Category 1 child 1:** Result 4, Result 5

**Category 1 child 2:** Result 6

So essentially all the results are displayed under their category headings. The only caveat to this would be that the headings only show if there are results.

I managed to do this in a round about by putting an embed on the results page which fed each category id into the results tag, the problem here was that it just displayed every entry rather than what was searched for (see code):

```
{exp:channel:categories channel="products"}
  {embed="products/results-list" category="{category_id}"}
{/exp}

//Results tag in the embed template.
{exp:low_search:results collection="products" limit="999" query="{segment_3}" status="Open|Featured" category="{embed:category}"}

```

That didn't work so I stripped that out and I currently have the results tag code above (minus the category declaration). My search form looks like this:

```
{exp:low_search:form query="{segment_3}" collection="products" result_page="products/results" form_id="filter"}

  //Followed by a series of these
  <div>
    <a class="button filter_toggle" href="#">Sound</a>
    <fieldset>
      {exp:channel:categories channel="products" category_group="1" show="1|15|16|17|18|19|20|21|22" show_empty="no" id="nav_categories_sound"}
        <label class="inline" for="{category_url_title}"><input type="checkbox" name="category[]" {if category_url_title == "sound"}class="first-check"{/if} id="{category_url_title}" value="{category_id}" {if '{category_id}' IN ({low_search_category:sound})}checked="checked"{/if}> {category_name}</label>
      {/exp:channel:categories}
    <fieldset>
  </div>

  //And then
  <div>
    <input type="submit" class="button" value="Show results">
  </div>

{/exp:low_search:form}

```

Any help would be greatly appreciated, Thank you.

# Answer
> 1 votes
I managed to come to a conclusion in the end.

I did the search query and got all the categories from those entries. I fed the category IDs into a PHP array, removed all the duplicates, then did a set of embeds using the collected IDs. Posting here if anyone is interested.

```
<div class="col-sm-12">
  {exp:low_search:results collection="products" limit="999" query="{segment_3}" status="Open|Featured"}
    {exp:gwcode_categories depth="2" entry_id="{entry_id}" show_empty="no" style="linear"}
      <?php $categories[] = '{cat_id}'; //Store all child categories into array ?>
    {/exp:gwcode_categories}
  {if no_results}
  <div class="search_error">
    <p>
      Sorry, your query did not return any results.
      Please try again.
    </p>
  </div>
  {/if}
  {/exp:low_search:results}
    <?php
    $categories = array_unique($categories); //Remove all duplicate entries
    foreach ($categories as $category) { //Loop through all array items and create embed template for each
      echo '{embed="products/results-list" category="'.$category.'"}';
    }?>
</div>

```

Then just create a normal entries list using the category embed from the PHP array.

```
{exp:channel:entries channel="products" category="{embed:category}" status="Open|Featured"}
  ...
{/exp:channel:entries}

```

This works for me but might not for anyone else.

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


# Question
Title: How to Tell Difference Between status="closed" and {if no_results}?
I have a safecracker form I just converted to channel:form and I just changed it so when an entry is created it's automatically set to status="closed"

What I'm trying to do is display a message if the created entry is still being moderated (status is closed), display a message if there is NO entry created, or display a msg if there IS an entry created.. How do I tell the difference?

```
{exp:channel:entries
channel="personal_trainer_directory"
limit="1"
dynamic="no"
author_id="CURRENT_USER"
status="closed"
}
    ***DISPLAY IF STATUS IS CLOSED***
{/exp:channel:entries}

{exp:channel:entries
channel="personal_trainer_directory"
limit="1"
dynamic="no"
author_id="CURRENT_USER"
}
    {if  no_results}
    ***DISPLAY IF NO RESULTS***
    {/if}
    ***DISPLAY IF THERE IS A RESULT***
{/exp:channel:entries}

```

# Answer
```
    {exp:channel:entries
channel="personal_trainer_directory"
limit="1"
dynamic="no"
author_id="CURRENT_USER"
status="open|closed"
}
    {if  no_results}
    ***DISPLAY IF NO RESULTS***
    {/if}

{if status=="closed"}
    ***DISPLAY IF STATUS IS CLOSED***
{if:else}
    ***DISPLAY IF THERE IS A RESULT***

{/if}
{/exp:channel:entries}

```

Is that what you mean?
> 5 votes

---
Tags: channel-entries, safecracker, channel-form, status
---


# Question
Title: Hook for Adding Custom Channel Entries Parameter Option
I'm trying to do something like orderby="custom\_order"

What hook would let you add and run a custom parameter option?

Thanks!

# Answer
A hook would probably not be the best way to do this. With a module, you can extend the functionality of the channel:entries tag by passing your custom module tag off to channel:entries.

This gist is an excellent example to follow.

Basically you'd have to use the parameters sent to your custom module to create a pipe-separated list of entry ids that you want in the order you want them. Then you'd feed it to the channel entries tag by using `$this->EE->TMPL->tagparams['fixed_order'] = $entry_ids;`

Extending the channel:entries tag like this makes it act exactly like a normal version of the tag, so all the parsing works perfectly, etc.
> 1 votes

---
Tags: channel-entries, add-on-development, parameters
---


# Question
Title: Expresso Store - Stripe - "The number parameter is required"
We've followed the tutorial (https://exp-resso.com/docs/payment\_gateways.html#stripe) and everything looks correct however when we test the system we get the following error: "The number parameter is required"

Here's our code:

```
{exp:store:checkout
    form_class="form-horizontal"
    return="account/order/ORDER_HASH"
    payment_method="stripe"
    error_handling="inline"
    error_delimiters='<span class="help-inline">|</span>'}

    {if no_items}
        {redirect="basket/index"}
    {/if}

<div class="container content">

  <header>
    <div class="progress progress-info progress-striped"><div class="bar" style="width:90%"></div></div>
    <h1>Confirm Order</h1>
  </header>

  <script type="text/javascript">

      $(function() {
          $.getScript('https://js.stripe.com/v2/', function() {
              Stripe.setPublishableKey('pk_test_1G3rLmcUygjAVG3uAg6WWBaS');
          });

          /* Ensure your checkout submit button has id="checkout_submit" */
          $checkout_submit = $("#checkout_submit").click(function() {

              /* Only handle requests for Stripe gateway */
              if (this.form.elements["payment_method"].value == "stripe") {

                  /* Temporarily disable the checkout submit button */
                  $checkout_submit.attr('disabled', true);

                  /* Create a Stripe card token */
                  Stripe.card.createToken($(this.form), stripeResponseHandler);

                  /* We don't want to submit the form yet */
                  return false;
              }
          });

          /* This function is triggered once Stripe has generated the token */
          function stripeResponseHandler(status, response) {
              /* Re-enable the checkout submit button */
              $checkout_submit.attr('disabled', false);

              /* Check whether we have a valid credit card */
              if (response.error) {
                  alert(response.error.message);
              } else {
                  /* Set the card token and submit the checkout form */
                  $("#payment_token").val(response.id);
                  $checkout_submit.off("click").click();
              }
          }
      });

    </script>

    <div class="primary-col">

    <div class="col">
      <fieldset>
        <legend>Billing Details</legend>
        <div class="control-group">
          <div><b>{billing_name}</b></div>
          <div>{billing_address1}</div>
          <div>{billing_address2}</div>
          <div>{billing_address3} {billing_postcode}</div>
          <div>{billing_region_name}</div>
          <div>{billing_country_name}</div>
          <div>{billing_phone}</div>
          <div>{order_email}</div>
        </div>
      </fieldset>
    </div>

    <div class="col">
      <fieldset>
        <legend>Shipping Details</legend>
        <div class="control-group">
          {if shipping_same_as_billing}
          Same as Billing Details
          {if:else}
          <div><b>{shipping_name}</b></div>
          <div>{shipping_address1}</div>
          <div>{shipping_address2}</div>
          <div>{shipping_address3} {shipping_postcode}</div>
          <div>{shipping_region_name}</div>
          <div>{shipping_country_name}</div>
          <div>{shipping_phone}</div>
          {/if}
          {if shipping_country_name =="United Kingdom"}
          {if:else}
          <div class="confirmnote">
            <p>Overseas Delivery cost is calculated after your order is placed based on your order value, weight and location.</p>
          </div>
          {/if}
        </div>
      </fieldset>
    </div>

    <div class="full-col">
     <fieldset>
        <legend>Payment</legend>

        {if error:payment_method}
        <div class="control-group">
          <div class="alert alert-error">{error:payment_method}</div>
        </div>
        {/if}

        <div class="control-group">
          <label class="control-label" for="payment_card_no">Card No</label>
          <div class="controls">
            <input type="text" value="" data-stripe="number" />
          </div>
        </div>

        <div class="control-group">
          <label class="control-label" for="payment_name">Name</label>
          <div class="controls">
            <input type="text" value="" data-stripe="name" />
          </div>
        </div>

        <div class="control-group">
          <label class="control-label" for="payment_exp_month">Expiry</label>
          <div class="controls">
            <select data-stripe="exp-month">
                <option value=""></option>
                {exp_month_options}
            </select>
            <select data-stripe="exp-year">
                <option value=""></option>
                {exp_year_options}
            </select>
          </div>
        </div>

        <div class="control-group">
          <label class="control-label" for="payment_csc">CSC</label>
          <div class="controls">
            <input type="text" size="4" value="" data-stripe="cvc" />
          </div>
        </div>

      </fieldset>

    </div>

  </div> <!-- primary-col -->

  <div class="secondary-col">

    <fieldset>
      <legend>Order Summary</legend>

      <table class="table table-condensed">
        <thead>
          <tr>
            <th style="width:60%">Product</th>
            <th style="text-align:right">Total</th>
          </tr>
        </thead>
        <tbody>
          {items}
          <tr>
            <td>{item_qty} × {title}</td>
            <td style="text-align:right">{item_subtotal}</td>
          </tr>
          {/items}
          <tr>
            <th>Subtotal</th>
            <th style="text-align:right">{order_subtotal}</th>
          </tr>
          {if shipping_method_id}
          <tr>
            <td>Shipping ({shipping_method})</td>
            <td style="text-align:right">{order_shipping}</td>
          </tr>
          {/if}
          {if order_tax_val}
          <tr>
            <td>{tax_name} ({tax_percent}%)</td>
            <td style="text-align:right">{order_tax}</td>
          </tr>
          {/if}
          <tr>
            <th>Total</th>
            <th style="text-align:right">{order_total}</th>
          </tr>
        </tbody>
      </table>
    </fieldset>
  </div> <!-- /secondary-col -->

    <div class="form-actions">
        <a href="{path='basket/checkout'}" class="btn">Back</a>
        <input type="hidden" id="payment_token" name="payment[token]" value="" />
        <input type="hidden" name="payment_method" value="stripe">
        <input type="submit" name="submit" value="Confirm Order & Pay" id="checkout_submit" class="btn btn-success" />
    </div>

```

Any ideas/suggestions would be most appreciated!

# Answer
> 3 votes
Two things.

First, check you are running the latest version of Store. There was a bug related to Stripe card tokens fixed in v2.0.4.

Second, check which fields are actually being submitted to Store (in your browser's network tab), after the Stripe response comes back. Make sure `payment[token]` is actually submitted, and that it contains something which at least looks like a valid token (should be a random string). If Store can't find a card token, it will look for a card number instead, which is why you see the error "The number parameter is required".

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


# Question
Title: Channel Images on Amazon S3 is not retrieving the pertinent images
Product (Add-On): Channel Images
Product (Add-On) Version: 5.4.9

ExpressionEngine Version: 2.7.2
MSM Install?: No

After updating Channel Images to 5.4.9 in order to mitigate a bug present in its implementation with Zenbu, I've run into a new issue. When uploading content with Channel Images, my images are able to be uploaded to their buckets, but the system is not seeing them on the other side. I just uploaded a bunch of images in a test entry, verified they existed on the correct bucket, but went to check on the control panel, and the system says it can't find the images! Any idea what's going on there? This is a definite blocker for me and my client right now.

# Answer
> 2 votes
Turned out the update seemed to change my S3 location; I updated them to the correct server and they started working again. Latest version of the add-on doesn't seem to have this issue anymore.

---
Tags: channel-images, s3
---


# Question
Title: Import existing File field content to Matrix gallery
I have a channel with a File field that I'd like to replace with a Matrix field in order to create an image gallery for each channel entry, however there are thousands of entries in the system already that I am worried will be wiped if I modify the field type. Is there a way to incorporate the existing image files into a Matrix entry, or is my best option to create a Matrix gallery alongside the single File field?

Thanks!

# Answer
Your best bet is probably to create the Matrix as a new field. Then you can non-destructively work on copying the data over from the original file field to the new Matrix field.

If you are familiar with working with SQL and the ExpressionEngine database, it shouldn't be too difficult to pull out the current field values and then create/update the necessary records to copy the values over to the Matrix field.

However, if you aren't that familiar with working with the database, you could use the Datagrab add-on. Simply create a template that outputs XML with the current value of the file field and the entry ID. Save the output as an XML file. Then you can re-import that file with Datagrab and update the entries based on the entry ID, and map the file to the Matrix.
> 2 votes

---
Tags: matrix
---


title: Extending the EE Discussion Module

text:
# Question
Title: Extending the EE Discussion Module
I have a future project that I am working on quoting and they have a need for a pretty active community forum. I would love to be able to use the EE Discussion Module but would have a few things that would be preferred to be included. Here are a few...

1. A WYSIWYG editor for forum posts. Most of the people who use this forum would not be considered techinical gurus, and anything that looks like code would decrease the usage.
2. Multiple file upload, without previewing or reloading the page.
3. "like" or rating for forum topics or posts.

Beyond that there are other things the client would like but can be handled by using the forum templates, - social sharing, light boxes for images, etc...

I have already purchased teh Scaffold theme which gives a great starting point for theming and moving forward but I think what is going to be more difficult is core functionality of the module.

Ideally it would be perfect if I could just replace each section of the forum with a field type add-on and then i could extend it on the fly anytime, but that's impossible from my understanding. I did have one twitter reply that discussed creating your own forum with channels and SafeCracker but as discussed performance could be an issue and I dont see the need to reinvent the wheel if its not needed.

Anyone who has had experience or could forward me in the right direction from some more advanced Discussion module usage please let me know.

# Answer
> 3 votes
I followed this old EE thread and got a WYSIWYG in place. I modified the `forum_themes/scaffold/forum_global/html_footer.html`, adding this snippet:

```
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<script src="/themes/third_party/wygwam/lib/ckeditor/ckeditor.js"></script>
<script src="/themes/third_party/wygwam/lib/ckeditor/adapters/jquery.js"></script>
<script src="/themes/third_party/wygwam/lib/ckeditor/ckeditor-forums.init.js"></script>

```

(I used an existing CKEditor install, from WYGWAM, rather than downloading another copy from CKEditor.com.)

My init.js (`ckeditor-forums.init.js` above) file looks like this:

```
jQuery(function(){
// ckeditor config
var wysiwyg_nl2br_config = {
    toolbar :
        [
            ['Bold','Italic','-','NumberedList','BulletedList','-','Link','Unlink']
        ],
    width : '650px',
    height : '200px',
    forcePasteAsPlainText : 'true',
    autoGrow_onStartup : false,
    enterMode : CKEDITOR.ENTER_P
};

jQuery("textarea#body").ckeditor(function(){
    // attach CKFinder
}, wysiwyg_nl2br_config);

```

});

Since the client wanted something very simple and sparse. You can, of course, add all the other various plugins and buttons you want.

# Answer
> 2 votes
For the all of your 3 required points, the EE discussion forum module file will need to be altered. Yes, the discussion forum have some hooks but those hooks wouldn't be helpful for you.

1) Yes, A WYSIWYG editor can be inserted by updating the template files and including necessary JS. Also, the file upload path should be well defined, module file also need to be altered so that it can parse WYSIWYG contents properly rather than current encoding process. I think, this requirement can be achieved by just inserting WYSIWYG editor into the template as it will store row HTML code which will be parsed at browser.

2) In the multiple file upload, (i) you need to give member facility to upload more than one files with any thread which can be achieved by some JQuery stuffs or plugin, if you would like to have simple just put a constant number of file fields. (ii) you will be need to process all those uploaded files and save the info within the database table. I think, this would be managed within the database table "exp\_forum\_attachments".

3) For the "like" or rating for forum topics or posts, you will need to extend this module by creating some new database tables for managing/storing likes or rating of forum topics or posts, need to create some new actions/methods into module file to process it.

---
Tags: forum, discussion
---


title: Minimee 2.18 with Cloudfront

text:
# Question
Title: Minimee 2.18 with Cloudfront
I'm still quite new to ExpressionEngine

Been messing around with using JohnDWells' Minimee extention to serve minified .css and .js files from cloudfront rather than the site itself (Base URL) using cloudfronts custom origin feature.

It seems to work quite well. Expect Minimee is not detecting changes made to .css and .js files in the Base Path, and doesn't produce an updated combined .css or .js file.

Has andbody else tried this method (I searched, but didn't find anything specific)?

Any sugesstions on what I may (surely) be missing?

# Answer
Figured this out.

For some reason the combined .css and .js files are updated once you update changes to a template.
> 1 votes

---
Tags: extension, caching, cloudfiles, aws
---


# Question
Title: Multiple Sites, Sharing Several Templates
NOTE: when I use the term "template" below, I do not mean EE templates. Rather, I mean templates like the ones that can be purchased from www.TemplateMonster.com.

Assume I needed to deploy and manage several similar websites. Is there a way I can set up a few website templates and have the individual websites associate themselves with one of those templates?

For example, say I have 50 sites to deploy and 5 templates to choose from. Sites 1-10 wants to use template 1, sites 11-20 wants to use template 2, and so on. Each site will have a different company name, logo, perhaps slightly different colors or layout, etc. (things that can probably be set as a global variable).

When I make a change to one template, I generally want it to affect all the sites that have chosen to use that template. All the sites will generally have the same data (e.g. if they choose to have a blog, they will all have the same channel fields for blogging, etc.)

I'm trying to figure out if I can set up MSM, then put the template files in some directory that is accessible to the individual sites, then configure each site to just point to the appropriate directory. If this is possible, are there any drawbacks to this approach?

# Answer
If you don't need to give each site control panel level access to change their chosen templates (but instead they'd need to ask you to do this), and you're saving your templates as files, then you can probably just use symlinks.

So your templates directory could look like this:

```
templates
-- theme1
-- theme2
-- theme3
-- site1 (symlink to theme2)
-- site2 (symlink to theme1)
-- site3 (symlink to theme1)
-- site4 (symlink to theme3)
etc

```

Not tested, but it should work.
> 2 votes

---
Tags: templates, multi-site-manager
---