title: Deprecated hash replacement

text:
# Question
Title: Deprecated hash replacement
EE is warning about a deprecated function from the NCE LDAP plugin:

```
$encrypted_password = $this->EE->functions->hash(stripslashes($user_info['password']));

```

I see the replacement below, but can't quite figure out how to rewrite this line to use the do\_hash...and work. Anyone able to rewrite this? http://ellislab.com/codeigniter/user-guide/helpers/security\_helper.html

# Answer
> 3 votes
The changelog says:

> Deprecated methods:
> Security helper’s do\_hash(), use PHP’s hashing functions instead.
> Removed Methods:
> Functions::hash()

The link you provide shows that do\_hash() uses SHA1 by default. So:

```
$encrypted_password = hash('sha1',stripslashes($user_info['password']));

```

---
Tags: php, plugin
---


# Question
Title: Problem deleting videos using 'Channel Videos' Plug in
I'm using 'Channel Videos' plug in which works fine to display videos on my sites page. But when I try and delete a video from the entry, it appears to be removed looking at the control panel, I click submit and the video comes back again and still displays on the control panel and on the site. I'm using Channel Videos 3.1.0 and EE 2.5.5

Any help would be appreciated thanks.

# Answer
I experienced the same issue (also Channel Videos 3.1.0 and EE 2.5.5) on a site which was making use of SSL (https) - I was able to resolve the issue by using https when logged into the CMS. i.e. https://domain.com/system/...

Videos then 'stayed deleted' from the Channel Videos field.

{site\_url} = https://domain.com

While I'm not 100% sure why it worked, I hope it helps nonetheless!

Matt
> 1 votes

---
Tags: channel-videos
---


# Question
Title: Merge multiple relationship fields into a single multi-relationship field
Has anyone looked into merging several pre-2.6 relationship fields into a 2.6+ multiple relationship field? For example, if I have a book store where each book can have multiple authors and currently have `book_author`, `book_author2`, and `book_author3`. This is clearly ugly and horrible, so I would like to just have `book_authors`, which would contain the related authors from any of the original three fields that was set.

I'm sure it could be done with enough SQL magicry, but I'm hoping someone has already figured out a good system for it.

# Answer
If you look within the table structure for the relationship, the relationship data is stored within database table exp\_relationships so only we need to update this table for the field\_id. The parent\_id and child\_id are already in same format required for multi-relationship.

You need to follow these steps: 1) Make the "book\_author" as multi-relations by checking "Allow multiple relations?" from the field settings.

2) book\_author2 and book\_author3 are no longer needed in relationship so exp\_relationships database table need to be updated accordingly by SQL:

```
UPDATE exp_relationships LEFT JOIN exp_channel_titles
ON exp_relationships.parent_id=exp_channel_titles.entry_id
SET exp_relationships.field_id=[book_author FIELD ID]
WHERE exp_channel_titles.channel_id=[CHANNEL ID]

```

You might update the \[book\_author FIELD ID\] and \[CHANNEL ID\] according to your preference.

**Please Note**: I didn't try it yet but after seeing all the table structure for multi-relationship, it would work perfectly.

Once everything worked perfectly you can delete fields book\_author2 and book\_author3.
> 3 votes

# Answer
I think you would want to look at Matrix \+ Playa add-ons. You could add a Matrix field book\_authors where each row is a Playa field type related to the author channel entries.

Or if each author is not a channel entry but instead more of a list, you could use Low Variables field type as a multi-select field (of author info created in a LV variable group) in your Matrix rows.
> -1 votes

---
Tags: custom-fields, relationships, upgrade
---


# Question
Title: Assets stopped connecting to Amazon S3, Access denied by target host
Assets has been working well for the past couple of weeks uploading files to Amazon S3. The past few days the customer has started uploading the main bulk of his files Wav files, approx. 10Mb up to 50Mb in size. All was working well, until last night it stopped.

When refreshing the bucket list in Asset Sources settings, it states: "Access denied by target host"

Access and Secret Keys are correct, I even tried creating new ones. S3 permissions on the bucket is correct. In fact nothing has changed our end.

I read online we should create a Bucket Policy. I did this, to no avail, same error. I even made a completely open policy allowing everyone to do everything, still same error.

I disabled our firewall, same error.

Just seems Amazon is blocking us all of a sudden for no reason.

Do you have any advice, it renders Assets and S3 useless and completely changes the way our site works.

Thanks in advance

# Answer
I have solved this issue.

The Assets error message did not seem very helpful, it was inconsistent with the issue. The Assets response implied the Amazon credentials were wrong, but they were not.

So therefore I needed to debug tha actual Amazon response.

So in the function listBuckets() in system/third\_party/assets/sourses/s3/lib/S3.php I could see there is a response object being returned by Amazon, called $rest.

Outputting $rest to the screen showed me

```
error => Array
(
    code => RequestTimeTooSkewed
    message => The difference between the request time and the current time is too large.
)

```

From this I assumed my server time was wrong, and indeed it was, it was about 30 minutes out.

**Correcting the server time fixed the issue.**

Note: The server is UTC timezone, which is 1 hour behind the actual summer time here in the UK. So for example, if it was 20:30 I had to set the servet time to 19:30 for it to work.

So the problem is fixed BUT this has identified a lack of reporting in Assets.

**I think Assets needs to output the actual Amazon error returned instead of showing a generic (and incorrect) error whenever any error is returned from Amazon.**
> 3 votes

---
Tags: assets, pixelandtonic
---


# Question
Title: Help with sequential numbering in a Entries loop?
I'm trying to get my head around EE so please bear with me on something probably simple:

How do you loop through a EE entries chunk and append a number? Like a id="blogitem-1", id="blogitem-2", id="blogitem-3"... there may be no end to the numbering.

I have a blog section that requires each hidden ID be sequential. I got the jquery popover working using {entry\_id} but I need to go forwards and backwards and the pager doesn't work. I cheated a little using {switch="1|2|3|4"}... but that's really ugly and it has a fixed end.

Here's the code snippet:

```
{exp:channel:entries
    channel="blog"
    disable="category_fields|member_data|pagination|trackbacks"
    status="Open"
    dynamic="no"
    paginate="bottom"
}
<!-- This is a blog item -->
<div class="blogitem-content hidden" id="blogitem-{entry_id}">
    <img src="{base_image:blogimg}" alt="{title}">
    <h2 class="primary-color">{title}</h2>
    <h3>{subtitle}</h3>
    {body}

    <ul class="pager">
        <li class="previous"><a href="#blogitem-2" class="">← Previous</a></li>
        <li class="next"><a href="#blogitem-4" class="">Next →</a></li>
    </ul>

</div>
<!-- / Blog item -->
{/exp:channel:entries}

```

This shows what could be entry #3, with the pager linking to the previous id (#2) and the next (#4). While "{entry\_id}" lets me pop-up the post, I can't navigate.

I also don't want to expose PHP to the template (not understanding PHP too much I don't want to open up something that can bite me later). I can't seem to generate a simple progressive 1, 2, 3... for the id.

I'm learning EE and a bit of jQuery, so sorry if this is elementary

# Answer
You can use {count} or {absolute\_count}, instead of {entry\_id}. {count} restart on every page, while {absolute\_count} increases across pagination.

By the way, 'tackbacks' isn't a value of the disable parameter.
> 4 votes

---
Tags: channel-entries, jquery
---


title: CartThrob Price Modifier Question

text:
# Question
Title: CartThrob Price Modifier Question
I am trying to display information stored in a price modifier column I added called {option\_color}. Can someone help me? I tried the following but didn't work:

```
{exp:cartthrob:add_to_cart_form
        class='form-horizontal'
        name="productView"
        entry_id="{entry_id}"
        no_tax="{no_tax}"
        no_shipping = "{no_shipping}"
        return="store/view_cart"}

    {exp:cartthrob:item_options field="envelope_options" entry_id="{entry_id}" row_id="{row_id}"}
        {option_label}: {option_color}
    {/exp:cartthrob:item_options}

{/exp:cartthrob:add_to_cart_form}

```

# Answer
I answered my own question...

```
{exp:cartthrob:add_to_cart_form entry_id="{entry_id}"}

  {envelope_options}
    {option_name} {option_color}
  {/envelope_options}

{/exp:cartthrob:add_to_cart_form}

```
> 1 votes

# Answer
I always use Matrix to create my price modifiers, over the CT Price Modifier field type.

It's Much more flexible in terms of added extra options.
> 0 votes

---
Tags: cartthrob
---


# Question
Title: How to allow customers to add a note to each item in a CartThrob cart?
I am using CarThrob for purchasing places on training courses. Each course type (singing, acting, dance etc) is an entry. Each entry has a Matrix field used for options.

Matrix column names are: option\_value (text), age-range (text), time (text), price (text), booked (P&T Pill), student\_name (text).

I have CartThrob set so multiple quantities are always added as single items.

On my checkout page in the update\_cart\_form I would like the customer to be able to fill in the "Student name" field for each item.

At the moment I am getting the student\_name input field displayed but as soon as you enter text into it and update it creates a duplicate field next to itself. I can't work out why?

This is my Update cart form.

```
                    {exp:cartthrob:update_cart_form

                    id="update_cart_form"
                    class="simple"
                    return="weekend-courses/checkout"
                    }

                    {exp:cartthrob:cart_items_info}

                    {if first_row}
                    <table>
                        <thead>
                            <tr>
                                <th>Subject</th>
                                <th>Quantity</th>
                                <th>Course</th>
                                <th>Cost</th>
                                <th>Student Name</th>
                                <th></th>
                            </tr>
                        </thead>
                        <tbody>
                    {/if}
                            <tr>
                                <td>{title}</td>
                                <td><input class="short" type="text" name="quantity[{row_id}]" size="2" value="{quantity}" /></td>
                                {exp:cartthrob:item_options row_id="{row_id}"}
                                {options}
                                {if selected}
                                <td>{option_value}</td>
                                <td>{price}</td>
                                <td><input type="text" name="item_options[{row_id}][student_name]" value="{item_options:student_name}" /></td>
                                {/if}
                                {/options}
                                {/exp:cartthrob:item_options}
                                <td>
                                    <label class="checkbox" for="delete_this_{row_id}">
                                        <input type="checkbox" id="delete_this_{row_id}" value="yes" name="delete[{row_id}]">
                                        Remove item
                                    </label>
                                </td>
                            </tr>
                    {if last_row}
                            <tr class="shaded">
                                <td>Total</td>
                                <td></td>
                                <td></td>
                                <td>{cart_total}</td>
                                <td><button type="submit" value="weekend-courses/checkout" name="return" class="btn">UPDATE</button></td>
                                <td></td>
                            </tr>

                        </tbody>
                    </table>
                    {/if}

                    {/exp:cartthrob:cart_items_info}

                {/exp:cartthrob:update_cart_form}

```

# Answer
I don't think you need the row\_id in the name attribute.

It should be like this

```
<input type="text" name="item_options[student_name]">

```
> 1 votes

---
Tags: cartthrob
---


# Question
Title: EE 2.6.1 relationships - just not working - at all
I don't know if I am just going a bit barmy but I upgraded a site we are developing from 2.5.5 to 2.6 and then to 2.6.1

Everything looked ok until I tried to make a playa relationship work and no matter what I tried there was no fun to be had.

I removed playa and tried to do the same thing using the new relationships field in 2.6.1 and still nothing.

The setup is:

* Parent Channel = schools
* Child Channel = people
    + Restricted to people with status of teacher
* Parent can only have one child

The code (which is on a page by itself):

```
{exp:channel:entries channel="schools"}
<h3>{title}</h3>
<ul>
    {cf_schools_teacher}
        <li>{cf_schools_teacher:cf_people_first_name}</li>
    {/cf_schools_teacher}
</ul>
{/exp:channel:entries}

```

In the output I only get the Schools title and the ul tags - I checked the database exp\_relationships and the pointers all seem to be correct although there is no data in the field in exp\_channel\_data (i'm not sure if there's meant to be)

Am I missing something basic? Or should I abandon 2.6.1 and start again in 2.5.5

Many Thanks Sean

# Answer
I got it...

Because I am in the parent and there is only one child entry I don't need the cf\_schools\_teacher tag pair - just leave them out.

:)
> 1 votes

---
Tags: relationships
---


title: Fieldpack 2.01 - Switch not working

text:
# Question
Title: Fieldpack 2.01 - Switch not working
I'am trying to create a new Field of type "Fieldtype - Switch", but I'am getting this error:

Unable to load requested field type file: ft.pt\_switch.php. Confirm the fieldtype file is located in the expressionengine/third\_party/ directory

Which is weird, because the correct file should be ft.fieldpack\_switch.php.

I had the old 1.x version installed, but I uninstalled everything and removed the files. My EE version is 2.6.

What can cause this and how to fix it?

# Answer
> 2 votes
Fieldpack 2.02 fixed this problem.

---
Tags: switch, field-pack
---


# Question
Title: Any ideas on how to create a 'find properties near me' feature on EE?
I'm working on an estate agents website and am looking to create a 'find properties near me' feature.

Any ideas on how I might do this will be gratefully received!

Thanks in advance,

Tom

# Answer
Geofinder add-on will help you here: http://devot-ee.com/add-ons/geofinder

Docs: http://mightybigrobot.com/docs/geofinder/

Then each of the properties is an entry which has a longitude and latitude reference for the location.

Example search form:

```
{exp:geofinder:simple_form id="findhome" result_page="/home-search" class="group"}
    <fieldset>
        <legend>Search for a home</legend>
        <input type="hidden" name="radius" value="1000" />
        <label for="searchhome">Search for a home</label>
        <input type="text" name="geoquery" id="searchhome" class="required" title="Enter a search location" value="" />
        <button type="submit">Search</button>
    </fieldset>
{/exp:geofinder:simple_form}

```

Example results page:

```
{exp:geofinder:location_results channel="content" limit="6" geoquery="{segment_2}" radius="1000" latitude="latitude" longitude="longitude" disable="member_data|category_fields|trackbacks"}
    {if no_results}No results can be found for that location. Please try a different search term: either a postcode, city or town{/if}
        <div class="homeresult group">
            <div class="summary">
                <h2><a href="{page_uri}">{if alternative-title}{alternative-title}{if:else}{title}{/if} <em>{location-details}{town}, {county}{/location-details}</em></a></h2>
                <h3>{distance} miles from {exp:markup_master:replace find="+" replace=" "}{segment_2}{/exp:markup_master:replace}
                    <a href="#?custom=true&width=600&height=400" rel="popup-map" class="button">Show on a map
                        <span class="longitude">{longitude}</span>
                        <span class="latitude">{latitude}</span>
                    </a>
                </h3>
                {if "{excerpt}"}{excerpt}{if:else}{exp:trunchtml chars="150" inline="..."}{content-text}{/exp:trunchtml}{/if}
            </div>
        </div><!--/.homeresult-->
{/exp:geofinder:location_results}

```

**Update**

The above example is where you prompt the user for a location, if you want to allow for mobile devices and automatically defaulting to the users location based on IP, you could use IPGeo http://devot-ee.com/add-ons/ipgeo. Although a great add-on, it does have a fair overhead and needs to be updated every few months to ensure all the latest IP address database.

On the initial search form you would add hidden fields like so:

```
{exp:ipgeo}
    <input type="hidden" name="user_lat" value="{latitude}">
    <input type="hidden" name="user_lng" value="{longitude}">

<input type="text" name="geoquery" id="searchhome" class="required" title="Enter a search location" value="{city}" />
{/exp:ipgeo}

```

I've only entered the automatic City entry above so that the user has something to submit to.
> 2 votes

# Answer
I understand that the Google Maps for ExpressionEngine add-on is a go-to addon for "geofinding," based on this examples page in which there is a "store locator" example. As luck would have it, that particular example is borked right now (I get an "out of memory error" when I go to access the particular example).

It sounds like it would be worth it to write the developer, ask them about the add-on's compatibility with the latest EE version, and see if they can't fix the issue on the examples page so you can see how it performs.

I have this addon running on a site I'm using and I like it (it performs far better than other addons have, in my experience), but so far, I've only used it to display maps.

Rob
> 1 votes

---
Tags: search, google-maps, geofinder
---


title: Exp:resso Store 3D Secure Integration

text:
# Question
Title: Exp:resso Store 3D Secure Integration
My client has asked to integrate 3D Secure with their Exp:resso Store installation.

I have been searching and found that in the change log this has been added for SagePay in the UK. This is who the client is using.

Changelog: https://exp-resso.com/docs/store/release\_notes.html#store\_150

I can't find anywhere in the docs how to implement this. Does anyone know how? Is it a setting on SagePay side? Or is it a parameter I need to add in the checkout form?

Cheers

# Answer
Got it! The setting is in SagePay itself: Settings \> 3D Secure \> Turn On and set rules.
> 1 votes

---
Tags: expresso-store
---


title: Conditional tracking

text:
# Question
Title: Conditional tracking
I want to exclude my site's tracking code(s) from my local development templates, but I've a hard time writing the conditional.

I am using an embedded template which contains the doctype, metadata and also has an embed for the css template.

Could you write a conditional within this embedded template which checks if there is a file (snipped or embedded template) called "analysis"?

# Answer
using my bootstrapped config file http://d.pr/n/tTcT I create a global variable for the particular environment I'm working in and then in my template code I do

```
{if gv_env == 'prod'}
my analytics tracking code
{/if}

```
> 1 votes

---
Tags: conditionals
---


# Question
Title: Using the Entry title variable in an Channel Entry field
I have a Channel Entry field that contains a table. I need the caption to contain the title. I tried:

```
<caption>{title}</caption>

```

Thinking it would work, given that it's within the scope of the Entry, but that didn't work.

What would I need to write?

# Answer
> 0 votes
You can use the Allow EE code plugin to... allow EE code within your fields.

You'd do something like this in your template:

```
{exp:allow_eecode}
  {your_custom_field}
{/exp:allow_eecode}

```

If your custom field has `{title}` in it, it should be processed.

Of course, you need to be careful with this because they could potentially enter any EE code.

---
Tags: channel-entries
---


# Question
Title: CartThrob automatic price calculated by VOLUME (or WEIGHT) and modifiers value
Here is what i'm gonna do with CartTrhob.

I want to sell a product that can be sold in different material. Every product has it's own volume in cm3, and every material has a Price per cm3.

So for example:

**PRODUCT\_A** has a **VOLUME** of **10 cm3**

In a channel called "MATERIAL" i have saved all the available material that can be applied to every PRODUCT. Every material has this fixed values:

**MATERIAL\_A** \- **PRICE/CM3=2** \- **PRODUCTION\_FEE=3**; **MATERIAL\_B** \- **PRICE/CM3=8** \- **PRODUCTION\_FEE=2**; **MATERIAL\_C** \- **PRICE/CM3=6** \- **PRODUCTION\_FEE=5**;

The price is made by this formula:

**MATERIAL\_PRICE** = (**PRODUCT\_VOLUME** * **MATERIAL\_PRICE/CM3**) + **MATERIAL\_PRODUCTION\_FEE**

So in this case i'll have:

PRODUCT\_A:

* MATERIA\_A\_PRICE = (10 * 2) + 3 = 23$
* MATERIA\_B\_PRICE = (10 * 8) + 2 = 82$
* MATERIA\_C\_PRICE = (10 * 6) + 5 = 65$

I would that every single material price for every single product is automatically calculated by the above formula. So every time i'll add new product i have to add only the VOLUME variable and EE does the rest.

At the end, after all material prices are calculated, i would that MATERIAL\_A\_PRICE is shown by default, as it is the default PRODUCT PRICE.

I think that the matrix price modifiers is the solution but i can't find the solution to make this MAGIC and store all that value in entries.

Some brave man can help me?

--- ADDED LATER ---

I found that question here:

Pre-fill matrix field when creating new entry?

and the script to add in the instruction is this:

```
<script>
$(function() {

// Make sure that this is the publish form
if (!EE.publish)
return;

// Only proceed when creating a new entry
var entryId = $('#publishForm').find('input[name="entry_id"]').val();
if (entryId != 0)
return;

function initLabels(id, labels) {
var addEntryButton = $('#sub_hold_field_' + id + ' .matrix-btn.matrix-add');
if (!addEntryButton.length)
    return;

// Need to wait after `document.ready` has finished executing!
setTimeout(function() {
    var field = $('#sub_hold_field_' + id);

    // Only proceed if matrix is empty
    // Note: This is not the case if a validation error occurs!
    if (!field.find('.matrix-norows').is(':visible'))
        return;

    // Create one row for each label
    for (var i = 0; i < labels.length; ++i)
        addEntryButton.click();

    // Skip the placeholder row for "No rows have been added yet..."
    field.find('tbody tr:not(.matrix-norows)').each(function(i) {
        $(this).find('.matrix-firstcell textarea').val(labels[i]);
    });
}, 0);
}

// Check that this is an entry of the expected channel field group
if (EE.publish.field_group == 2) {
// "Custom Parameters"
initLabels('23', [
    'Lens Type',
    'Focal Length',
    'Manufacturer',
    'Model',
    'Serial Number'
]);

// "Track Information"
initLabels('17', [
    'Artist',
    'Title',
    'Label',
    'Artwork'
]);
}

})
</script>

```

But i have no idea on how to customize for me. How i can auto-fill with material name, price/cm3 and commission\_fee hidden value in script to make the operations?

# Answer
> 0 votes
finally it seems i found the right way.

This is what i've done.

1. I create a Channel Material - Product. In that i put all the material i need, with this field:

* Title (name of material);
    * Material price (price-per-volume);
    * Material handling fee (fixed-fee-per-material);
2. Then i create a field in the product channel field

* I choose Playa as fieldtype, with multiselection for the material - product channel

In the view-product template i put this code:

```
{exp:cartthrob:add_to_cart_form
entry_id="{entry_id}"
allow_user_price="yes"
no_tax="{no_tax}"
no_shipping = "{no_shipping}"
return="store/carrello"}

<select name="price">
   {exp:playa:children field="selezione_materiale"}
      <option value="{exp:cartthrob:arithmetic prefix="" dec_point="." decimals="2" expression="{embed:volume} * {material_price} + {production_fee}"}">{title} - {exp:cartthrob:arithmetic prefix="€ " decimals="2" expression="{embed:volume} * {material_price} + {production_fee}"}</option>
    {/exp:playa:children}
</select>

<button type="submit" class="btn btn-primary btn-block">Acquista</button>

{/exp:cartthrob:add_to_cart_form}

```

What do you think? Let me know.

# Answer
> 1 votes
Your best bet here is to leave the actual price calculation out of the entry itself, and instead do it in the template using the Volume data you pull from the product entry and your available Material entries.

I'd write a custom plugin (start with pkg.io) that accepted the product's volume as a parameter, then grabbed a list of the materials and did the math in PHP, returning your list of prices for outputting in a dropdown or radio group with the `name` of `price`. (Make sure your CartThrob form has `allow_user_price="yes"` as a parameter.)

Some quick, untested code (will need to be modified for your particular setup obviously):

```
function get_prices()
{
    $vars = array();
    $volume = $this->EE->TMPL->fetch_param('volume');
    $materials = $this->EE->db->query("
        SELECT t.title as material_name, d.field_id_XX as material_price, d.field_id_XX as material_production_fee
        FROM exp_channel_titles t
        LEFT JOIN exp_channel_data d
        ON d.entry_id = t.entry_id
        WHERE t.channel_id = XX
    ");
    foreach($materials->result_array() as $material)
    {
        extract($material);
        $price = ($volume * $material_price) + $material_production_fee;
        $vars[] = array(
            'material' => $material_name,
            'price' => $price
        );
    }
    return $this->EE->TMPL->parse_variables($this->EE->TMPL->tagdata, $vars);
}

```

Then in your template:

```
<select name="price">
{exp:my_plugin:get_prices volume="{product_volume}"}
    <option value="{price}">{material} ({price})</option>
{/exp:my_plugin:get_prices}
</select>

```

---
Tags: cartthrob, modifiers
---


# Question
Title: html structure conditional on matrix row counts
I am using zurb foundation and a pixelandtonic matrix field. I want to do a new html row for every 3 matrix rows i.e

```
  {!-- something needs to wrap round this to say for every 3 rows do a new one of these
 <div class="row">
            {cf_about_us_biographies}
            <div class="four columns">
                <img src="{cf_about_us_bio_photo}">
                <ul class="accordion">
                    <li>
                        <div class="title">
                            <h5>{cf_about_us_bio_name}<br><span>{cf_about_us_bio_title}</span></h5>
                        </div>
                        <div class="content">
                            {cf_about_us_bio_biog}
                        </div>
                    </li>
                </ul>
            </div>
            {/cf_about_us_biographies}
            </div>

```

My brain is fried, i want someone to help me as what i have been doing is stupid!

# Answer
> 4 votes
Is this not a case for using {switch="||do-thing"}?

```
{switch='<div class="row">||'}
        {cf_about_us_biographies}
        <div class="four columns">
            <img src="{cf_about_us_bio_photo}">
            <ul class="accordion">
                <li>
                    <div class="title">
                        <h5>{cf_about_us_bio_name}<br><span>{cf_about_us_bio_title}</span></h5>
                    </div>
                    <div class="content">
                        {cf_about_us_bio_biog}
                    </div>
                </li>
            </ul>
        </div>
        {/cf_about_us_biographies}
 {switch='||</div>'}

```

The issue there though is if you have a number of items that isn't divisible by 3. From memory there's a useful plugin for handling this but I can't recall its name off the top of my head.

Try looking here Output matrix rows in sets of two

# Answer
> 1 votes
@JohnWBaxter and @foamcow - there's actually a solution for that if you don't want to have to do calculations. The basic idea is that you want to close the row, even if the number of entries is not exactly divisible by three. So you need to get a little more clever with the closing. Yes, use switch, but use it conditionally (and contain all the divs within the matrix so you don't have the wrapping markup appearing even if there are no entries):

```
{matrix_field}
    {switch="<div class='row'>||"}
       YOUR PER ENTRY PARKUP
    {if row_count == total_rows}</div>{/if}
    {if row_count != total_rows}{switch="||</div>"}{/if}
{/matrix_field}

```

If you only use the switch var as given in the first example/answer, your layout will be thrown off if you don't have a set of entries divisible by exactly 3. With my example, you are fine either way, because the switch interval is applied only when the entry is not the last entry, which when ensures that it applies at the required interval but not for the last one - the last one is applied OUTSIDE of the switch interval because there is always a last entry.

Hope that helps.

---
Tags: matrix, pixelandtonic, html
---


# Question
Title: Adding wrapper markup at intervals within loops (entries, matrix, playa, etc)
I've seen this question get asked a few times, sometimes in different contexts or within different questions pertaining to particular add-ons, but I'm looking for a general solution that can be applied broadly.

With the various frameworks - Zurb Foundation being one of my favorites - or even if you roll your own, there is often a "wrapper" class that plays a role in positioning and sizing of the container elements inside it - such as your columns.

If my three columns are each an entry and I have six entries to display, how do I group my entries into threes with the wrapper class around them with a single loop (entries, matrix or playa)?

# Answer
> 4 votes
I see this one asked a lot and my solution seems to work very well so I thought I would abstract it and share it.

This is actually a bit easier than you might think, as long as your loop supports the native SWITCH variable - the native channel entries loop does, as does Matrix, Playa, Low Reorder and others, I'm sure.

Switch is a terrific way to insert "something" on an interval basis. All you have to do is get clever about how it's used.

With the above example, my desired final markup might be something like this:

```
<div class="row">
    <div class="four columns">
        My entry content for column one
    </div>
    <div class="four columns">
        My entry content for column two
    </div>
    <div class="four columns">
        My entry content for column three
    </div>
</div>
<div class="row">
    <div class="four columns">
        My entry content for column four
    </div>
    <div class="four columns">
        My entry content for column five
    </div>
    <div class="four columns">
        My entry content for column six
    </div>
</div>

```

And so here's how i would do it (commented so you can see what's going on)

```
{exp:channel:entries channel="columns" limit="6" orderby="date" sort="desc" disable="whatever|not|needed" dynamic="no"}
    {switch="<div class='row'>||"}{!-- open a new row at intervals of three entries --}
    <div class="four columns">
        My entry content for column {count}
    </div>
    {if count != total_results}{switch="||</div>"}{/if}{!-- close the row at intervals of three as long as the current entry is not the last in the loop --}
    {if count == total_results}</div>{/if}{!-- always close the open row after the last entry --}
{/exp:channel:entries}

```

As indicated, this works within any loop that supports the SWITCH variable - but the variables for count and total results vary according to the loop requirements. Matrix, for example, uses row\_count and total\_count in place of count and total\_results respectively. Playa uses the same as the entries loop, as does low\_reorder:entries.

This does NOT, however, compensate for formatting issues that would arise with the framework is the number of items in the loop does not divide evenly. For example, if my entries loop above contained only 5 items, the Zurb Foundation framework would position the fourth item to the left and the fifth item to the far right, since the fifth would now be the last column in its row. At least that's the default behaviour. But you can also use the switch variable to add a class to each column and then target it accordingly with other conditional CSS styling as needed.

Hope this helps!

---
Tags: loop, interval
---


title: Category Description

text:
# Question
Title: Category Description
Is there anyway to allow HTML into the 'Category Description' field or better add a WYSIWYG editor to this field? Any input would be a big help.

# Answer
> 2 votes
I know DevDemon's Editor adds WSYIWYG capabilities to the categories page. There may be other third party addon's that do this also, this is the first that comes to mind.

---
Tags: categories
---


title: WHERE and JOIN in EE Add-on Dev

text:
# Question
Title: WHERE and JOIN in EE Add-on Dev
I'm trying to get my EE add-on (using Dashee) to get entries from the DB.

So far I have

```
    $this->_EE->db->select('ct.channel_id, ct.title, ct.entry_date, ct.status, cd.field_id_52, cd.field_id_67, cd.field_id_73');
    $this->_EE->db->from('channel_titles AS ct, channel_data AS cd');
    $this->_EE->db->where('ct.channel_id', $settings->channel_id);
    $this->_EE->db->order_by('entry_date DESC');
    $this->_EE->db->limit($settings->limit);
    $entries = $this->_EE->db->get();

```

Which works, but when it outputs I get 4 entries, when really there should only be 1. But the overall total of entries on my site is 4.

What I think is happening is

```
$this->_EE->db->where('ct.channel_id', $settings->channel_id);

```

Is not selecting the correct channel, but not sure why.

Settings are set like this:

```
        $this->settings = array(
            'title' => 'Recent Orders',
            'channel_id' => '6',
            'limit' => '10',
            'field_firstname' => 'orders_firstname',
            'field_surname' => 'orders_surname',
            'field_total' => 'orders_total',
            'custom_url' => '10',
            'status' => 'Processing'
            );

```

# Answer
> 0 votes
I managed to fix this using 'join'

```
        $entries = $this->_EE->db->select('ct.entry_id AS entry_id,
                                           ct.channel_id AS channel_id,
                                           ct.title AS title,
                                           ct.entry_date AS entry_date,
                                           ct.status AS status,
                                           cd.field_id_52 AS total,
                                           cd.field_id_67 AS first_name,
                                           cd.field_id_73 AS surname')
                                 ->from('channel_titles ct')
                                 ->join('channel_data cd','ct.entry_id = cd.entry_id', 'inner')
                                 ->where('ct.channel_id', $channel_id)
                                 ->order_by('ct.entry_date DESC')
                                 ->limit($settings->limit)
                                 ->get();

```

# Answer
> 0 votes
Another option would be to use a proper API for this. Take a look at Channel Data. I made it so that it would solve this exact problem, as I grew tired of writing hard to maintain code, and one with hardcoded id's.

In Channel Data, you would do the following:

```
$entries = $this->EE->channel_data->get_channel_entries($channel_id, array(
    'where' => array(
        'channel_titles.channel_id' => $this->settings->channel_id
    ),
    'order_by' => 'entry_date'
));

```

*This would return an Active Record object the same as the `$this->EE->db->get()` method*.

https://github.com/objectivehtml/Channel-Data

While there is nothing wrong with other solution, Channel Data can provide a more abstract approach that can be easier to maintain in the long run if the fields ever were to change.

---
Tags: add-on, mysql, dashee
---


title: Related Categories

text:
# Question
Title: Related Categories
Is there anyway to relate a category tag pair to a entries tag pair? I have this code below and I am trying to get the 'long\_head' custom category name to relate to the entries being outputted above it. So if the entry above had a category of 'BEANS' I would like the 'long\_head' to be the long head from the category 'BEANS'.

Any help would be great.

```
{exp:channel:entries channel="services" limit="1"}
<div id="page">
    <h2>{title}</h2>
    <div>
        {service_text}
    </div>
</div>
<!-- // page -->
{/exp:channel:entries}

<div id="nxtBack">
    <p><a href="{site_url}" title="Back to Home Page">← Back to Home Page</a></p>
</div>

<div id="rel-work">
    {exp:channel:categories style="none"}
    <h2>{long_head} Projects</h2>
    {/exp:channel:categories}
    <ul>
        {exp:channel:entries channel="work" limit="20" status="New|Open" related_categories_mode="yes" custom_fields="yes"}
        {if no_results}
            <p class="alert">There are currently no related projects to this service in our online portfolio.</p>
        {/if}
        <li>
            <a href="{title_permalink="work/view"}" title="{title}"><img src="{project_th}" alt="{title}" />{if status == "New"}<img src="/_/img/new-work.png" class="new" alt="NEW Project - {title}" />{/if}</a>
            <h3><a href="{title_permalink="work/view"}" title="">{title}</a></h3>
            <h4>{categories backspace="2"}<a href="{path="work"}" title="">{category_name}</a> / {/categories}</h4>
            <p>{project_excerpt}</p>
        </li>
        {/exp:channel:entries}
    </ul>
    <p><a href="{site_url}work" title="View all work">View all work →</a></p>
</div>
<!-- // rel-work -->

```

# Answer
Since you're just outputting a single channel entry at the top, you can just enclose the category section inside the `channel:entries` loop:

```
{exp:channel:entries
    channel='services'
    limit='1'
    disable='pagination|member_data'
}
    <div id="page">
        <h2>{title}</h2>
        <div>
            {service_text}
        </div>
    </div>
    <!-- // page -->

    <div id="nxtBack">
        <p><a href="{site_url}" title="Back to Home Page">← Back to Home Page</a></p>
    </div>

    <div id="rel-work">
        {categories}
            <h2>{long_head} Projects</h2>
        {/categories}

{/exp:channel:entries}

```
> 1 votes

---
Tags: categories
---


title: SEO meta - Multiple fallback options?

text:
# Question
Title: SEO meta - Multiple fallback options?
I've looked at SEO Lite and NSM Better Meta.

These SEO addons come with 1 default fallback template. By "fallback" I am referring to fallback meta data that displays if there is no title, description, or keyword values saved to the entry.

I need to be able to have different fallback SEO meta on a per section basis if no SEO meta is entered for an entry. Any ideas?

# Answer
Have you seen my blog post on SEO & ExpressionEngine. I'm sure using that approach would get you partway to what you want to do.

Additionally I would take a look at SurgEEo - which I believe addresses some of what I was trying to do in the blog post linked above. I'm going to be trying out SurgEEo on my next build so can't guarantee this yet.
> 1 votes

# Answer
SEO Lite has tag parameters that allow you to override the default meta data directly within the template. So you can do something like this:

```
{exp:channel:entries limit='1'}
    {if channel_short_name == 'blog'}
        {exp:seo_lite
            entry_id='{entry_id}'
            default_title='Blog'
            default_description='The bestest blog in the whole wide world.'
            default_keywords='blog, posts, stuff, junk, things'
        }
    {/if}
    {if channel_short_name == 'contact'}
        {exp:seo_lite
            entry_id='{entry_id}'
            default_title='Contact'
            default_description='Contact us because we are awesome.'
            default_keywords='contact, email, form, notify'
        }
    {/if}
{/exp:channel:entries}

```

There's a similar example in the docs that uses embedded template variables.
> 0 votes

---
Tags: templates, seo, seo-lite
---


# Question
Title: Zoo Visitor Update Hangs Browser But Submits Content
I have a Zoo Visitor form that populates a channel entry. All is well in that it actually submits the content. However, the strange thing is I would have no way of knowing that until I check ExpressionEngine's control panel and seeing that the edits have been made -- because the browser hangs the moment I press submit. It looks like it's perpetually loading. Then trying to go anywhere else on the site makes it super super slow.

When I close the browser and visit the form again, everything loads fast on the site. But when I make a change in the form and press enter, again, browser hangs forever even though it looks like it submitted in EE. It never goes to the /success/ page.

Help?

# Answer
I disabled MX Notify Control and everything began working again. It looks like that was the culprit!
> 2 votes

# Answer
The most likely culprit is an extension using the entry\_submission\_end hook (http://ellislab.com/expressionengine/user-guide/development/extension\_hooks/api/channel\_entries/) that is getting hung up. (It'd be after the entry\_submission\_start/ready hooks, since it's saving the entry)

Your best bet is to disable all the extensions, and to see if the problem persists.
> 4 votes

---
Tags: zoo-visitor
---


# Question
Title: How can I remove thousands of spam members on a non-member site?
My first EE 1.6.8 site is coming back to haunt me. The site crashed and burned the other day. Took a look at the members in the DB and there's about 78000 spam members in there. I have access to PHPAdmin for the DB, but I don't know what I'm doing in there. Any help?

# Answer
**Always backup first!**

Hopefully they're all still pending. Go into phpMyAdmin query tab and run the following query to delete pending members:

```
DELETE FROM exp_members WHERE group_id = 'PENDING GROUP ID'

```

You can also run the query right from the control panel:

> Admin › Utilities › SQL Manager › Database Query Form

If the site isn't setup to verify membership, you could run a query to delete all members after a certain date, specifically the day of spam and after:

```
DELETE FROM exp_members WHERE join_date > 'UNIXTIMESTAMP'

```

Use this tool to help figure out the unix timestamp. If you don't feel comfortable running the query at first, you could always run a `SELECT` query to confirm correct selection of members.

```
SELECT * FROM exp_members WHERE join_date > 'UNIXTIMESTAMP'

```
> 6 votes

---
Tags: members, database, spam
---


# Question
Title: How to display the chosen item_option of a product as selected option in the cart? - CartThrob
I am using the update\_cart\_form nested inside the cart\_items\_info tag, to allow customers to edit the size or quantity of their item (as well as delete it from cart). I cannot find a way to have the item option they selected as the selected option in the (for example, if Medium is selected under the product\_size, display that as the selected option)

I would also like to replicate this for displaying their currently chosen shipping method. Here is the code I currently am using:

```
{exp:cartthrob:cart_items_info}
    {if no_results}
        <p>You have nothing in your cart. <a class="blue" href="/shop">GO SHOP »</a></p>
    {/if}
    {if total_items > 0}
        {if first_row}
             {exp:cartthrob:update_cart_form  return="checkout" class="cart_form"}
        {/if}
                <ul class="cart-table">
                    {if product_detail_image}
                        <img src="{product_detail_image:feed}"/>
                    {if:else}
                        <img src="{site_url}content/img/ride.png"/>
                    {/if}
                    <li><p>{title} <span>Quantity: <input type="text" name="quantity[{row_id}]" size="1" maxlength="2" value="{quantity}" /></span></p>
                        <p>{exp:cartthrob:item_options entry_id="{entry_id}" }
                        {if dynamic}
                            <label>{option_label}</label>
                            {input}
                        {if:else}
                            {if options_exist}
                                {select}
                                    <option {selected} value="{option_value}">
                                    {option_name}{if option_price_numeric > 0} +{option_price}{/if}
                                    </option>
                                {/select}
                            {/if}
                        {/if}
                        {/exp:cartthrob:item_options}
                        <span><input type="checkbox" name="delete[{row_id}]"> Delete this item</span></p>
                    </li>
                </ul>
            {if last_row}
                <select name="shipping_option">
                        {exp:cartthrob:get_shipping_options}
                                <option value="{rate_short_name}" {selected}>{rate_title} - {rate_price}</option>
                        {/exp:cartthrob:get_shipping_options}
                </select>
                <input type="submit" value="Update Cart" />
            {/exp:cartthrob:update_cart_form}
        {/if}
    {/if}
{/exp:cartthrob:cart_items_info}

```

# Answer
Instead of using:

```
<option {selected} value="{option_value}">

```

Use:

```
<option {if selected}selected{/if} value="{option_value}">

```

Also, add the `row_id` parameter to your `{exp:cartthrob:item_options}` tag.
ie.

```
{exp:cartthrob:item_options row_id="{row_id}"}

```
> 0 votes

---
Tags: cartthrob, shipping, shopping-cart
---


# Question
Title: How to order by price products in Exp:resso Store
I would like to order my products by price, how cat i do this?

I use:

```
{exp:channel:entries channel="products" orderby="product:price_val"}

```

But it's not work...

# Answer
You need to use the Store Search tag instead, which adds some custom Store options:

```
{exp:store:search channel="products" orderby="price"}
    <!-- normal channel entry template here -->
{/exp:store:search}

```
> 2 votes

---
Tags: expresso-store
---


title: Quickly delete 1000s of members

text:
# Question
Title: Quickly delete 1000s of members
I've picked up an old EE 1.6 site that has 58k spam member accounts. Anybody got a safe way to delete them all without going through every paginated screen in the CMS? It's on a live server but I suppose I could edit the SQL to change pagination.

I'd rather do it directly in myqsql though I think, but I want to make sure no table relationships are broken.

# Answer
> 9 votes
If the members you are deleting have something simple in common (e.g. They never logged-in ) then you can use the member clean up tools - these might work for you.

Go CP Home › Admin › Utilities › Data Pruning › Membership Account Pruning

Obviously back-up first before even looking at this and YMMV but for EE 1.6 the data pruning might be handy.

# Answer
> 4 votes
The easiest way to delete 1000s of members is to use the following SQL after backing up your database:

```
DELETE
FROM `exp_members`
WHERE `group_id` =x

```

x is the member group number you want to delete members from.

# Answer
> -1 votes
I would think your best bet is backing up the DB in production, writing a script to test the removal on your local machine, performing the update on your local machine, importing the changes back to the DB.

You might have to do a site-wide content freeze for a few hours, but that's pretty standard in situations like this.

---
Tags: members
---


# Question
Title: Fatal Error Out of memory when trying to access PHP info utility in ee control panel
I'm using EE 2.5.5 and noticed recently that the php info tool is showing this error when accessed:

Fatal error: Out of memory (allocated 10485760) (tried to allocate 131121 bytes) in /home/curvedes/public\_html/mercytouch2/system/expressionengine/controllers/cp/tools\_utilities.php on line 2096

Any suggestions on how this should be fixed would be appreciated.

# Answer
Sounds like you need to increase your PHP memory limit in your php.ini file.

Your server administrator can configure this for you if you have no access to your PHP configuration. If you run a local environment using Mamp or Wamp, you can edit the php.ini and find where it says `memory_limit = 32M` (integer may vary so search for memory\_limit)

Increase to a higher number like 128M and save the file. Restart the server.

Mamp Pro Example http://blog-en.mamp.info/2009/09/increase-php-memory-limit-with-mamp-pro.html
> 1 votes

---
Tags: ee2
---


title: Rebuild url_title fields?

text:
# Question
Title: Rebuild url_title fields?
I have a site with 1000's of products that were originally entered incorrectly. The titles have been updated, but the URL title's still have the old data. Is it possible to bulk update these entries to with either a sql query or script?

# Answer
You can do a bulk update of URL Titles with SQL like:

```
UPDATE exp_channel_titles SET url_title=REPLACE( LOWER(title) , ' ', '-') WHERE channel_id=1

```

You can see URL Title is being derived from Title replacing space with dash and changing in lower case. You can have channel\_id and any other condition in WHERE according to your preference.

You can have second approach by writing script using Channel Entry API like:

```
        $this->EE =& get_instance();
        $this->EE->load->library('api');
        $this->EE->api->instantiate('channel_entries');
        $this->EE->api->instantiate('channel_fields');

    $channel_id = 'Channel id number here';

        $entries = $this->EE->db->select('entry_id, title')->where('channel_id', $channel_id)->get('channel_titles')->result_array();
        foreach($entries as $entry)
        {
            $data = array(
                    'title' => $entry['title'],
'channel_id' => 'channel id number'
                );
            $this->EE->api_channel_fields->setup_entry_settings($channel_id, $data);
            $this->EE->api_channel_entries->update_entry($entry['entry_id'], $data);
        }

```
> 6 votes

# Answer
Bhashkar's answer is great - though a quicker solution might be to install Title Master. It has an option to update the URL title for all entries in a particular channel at once - and it's also an incredibly useful add-on.
> 1 votes

# Answer
If you want the URL title to follow the same format as in the CP when creating an entry. Eg My Title is my-title then a simple PHP script could batch change these as both fields are in the same table.
> 0 votes

---
Tags: entries, url-title
---


title: System Messages ext issue

text:
# Question
Title: System Messages ext issue
I am using new relic to watch my EE install and am seeing a ton of slowness around this call.

I am also using http://devot-ee.com/add-ons/custom-system-messages \- and am not sure if the issue is coming from that plugin or the EE system messages.

Has anyone seen this before?

System\_messages\_ext::extend\_output\_class

# Answer
> 1 votes
Jordan, can you post this over at boldminded.com/support? Include version of EE, and maybe FTP access so I can debug this. There are several other calls in there with 93% and 6,320 ms, so the CSM call isn't much different.

---
Tags: error, newrelic, custom-system-messages
---


# Question
Title: Matrix and Playa: Pull Channel Entry Data
I have a matrix field ({home\_layout}) with the first cell setup as a Playa select single entry all in the channel home.

How can I now call the channel entry data from that Playa field which is from the channel main?

So far I have:

```
{exp:channel:entries channel="home"}
{home_layout}
{playa}
{title}
{/playa}
{/home_layout}
{/exp:channel:entries}

```

...which is returning nothing.

First time i've used Playa and Matrix so appreciate any help.

N

# Answer
This is working beautifully now:

```
{exp:channel:entries channel="home" status="homepage|open"}
{home_layout}

{playa_1}
<h1>{title}</h1>
{/playa_1}

{/home_layout}

```
> 1 votes

# Answer
Try using the Playa children tag instead of the regular Playa field tag, so you can make use of the `var_prefix` parameter.

```
{exp:channel:entries channel="home"}
  {home_layout}
    {exp:playa:children field="playa_field" var_prefix="pl"}
      {pl:title}
    {/exp:playa:children}
  {/home_layout}
{/exp:channel:entries}

```
> 0 votes

---
Tags: matrix, playa
---


# Question
Title: image re-sizing in Expressionengine Discussion Forums
I am using ExpressionEngine 2.5.5 and Discussion Forum 3.1.10.

Issue i am having it will not re-size photos when my members post them as Image Links, it works in Chrome browser but it will not work in Firefox or IE.

When you look at the forum post where photo is posted with chrome browser it is nicely re-sized to fit the look of the forum.

However if you look at the same post where image is in Firefox or IE the image is huge (true size) and breaks the look of the forum.

Any suggestions on how to fix or where to look would be much appreciated.

# Answer
> 1 votes
Sounds like you need to modify the CSS file of the forum theme. This example is working blind as I don't have it installed, but this may work if you can find where the CSS is being set for the image. Set the maximum width to a pixel value or even try max-width: 100%.

A guessing example

```
.post img {
max-width: 480px;
}

```

or

```
.post img {
max-width: 100%;
}

```

I run into this problem if images don't have a specified width in the stylesheet. Images larger than the the width of the table cell will stretch the cell.

---
Tags: ee2, forum, twitter-bootstrap
---


# Question
Title: Validation issue with Zoo Visitor Update, SafeCracker Registration / SafeCracker Update Forms in one template
I have one template that has three separate forms. None of these are nested. The first is on the "/your-account page" and the other two are in modals. On this account page a user can update their info (form 1), add a dog (form 2), or edit that dog (form 3). They each have unique ids and have a unique "return." Include\_jquery and safecracker\_head parameters are set to "no" in each form. I am using Stash to store the variables for the dog forms and no channel:entries loops are being used.

1. zoo\_visitor:update\_form \[channel = "zoo\_visitor"\] --- include\_jquery="yes" safecracker\_hea="yes"
2. safecracker (registration) \[channel="dogs"\] --- include\_jquery="no" safecracker\_head="yes"
3. safecracker (update) --- include\_jquery="no" safecracker\_head="yes"

Each of these forms works as intended and creates/updates when submitted. The issue I am having is with validation errors. When I intentionally leave an input blank etc, my errors do not appear inline. I get this one (non-inline) error "The form you submitted contained the following errors: **You must specify a valid entry to edit.**"

If I remove the "Update Dog" form then validation works on the "User Profile Update," but not on the "Add a Dog" form.

At this point I have tried so many different variations that I am just stumped. The template, as you can imagine, is quite long, but I can add it if needed.

Thanks for looking!

FYI: Running EE 2.5.5 and ZV 1.3.25

**Update:** It looks like the issue is with the parameter error\_handling="inline" so if I turn that off, then everything works great. I still don't know why this is, but I might have to resort to using javascript validation. Here is a link to my template http://pastie.org/private/v6f4keocja5auqcozsvw

# Answer
It seems that your form3 isn't getting entry id or url\_title for the entry which need to be updated.

In the case you are getting issue by passing entry\_id or url\_title as parameter within the edit tag dynamically, just put hidden field for entry\_id or url\_title like:

```
<input type="hidden" name="entry_id" value="[ENTRY ID]" />

```

OR

```
<input type="hidden" name="url_title" value="[URL TITLE]" />

```

As you are using modal for update form so entry\_id or url\_title can be fetched and value can be updated with some JavaScript.
> 1 votes

---
Tags: safecracker, zoo-visitor, validation
---


# Question
Title: Sub-folder naming convention in Assets 2
If I create a sub-folder with more than a one-word title using Assets, the name is joined with an underscore i.e. 'Technical\_Manuals'. Is there any way around this as obviously this wont be suitable front-end?

# Answer
> 1 votes
You want folders, filenames, template groups, and even templates to follow the lowercase, no spaces, use of underscores or dashes format. Additional with files, you want extensions. All these things can be transformed for the front-end with Plugins or PHP. The use of spaces will introduce encoding in the url (`%20`) etc., since they are consider unsafe.

You can use any basic Find and Replace plugin to strip dashes or underscore from text for the front end, see Low Replace or Find and Replace Plus by Laisvunas as two examples. You can then also use CSS or a plugin to transform from lowercase to Sentence case, Title Case or other options as well.

---
Tags: assets
---


title: Assets not showing files in backend

text:
# Question
Title: Assets not showing files in backend
I'm building a custom fieldtype that uses **Assets**. So far, I've implemented **Assets.Sheet**, as described here: http://docs.pixelandtonic.com/assets/developers/sheet.html.

But when the Sheet slides into view, **Assets tries to refresh** the files, and **no files are being shown**. There are **no JS errors** and the thumbnail list is emty (checked the html code). Only a console message from **garnish-0.1.min.js** saying: "**Double-instantiating a select on an element**".

The sheet does work properly with any other standard Assets field, but not with my fieldtype.

Here's a screenshot: http://cl.ly/image/3b2D2t1I3g0f

Anybody any idea how to solve this?

# Answer
> 0 votes
With a lot of help from @AndrisSevcenko from Pixel & Tonic, the issues have been resolved. Mostly caused by the code I wrote, a small fix was added to Assets and will be added to the next release.

Thanks again Andris!

---
Tags: assets, add-on-development, pixelandtonic, javascript, fieldtype
---


title: Assets broke the category image field

text:
# Question
Title: Assets broke the category image field
I'm using Assets in a MSM setup. But it seems that it broke the category image functionality. Is there a work-around or a fix for that?

Thanks, Diederik.

# Answer
Due to some JS errors in another custom made Accessory, the category image functionality was broken. This had nothing to do with Assets. Just wanted to put this straight.
> 0 votes

---
Tags: assets, image, categories
---


title: Carthrob on authorize hook extension

text:
# Question
Title: Carthrob on authorize hook extension
I am creating an extension to save some data from orders through CT into a new db table.

My code is causing this error message:

> Object of class CI\_DB\_mysql\_result could not be converted to int

Here is my code:

```
function cartthrob_on_authorize()
{
    foreach ($this->EE->cartthrob->cart->items() as $item) {

        // Create array to store member id and purchased upload slots
        $my_data = array(
            'member_id' => $this->EE->session->userdata('member_id'),
            'upload_total' => $item->item_options('fees'),
        );

        // Store member id in variable
        $member_id = $my_data['member_id'];

        // Query table to check if there if record with member id exists
        $query = $this->EE->db->get_where('exp_competition_purchase_upload_total', array('member_id' => $member_id));

        // If query returns more than 0 update record
        if($query->num_rows() > 0) {

            //Find current upload total value
            $this->EE->db->select('upload_total');
            $upload_total = $this->EE->db->get('exp_competition_purchase_upload_total');

            // If upload total is more than 0
            if($upload_total > 0) {

                $new_total = $upload_total + $my_data['upload_total'];

                $my_data['upload_total'] = $new_total;

            }

            $this->EE->db->update('exp_competition_purchase_upload_total', $my_data);

        // If query returns 0 insert new record
        } else {

            $this->EE->db->insert('exp_competition_purchase_upload_total', $my_data);

        }
    }
}

```

I am fairly new to PHP, so I could be doing some stupidly wrong (more than likely).

Can anyone take a look and see if I am making any obvious errors here?

Thank you

# Answer
> 2 votes
This line here:

```
$upload_total = $this->EE->db->get('exp_competition_purchase_upload_total');

```

Is getting a result object, not the actual upload\_total column. Change it to this to get the actual column value.

```
$upload_total = $this->EE->db->get('exp_competition_purchase_upload_total')->row('upload_total');

```

---
Tags: cartthrob, php, php-errors
---


title: Pagination current_page not retaining

text:
# Question
Title: Pagination current_page not retaining
I have the following code:

```
{paginate}
    {pagination_links}
    <div class="block_pager">
        {previous_page}
        <a href="{pagination_url}" class="prev">Previous</a>
        {/previous_page}
        {next_page}
        <a href="{pagination_url}" class="next">Next</a>
        {/next_page}
        {current_page}
        <div class="pages">
            <ul>
                {page}
                <li ><a href="{pagination_url}">{pagination_page_number} -  {current_page}</a></li>
                {/page}

            </ul>
        </div>

        <div class="clearboth"></div>
    </div>

    {/pagination_links}
{/paginate}

```

Which returns:

Why is `{current_page}` losing scope?

# Answer
> There is no direct negation for `{current_page}` \[source\]

Use a conditional instead:

```
{if current_page}
  <strong>{pagination_page_number}</strong>
{if:else}
  <a href="{pagination_url}">{pagination_page_number}</a>
{/if}

```
> 1 votes

---
Tags: pagination, variable
---


# Question
Title: Filter comments by Entry Author in the Control Panel
I've been looking up the hooks that can be used with the Comment Module. But I don't think there is one I could use to **filter the list of comments by entry author in the Control Panel**. I'm trying to filter that list so users only see the comments on entries they've added.

Is there any existing **add-ons** that can do this? Or are there any **hooks** I could use to write an add-on myself?

Thanks in advance! Diederik.

# Answer
One approach to only show comments on posts that have been authored by the logged in user is to use a conditional comparing `logged_in_member_id` to `author_id`. Do this inside your channel entries tag pair and embed the comment entries if the condition is met. Simplified example:

```
{exp:channel:entries channel="blog"}
    <h1>{title}</h1>
    {if logged_in_member_id == author_id}
        <p>You wrote this post, so can see these comments:</p>
        {embed="embeds/_comments"}
    {/if}
{/exp:channel:entries}

```
> 1 votes

---
Tags: comments, filter, hook, author
---


# Question
Title: Store that sells video packages with access
I have a client that wants to add video subscriptions to their offering. They want people to be able to download as well as view on-site. I browsed around for something I thought might work that was already in use, but didn't see anything out there.

Is there something I have missed or is this something that will need to be built from scratch? I just didn't want to re-invent the wheel. ;)

They will be able to purchase individual videos as well as packages or bricks.

Thanks.

# Answer
> 0 votes
You could totally do this with CartThrob Pro w/Subscriptions.

---
Tags: ecommerce, video
---


title: Next & Previous files

text:
# Question
Title: Next & Previous files
I am using assets for a photo gallery site.

The first page shows the list of images as thumbnails, when you click a thumbnail it loads a page where it just shows the single image (passing the file\_id through segment\_4).

What I want to do make the large image on this page clickable to go to the next image on it's own page (unique URL).

Can someone tell me if this is possible and if so how i should go about it.

big thanks.

# Answer
You could use the Will Hunting plugin to do simple math to increment/decrement the next/prev links based off `{segment_4}`:

```
<a href="{exp:will_hunting:solve exp="{segment_4} - 1"}">prev page</a>
<a href="{exp:will_hunting:solve exp="{segment_4} + 1"}">next page</a>

```
> 0 votes

---
Tags: assets
---


# Question
Title: Abort the channel entry publish process?
I am working on an extension that takes some entry data (from the control panel) and performs some tasks with it, just prior to insert/update. I am currently using the "entry\_submission\_end" hook to accomplish this. However, I would like to abort the entry submission/update process if my extension tasks are not completed successfully. It doesn't look like the "entry\_submission\_end" hook provides the

```
if (ee()->extensions->end_script === TRUE) return;

```

code to do this. What hook can I use to accomplish this? Thanks.

--Garrett

# Answer
Actually, that hook does check for `end_script` \- it just happens inside the `trigger_hook()` method.

However, if you want to bail out of an insert/update when your custom tasks are not completed, then you need to use something earlier than `entry_submission_end` (it's too late at that point, the entry has already been submitted).

I'd suggest either `entry_submission_start` or `entry_submission_ready`.

And be sure to redirect the user after you set `ee()->extensions->end_script` to `TRUE`, lest they end up at the WSOD!
> 1 votes

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


# Question
Title: Alternating layouts within one set of channel entry tags
New to ExpressionEngine so apologies if my question has an obvious answer. Basically, I have two paths for a single channel's content on one page, one arranges the image to the left and the title to the right while the other does the opposite. They both have a specific pattern of five different sizes each that I have organised using the {switch} tag. \[I should mention Foundation is how I'm creating the HTML structure.\]

The image left layout:

```
<div class="row pad-bottom {switch='vid-m|vid-m|vid-l|vid-s|vid-s'}">
    <div class="{switch='four columns offset-by-one|four columns|three columns|four columns offset-by-one|three columns offset-by-two'} text-right title">
        <div class="inner">
            <a href="">{title}</a>
        </div>
    </div>
    <div class="{switch='seven columns|eight columns|nine columns|six columns end|seven columns'}">
        <div class="row">
            <div class="ten columns centered {switch='vid-m|vid-m|vid-l|vid-s|vid-s'}" style="background-image: url('')"><a class="" href=""></a></div>
        </div>
    </div>
</div

```

The image right layout:

```
<div class="row pad-bottom {switch='vid-m|vid-m|vid-l|vid-s|vid-s'}">
    <div class="{switch='four columns offset-by-one|four columns|three columns|four columns offset-by-one|three columns offset-by-two'} text-right title">
        <div class="inner">
            <a href="">{title}</a>
        </div>
    </div>
    <div class="{switch='seven columns|eight columns|nine columns|six columns end|seven columns'}">
        <div class="row">
            <div class="ten columns centered {switch='vid-m|vid-m|vid-l|vid-s|vid-s'}" style="background-image: url('')"><a class="" href=""></a></div>
        </div>
    </div>
</div>

```

What I'm looking to do is flow a single channel's entries from one to the other, alternating left and right on the way down. The only result I've managed to get anywhere near this is having the channel entries tag outside both but this causes each entry to be duplicated, but the layout is correct. Sorting the entries would require calling the channel entry each time and offsetting and limiting which doesn't help either.

Any help or insight would be brilliant.

Thanks in advance!

# Answer
> 0 votes
I think this is more of an issue of how you are displaying your data with html. This data should be in a single container. In the container each image (or image container) should be given a left and right class. then when you are pulling the entries it should be something like this

```
<div class="two-column-container">
  {exp:channel:entries channel="example"}
    <div class="data {switch 'left|right'}">
      {title},{img},{ect...}
    </div>
  {/exp:channel:entries}
</div>

```

Then from there adjust your css.

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


# Question
Title: How do I pass a variable to mySQL without using the query module?
I can echo the current `entry_id` but when I try to pass that variable to a mySQL statement, it doesn't work.

```
{exp:channel:entries channel="test" entry_id="20"}
  <?php
  $entry_id = '{entry_id}';
  echo $entry_id; // returns 20

  $sql_query = "SELECT col1 FROM table WHERE entry_id = $entry_id"; // doesn't work
  $sql_query = "SELECT col1 FROM table WHERE entry_id = 20"; // this works

  // rest of code
  ?>
{/exp:channel:entries}

```

# Answer
I don't think it would work with any of "PHP Parsing Stage" of template preference. You can use Query module tag instead of using PHP code with channel entry tag like:

```
{exp:channel:entries channel="test" entry_id="20"}

{exp:query sql="SELECT col1 FROM table WHERE entry_id = '{entry_id}'" parse="inward"}
{col1}
{/exp:query}

{/exp:channel:entries}

```

It would work for you.

*** Edited ***** In the case, it's necessary for you to have PHP code within the template you can embed a template within it like:

```
    {exp:channel:entries channel="test" entry_id="20"}

{embed="temp_grp/embedded_temp" entry_id="{entry_id}"}

    {/exp:channel:entries}

```

and you can have PHP code within the template like:

```
  <?php
  $entry_id = "{embed:entry_id}";

  $sql_query = "SELECT col1 FROM table WHERE entry_id = $entry_id";

  // rest of code
  ?>

```

Don't forget setting the "PHP Parsing Stage" as "Output" in template preferences with "Allow PHP"
> 1 votes

---
Tags: templates, php, sql
---


title: Help with a query in channel images

text:
# Question
Title: Help with a query in channel images
I am using the following query to check if an entry in the channel images table has any categories marked 'private'.

```
{exp:query sql="SELECT * FROM exp_channel_images WHERE entry_id = '{entry_id}'
 AND category = 'private' "}
 {if no_results} 0 images {/if}
{/exp:query}

```

The {if no\_results} output does not work. Can anyone suggest another way I can do this? Thanks

# Answer
Your query seems correct. Although, you can use channel images tag instead:

```
{exp:channel_images:images entry_id='entry_id' category='private'}
    {if image:no_images} 0 images {/if}
{/exp:channel_images:images}

```

In case you would like to use query module, it would work also:

```
{exp:query sql="SELECT COUNT( * ) AS total_images FROM exp_channel_images WHERE entry_id = '{entry_id}' AND category = 'private'"}
 {if total_images == 0} 0 images {/if}
{/exp:query}

```
> 1 votes

# Answer
I don't have an EE database in front of me, but I could've sworn it was category\_id in that table, not category. If your query is invalid, it would prevent no\_results from working as well.
> 0 votes

---
Tags: query, channel-images
---


title: Matrix Playa Count Conditionals issues

text:
# Question
Title: Matrix Playa Count Conditionals issues
Sorry, I'm having a little brain freeze here and am hoping for some help.

I currently have the following code:

```
<div class="my-div">
    {exp:playa:children channel="somechannel"}

        {matrix_field}

            {if field_row_index == 0}
                <div>
                    <ul>
            {/if}

            {playa_field}

                playa vars

            {/playa_field}

            {if row_count == total_rows}
                        </ul>
                    </div>
            {/if}

        {/matrix_field}

    {/exp:playa:children}

</div>

```

I'm trying to figure out how to get my-div (opening and closing div) inside the exp:playa:children tag but, to only display once.

In other words, I want my-div to wrap all the playa:children IF and when any exist but, to not repeat over and over again.

Currently what I have works fine except if there isn't any data then my-div still shows up which is not what I want.

Thanks!

# Answer
I (we) ended up figuring out a solution!

This after some 30+ back and forth emails with Lisa, both of us learning a bunch of stuff about how Playa - within Matrix - within {epx:playa:children} works. Plus count, row\_count and total\_results, total\_rows and a bunch of other variables for Playa and Matrix plus all the var\_prefix scenarios.

Ultimately I finally gave up for the most part at which point Lisa suggested I look into Switchee which I did only to realize I was running into the same count issue I was having before. More on that at the bottom of this answer.

Anyway, this for some reason, out of the blue, gave me an idea to try Column-bo which is similar to Splitter if you are familiar with that add-on.

Column-bo's example shows it being used and wrapped around the channel entry tag so I wasn't quite sure it would work inside the channel entry tag itself and wrapping the {exp:playa:children} tag or not.

I honestly can't believe it but, it did in fact work!

The pseudo code looks like this:

```
{exp:columnbo:lists columns="1" open='<div class="my-div">' close="</div>" delimiter="</div>" no_results=""}

    {exp:playa:children channel="somechannel" var_prefix="child"}

        {child:matrix_field var_prefix="mx"}

            {if mx:field_row_index == 0}
                <div>
                    <ul>
            {/if}

            {mx:playa_field var_prefix="ply"}

                <li>{ply:title}</li>

            {/mx:playa_field}

            {if mx:row_count == mx:total_rows}
                        </ul>
                    </div>
            {/if}

        {/child:matrix_field}

    {/exp:playa:children}

{/exp:columnbo:lists}

```

which gives me something like following which is exactly like my original code from my question except that the my-div div now only occurs when we have results where as before it was there with results or without:

```
<div class="my-div"> <--- 1 my-div no matter how many inner divs, ul, li sets existed
    <div>
        <ul>
            <li>Title 1 A</li>
            <li>Title 1 B</li>
            <li>Title 1 C</li>
        </ul>
    </div>
    <div>
        <ul>
            <li>Title 2 A</li>
            <li>Title 2 B</li>
        </ul>
    </div>
</div>

```

With Playa, Matrix and their count, row\_count and total\_rows, total\_results variables and conditionals etc. I was only ever able to achieve the following where each playa matrix set of rows is wrapped:

```
<div class="my-div"> <--- 1 of 2
    <div>
        <ul>
            <li>Title 1 A</li>
            <li>Title 1 B</li>
            <li>Title 1 C</li>
        </ul>
    </div>
</div>
<div class="my-div"> <--- 2 of 2
    <div>
        <ul>
            <li>Title 2 A</li>
            <li>Title 2 B</li>
        </ul>
    </div>
</div>

```

Ultimately I'm not sure the var\_prefixing mattered or not though, I left it for good mesure.

My initial question doesn't do this issue justice, I realize that though, I hope my explanation/answer does help someone.

Thanks to Lisa and P&T Email Support for bearing with me through this one!

**Why Column-bo works and Playa/Matrix vars/conditionals does not?**

Column-bo is presumably counting the closing divs and then wraps the first and last one with my-div. So, if you look at my html output example above Column-bo is seeing two closing divs based on the delimiter param I gave it to look for (it could see more divs or none even dependent on the current parent entry and the relationships) then it wraps all of those divs with my-div div of course; once since the columns param is set to 1. Also, if there are no\_results or no closing divs ie. the dilimiter then it doesn't add my-div which is perfect.

Playa/Matrix on the other hand is seeing the following counts: 1,2,3 & 1,2 (which is Title 1 A-C and Title 2 A-B) from the playa\_field's data and why the conditionals using 1 doesn't work as there are two 1's and total\_results doesn't work either because there are two total\_results if you want to think about it that way. Actually, it does work, as it's doing what it's suppose to do, by wrapping my-div twice but, it's just not doing what I wanted/needed it to do of course.

P.s. I questioned how all this Playa within Matrix with Playa:Children along with everything else I had in my template plus now adding in Column-bo would effect performance. My code is adding 40 queries to the mix. I'm get the following Total Execution time: 0.3644 which is about .1 more than not having the code in place. No caching mind you so, I think it will be fine :)

**UPDATE**

Ultimately something about using `{exp:playa:children}` was causing an issue with orderby and sort. I was never able to get things to order correctly so, I scrapped it and went with all the regular tags.

Now everything sorts based on the very first Matrix row order in the entry itself so, if the client moves those rows around everything reorders as expected.

There is some real Inception going on here but it works. I ended up with something like this:

```
{exp:columnbo:lists columns="1" open='<div class="my-div">' close="</div>" delimiter="</div>" no_results=""}

    {matrix_field var_prefix="child"}

        {child:playa_field var_prefix="play"}

            {play:matrix_field var_prefix="mx"}

                {if mx:field_row_index == 0}
                    <div>
                        <ul>
                {/if}

                {mx:playa_field var_prefix="ply"}

                    <li>{ply:title}</li>

                {/mx:playa_field}

                {if mx:row_count == mx:total_rows}
                            </ul>
                        </div>
                {/if}

            {/play:matrix_field}

        {/child:playa_field}

    {/matrix_field}

{/exp:columnbo:lists}

```
> 1 votes

# Answer
How about:

```
    {exp:playa:children channel="somechannel"}
{if count == "1"}<div class="my-div">{/if}

        {matrix_field}

            {if field_row_index == 0}
                <div>
                    <ul>
            {/if}

            {playa_field}

                playa vars

            {/playa_field}

            {if row_count == total_rows}
                        </ul>
                    </div>
            {/if}

        {/matrix_field}

{if count == total_results}</div>{/if}
    {/exp:playa:children}

```

That should work for you.... if you're inside a channel entries tag, however, you'll need to utilize var\_prefix to make it specific to the playa tags.

Make sense?
> 1 votes

# Answer
You could wrap your div.my-div tag with an if statement, like so:

```
{if "{my_playa_field:total_children channel="somechannel"}" > 0}
    <div class="my-div">
{/if}

```

You could do the same with the closing tag.

I haven't tested this, but I hope it helps. Some more info on the P&T site.
> 0 votes

---
Tags: matrix, playa, conditionals, pixelandtonic, count
---


title: How to generate large XML

text:
# Question
Title: How to generate large XML
We are generating an XML file everyday detailing the cartthrob orders for the day. The format of this XML is awkward as it needs to repeat certain content at different points as well as a host of conditionals.

I chose stash to record all the orders, stash the main content along with a couple of nested items for cart variations and all works well until we hit upwards of 50 orders.

The server is set to 256MB and now we're getting **Server Gone Away Error: 2006**. The client has noted that max\_allowed\_packet=8M and the entire database is only 4M - so this error could be a false negative ?

Upping the ram suppressed that previous error now we're getting server 500 errors.

I have NFI on how to proceed or what to address. The template is as skinny as I can make it. I tried swapping some initial capture tags with {exp:query} and savings were minimal.

This is the basic concept of the XML template that works fine until 50+ orders are being recorded:

```
{stash:set_list} //set the list
{exp:channel:entries disable="categories|etc"} //query the orders channel
  {stash:first_name} //stash the content
  {stash:lastname}
  {stash:nested_list}
    {order_items} //Grab ordered variations stored in CartThrob matrix
      {stash:qty}
      {stash:color}
      {stash:price}
    {/order_items}
  {/stash:nested}
{/exp:channel:entries}
{/exp:stash:set_list}

Then we build the XML
<xml>
{exp:stash:get_list} //set above, repeat for each order
<customer>
{first_name}
{last_name}
<order_items>
{stash:get_list:nested} //grab the ordered items
  {qty}
  {price}
  {etc…}
{/stash:get_list:nested}
</order_items>
<somepreviousitem>{first_name}</somepreviousitem>
</customer>
{/exp:stash:get_list}
</xml>

```

Simplistically what can I try to improve this situation? Is there a way to set a batch of sorts ?

Output profiler doesn't help the XML is a template and the extra code breaks the output. Tried BiopsEE but server is running PHP 5.2.17 and required 5.3 - cant change it.

# Answer
I generate XML files for orders for clients in a very similar format - I use `{exp:query sql=""}...{/exp:query}` for the lot. Eg, I don't touch any exp:channel / order:items / embeds etc. Can spit out ~1500 orders and relevant details in no time - We have a separate function that can run live currency conversion on the order totals in these XML files - whilst that's slower as it connects to a google api, we've never had any memory issues.

If you temporarily change the template format out of XML and back to PHP. What does the output profiler say about where your memory limits are being consumed?
> 1 votes

---
Tags: cartthrob, stash, server, xml
---


title: Template Caching - Blank Page

text:
# Question
Title: Template Caching - Blank Page
I am running into an odd error with a new EE site I am coding. I tried to turn on the template caching. When I load the page on the front-end website it works the first time but becomes blank on reload. e.g. First Load (http://cl.ly/image/1l27232q1V04) vs Second Load (http://cl.ly/image/0e452626213g). Here is the homepage (http://cl.ly/code/2g1p3f0i3z04) and wrapper (http://cl.ly/code/0V2f2C1f0W3J) template code. Any ideas why I am getting a blank load when trying to use template caching?

I am using EE Core 2.6.0. The main plugins I am using are stash, switchee, ifelse, structure, wygwam, matrix, playa, calendar, freebie, imageSizer & assetLinker.

# Answer
Since the stash saves the values of variables on the moment of parsing, you can't cache the templates, except on Stash itself.

For example, on the first template, you set the variable "content":

```
{exp:stash:set name='content'}
    <div class='aside adoption-info'>
    (...)
{/exp:stash:set}

```

If the page is cached, this code isn't evaluated anymore. On the wrapper template, the variable "content" will be empty.

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

```

Even if you set both templates to cache, each one will have its own cache file that you be put together on a really later stage of parsing.

Personally, I guess your code is too complex, but I didn't look at it enough to say for sure. Try to make it simpler or to just use the cache of Stash.
> 1 votes

---
Tags: templates, cache, caching
---


title: Maximum rows in a Matrix field

text:
# Question
Title: Maximum rows in a Matrix field
Is there a theoretical (or practical) limit to the number of rows you can have in a Matrix field?

Let's say each row has 5 single line text fields and a date field.

# Answer
> 1 votes
I would say with that kind of data, the practical limit would be pretty high, since each row would have very little data (compared to, say, a Playa field in one or more columns).

Said practical limit would be based on a combination of your server memory (for selecting and iterating all the row data, then all the regex used in parsing each row in your template), and browser memory (due to the required javascript in the CP).

Looking at the Matrix fieldtype:

* any given Matrix field will only display up to 1000 rows on the Publish screen
* the default limit for Matrix rows in templates is 100 (though you could set this to something higher in the template tag)

---
Tags: matrix, pixelandtonic
---


# Question
Title: I did the Expression Engine upgrade to 2.61 and now when I add a PAGE it won't let me set the status
I did the Expression Engine upgrade to 2.61 and now when I add a PAGE it won't let me set the status it just is blank so I can not set it to open. if I add or update it sets to blank... what can I do?

# Answer
Make sure you have a status group assigned to that channel.
> 2 votes

---
Tags: ee2, ee2-upgrades
---


title: if conditions not working in JS

text:
# Question
Title: if conditions not working in JS
Why are my if conditions not working when they are inside a javascript but they work in plain html? the {if longitude} outputs {if""} when viewed in the browser.

```
{exp:user:users sort="asc" limit="100" group_id="5"}
{if longitude}
         {
            "properties": {
                "tags": [],
                "phone": "",
                "classifiers": ['a'],
                "address": "",
                "name": "{billing_name}",
                "province": "{billing_region}",
                "owner": "",
                "postcode": "",
                "city": "{billing_city}",
                "country": "{billing_country}"
            },
            "type": "Place",
            "geometry": {
                "type": "Point",
                "coordinates": [ {longitude},{latitude} ]
            }
        },
{/if}
{/exp:user:users}

```

# Answer
By default EE prevents the advanced conditional parser from processing anything between `<script>` tags. Try adding this config variable:

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

```
> 6 votes

# Answer
I think the case might be that the conditionals are being rendered by the js and not by EE. It wouldn't surprise me.
> 0 votes

# Answer
Strange anomaly, that I don't know if it still exists or not is that for this type of thing to work, I had to make sure that php error reporting was set to "1" for

```
jQuery(function(){
      options = {serviceUrl:'{site_url}utility/suggest_names'};
      a = $('#query').autocomplete(options);
    });

```

to work properly.
> 0 votes

---
Tags: conditionals, javascript
---


title: Maximal image width in Wygwam field

text:
# Question
Title: Maximal image width in Wygwam field
Is there any possibility to set a maximal width (or height) for the image selection modal window in wygwam?

# Answer
> 2 votes
Not sure about setting it to enforce prior to upload, but it can be enforced after the fact in-template using CE Image's bulk tag pair wrapped around your Wygwam custom field.

---
Tags: wygwam, image, assets
---


title: Super Admin Control Panel login issue

text:
# Question
Title: Super Admin Control Panel login issue
I have a strange issue login issue for super-admins. The site is up and running and all other users can login as normal but it hangs when ever a super-admin logins in. I have manually cleared the cache but to no avail . I am running expression engine 2.4.0

# Answer
> 0 votes
Thats for the feedback, upgraded to 2.6 and we ended up with more errors. Turned out the server admin had messed around with fastcgi on the server and once those changes were rolled back our upgrade worked ok.So a combination of the fast cgi fix and the upgrade solved our issue.

# Answer
> 0 votes
Is this a new issue? By chance, are you running NSM Addon Updater and any of P&T's add-ons? We had a similar-sounding issue with a number of our installs when P&T moved over to devot-ee -- SuperAdmins would be the only ones affected assuming they are the only ones you are letting see the NSM Addon Updater info. We disabled NSM Addon Updater and everything went back to normal.

---
Tags: control-panel, super-admin
---


title: Assets upload not displaying thumbnails

text:
# Question
Title: Assets upload not displaying thumbnails
I've recently uploaded a load of files to the assets folder in my file directory and indexed them via the control panel in the back end but i'm getting lots of transparent thumbnails instead of correct thumbs? Any ideas?

http://postimg.org/image/fpvy74mvh/

# Answer
> 2 votes
Make sure that you have a /system/expressionengine/cache/assets folder and that it is writable. Assets stores all the indexed thumbnails there. Also make sure that your system path settings match the url you are accessing the CP with. i. e. with or without the "www"

---
Tags: pixelandtonic, module, error
---


# Question
Title: RTE in safecracker submits form when clicking 'link' or 'quotes'
very strange behaviour when using the rich text editor in a safecracker form on the frontsite. Every works as expected except 2 buttons from the toolset: 'link' and 'quote'. When clicking these button, the safecracker form itself gets submitted.

Anyone? rg, Tim

# Answer
> 0 votes
Ok, I finally found what was causing this. 3 things that needed to be changed

1. 2 conflicting jQuery libraries were loaded on the same page. For the form to behave normal I needed to keep the one included in safecracker using the include\_jquery="yes" parameter and the other one was removed from the page
2. For some other functionalities on the site we load foundation.min.js - I needed to leave this out the form pages
3. And for cosmetic faults I needed to load at the top of the page

Hope that might help someone someday! T.

---
Tags: safecracker, richtext
---


title: Using mobile and CE cache together

text:
# Question
Title: Using mobile and CE cache together
It seems that mobile isn't compatible with CE Cache. Or the other way around. Can this be solved? When caching a page, you only see the desktop version of the template. The mobile template isn't loaded.

Thanks in advance! Diederik.

# Answer
You should be able to cache both versions with CE Cache. You just need to place a variable into the CE Cache id parameter that differentiates between the mobile and regular versions of the website. I haven't tested it but the following should work:

```
{exp:ce_cache:it id="page-{is_mobile}" seconds="3600"}

```

If the {is\_mobile} global variable doesn't work you could also try with {segment\_1}. According to the docs on devot:ee, it's meant to be prefixed with 'mobile\__'.

> Because of the lack of extension hooks during the stage where Mobile works its magic, I had to hack into the segment variables array to make this work. Because of that, when using native EE routing (not with Pages or Structure), {segment\_1} will also be prefixed with mobile\__ in the mobile templates.

I've done this on a Structure based site that used Zoo Triggers. Zoo Triggers overwrites the segment variables behind the scenes which means caching doesn't work for similar reasons. The code I used in that instance looked like this:

```
{exp:ce_cache:it id="news_index-{triggers:segment_2}-{triggers:segment_3}-{triggers:segment_4}" seconds="3600"}

```
> 1 votes

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


# Question
Title: Assets add file button not working (sometimes)
A user reported that when trying to add a photo in the control panel publish page it did not work. Clicking the "add file" button does nothing. I was able to verify that it did not work. I went to the Assets module settings and the file folders would not load any images. The waiting icon would just spin and spin.

Today I tried it again, and it did work. However she reported it still did not work for her. I again verified it worked. Now that I'm on a different computer (both of my are macs using safari and 10.8) it isn't working for me again. Opening the inspector I see this:

It used to work no problems, so this is new.

EE 2.5.3 Assets 1.1.5

# Answer
> 1 votes
Make sure you and your client are accessing admin from the correct URL.

**www.yoursite.com/admin.php** could be different from **yoursite.com/admin.php** (with no www) depending on your install.

LISA WESS (Pixel and Tonic) responded to a similar question:

You were seeing JS cross-site security blocking, due the lack of 'www'. Your domains need to be consistent to avoid that problem - not just with P&T add-ons, at that. You should ensure that your installation always uses either www, or no www. Consistency there should help you avoid running into this.

---
Tags: assets, pixelandtonic, javascript
---


title: Pre-Cache Template Base on URL

text:
# Question
Title: Pre-Cache Template Base on URL
I am working on a site that has an employees channel with over 1000 entries. When a user visits the "all employees" page we are paginating the results and all is well, however when a user views the print template for this page the client would like the full list of employees to be shown. When this template is loaded the request times out.

I have optimised the template as best I can (simple conditionals, etc) and tried upping the PHP execution time, but still no luck. I think the biggest killer to rendering is that we need to access a matrix and a playa field for each employee. If anyone has any advice on ways to get this page to load that would be greatly appreciated.

**EDIT: Updated with code sample**

```
{exp:channel:entries
    site="default_site"
    channel="employees"
    orderby="title" sort="asc"
    disable="categories|category_fields|member_data|pagination"
    limit="10000"
    entry_id="{alpha_ids}"
    cache="yes" refresh="720"
}
<tr>
    <td>{title}</td>
    <td>{p_position}</td>
    <td>{p_locations limit="1"}{office site="default_site"}{title}{/office}{/p_locations}</td>
    <td>{if p_locations}{p_locations limit="1"}{phone}{/p_locations}{/if}{if p_locations == ""}{p_phone}{/if}</td>
    <td>{p_email_address}</td>
</tr>
{/exp:channel:entries}

```

In this code snippet `{alpha_ids}` is the result of filters (in the case causing the issue, this contains all entries). `{p_locations}` is a matrix field. The columns in this matrix are `{office}` (playa single-select) and `{phone}` (text field).

# Answer
Thanks for your help, there are some excellent resources to consider when I have the time to dig in and figure them out.

In the end I got a solution similar to this working. Here is the code I have working now:

```
{exp:channel:entries
    site="default_site"
    channel="employees"
    orderby="title" sort="asc"
    disable="categories|category_fields|member_data|pagination"
    limit="10000"
    entry_id="{alpha_ids}"
    cache="yes" refresh="720"
}
<tr>
    <td>{title}</td>
    <td>{p_position}</td>
    <td>
        {exp:playa:children
            site="default_site"
            field="p_locations"
            col="office"
            limit="1"
            disable="custom_fields|categories|category_fields|member_data|pagination"
        }
            {title}
        {/exp:playa:children}
    </td>
    <td>
        {if p_locations}{p_locations limit="1"}{phone}{/p_locations}{/if}
        {if p_locations == ""}{p_phone}{/if}
    </td>
    <td>{p_email_address}</td>
</tr>
{/exp:channel:entries}

```

Basically, the change just reduces a call to Matrix and skips straight to pulling the Playa data.
> 0 votes

# Answer
That's a lot of entries to load for sure. I've done something like this once before with map data, but the solution may be the same for you. Assuming that your template is as optimized as it's going to get, you may need to cache and retrieve the "all" list in chunks - that's what I had to do for my map data. I did it using Solspace Template Morsels. It allowed me to chunk up my list into manageable groups (distinct entries loops with start and end points), cache them (a bunch of options for how long to cache and under what conditions to break the cache), and then assemble them into the single template. On top of that, you could cache the "assembled" template as well.
> 1 votes

# Answer
Try CE Cache http://devot-ee.com/add-ons/ce-cache. Very easy to implement. I had a matrix/playa "problem" and CE Cache sped up the page incredibly.
> 0 votes

---
Tags: channel-entries, templates, matrix, playa, optimization
---


# Question
Title: Freeform: submit results in system error message without a message
weird problem. I have a website with freeform that suddenly broke. When you submit a form a basic ExpressionEngine error message is shown but without an error message.

After discovering the problem i upgraded the system from ee2.3.1/freeform3.1.5 to ee2.6.0/freeform4.0.12 but the exact same problem keeps happening. I've already stipped down a test form to the bare minimal but that doesn't change anything.

```
{exp:freeform:form
    form_name="adwords"
    return="homepage/verzonden"
}
    <label>E-mail</label>
    <input type="text" name="email"/>
    <button type="submit">Verzenden</button>

{/exp:freeform:form}
```

Anybody got a clue where to look next?

# Answer
The great people of solspace took a look at my systems and found the error.

It was caused by me using the Low NoSpam add-on. It was causing an error without outputting an error message. Disabling the add-on restored functionality.
> 1 votes

# Answer
So the big question is, What changed before it broke?" ,htaccess? new server? Are you getting any php errors? Any console errors? This is not an error I have seen before. Any chance I can get a CP login and ftp access to your site? support att solspace dott com
> 0 votes

---
Tags: error, solspace-freeform, system-messages
---