title: If statement within channel tag

text:
# Question
Title: If statement within channel tag
Does anyone know if something like this is possible:

```
{exp:channel:entries channel="choices_events|jobs-opps" show_future_entries="yes" show_expired="no" disable="trackbacks" orderby="date_time|job-start-date" sort="asc" paginate="bottom" status="open" dynamic="no" parse="inward" {if channel_short_name == "jobs-opps"}category="258"{/if}

```

So I've got 2 channel entries that I want to list 'choices\_events' and 'jobs-opps'. If the entries are under 'jobs-opps' I only want to display the 'jobs-opps' within the category '258'.

The above code isn't working for me at the moment.

Julie

# Answer
There's 2 issues here, the first is using a conditional inside the tag parameters, the second is as @Siebird has mentioned, you can't reference {channel\_short\_name} outside of the channel entries tag pair.

One solution as @Siebird mentioned is to use a segment, which would be preferable, the other is to do another channel entries but that would only work for the embedded approach. For the conditional answer, I've referenced {channel\_short\_name} which obviously won't work, but I've given a complete solution at the bottom.

Two possible ways that come to mind to resolving the conditional, the duplicate:

```
{if channel_short_name == "jobs-opps"}
    {exp:channel:entries channel="choices_events|jobs-opps"
        show_future_entries="yes" show_expired="no"
        disable="trackbacks" orderby="date_time|job-start-date"
        sort="asc" paginate="bottom" status="open" dynamic="no"
        parse="inward" category="258"}
    ...
    {/exp:channel:entries}
{if:else}
    {exp:channel:entries channel="choices_events|jobs-opps"
        show_future_entries="yes" show_expired="no"
        disable="trackbacks" orderby="date_time|job-start-date"
        sort="asc" paginate="bottom" status="open" dynamic="no"
        parse="inward"}
    ...
    {/exp:channel:entries}
{/if}

```

Not great!

Or the embed (which is what I tend to use in this instance):

In the template (or ideally if it has a parent template) have the conditional and the embed...

```
{if channel_short_name == "jobs-opps"}
    {embed=template-group/my-embed category="category='258'"}
{if:else}
    {embed=template-group/my-embed category=""}
{/if}

```

Then in the embedded template (template-group/my-embed) used for both has the following...

```
    {exp:channel:entries channel="choices_events|jobs-opps"
        show_future_entries="yes" show_expired="no"
        disable="trackbacks" orderby="date_time|job-start-date"
        sort="asc" paginate="bottom" status="open" dynamic="no"
        parse="inward" {embed:category}}
    ...
    {/exp:channel:entries}

```

Note the embedded variable passing the category parameter.

To resolve the {channel\_short\_name} issue, simple wrap the first template in the channel entries tag pair:

```
{exp:channel:entries channel="choices_events|jobs-opps" disable="trackbacks"
    status="open" dynamic="no" limit="1"}
    {if "{channel_short_name}" == "jobs-opps"}
        {embed=template-group/my-embed category="category='258'"}
    {if:else}
        {embed=template-group/my-embed category=""}
    {/if}
{/exp:channel:entries}

```

You will need to tweak the parameters a little, as it's not obvious as to what you're outputting on what URLs, you're listing multiple entries, but unknown if these could be from both channels at the same time, or separate channels depending on the URL. so currently the parent is limited to 1 loop, whereas the embedded templates will loop through everything.
> 1 votes

# Answer
It is, if you're using a global, segment or embed variable. `{channel_short_name}` is a single variable tag within the channel entries tag.

Is it possible to use a conditional based off the `{segment_X}`?

```
{exp:channel:entries
    channel="choices_events|jobs-opps"
    show_future_entries="yes"
    show_expired="no"
    disable="trackbacks"
    orderby="date_time|job-start-date"
    sort="asc" paginate="bottom"
    status="open"
    dynamic="no"
    parse="inward"
    {if segment_2 == "jobs-opps"}category="258"{/if}
}

```
> 2 votes

# Answer
I think, you can do it without having if condition within the channel entry tag by just having NOT with all the categories except 258 of that channels category group like:

```
{exp:channel:entries
    channel="choices_events|jobs-opps"
    show_future_entries="yes"
    show_expired="no"
    disable="trackbacks"
    orderby="date_time|job-start-date"
    sort="asc"
    paginate="bottom"
    status="open"
    dynamic="no"
    category="not 250|251|252|253|254|254|255|256|257|259"}

```

I understand there may be a number of categories with NOT but you can reduce it by having category\_group="not 1|2|3" parameter.
> 0 votes

---
Tags: channel-entries
---


# Question
Title: Other module tags inside tag data causing issue
I am creating a small plugin, and am having an issue. I am using Carthrob for my e-commerce, and want to take some information into the tag data for my plugin.

My tag is the following:

```
{exp:submission_data:details cart_entries="{exp:cartthrob:cart_items_info}{entries}x{quantity},{/exp:cartthrob:cart_items_info}"}

```

The code within the tag data is outputting:

> 4x1,2x3,1x4,

Here is the part of the my plugin:

```
$tagdata = $this->EE->TMPL->tagdata;

$cart_entries = $this->EE->TMPL->fetch_param('cart_entries');

$cart_entries_total = 0;
$explode = explode(",", $cart_entries);

foreach ($explode as $explodeSegment) {
    if (trim($explodeSegment) != "") {
        list($amount, $quantity) = explode("x", $explodeSegment);
        $cart_entries_total += ((int)$amount * (int)$quantity);
    }
}

```

Currently this is returning 0, instead of 14.

If I add the data (4x1,2x3,1x4,) manually, it outputs the correct number.

I am guessing this is something to do with the CT tags in the tagdata.

Do I need to remove them in the code? how, or is there another solution?

Thank you.

# Answer
> 1 votes
Try adding parse="inward" to the exp:submission\_data:details tag.

---
Tags: php, module, plugin
---


# Question
Title: using exp:stash:get as filtered category returns no results despite exp:stash:get returning a result
```
{exp:channel:entries dynamic="no" category="{exp:stash:get name="current_category_id"}"}
    content
{/exp:channel:entries}

```

returns no results. However,

```
{exp:channel:entries dynamic="no" category="1"}
    content
{/exp:channel:entries}

```

returns the expected results, and

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

```

returns `1`.

It seems to me that the first example should work. What am I missing?

Edit: here is how the stash is set. Apologies for its being somewhat contorted. segment\_2\_category\_id is powered by seg2cat.

```
{exp:stash:set name="current_category_id"}
{if {segment_2_category_id} == "91"}91
{if:elseif {segment_2_category_id}=="90"}90
{if:elseif {segment_2_category_id}=="4"}4
{if:elseif {segment_2_category_id}=="3"}3
{if:elseif {segment_2_category_id}=="2"}2
{if:else}1{/if}{/exp:stash:set}

```

# Answer
Well from the looks of it you don't really need to use Stash at all. If you use something like Low Seg2Cat or URL Helper you can just pull in `{segment_2_category_id}` straight into your Channel Entries tag as the parameter value:

```
{exp:channel:entries dynamic="no" category="{segment_2_category_id}|1"}
    content
{/exp:channel:entries}

```

With regards to the Stash issue however it's to do with parse order as you're including several complex conditionals in your template. Stash provides several ways to circumvent the parse order but in this case you can greatly simplify your conditional logic to use either simple conditions (just if's - no elseif's).
> 2 votes

# Answer
You have to set parse as "inward" and to pay attention to quotation marks.

```
{exp:channel:entries dynamic="no" category="{exp:stash:get name='current_category_id'}" parse="inward"}
    content
{/exp:channel:entries}

```
> 0 votes

---
Tags: channel-entries, categories, stash, channel, low-seg2cat
---


title: Can I add a default category to images?

text:
# Question
Title: Can I add a default category to images?
In channels you can define a default category to added entries, and I'd like to do something similar for added images.

This is a Safecracker File field (using Safecracker to upload).

Thanks for any help!

# Answer
I don't think, there is such a feature for assigning a default category to updated image from channel entry. Although, a category can be assigned to image in File Manager while editing it.

Your need can be fulfilled by developing an extension using the hook "entry\_submission\_end" which will assign a default category to uploaded image.
> 1 votes

---
Tags: image, categories, safecracker-file
---


# Question
Title: How to clear EE native cache and CE Cache
I have got a site that has both EE caching applied and CE Cache module. I have updated the html mark-up in the template but my changes aren't showing through.

There are several cache parameters for EE tags which I have set to one minute. I have reloaded the pages couple minutes later and still have the old version.

Also, I have set CE cache module tag that's wrapped around the template ({exp:ce\_cache:it id="page" seconds="1"}) to one second and have cleared the "Clear Driver Site Cache" in the admin/control panel.

Anything else am suppose to be doing?

Thanks

# Answer
> 1 votes
You can clear EE cache from Control Panel -\> Tools -\> Data -\> Clear Caching.

For CE Cache:

Go to CE Cache module settings. Click "View Items" next to either File or Database driver (the method of cache store, usually File). Here you can clear the cache by clicking "Delete Children".

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


# Question
Title: Expresso-store: How do I show a button if the cart has items in?
I'm using this to check if there is anything in the cart, but it throws an error on the front end. Is there a different ay to do this?

{exp:store:cart} {if items}Go to Order Form{/if} {/exp:store:cart}

The error: Message: Array to string conversion Filename: libraries/Functions.php Line Number: 2584

# Answer
> 1 votes
Just needed to use {items}{/items}.

# Answer
> 1 votes
You can also use `{no_items}` to check if the cart is empty:

```
{exp:store:cart}

    {if no_items}
        Your cart is empty!
    {/if}

    Your cart: {order_qty} items - {order_total}

{/exp:store:cart}

```

---
Tags: expresso-store
---


title: Can snippets contain PHP?

text:
# Question
Title: Can snippets contain PHP?
The documentation says:

> Snippets are expanded at a very early stage on each template, making it possible for them to hold dynamic content, ExpressionEngine tags, other variables, **PHP**, etc.

The evidence seems to run contrary to that statement.

Can PHP be used in a snippet as it can in an embed when enabled?

The scenario: I have Google Analytics and other tracking code in a snippet. I want to wrap it in a simple PHP conditional to check for the live site URL, so I'm not hitting that code in my development/staging environment.

Thanks!

Mark

# Answer
> 4 votes
Yes, as long as the template in which you put the snippet has PHP enabled.

---
Tags: php, snippets
---


title: trouble with basic conditional

text:
# Question
Title: trouble with basic conditional
I can't figure out why this conditional does not work. It is a dropdown navigation item in my main nav.

```
    <ul>
    {exp:channel:entries
        channel="locations"
        orderby="date"
        sort="asc"
        dynamic="no"
        disable="categories|category_fields|member_data|pagination"
    }
        <li{if segment_2=='{url_title}'} class="on"{/if}><a href="{url_title_path='contact'}" title="">{title}</a></li>
    {/exp:channel:entries}
    </ul>

```

I know segment\_2 is the same as the entry's url\_title.

Any help is appreciated.

# Answer
Force the conditional to be parsed after the exp:channel:entries module.

```
<ul>
{exp:channel:entries
    channel="locations"
    orderby="date"
    sort="asc"
    dynamic="no"
    disable="categories|category_fields|member_data|pagination"
}
    <li{if "{segment_2}" == "{url_title}"} class="on"{/if}><a href="{url_title_path='contact'}" title="">{title}</a></li>
{/exp:channel:entries}
</ul>

```
> 1 votes

---
Tags: conditionals
---


title: products like this

text:
# Question
Title: products like this
Does Exp:resso Store offer "Related Products"? An example would be on the page for a Micheal Jackson CD. Is there a built in logic that displays recommendations "You might like Janet Jackson". If so, can you send me a link with more information on this functionality? Thanks!

# Answer
> 3 votes
In Store products are just regular channel entries so you can use any of the regular relationship methods used in EE to relate them. Although there is no ready-made way of adding a "you may also like..." feature it's fairly easy to add with EE right out of the box.

In addition to using categories to relate products that Iain mentioned, EllisLab have completely revamped this area in EE 2.6+. You can read about it on their blog or in the documentation. Both provide some useful examples.

If you're using an older version of EE than Playa has been a loyal companion for many years and filled the gap prior to EE 2.6. You may still prefer to use that over EE's default relationship handling.

# Answer
> 1 votes
Not sure about Expresso store but natively in EE if you are using categories for your products, you could take a look at the related\_categories\_mode parameter on the channel:entries tag.

That will show entries filed under the same category as the current single entry being viewed.

Another alternative would be to use tagging for your products, using something like Solspace Tag. That has a related\_entries tag which will display entries tagged similarly to the currently viewed entry.

Hope that helps.

---
Tags: expresso-store
---


title: Expresso Store Promo Code Use In Email?

text:
# Question
Title: Expresso Store Promo Code Use In Email?
Can I use a promo code variable in the email for new orders? The client would like to be notified of the promo code used in the email itself, which gets bcc'ed to them as well as the buyer. Something like this:

```
Order Id    - {order_id}
Order Total - {order_total}
Voucher (if used): {promo_code}

```

# Answer
Yes you can include the `{promo_code}` and `{promo_value}` in your email templates if you want to. If you want to show the total discount on the order then use `{order_discount}`.
> 1 votes

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


# Question
Title: change expresso store field with safecracker
i want to change the price field from frontend , actually im templating like this but seems DONT WORK... any help will be appreciate!!

```
{exp:safecracker channel="MY_CHANNEL" return="/PATH"  entry_id="{segment_3}"}

{exp:store:product entry_id="{entry_id}"}
    <td><input type="text" name="price" id="price" value="{price}" ></td>
        <td><input type="text" name="sku" id="sku" value="{sku}" ></td>
{/exp:store:product}
<input type="submit" name="submit" value="Submit">

{/exp:safecracker}

```

# Answer
> 1 votes
You can't use the `{exp:store:product}` tag inside an `{exp:safecracker}` tag, they do totally different things (the product tag is for creating add to cart forms).

You want something like this:

```
{exp:safecracker channel="MY_CHANNEL" return="/PATH"  entry_id="{segment_3}"}
    {field:product_details}
    <!-- (or whatever you named your product details field) -->
{/exp:safecracker}

```

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


# Question
Title: Structure-like behavior from Channels/Relationships (EE 2.6.1)
Some of my clients need to add what I would call "ad-hoc" pages to their sites. As many have pointed out, this is (a) somewhat contrary to the spirit/concept of EE channels and (b) when necessary, arguably best handled by the Structure module.

On a new project I'm considering skipping Structure and incorporating two channels: one called Pages and another called Sub-Pages. Both channels would have generic `{main_content}` and `{sidebar_content}` fields, but Sub Pages would have a `{page_assignment}` relationship field to subordinate the page to an existing Page.

How would you output a dynamic navigation of titles/links with unordered lists, adding active classes as appropriate? To save space, Sub Pages belonging to a Page should only be listed when that Page or sibling Sub Pages are active. In other words, you have to "click into" a Page to see its Sub Pages.

So if I'm on the Products landing page or the Products 1 sub page, the nav should look like:

```
Products
    Product 1
    Product 2
    Product 3

About the Company

Services

```

But if I'm on the About the Company landing page or the Our History sub page, it should look like:

```
Products

About the Company
    About Our Team
    Our History

Services

```

# Answer
> 3 votes
> @James Right, I really do understand that argument, but at the same time the "streams of content" philosophy requires knowing quite a lot about content before it is ever created.

Yep, you're absolutely right there. Most EE sites I've made usually end up with a generic 'Pages' channel, but I always try to drill home that it needs to be for exceptional one-off circumstances. (I'm running Structure on one site and it's a complete mess because the client is defining their own IA. They probably like the power they have, but the site suffers).

For setting up a Pages channel I usually use the native Pages module and explain that by default their 'page' will be available at site.com/pages/\[url\_title\] but that they can override/clean up this url to be whatever they like by completing the Page URI field. (There's an add-on somewhere that automatically fills in the Pages URI field with the url\_title on save, but I can't find it at the moment)...

I create a generic Pages template (template group in fact), and point the Pages module's default settings for the pages channel to use that template, then I always hide the template selector in the publish screen (using Publish Layouts) so the client can't choose which template gets used.

Then 6 months later I come back and find 100s of 'pages' that should have been 'events' or 'conferences' or 'products' or anything else and I'm a little bit sick in my mouth.

# Answer
> 1 votes
This seems to be a great role for NavEE. As you can see in my post (thanks for the link, BTW) I'm a fan of NavEE because it accomplishes much of the good stuff about Structure (easy nav menus) without abandoning the EE philosophy.

You could have a NavEE fieldtype associated with those two channels whereby the client could create nav links, and NavEE's template tags allow for the dynamic collapsing sub-menus you're looking for.

# Answer
> 0 votes
Ok, this is the closest I've gotten. It's pretty gross. The main bug so far is that when viewing the home page (`{site_url}`), the first top-level Page is "expanded," showing its sub-page links, even though you would think `{segment_3}` doesn't exist and therefore `$active_parent` should be empty.

Keep in mind my concept of parents/children is the opposite of the EE terminology for some reason.

```
    <nav>
    <ul>
        {!-- if we're on a sub_page, retreive and store its parent top-level page  --}
        <?php $active_parent = ""; ?>
        {exp:channel:entries channel="sub_pages" url_title="{segment_3}" limit="1" dynamic="no"}
        <?php $active_parent = '{page_assignment}{page_assignment:url_title}{/page_assignment}';?>
        {/exp:channel:entries}

        {!-- begin loop of top-level pages --}
        {exp:channel:entries channel="pages" limit="99" dynamic="no"}

            {!-- store this entry's url_title --}
            <?php $this_title = "{url_title}";?>
            {!-- get its child sub_pages --}
            <?php unset($this_child_array); ?>
            {parents field="page_assignment"}<?php $this_child_array[] = "{parents:url_title}"; ?>{/parents}

        {!-- show top-level pages --}
        <li <?php if ( ("{segment_3}" == "{url_title}") || (in_array("{segment_3}", $this_child_array)) ) { ?> class="primary-active"<?php } ?>>
            <a href="{comment_url_title_auto_path}">{title}</a>

            {!-- show any sub-pages under each top-level page if (a) that top-level page is active or (b) one of its sub-pages is active  --}
            <?php  if ( ("{segment_3}" == "{url_title}") || ($active_parent == "{url_title}") )  {  ?>
            {parents field="page_assignment"}
                {if '{parents:count}' == '1'}<ul>{/if}
                    <li{if "{segment_3}" == "{parents:url_title}"} class="sub-active"{/if}><a href="{parents:comment_url_title_auto_path}">{parents:title}</a></li>
                {/parents}
                {if '{parents:count}' == '1'}</ul>{/if}

                <?php } ?>

    </li>

    {/exp:channel:entries}

    </ul>

</nav>

```

---
Tags: php, structure, navigation, pages
---


# Question
Title: Combining categories within channel tag category parameter
This is my code:

```
{embed="jobs-opportunities/.main_job_list" cats="14&85|14&240"}

```

You'll see I'm trying to list entries that are either from 1 set of categories or another. I feel the above should work but it doesn't. It doesn't work when I put it into the channel entries tag either, rather than an embed.

Does anyone know if this is possible?

Thanks, Julie

# Answer
You can't use both operators on channel:entries module. Try Dandy Cat, that allows you to use "(14&85)|(14&240)".
> 1 votes

# Answer
I don't believe so. The inclusive `&` operator in the `category` parameter will return entries with all the categories, but it looks like you can't use that along with stacking `|`
> 0 votes

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


# Question
Title: EE 1.7.0 cookie and login issue (disallowed key characters)
Quite out of the blue on a client site running 1.7.0, all pages loaded after the initial visit rendered the dreaded "Disallowed Key Characters" message.

Upon some investigation, I determined it was the **exp\_tracker** cookie that was triggering this. Its value is being set to `a%3A1%3A%7Bi%3A0%3Bs%3A5%3A%22index%22%3B%7D` (as an example), which is not passing the Input class' `clean_input_keys()` function, triggering the error.

So, why this crazy value for the `exp_tracker` cookie, and why all-of-a-sudden? It continues to get set like this. For now my fix is to comment-out the filtering of the `$_COOKIE` array.

But, possibly related, I can also no longer login to the control panel - with or without the cookie filtering removed. I log-in, my session ID is set, but I just immediately return to the login screen, no error.

Are these related? Anyone seen this before?

# Answer
This ended up being resolved via EllisLab support:

> I'm fairly sure the Suhosin Extension installed on your PHP installation is running the cookie values, or HTTP headers as a whole, through a filter and potentially removing anything that looks suspicious (like encoded semicolons) and it's also filtering the whitespace as we can see from the inserted underscores.

A support request to the host (Dreamhost) resolved this.
> 1 votes

# Answer
Well once you run that through a URL decoder you can see it's just serialized data being URL encoded for some reason. One of my clients' EE 1.7.1 site has similar serialized data being stored, just not URL encoded, so the serialization aspect is a-ok.

All-of-a-sudden changes like this I find can sometimes be traced back to the webhost updating PHP or Apache versions or the like. It's worth asking them if any such updates were made recently.

Also, since this is apparently a cookie issue, is it replicable in other browsers/platforms?

(I would have posted this as a comment instead of an answer, since it's not really an answer, but the rep system isn't allowing me to comment on things yet... :-/ )
> 2 votes

---
Tags: ee1, login, cookies
---


# Question
Title: How to export EE1 entries and comments and re-import them to another EE1 install?
Is there an add-on that makes this fairly easy to accomplish? We'd only like to export/import blog entries and the field groups are identical on both EE installs.

# Answer
I would look into using the following EE 1.x compatible addons.

Import Data Into ExpressionEngine

CSV Grab

Feed Grab

The third option is probably the easiest as all you'd need to do is set up an RSS feed in your existing site and then point to it on your new site following the documentation.
> 1 votes

# Answer
I don't think there's any addon out there for such a purpose and I'm not sure I'd trust it entirely if there was in comparison to grabbing the data from the database directly.

I can't remember the EE1 DB schema but they should be fairly easy to get to. In EE2 all your channel data is listed in `exp_channel_*` and comments in `exp_comments`. Possibly also `exp_comment_subscriptions` if there are any. It should follow a similar suit in EE1 so you can export the data from those tables and import into your new database. Just double check if you have any addons in use which may link into channel entries and be sure to install those wherever it's being moved to and grab their data too.
> 1 votes

---
Tags: ee1, import, export
---


title: GWCODE CATEGORIES - Channel entries

text:
# Question
Title: GWCODE CATEGORIES - Channel entries
I am trying to display a series of entries ordered by subcategories using a category segment

```
{exp:gwcode_categories cat_id="{last_segment_category_id}" last_only="yes" style="linear"}
<h2>{cat_name}</h2>
{exp:channel:entries dynamic="yes" channel="work" status="not Closed" sort="asc" category="{cat_id}"}
{title}
{/exp:channel:entries}
{/exp:gwcode_categories}

```

But I can only get the cat\_names to appear, I cannot get the entries to appear.

# Answer
> 2 votes
I never used this addon, but looks like a parsing order issue. Set the parameter parse to "inward".

```
{exp:gwcode_categories cat_id="{last_segment_category_id}" last_only="yes" style="linear" parse="inward"}
    <h2>{cat_name}</h2>
    {exp:channel:entries dynamic="yes" channel="work" status="not Closed" sort="asc" category="{cat_id}"}
        {title}
    {/exp:channel:entries}
{/exp:gwcode_categories}

```

---
Tags: categories
---


title: Target Every Other Matrix Row

text:
# Question
Title: Target Every Other Matrix Row
I'm using EE to light up a HTML email template, so, not surprisingly, I've had to resort to some trickery to get the layout working in Outlook.

Basically, I have a table, and I need a cell in the table to alternate between the left and right side for every other matrix row:

```
{my_matrix_field}
    <table cellpadding="0" cellspacing="0" border="0" width="210" align="{switch='left|right'}">
        <tr>
            {if row_count:even}
                <td width="10"></td>
            {/if}

            <td width="200">
                <img src="{image}" alt="{alt}" width="200" height="200" />
            </td>

            {if row_count:odd}
                <td width="10"></td>
            {/if}
        </tr>
    </table>
{/my_matrix_field}

```

Possible?

# Answer
Try to use multiple switch tags.

```
{my_matrix_field}
    <table cellpadding="0" cellspacing="0" border="0" width="210" align="{switch='left|right'}">
        <tr>
            {switch='|<td width="10"></td>'}
            <td width="200">
                <img src="{image}" alt="{alt}" width="200" height="200" />
            </td>
            {switch='<td width="10"></td>|'}
        </tr>
    </table>
{/my_matrix_field}

```
> 4 votes

---
Tags: matrix, html-email
---


# Question
Title: Wygwam better source view using CodeMirror
I've been trying to integrate CodeMirror code editor into Wygwam's source view without much success. I have tried using the "wygwam\_config" hook as well as adding a config.js file to Wygwam's advanced settings configuration screen which is supposed to enable the code mirror plugin.

Basically I would like this plugin to override the native source view: http://ckeditor.com/addon/codemirror

Is this possible?

# Answer
That plugin looks like it's for CKEditor 4. Wygwam uses CKEditor 3. I'm not sure if plugins from one version work with the other.
> 1 votes

---
Tags: wygwam
---


# Question
Title: Does Exp:resso Store have Google Analytics Ecommerce tracking ability built in?
Does Exp:resso Store have out of the box support for Google analytics ecommerce tracking (like Magento)?

More details: https://developers.google.com/analytics/devguides/collection/gajs/gaTrackingEcommerce

# Answer
Yup. The full documentation is avilabe at https://exp-resso.com/docs/store/settings\_conversion\_tracking.html
> 1 votes

---
Tags: expresso-store
---


# Question
Title: need to create v1.7.x plugin for pulling data from an oci8 database into template
I've used oci8 databases in CodeIgniter applications in the past, but before I have never connected to a database in EE plugins I have written in the past.

I imagine I could use the database class to connect and query the oracle (oci8) database to return the data to the template.

I have always set up the database settings in the db config file of my CodeIgniter instance. I am unsure of what to do when trying to set the db connection within the plugin code. I need a push start. Any help is appreciated. Thanks.

# Answer
I have multiple functions in the plugin I created, but I'll just include one, for simplicity.

For usage in the template:

{exp:banner\_courses:list\_all\_courses term\_code="201340"}

This returns all courses within the term of 201340

You'll notice it calls a private function get\_course\_listing "$this-\>get\_course\_listing()", that retrieves all courses that relate to the subject. That isn't really important.

The meat and potatoes of getting yourself up and running with retrieving data from an oracle database is in the construct

```
<?php

$plugin_info = array();

class banner_courses {

  var $return_data;

  function __construct() {
    $this->db = '(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=host.name)(PORT=1521))(CONNECT_DATA=(SID=instance.name)))';
    $this->conn = oci_pconnect('username', 'password', $this->db);
  }

  function list_all_courses()
  {
    global $TMPL, $FNS;

    $term_code = ( ! $TMPL->fetch_param('term_code')) ? FALSE :  $TMPL->fetch_param('term_code');

    if(!$term_code)
            return $this->return_data = '';

        $subject_query = oci_parse($this->conn, "SELECT DISTINCT SUBJECT_DESC, SUBJ_CODE FROM szvcourses WHERE TERM_CODE = :term_code ORDER BY SUBJECT_DESC");

        oci_bind_by_name($subject_query, ":term_code", $term_code, 6);

        oci_execute($subject_query);
        oci_fetch_all($subject_query, $subjects);

        $i = 0;
        $count = count($subjects['SUBJECT_DESC']);

        $course_listing = '';

        while($i < $count):
            $course_listing .= $this->get_course_listing($term_code, $subjects['SUBJ_CODE'][$i]);
            $i++;
        endwhile;

        return $this->return_data = $course_listing;
  }

}
?>

```
> 0 votes

---
Tags: add-on-development, database, plugin, ee1
---


title: Template issue when Strict URLs enabled

text:
# Question
Title: Template issue when Strict URLs enabled
I have a problem with one template after enabling Strict URLs - it returns 404 instead displaying content from the channel named News. The URL to open that template is like http://www.mydomain.com/index.php/news/

Template code:

```
    {embed="includes/header_main"}
    {embed="includes/header_two_column"}
<div id="wrapper">
  <div id="content">
            <div id="content_main">
                      {if segment_2 == ''}
                         {exp:channel:entries channel="news"}
                            <h1 class="orange">{title}</h1>
                            {news_summary}
                            <a href="/index.php{page_uri}">Read more</a>
                            <br /><br /><br />
                         {/exp:channel:entries}
                    {if:else}
                         {exp:channel:entries channel="news"}
                            <h2 class="bigorange">{title}</h2>
                            {news_body}
                            <p><a href="/index.php/nm">Back to news</a></p>
                         {/exp:channel:entries}
                    {/if}
                    </div>
            <div id="content_sub_buttons">
                <div style="background-image: url(/uploads/images/doc_photo.png); width:212px; height: 199px;">
                <div style="padding-top: 12px; padding-left: 15px;">
                {exp:ce_cache:escape}
                {exp:random_number min="1" max="6"}
                <img src="/uploads/images/kids/{random_number_0}.png">
                {/exp:random_number}
                {/exp:ce_cache:escape}
                </div>
                </div>
            </div>
            <div class="clear"> </div>
        </div>
        {embed="includes/footer"}

```

Any clue why is not loading that template?

Thanks

# Answer
Strict URL is working exactly how it is supposed to for you. From the EE blog:

> With Strict URLs disabled, it’s possible to visit http://example.com/about-us/ and view that content. But you can also visit http://example.com/site/about-us/ and get the exact same content. This flexibility can be advantageous, but it comes with a price: dual availability can cause search engines to lower the content’s ranking.
>
> With ExpressionEngine 2.6 and up, Strict URLs will be enabled by default in new installations. Using the same example, http://example.com/site/about-us/ is the only valid URL for that content. Visiting http://example.com/about-us/ with Strict URLs enabled will trigger ExpressionEngine’s defined 404 behavior.

If you have `site/news` as a template and strict URLs enabled, you can't access the news template with `index.php/news`. You have to have `index.php/site/news`.

**UPDATE**

Can you see if this does anything for you? Change your complex conditional to two simple conditionals:

```
{if segment_2 == ''}news home{/if}
{if segment_2 != ''}news listing{/if}

```
> 1 votes

# Answer
In your example of `http://www.mydomain.com/index.php/news/` you need to make sure that `news` is set as you default template group and that it contains a template called `index`. Otherwise you have to explicitly declare the template\_group/template in the URL.
> 0 votes

---
Tags: ee2, templates, channel
---


# Question
Title: Category Filtering from two groups - relationships (?)
Does anyone know a way to create a category based naviagation which has two category groups that need to relate to each other in order to build out a basic list?

I have channel with two category groups assigned to it:

* Type
* Brand

I then have categories in said groups like so:

* Type

+ Guitar
    + Amplifier
* Brand

+ Guitar Brand 1
    + Guitar Brand 2
    + Amplifier Brand 1
    + Amplifier Brand 2

Now, I'd like to display a list of categories from the Brand category group. That of course is easy but, I'd like to filter that by each of the Type group categories as well.

For example: I'd like to display a list of Brands which, based on my above example cats, would display Guitar Brand 1 and Guitar Brand 2 as those are both guitars and have been assigned the Guitar category as well. I'm filtering Brands categories based on the Type (Guitars in this case).

Note: this is a global navigation so there isn't anything I can do with URLs.

Any ideas on an approach? Is this even possible with native EE? Any add-ons which would make this possible?

Thanks for your input and ideas!

# Answer
> 1 votes
If I understood you right, I think it's easier to setup your categories this way:

* guitar
    + guitar brand 1
    + guitar brand 2
* amplifier
    + amplifier brand 1
    + amplifier brand 2

This way, you can filter them by its parent categories.

---
Tags: relationships, filter, categories, category-group
---


# Question
Title: linking to admin from the main site - session parameter
I want to provide admin links from the main site for clients, however within the admin URL there is the session parameter.

Is there a way to output the admin url path that includes the dynamic session parameter? Alternatively i can switch the session ID off in security settings but thats a second preference.

Any ideas?

# Answer
It is possible, but the mechanism for generating session IDs changed for EE 2.6, so if you want to retain compatibility with 2.5 and under (as I did) you need to add in a quick `version_compare` check.

Here's the snippet that I'm using with Missing Link.

```
$sess_type = $this->EE->config->item('admin_session_type');
$session_id = ($sess_type == 'c') ? '0' : $this->userdata['session_id'];

if (version_compare(APP_VER, '2.6.0', '>=') AND $sess_type == 'cs')
{
 $session_id = $this->userdata['fingerprint'];
}

```

That should give you an accurate `$session_id` no matter which EE version or session type is in use.

I'd strongly recommend creating a plugin for this, if you haven't already, as PHP in templates is a Bad Idea.
> 3 votes

# Answer
No, there's no native way to output the admin URL path with a dynamic session preset. You will have to have cookies turned on and include `S=0&` right after the `?` in URL.
> 0 votes

---
Tags: sessions, admin
---


# Question
Title: Using code accross multiple functions in a plugin
I am new to plugin development, so sorry for this most likely very easy question.

In a plugin, where can I store variables and queries that will be used accross multiple functions?

Example of Private:

```
private function uploadsQuery() {

    $member_id = $this->EE->session->userdata('member_id');

    $sql = "
        SELECT COUNT(t.author_id) AS current_uploads, c.upload_total AS upload_total
        FROM exp_competition_purchase_upload_total AS c
        LEFT JOIN exp_channel_titles AS t ON c.member_id = t.author_id AND t.channel_id = '4'
        WHERE c.member_id = $member_id
    ";

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

}

public function details() {

    return $this->uploadsQuery();

    $data = $query->result_array();

    return $this->EE->TMPL->parse_variables( $this->EE->TMPL->tagdata, $data );

}

```

# Answer
If they are static variables, you could store them in the construct and refer to them like this:

```
function __construct()
{
  $this->var1 = "data";
  $this->var2 = "data";
  $this->query = "select * from table";
}

function getVar1()
{
  return $this->var1;
}

function getVar2()
{
  return $this->var2;
}

// below has not been tested, but it should give you an idea
function getResults()
{
  //load db lib
  $q = $this->query($this->query);

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

  return $q->result_object();
}

```

Or you could have private functions that you refer to in all of your functions.

```
private function nameQuery()
{
  // return data
}

function getName()
{
  return $this->nameQuery();
}

```

I have updated my original post with a revised version of the code you updated your posted with.

The first return you had in your details function will just return that and ignore the rest of the function.

You want to return the data retrieved from the uploadsQuery function, so you need to return that data in that function.

Then you want to store that data into your $data variable as seen in the details function, to be passed into the parse\_variables function.

I can't say this works for sure, but it'll give you a push in the right direction

```
private function uploadsQuery() {

    $member_id = $this->EE->session->userdata('member_id');

    $sql = "
        SELECT COUNT(t.author_id) AS current_uploads, c.upload_total AS upload_total
        FROM exp_competition_purchase_upload_total AS c
        LEFT JOIN exp_channel_titles AS t ON c.member_id = t.author_id AND t.channel_id = '4'
        WHERE c.member_id = $member_id
    ";

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

    if($query->num_rows() == 0) // no data retrieved from table, return false
      return false;

    return $query->result_array(); // return this data, to be used in your other function
}

public function details() {
    $data = $this->uploadsQuery(); // storing the data that was returned from the uploadsQuery function

    if(!$data)
        return false; // no data to pass into parse_variables below, so just return false

    return $this->EE->TMPL->parse_variables( $this->EE->TMPL->tagdata, $data );
}

```
> 4 votes

---
Tags: plugin
---


# Question
Title: redirect from Control Panel (top right link) not working
There is a similar issue mentioned here, but the answer doesn't work for me...

If I click on the site link it'll forward as follows:

```
http://example.nl/?URL=http://example.nl/

```

This works for all my EE sites, except one. This shows a blank page. I have completely removed the .htaccess file to test if that was the cause, but no change. Since this normally presents a EE page like this:

```
To proceed to the URL you have requested, click the link below:

http://example.nl/

```

I assume the issue is EE related? Or is it server related?

# Answer
It appeared I hadn't updated the index.php file in the root of the site, which handles the redirect. Not something I do with every upgrade, but can apparently mess things up if you don't.
> 0 votes

---
Tags: url, rewrite
---


# Question
Title: Send multiple selctions to postprocess template to then be emailed
I'm trying to send multiple selections from a safecracker form to a PHP postprocess template which will eventually send emails to the emails selected on the form. This is my code;

```
<select name="notified[]" id="notified" multiple="multiple">
                            <option value="">None</option>
                            <option value="email@example.com">Communications</option>
                            <option value="email2@example.com">Newsletters</option>
                            <option value="email3@example.com">Research</option>
                            <option value="email4@example.com">Corporate Services</option>
                        </select>

```

When I add in the \[\] after notified in name="notified" and then try to echo out the response in my postprocess form it throws up a PHP database error Error Number: 1054 Unknown column 'Array' in 'field list'. If I remove the \[\] I don't get the error but obviously it just shows me one of the values, even if I select more than one.

I'm not sure why the \[\] aren't working?

Any help would be very much appreciated. Thanks, Julie

EDIT: When I change notified\[\] to something\[\] the PHP error goes. But now I can't work out how to echo out the selected values on my postprocess page...

# Answer
> 1 votes
This isn't a EECMS related problem.

The error "Unknown column 'Array'" occurs because if you append a "\[\]" to the name of the field its value is gonna be always an array.

You need to deal with this variable on you PHP template.

I'm just guessing, but maybe this could help you:

```
$_POST['notified'] = implode(",", $_POST['notified']);

```

If you update your question and show the PHP code, we can help you better.

---
Tags: safecracker, php-errors
---


# Question
Title: display one category group in channel entry
I want to display an entry's category, but only from a specific category group.

```
{exp:channel:entries channel="paintings" limit="10"}
{title}
{categories group_id="42"}{category_name}{/categories}
{/exp:channel:entries}

```

If I just use: {categories}{category\_name}{/categories} I get all categories but I only want categories display if they are in group 42. If they have nothing in group 42 I want nothing to display

# Answer
> 2 votes
{categories show\_group="42"}{category\_name}{/categories}

---
Tags: categories
---


title: Low Search: Sort existing results set

text:
# Question
Title: Low Search: Sort existing results set
I'm having a little bit of difficulty trying to sort a search result set returned by Low Search

The user has the option to enter keyword(s) as well as choose many search parameters, but result sorting options are not provided on search form page. On the results page there's a select list at the top to choose from various sorting options.

```
{exp:low_search:form form_id="searchResultsSort" query="{segment_3}" result_page="/the-register/new-results"}

  Sort by <select id="searchResultsSortSelect" name="orderby_sort">
    <option value="">Relevance</option>
    <option value="company_computed_rating|desc">Rating</option>
    <option value="company_date_registered|asc">Length of membership</option>
    <option value="company_membership_package|desc">Package level</option>
  </select>

{/exp:low_search:form}

```

The problem is that the keyword(s) don't seem to be submitted since the result of this sorting is a longer result set and the Search Log shows no keywords.

Any thoughts?

# Answer
> 2 votes
After some experimentation I think I may have found the solution. I thought the Filters tag was just for reducing the result set, but it looks like it can be used for sorting/ordering as well:

```
{exp:low_search:filters query="{segment_3}"}
  <a href="{low_search:url toggle:orderby_sort="company_date_registered|asc"}">Length of membership</a>
{/exp:low_search:filters}

```

Now to sort out the right JS to get this to work in a select list.

---

**Edit:** JS sorted. Here's the final result in case useful to anyone else:

```
<div id="searchResultsSort" class="clearfix">
  {exp:low_search:filters query="{segment_3}"}

    Sort by <select id="searchResultsSortSelect" name="orderby_sort">
      <option value="{low_search:url toggle:orderby_sort="search_count|desc"}">Relevance</option>
      <option value="{low_search:url toggle:orderby_sort="company_computed_rating|desc"}">Rating</option>
      <option value="{low_search:url toggle:orderby_sort="company_date_registered|asc"}">Length of membership</option>
    </select>

  {/exp:low_search:filters}
</div>

```

and the JS:

```
$("#searchResultsSortSelect").change(function(){
  location.href=$(this).val();
});

```

# Answer
> 1 votes
The answer above didn't work for me - it required a minor amendment - in that the toggle parameter, when it already existed in the url, was appending the new orderby\_sort value instead of replacing it.

I removed the toggle: prepend so that the parameter was replaced with the new value and it worked perfectly.

---
Tags: low-search, sort, orderby
---


title: Matrix - link to specific item in row

text:
# Question
Title: Matrix - link to specific item in row
I have a P&T matrix field with a series of cells: images/title/dimensions/date/price

I display all the images in a row and if I click on the image I would like to go to a single entry page that shows ONLY that one image with the other cells (title/date etc)

Is this possible or am I better off makeing each row it's own entry?

# Answer
> 1 votes
There's an add-on called Matrix URL Title, also from P&T, that would allow you to do something like this. It would involve some conditionals in your template, as you might expect, but I've done it before. Worth a look anyway if your user entry flow makes more sense as a matrix rather than a new channel entry per row.

# Answer
> 2 votes
Great question! In my experience, when you need a specific page for content like this, while Matrix is tempting, it is far more efficient (and easier) to create a new channel and/or channel entry.

---
Tags: matrix, pixelandtonic
---


# Question
Title: Is there a way to access an embedded template variable with PHP?
Is there a way to access an embedded template variable with PHP? I thought maybe it'd be in the $\_GET or $\_POST var, but no such luck.

# Answer
> 3 votes
The array of embed\_vars can be accessed this way on EECMS 2.5.5-:

```
$this->EE->TMPL->embed_vars

```

And this way on EECMS 2.6+:

```
ee()->TMPL->embed_vars

```

Use "embed:var\_name" as the array key.

# Answer
> 0 votes
Can you give more description on what you are trying to accomplish?

My immediate guess from what you have told us would be to use something like Stash and create a global variable then parse your php after EE to allow the variable you need to be available for php parsing.

---
Tags: ee2, php
---


title: 301 Redirect URL Appending Query String

text:
# Question
Title: 301 Redirect URL Appending Query String
From yesterday, I'm trying this 301 url redirect but its not working as expected. Please help me with this. here is the .htaccess file code.

```
Options +FollowSymLinks +SymLinksIfOwnerMatch -MultiViews
RewriteEngine On
RewriteCond %{HTTP_HOST} ^mydomain.com [NC]
RewriteRule ^(.*)$ http://www.mydomain.com/$1 [L,R=301]
RewriteBase /
rewriterule ^(.*)/(.*)\.html$ product.php?id=$1&name=$2 [L]
rewriterule ^deals/(.*)$ details.php?id=$1 [L]
rewritecond %{SERVER_PORT} 80
rewritecond %{REQUEST_URI} publisher.php

Redirect 301 /deals/74/product-name.html http://mydomain.com/74/product-name.html

```

Whenever I enter www.mydomain.com/deals/74/product-name.html, It redirects me to "www.mydomain.com/deals/74/product-name.html?id=74&name=product-name"

I'm not sure why its appending "?id=74&name=product-name" after url? I want to display only "www.mydomain.com/deals/74/product-name.html"

I don't know how to fix this problem. I'll appreciate if you can guide me on this.

# Answer
Well... Append "?id=74&name=product-name" is what the line 6 of your code does:

```
rewriterule ^(.*)/(.*)\.html$ product.php?id=$1&name=$2 [L]

```
> 1 votes

---
Tags: php, redirects, apache, rewrite, .htaccess
---


# Question
Title: In EE 2.6 how do we set different localization/timezone site-wide than the server's timezone?
Presuming alternating DST is no longer an issue, I'm confused about the new change. It seems there is now only one configuration option but that is just for the server's time zone:

> This setting lets you specify the time zone where your server is located.

And they give a clear warning if you just put whatever you feel like:

> If you do not set this preference so that it correctly reflects the location of your server it may cause problems with your dates and times. If you are not sure where you server is located please ask your hosting provider.

So what if we want the system to go by a different timezone setting, e.g. my server is in GMT, but my members, activities, etc. are primarily in New York (GMT-5)?

What are the config settings for this now? There seems to be a new setting, "`time_reference`":

```
/*
|--------------------------------------------------------------------------
| Master Time Reference
|--------------------------------------------------------------------------
|
| Options are "local" or "gmt".  This pref tells the system whether to use
| your server's local time as the master "now" reference, or convert it to
| GMT.  See the "date helper" page of the user guide for information
| regarding date handling.
|
*/
$config['time_reference'] = 'local';

```

But how do we set a different default timezone for the site? Are one of the old configs still used for that? Can't seem to get it straight.

Related questions pre 2.6:

Forcing DST settings for users

How are we supposed to manage time and respect localization/DST in EE?

# Answer
For the values of the timezone variables below you can use both PHP timezones (e.g. `America/New_York`) and CodeIgniter Timezones (e.g. `UM5`).

Through some tests (using `print_r($this->EE->config->config);`):

`$config['server_timezone']` is for your server's timezone.

`$config['default_site_timezone']` is for your site purposes.

What you choose on CP Home \> Administration \> Localization Settings sets `$config['server_timezone']` with a PHP Timezone. `$config['default_site_timezone']` remains empty, if it is not manually set in your config.php or bootstrap then the value of `$config['server_timezone']` will be used instead.

As of this writing (EE 2.6.1) you **must** manually set `$config['default_site_timezone']` to a CodeIgniter Timezone because for date entry fields their `field_dt_#` column in the database can only accept up to 8 characters, meaning the PHP Timezone in `$config['server_timezone']` will not be properly saved and thus changing the value in your date entry fields every time you save it as `Fixed`. You can also save `$config['server_timezone']` as a CI value and be done with it if your site and server timezones are the same, however, the select dropdowns on the Localization Settings page will not reflect your settings.

A new config is added, too:

```
$config['tz_country']

```

But it is not clear what this does asides from help populate the dropdown.
> 2 votes

---
Tags: dst, localization
---


# Question
Title: Paginating Recordset from Plugin to Template, How?
I am creating a plugin in which I select data from a table from other database, outside EE. Now to display the result in EE template, I have to traverse through records and create HTML within the plugin and assign that to a variable, that I return to the Template.

Is there a way to simply return the recordset to the template, and then use template to show the records, and also show the pagination? Pagination is a big issue for such cases.

# Answer
> 1 votes
Instead of creating the HTML in the plugin, you should use the Template Class for outputting the database results.

Example for Creating Pagination:

```
$total = 300;//Set from your recordset total
$per_page = 30;//how many records you want to show per page
$base_url = $this->EE->config->_global_vars['base_url'].'/'.$this->EE->uri->segment(1);//The url for the listing that EE will use for the pagination links

$this->EE->load->library('pagination');
$config['base_url'] = $base_url;
$config['total_rows'] = $total;
$config['per_page'] = $per_page;
$config['num_links'] = 3;
$config['uri_segment'] = 4;
$config['first_link'] = '1';
$config['first_tag_open'] = '<div class="pag-first">';
$config['first_tag_close'] = '</div>';
$config['next_tag_open'] = '';
$config['next_tag_close'] = '';
$config['num_tag_open'] = '';
$config['cur_tag_open'] = '<strong>';
$config['prev_tag_open'] = '';
$config['last_link'] = ceil($total/$per_page);
$config['last_tag_open'] = '<div class="pag-last">';
$config['last_tag_close'] = '</div>';

$this->EE->pagination->initialize($config);

$myPagination = $this->EE->pagination->create_links();

```

http://ellislab.com/expressionengine/user-guide/development/module\_tutorial.html About halfway down the page shows an example.

Assuming you haven't already sorted the listing itself (from the recordset), you want a tag pair in your plugin utilising $this-\>EE-\>TMPL-\>tagdata. You need an array of the data, the following example will contain stuff you don't need!

In this example I've got a response from an external database returned as an object called "Products":

```
$total = $products->hits->total;
if (empty($total) || empty($products->hits->hits))
    return;

$productOutput = array();
foreach($products->hits->hits as $key => $product) {
    $productDetails = array(
        "id"                => $product->_id,
        "name"              => ucfirst(stripslashes(strtolower($this->truncate($product->_source->name, $name_truncation)))),
        "url"               => $product->_source->friendly_url,
        "price"             => $product->_source->price,
        "original_price"    => $product->_source->original_price
    );
    $productOutput[] = $productDetails;
} //###   end of foreach   ###

$outputVars["pagination"] = $myPagination;
$outputVars["products"] = $productOutput;
$output = $this->EE->TMPL->parse_variables($this->EE->TMPL->tagdata, array($outputVars));

```

Note: You will have to restrict the data set to what you want to appear. So I'd suggest you do 2 queries to your external Database - one to get the total results only, the other to get a portion of the results that you need to display (to keep query speed down). To get the current page (basically calculate the offset you can get the relevant segment, e.g. `$this->EE->uri->segment(5, 0);`

The above code will loop through your plugin once (note the `array($outputVars)`). Within your plugin tags, you'll need `{pagination}` tag to output the pagination wherever you want in the template. And you'll need the `{products} ... {/products}` tag pairs to output the data recordset - which will loop for the amount you want shown.

---
Tags: ee2, pagination
---


# Question
Title: Distinguishing duplicate channel titles in a PlayA field when adding a record
For a field I am using PlayA and for the Field Options have selected two Channels.

The problem I have is that some of the titles within the two channels are the same and therefore when adding a new EE record it is impossible to tell from which of the two channels a particular title is from. Is there a solution to this?

I am guessing that as I am ordering by Entry Title, the first entry will be from the first channel and the second entry will be from the second, but I do not know if I can be certain of this.

The obvious solution of changing the titles in one of the channels is not an option for this particular web site.

# Answer
There is a hack in this thread may point you in a direction: Filter Playa List by Custom Field

Looks like it may not play well with the ajax filtering however.
> 1 votes

# Answer
I've had this problem before. Until Playa adds an inline "filter by channel" option within the playa fieldtype (something I would LOVE to see down the line), mirroring "filter by category", the latter is in fact an easy workaround. When I face this same challenge, I'll often create a category group that has a category per channel, and assign that category group to each of the channels in question. Then when creating an entry in each channel, I also assign the entry to the category that matches the channel - purely for filtering via the Playa field. Not ideal by any means, but in a pinch, it works, but makes two assumptions: (a) that the channels in question are not already clogged with category group assignments and (b) that the admin will remember to assign the categories in the entry screen (there are add-ons to make the category assignment a little more noticeable than they would otherwise be on the category tab, making them harder to overlook).

As long as with your Playa field you don't limit the selections to those categories, the filters work great (meaning, if a category assignment is forgotten, the entry still shows in the list when a category filter is NOT applied, just in case).
> 0 votes

---
Tags: playa
---


# Question
Title: Matrix field within safecracker form : new row opening blank page
EE 2.5.2 Matrix 2.5.5

When you hit the add new row + button in the Matrix field within a safecracker form it opens a new blank page. The new row is added successfully but I can't work out why it is opening a blank page as well.

# Answer
Do you have any errors in the console? It's usually the case that jQuery is being included twice on the same page. Be sure to use the include\_jquery="no" parameter and have your own jQuery included before any Safecracker code.
> 1 votes

---
Tags: matrix, safecracker
---


# Question
Title: PayPal Pro CreditCardType : Invalid Parameter
I'm using Expression Engine's exp-resso store plugin for our ecommerce store. I've set it up to use PayPal Pro as our on site payment gateway.

When submitting my form I receive this error "CreditCardType : Invalid Parameter"

Am I missing something obvious? Wouldn't the card type be set automatically depending on the card number? Do I need to explicitly place a select with card type options? Here's my current form:

```
<input type="text" id="payment_card_no" name="payment[card_no]" value="" />
<input type="text" id="payment_name" name="payment[name]" value="" />
<select id="payment_exp_month" name="payment[exp_month]" style="width:auto">
    <option value=""></option>
<option value="01">01</option>
    etc...
</select>
<select id="payment_exp_year" name="payment[exp_year]" style="width:auto">
    <option value=""></option>
    <option value="2013">2013</option>
    etc...
</select>
<input type="text" id="payment_csc" name="payment[csc]" value="" class="input-mini" />
<input id="checkout_submit" type="submit" name="submit" value="Place Order" class="btn btn-success" />

```

Thanks in advance!

# Answer
> 1 votes
You also need to include the card type when sending the information over to Paypal. This needs to be templated as a select menu. Use this as a starting point and remove any card types which you don't accept:

```
<select name="payment[card_type]">
    <option value="">Select one...</option>
    <option value="visa">Visa</option>
    <option value="mastercard">MasterCard</option>
    <option value="amex">American Express</option>
    <option value="discover">Discover</option>
    <option value="maestro">Maestro (UK)</option>
    <option value="solo">Solo (UK)</option>
</select>

```

Once that's included and sent across in the submission it should solve the error.

# Answer
> 0 votes
This variable should be optional per the developers guide. Which API call are you specifically using, I am assuming the DoDirectPayment API. Also are you testing this against the live site or the sandbox? Look at your raw request that you are sending out, the only other thing I can think of is that your cart is passing over the variable "CREDITCARDTYPE" but setting the value to "null" since you are not populating it which can cause the error.

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


title: Low Replace almost the same html

text:
# Question
Title: Low Replace almost the same html
I'm looking to strip some html from an img area with Low replace. This works great, but I have varying heights and widths to deal with.

So:

```
{exp:low_replace find="height=QUOTE365QUOTE|width=QUOTE500QUOTE" replace="SPACE" multiple="yes"}

```

ideally wants to be

```
{exp:low_replace find="height=QUOTE___QUOTE|width=QUOTE___QUOTE" replace="SPACE" multiple="yes"}

```

what should I put in the *_* bit for any number value? Possible?

# Answer
You, my friend, need to learn the ways of Regular Expressions. Try this:

```
{exp:low_replace
    find="(height|width)=QUOTE\d+QUOTE"
    replace="SPACE"
    regex="yes"
}

```
> 2 votes

---
Tags: low-replace
---


# Question
Title: retrieve the database name in an extension
I'm building a small plugin for EE and I need to retrieve the name of the database. ( specified in config \> database.php )

But I can't seem to find any docs that point me in the right direction.

# Answer
> 2 votes
The docs say that Database Class is initialized automatically.

A var\_dump(ee()-\>db) show us that the name of database can be retrieved by, on EECMS 2.6+:

```
ee()->db->database

```

And on EECMS 2.5.5-:

```
$this->EE->db->database

```

---
Tags: ee2, add-on-development, database
---


# Question
Title: Wygwam field not completely loading for one channel entry
We have a client site that uses Wygwam 2.7.1 on EE 2.5.3 and we have an issue on only one channel entry, and only for a few people. When the entry is loaded in the CP, certain users just see this:

All other users see the Wygwam field perfectly fine.

This channel entry has a lot of YouTube video embeds in the Wygwam field (about 20 videos). That's the only thing different from the other entries and this is only happening for two users so far on Firefox. There is a js error that only shows up for the users who are having this issue. The error is:

```
TypeError: w.filter is not a function
http://www.siteurl.com/themes/third_party/wygwam/lib/ckeditor/ckeditor.js
Line 31

```

I can't recreate this same error on any other computer. Has anyone come across this before or has an idea of how to fix it.

# Answer
> 1 votes
The issue appear to be with a video embed in the Wygwam field. Adobe is registering the SWF file as an unsafe operation and that's causing the editor window to stop loading.

---
Tags: pixelandtonic, wygwam
---


# Question
Title: Can't Add Products to Cart - Only in Safari
This is a very weird problem.

I've tested all the steps of the checkout process and it works fine most of the time. By most of the time I mean, in the local environment, it works on Chrome, Safari & Firefox but on a live server such as the staging environment, it works on Chrome & Firefox **but not Safari**

I tested both my own template as well as the pre-installed examples and got the same results. No luck with Safari on Staging Env.

I've also tested on Safari & Chrome on iPhone & iPad & the same thing happened. Chromes works well but Safari just doesn't want to do its job.

I've tried all the solutions from this question but still no luck.

Here is some of my system info:
**Safari: 6.0.4
EE 2.5.5
Expresso Store: 1.6.4
**

I don't think that there's any problem with the server though. have you ever experienced this issue? If yes, can you tell me where to start investigate?

Thanks!

# Answer
> 1 votes
At this point, I can confirm this is a server fault, the problem did not come from either Safari or Expresso Store. I've uploaded my local dev version to another staging server and everything appears to be working properly.

However, still need to investigate further to find out what really caused the problem since the current server is configured almost exactly the same as the one I just used to test.

Can anyone tell me what kind of settings I should check?

---
Tags: expresso-store
---


# Question
Title: The CP Theme appears to be locked. How do I change it?
I am seeing some strange Control Panel formatting in a site I work on. The site is running EE 2.6.1 and in general works fine, however, I cannot change the Control Panel theme. It defaults to Corporate and even if I remove Corporate from cp\_themes from the server, it still displays Corporate. Any suggestions on how to change that?

Thanks.

# Answer
Take a look in system/expressionengine/config/config.php - you'll probably find the theme is hardcoded there with `$config['cp_theme'] = 'corporate'`
> 0 votes

---
Tags: control-panel, cp-themes
---


# Question
Title: How do I change a Text Field to a Date Field without losing the content values?
Is there a way I can change a Text field to a Date field and not toast the data that is already there?

# Answer
> 4 votes
You should not lose any data which already exists in your fields when changing field types - but if you have anything but a UNIX timestamp stored in the existing text field, the Date fieldtype won't know what to do with the data.

**UPDATE:**

To update your existing fields from your current format (`5/14/2013`) to a timestamp for use with the Date fieldtype, put this code in a PHP-enabled template and run it (backup your database first of course):

```
<?php
    $this->EE =& get_instance();
    $current = $this->EE->db->query("
        SELECT entry_id, field_id_XX FROM exp_channel_data WHERE field_id_XX != ''
    ");
    foreach($current->result_array() as $row)
    {
        $timestamp = strtotime($row['field_id_XX']);
        $this->EE->db->query(
            $this->EE->db->update_string('exp_channel_data', array('field_id_XX' => $timestamp), 'entry_id='.$row['entry_id'])
        );
    }
?>

```

---
Tags: custom-fields
---


# Question
Title: Why is the Related Entries code showing after upgrading to EE 2.6.1?
I updated a client site today from 2.5.5 to 2.6.1 which automatically converted the related entries tag on the site.

However, I now have a new problem. For some reason the code is displaying on the page:

> Author {related\_entries id="blog\_author"} The Great Keyword Hunt: How to Know What SEO Keywords Your Business Should Target {/related\_entries}

Here is the code:

```
<span>{blog_author}
                        {if status == "open"}<a href="{blog_author:title_permalink=/about/bio}">{blog_author:title}</a><br />{blog_author:staff_title}{/if}
                        {if status == "closed"}<a href="{path=/about}">{blog_author:title}</a><br />{blog_author:staff_title}{/if}{/blog_author}</span>

```

Any clues why the code is showing like that?

# Answer
My guess is that you're using file-based templates, and during the upgrade only the database version of your templates were upgraded to use the new syntax (possibly due to insufficient permissions on the updater's part).
> 1 votes

---
Tags: related-entries
---


title: Allow users to add coupons to CartThorb

text:
# Question
Title: Allow users to add coupons to CartThorb
I was wondering what is the best way to allow users to add coupons to CartThorb? Does CartThorb allow coupons to be added from templates, if not where should I start from to enable this functionality?

I realize the question is vague, so I don't expect concrete answers, anything to point me into the right direction will do.

Appreciate it.

# Answer
> 1 votes
I'm actually working on a similar issue right now. We have a website where specific member groups have solspace user editable member templates but don't have control panel access. Attached to those profiles, are channel entries where they can display extra information about events in their area.

The first road I'm starting down is to make it so that the coupon is one of the fields in that entry, but not editable from the public side. When an entry is created, one of the fields will be the CartThrob "Coupon Code Field", so they could actually create their own codes using that custom field. But the actual settings field is not accessible, except to the staff that has control panel access. From there I will be modifying the coupon settings field to already have the default values in place upon entry creation, so staff can change the actual values if need be.

So this solution would apply to members that don't have control panel access, and can be done with solspace user or if it is desirable to have channel profiles automatically created then profile:edit (creates profile entries upon edit) or zoo visitor (creates profile entries automatically). I just don't know exactly how I would keep it all straight if two members create the same coupon code, maybe I'll make it so that a unique value needs to be pre-pended based on that unique member id or another value unique to that entry or member. Or tell them, "This is your code, period, full stop."

The second road will be to try a variation of this price field changer extension http://cartthrob.com/forums/viewthread/4547/#21625 (Also found in the SDK, but having an issue with that version on the most recent version of EE).

Essentially the channel would have a very basic coupon plugin type that would do nothing more than set the custom data that makes the price field changer set or unset the price based on the cart contents. This second way would make it so that coupon prices can be controlled from the actual product's channel entry, so it stays consistent. If it ends up that we really need to make it so that coupons stay in their own channel, then perhaps relationships or asigned author IDs will keep things organized... but now my head is starting to swell.

---
Tags: cartthrob, extension, coupon-code, discounts
---


# Question
Title: Do the Expresso Store shipping methods have to be displayed in a dropdown?
Is it possible, in Expresso Store, to display the shipping methods not in a dropdown, but in radial buttons or tick boxes instead? I'd like to display shipping methods side by side in designed boxes with radial buttons.

# Answer
The shipping method is a standard input field, you can template it however you want:

```
<input type="radio" name="shipping_method" value="1" />
<input type="radio" name="shipping_method" value="2" />
<input type="radio" name="shipping_method" value="3" />

```

Or, if you want to automatically generate the list:

```
{shipping_methods}
    <label>
        <input type="radio" name="shipping_method" value="{method_id}" />
        {method_title}
    </label>
{/shipping_methods}

```

Documentation here: https://exp-resso.com/docs/store/checkout\_tag.html#shipping\_methods
> 1 votes

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


title: 'pubsubhubbub' support for EE?

text:
# Question
Title: 'pubsubhubbub' support for EE?
A little background, we have a theory that content scrappers are using our feeds to scape and post our site content and it might be negatively effecting or search results. This topic was mentioned by Google engineer Matt Cutts at PubCon 2011. A solution that was put forth was to use "Fat Pings". Basically, ping Google as soon as the content is published so their servers have a strong record of the source server. Hosted services like Blogger and Wordpress.com already do this using pubsubhubbub.

So my question is: Does anyone know if there is an existing add-on or code for doing 'pings' when content is added to a channel or feed in Expression Engine?

I found a couple support threads on the Ellis Labs site, but not any real mentions of a solution. http://ellislab.com/forums/viewthread/132321/
http://ellislab.com/forums/viewthread/229845/

***Aside:*** *Are the Ellis Labs support forums incredibly slow for anyone else or is it just me?*

# Answer
> 2 votes
I implemented pubsubhubbub using Superfeedr and it's working well for me.

...and yes, the Ellis Labs support forums are maddeningly slow for me, too. Support is now a profit center for them, so free support is worse than a cost center, it competes with their business model.

\[edited to correct spelling of Superfeedr\]

# Answer
> 0 votes
Not exactly what you're looking for, but we have Sitemap Pinger extension

---
Tags: add-on, channel-entries, seo, rss
---


title: Members Group Access login

text:
# Question
Title: Members Group Access login
I've made 2 new Member Groups, Ouders and Kids. Both are base on the Members group.

I've a Template Group nieuws. Access for this index is only for Member Group Ouders.

I've a Template Group activities. Access for this index is only for Member Group Kids.

In my template nieuws/index I have this code:

```
 {if logged_in}

 {exp:channel:entries channel="nieuws" disable="categories|member_data"}
 ....
{/exp:channel:entries}

 {/if}

 {if logged_out}
{exp:member:login_form}
         <p> <label>gebruikersnaam</label><br> <input type="text" name="username" value="" class="formfield" maxlength="32" size="25">
         </p>
         <p> <label>wachtwoord</label><br> <input type="password" name="password" value="" class="formfield" maxlength="32" size="25">
         </p>

         <p><input type="submit" name="submit" class="button" value="LOGIN"></p>
{/exp:member:login_form}
{/if}

```

In my template activities/index I have this code:

```
{if logged_in}

{exp:channel:entries channel="activities" disable="categories|member_data"}
....
{/exp:channel:entries}

{/if}

{if logged_out}
{exp:member:login_form}
        <p>
<label>gebruikersnaam</label><br>
<input type="text" name="username" value="" class="formfield" maxlength="32" size="25">
        </p>
        <p>
<label>wachtwoord</label><br>
<input type="password" name="password" value="" class="formfield" maxlength="32" size="25">
        </p>

        <p><input type="submit" name="submit" class="button" value="LOGIN"></p>

{/exp:member:login_form}
{/if}

```

If I login with the username/password from a Kids Member Group I get access to both templates (nieuws and activities) when a Kids member should only have access to the activities template. If I login as a Ouders member I get access also to both template.

Am I doing something wrong or do I need an Add-on to achieve this.

Francois

# Answer
> 1 votes
You can modify **each** of your conditionals surrounding the channel entries tag to include group info.

```
{if logged_in_group_id == '1' OR logged_in_group_id == '7'}
  <!-- Enter in correct id for member group, including any admin groups. -->
  {exp:channel:entries ...}
{/if}

```

You can also redirect someone who went to the wrong page. For example, if a logged in kid goes to the nieuws page, you can redirect them to the activities page by adding this to the nieuws template.

```
{if logged_in_group_id == '7'}{redirect="/activities"}{/if}

```

---
Tags: members, registration, groups
---


# Question
Title: exp:entries search parameter not working when disable="custom_fields"
I am trying to create a Google sitemap. On some of my channels I need to only output URLs that match a certain criteria based on custom fields. If I use the search parameter it works fine... except if I am using the diable="custom\_fields" parameter. If that parameter is in then the search parameter is ignored completely. Seems like a bug to me since I can disable categories yet use the categories parameter just fine. So how can I get around this? I can't really enable custom fields since I will be running through all the pages in my site and that would slow things down quite a bit. Any ideas?

I was thinking of using a conditional inside the exp:entries tag... but with custom\_fields disabled, I wouldn't have anything to test against.

# Answer
This is not really a bug, but more of an inconsistency in how performance bottlenecks are determined.

The reason that you can still filter by category even when categories are disabled in your tag is likely because the `exp_category_posts` table has its columns indexed (so running a `JOIN` on them in the query is pretty fast), whereas the `exp_channel_data`'s custom field columns are not.

I'd just keep `custom_fields` enabled and use caching to lighten the load (either tag caching, template caching, or for a much better option, CE Cache).
> 0 votes

---
Tags: custom-fields, search, parameters, bug
---


title: Database error when www prefix is used

text:
# Question
Title: Database error when www prefix is used
I am using a version of the Focus Labs Master Config setup and I am getting a database error when using the www. prefix in front of the URL. This is a problem that I haven't run into before. Anyone have any thoughts?

You can see the issue at http://denvillechamber.com. Obviously add the www prefix to recreate the error.

# Answer
> 3 votes
This is because the master config changes database configurations based on the value of `$_SERVER['HTTP_HOST']`, and you likely have "denvillechamber.com" as your value, which is not the same as "www.denvillechamber.com".

Your site should not be accessible at both **www** and **non-www** locations - one should redirect to the other.

Put this in your `.htaccess` file:

```
RewriteCond %{HTTP_HOST} ^www\.denvillechamber\.com$ [NC]
RewriteRule ^(.*)$ http://denvillechamber.com/$1 [L,R=301]

```

Should fix your problem.

---
Tags: database, focus-lab-master-config
---


title: Embed an exp:channel tag into Wygwam

text:
# Question
Title: Embed an exp:channel tag into Wygwam
Is it possible to put a exp:channel entries tag loop into a wygwam field? Simply placing something, e.g.,

```
{embed="Common/sidebar_people" show_channel="48"}

```

... fails. The "Allow EE Code" plugin I thought was related but after installing it and looking through the php I'm unclear on its purpose.

# Answer
> 2 votes
You'll need to wrap your Wygwam field in the Allow EE Code plugin tags within your template:

```
{exp:allow_eecode embed="y"}
    {your_wygwam_field}
{/exp:allow_eecode}

```

---
Tags: ee2, wygwam, channel, embeds, tags
---


title: Category Group Name Condition

text:
# Question
Title: Category Group Name Condition
Is there a way to add a condition like {if results} or {if empty} when searching for a category in a channel entry?

```
{if a category 41 is selected display}Category Group Name: {categories show_group="41"}{category_name} {/categories}{/if}

```

I have a number of category groups in my channel. When displaying the selections I want to first show a heading (category group name) then the selected categories. If nothing is selected I don't want anything to show.

I am testing: http://devot-ee.com/add-ons/jco-entry-catcount

> {exp:jco\_entry\_catcount entry\_id="{entry\_id}" category\_group\_id="41":} {if nbrcategories \> 0} Provincial Riding: {categories show\_group="41"}{category\_name} {/categories}
> {/if} {/exp:jco\_entry\_catcount}
>
> {exp:jco\_entry\_catcount entry\_id="{entry\_id}" category\_group\_id="39":} {if nbrcategories \> 0} Federal Riding: {categories show\_group="39"}{category\_name} {/categories}
> {/if} {/exp:jco\_entry\_catcount}

# Answer
You should use GWCODE CATEGORIES (http://gwcode.com/add-ons/gwcode-categories/documentation)

something like:

```
{exp:gwcode_categories entry_id="{entry_id}" group_id="41"}
######
{/exp:gwcode_categories}

```
> 2 votes

---
Tags: categories
---


title: Stash + Matrix Parse Order?

text:
# Question
Title: Stash + Matrix Parse Order?
The following code works **if** I comment out the Matrix fields (images `{stash:st_{pre_channel}_image_url}`).

However, I can't get the code working with the image tags back in. I'm guessing it's a parse order issues :-/

I've tried everything I can think of, but no joy. Could someone point me in the right direction please?

```
  {preload_replace:pre_channel="people"}

    {exp:channel:entries disable="" channel="{pre_channel}" dynamic="no"}
    {categories}
        {exp:stash:append_list name="{pre_channel}_{category_id}" parse_tags="yes"}

        {!-- Main  --}
        {stash:st_{pre_channel}_title}{title}{/stash:st_{pre_channel}_title}
        {stash:st_{pre_channel}_page_url}{page_url}{/stash:st_{pre_channel}_page_url}

        {!-- Content --}
        {stash:st_{pre_channel}_intro}{cf_{pre_channel}_intro}{/stash:st_{pre_channel}_intro}
        {stash:st_{pre_channel}_maincontent}{cf_{pre_channel}_maincontent}{/stash:st_{pre_channel}_maincontent}

        {!-- Page Specific --}
        {stash:st_{pre_channel}_location}{cf_{pre_channel}_location}{/stash:st_{pre_channel}_location}

        {!-- Image --}
        {stash:st_{pre_channel}_image_url}
            {cf_{pre_channel}_images limit="1"}
                {mx_image}
            {/cf_{pre_channel}_images}
        {/stash:st_{pre_channel}_image_url}

        {stash:st_{pre_channel}_image_caption}    {cf_{pre_channel}_images limit="1"}{mx_caption}{/cf_{pre_channel}_images}{/stash:st_{pre_channel}_image_caption}

    {/exp:stash:append_list}
    {/categories}
{/exp:channel:entries}

```

Get

```
    {exp:channel:categories channel="{pre_channel}" style="linear" show_empty="no"}
        <div class="span12">
        <h3>{category_name}</h3>
        <div class="row">
            {exp:stash:get_list name="{pre_channel}_{category_id}"}
                <article class="span4">
                    <a href="{st_{pre_channel}_page_url}">
                        <img src="{st_people_image_url}" alt="{st_{pre_channel}_title}">
                    </a>
                    <header>
                        <a href="{st_{pre_channel}_page_url}"><h2>{st_{pre_channel}_title}</h2></a>
                        <p class="meta">{st_{pre_channel}_location}</p>
                    </header>
                </article>
            {/exp:stash:get_list}
        </div>
    </div>
{/exp:channel:categories}

```

# Answer
Why is the matrix inside {categories} variable pair? Looks like the point is that.

Matrix tag pairs won't get parsed if they are inside the categories tag pair.

I tried to find a way to do what you need, but I couldn't find any solution without using multiple channel:entries, on one way or another. Even using addons, we can't scape of this. Per example, there are some plugins that group entries by its categories, as Category Sorted Entries and NSM Categories, but they don't allow you the get data from matrix fields, which means: multiple channel:entries variable pairs!

So, lets try to do this without addons.

```
{preload_replace:pre_channel="people"}
{exp:channel:categories channel="{pre_channel}" style="linear" show_empty="no" parse="inward"}
    <div class="span12">
    <h3>{category_name}</h3>
    <div class="row">
        {exp:channel:entries disable="" channel="{pre_channel}" dynamic="no" category="{category_id}"}
            <article class="span4">
                <a href="{page_url}">
                    <img src="{cf_{pre_channel}_images limit='1'}{mx_image}{/cf_{pre_channel}_images}" alt="{title}">
                </a>
                <header>
                    <a href="{page_url}"><h2>{title}</h2></a>
                    <p class="meta">{cf_{pre_channel}_location}</p>
                </header>
            </article>
        {/exp:channel:entries}
    </div>
</div>
{/exp:channel:categories}

```

By this way, the channel:categories variable pair will created one channel:entries variable pair for every category. Entries could repeat if they have more than one category on this group.

Sadly, this is a really heavy code to parse. You should enable some cache feature on the tags or on the page.
> 1 votes

---
Tags: matrix, stash
---


# Question
Title: Why can't Simple Search find any results?
I have used Simple Search many times on many sites, but for some reason on this one, I am not getting any results when I know the keywords are there.

```
http://192.196.159.46/membership/business-search

```

Here is the code I am using:

```
{exp:search:simple_form channel="member_profiles" search_in="entries" result_page="/membership/business-keyword-results" where="any"}
<label for="keywords">Search:</label><br />
<input type="text" name="keywords" id="keywords" value="" size="30" maxlength="100" placeholder="keywords">
<input type="submit" value="Search" class="submit">
{/exp:search:simple_form}

```

Is there something simple I am overlooking? I would even settle for something complex.

Thanks.

# Answer
> 2 votes
Are you certain the fields in which you know the keywords exist are set to be searchable? That is likely the culprit.

Note also that `search_in="entries"` will not search entry titles.

---
Tags: simple-search
---


title: How do I compare date values?

text:
# Question
Title: How do I compare date values?
I would like to create a conditional based on the value of a date field compared to today's date.

In English it would be: if Expiration Date is less than today's date set class to "expired"

Here is how I tried it in EE:

```
{if "{business_expire_date}" < "{current_time}"}class="expired"{/if}

```

Unfortunately, it doesn't work as desired. What is the correct way to write this?

Thanks.

# Answer
> 7 votes
The dates need to be formatted properly first to compare them. Something like this:

```
{if {business_expire_date format="%U"} < {current_time format="%U"}}class="expired"{/if}

```

You may need to change the comparison operator `<` to get desired results.

---
Tags: date, advanced-conditionals, comparison
---


title: Is the Offline Template a static file?

text:
# Question
Title: Is the Offline Template a static file?
Is the Offline Template a physical .html file?

What I would like to do is write a database failure check in the config file so that if for some reason the database fails it will turn on maintenance mode which will display the offline template.

If the offline template is served from the DB this obviously will not work.

# Answer
The offline template is served from the DB, which can be edited in the control panel:

> Design \> Message Pages \> Offline Template

However, Custom System Messages allows you to use custom templates as system message which can parse other template tags.
> 4 votes

---
Tags: templates, admin, offline
---


# Question
Title: New & Empty Matrix Field Does Not Validate as Empty
I have an optional matrix field for a page banner in one of my channels. If someone publishes a new channel entry or edits one where the banner matrix field has never been touched, then the conditional `{if banner_matrix_field}banner matrix field has content{/if}` validates as true, even though it's empty.

For example, if I publish a new page, and leave the banner matrix field empty, then the class `graphic` will still display in my template:

```
{exp:channel:entries
    channel='test'
}
<header class="banner clearfix{if banner_matrix_field} graphic{/if}">
    {!-- Banner Content --}
</header><!--/.banner-->
{/exp:channel:entries}

```

If I add a row to the matrix field then delete it, then the field correctly validates as empty.

**UPDATE:** The add/delete row workaround actually only works every time you edit the entry. So if I edit the entry once, add/delete a matrix row, save, then come back and edit the same entry again and save without adding/deleting the matrix row, the conditional validates as true again.

It doesn't seem to matter what kind of fields are inside the matrix cells, I've tried it with Assets, File, and the default plain text cells with the same result.

* EE 2.6.1
* Matrix 2.5.5

# Answer
> 5 votes
You can use

```
{if banner_matrix_field:total_rows >= 1} graphic{/if}

```

Matrix docs link

---
Tags: matrix, conditionals
---


# Question
Title: How to handle 404 with segment_2 misspelling
How do I handle a 404 redirect when let's say I have a template group called "about" and a template in that group called "leadership" but someone types about/leaderships instead of about/leadership?

Thanks.

# Answer
> 1 votes
The misspelt URL will fallback to your about/index template, so just put a simple...

```
{if segment_2}{redirect="404"}{/if}

```

... in that template.

This assumes you don't need to use any arbitrary segment values in that template. If you do, or if you want to use the index template for multiple urls, then instead you should use a combination of the require\_entry parameter of the channel entries tag and the no\_results conditional on the inside of the tag to perform the redirect.

# Answer
> 1 votes
Assuming that you want a general solution for redirecting misspelt and non-existant url\_titles in your url, you need to use the require\_entry parameter in combination with a no\_results conditional as James Smith suggested. Here's a simple example:

```
{exp:channel:entries channel="projects" limit="1" require_entry="yes"}
   {if no_results}{redirect="404"}{/if}
{/exp:channel:entries}

```

Ryan Battles has written a good guide to ExpressionEngine 404 pages.

---
Tags: 404
---


title: expresso store and omnipay

text:
# Question
Title: expresso store and omnipay
I am hoping to use store with omnipay, as it has tokenized payments. I am prepared to code the plugin for my particular payment gateway, but is exp-resso planning to use omnipay in future releases?

If so, when?

# Answer
> 1 votes
It's not quite as simple as that. Omnipay might support token payments, but Store itself doesn't. Even if you wrote your gateway for Omnipay, that wouldn't give you the ability to easily save credit cards and charge them with Store, there would still be a lot of database logic etc missing. So it depends entirely on what you are trying to do.

As Justin mentioned, it's probably easier to contact support@exp-resso.com with questions like this so we can discuss what you are trying to do and the best way to approach it.

---
Tags: expresso-store
---


title: grouped category search

text:
# Question
Title: grouped category search
I have a zoo visitor channel for all my members. My zoo visitor has multiple category groups. I am trying to create a category drop filter menu to filter the members by category. In the drop menu I need each group name displayed and then all the categories:

ie: Filter by Category:

--Category Name A--

Category 1

Category 2

--Category Name B--

Category 1

Category 2

The 2 categories I am using right now are group ID 39 and 41

```
<form name="catmenu" action="">
  <select name="selcat" onchange="location=document.catmenu.selcat.options[document.catmenu.selcat.selectedIndex].value;">
  <option value="">Filter by Category</option>
  {exp:channel:categories cache="yes" refresh="60" channel="zoo_visitor" disable="category_fields" style="linear"}
{if parent_id == '39'}{if count != '1'}</optgroup>{/if}<optgroup label="{category_name}">{/if}
{if parent_id != '39'}<option value="{path='home/directory'}">{category_name}</option>{/if}
  {/exp:channel:categories}
 </select>
</form>

```

# Answer
You don't need addons for this. Try to use addons just when you really need them.

```
<form name="catmenu" action="">
  <select name="selcat" onchange="location=document.catmenu.selcat.options[document.catmenu.selcat.selectedIndex].value;">
  <option value="">Filter by Category</option>
    <optgroup label="group 39">
    {exp:channel:categories cache="yes" refresh="60" channel="zoo_visitor" disable="category_fields" style="linear" category_group="39" show_empty="no"}
        <option value="{path='home/directory'}">{category_name}</option>
    {/exp:channel:categories}
    </optgroup>
    <optgroup label="group 41">
    {exp:channel:categories cache="yes" refresh="60" channel="zoo_visitor" disable="category_fields" style="linear" category_group="41" show_empty="no"}
        <option value="{path='home/directory'}">{category_name}</option>
    {/exp:channel:categories}
    </optgroup>
 </select>
</form>

```
> 1 votes

# Answer
GWCode categories seems to be of some help. Testing this right now:

```
<form name="catmenu" action="">
  <select name="selcat" onchange="location=document.catmenu.selcat.options[document.catmenu.selcat.selectedIndex].value;">
  <option value="">Filter by Riding</option>
<optgroup label="Group 1">
{exp:gwcode_categories channel="zoo_visitor" entry_count="yes" group_id="39" excl_group_id="41" show_empty="no" style="linear"}
    <option value="{path="examplepath/{cat_url_title}"}">{cat_name} ({entry_count})</option>
{/exp:gwcode_categories}
<optgroup label="Group 2">
{exp:gwcode_categories channel="zoo_visitor" entry_count="yes" group_id="41" excl_group_id="39" show_empty="no" style="linear"}
    <option value="{path="examplepath/{cat_url_title}"}">{cat_name} ({entry_count})</option>
{/exp:gwcode_categories}

 </select>
</form>

```
> 0 votes

---
Tags: categories, zoo-visitor, filter
---


title: Creating session data in EE plugin

text:
# Question
Title: Creating session data in EE plugin
I am building an EE plugin and need to store some information in a session.

How can I save and retrieve information from a session in an EE plugin?

Thanks

# Answer
> 1 votes
The EE Session cache is for "Flash" content on page load, so useful for storing temporary data which will get wiped per page refresh.

If you need it to store data via your templates, I'd highly recommend this add-on: http://devot-ee.com/add-ons/session-variables-plugin

Otherwise you just want to utilise PHP sessions, here's some functions from one of my add-ons:

```
//###   Get the Session variable (Array) for this class   ###
public function get_session() {
    $this->create_session();

    if (!empty($_SESSION[$this->class]))
        return $_SESSION[$this->class];
    else
        return false;
}//###   End of get_session function   ###

//###   Set the Session variable (Array) for this class   ###
public function set_session($value = "") {
    $this->create_session();

    if (is_array($value))
        $_SESSION[$this->class] = $value;
    else
        $_SESSION[$this->class] = "";
    return;
}//###   End of set_session function   ###

public function create_session() {
    //###   Set up cookie storage for use with or without the www   ###

    $this->sessionID = session_id();
    if ($this->sessionID == "" && !headers_sent()) {
        $URL = $this->EE->config->item('site_url', 1);

        if (strpos($URL, "www.") !== FALSE)
            $domain = substr($URL, strpos($URL, "www."));
        else
            $domain = $URL;

        if ($searchPos = strpos($domain, "//"))
            $domain = substr($domain, $searchPos+2);
        if ($searchPos = strpos($domain, "/"))
            $domain = substr($domain, 0, $searchPos);
        if ($searchPos = strpos($domain, ":"))
            $domain = substr($domain, 0, $searchPos);
        if (substr($domain, 0, 1) != '.')
            $domain = '.'.$domain;

        //session_set_cookie_params(0, '/', $domain, false, true);
        setcookie(session_name(), session_id(), 0, '/', $domain, 0);
        setcookie(session_name(), session_id(), 0, '/', $domain, 1);
        session_start();
    }
} //###   End of create_session function

```

You'll need to set `$this->class` in the class or construct. You could extend it so the set added it as array elements, and get had a parameter for which element of the array to retrieve.

---
Tags: php, plugin
---


title: Muliptle Entries in single box on CMS?

text:
# Question
Title: Muliptle Entries in single box on CMS?
I'm trying to create a directory of pet stores in UK&Ireland and I would like to know how I can input the brands each store carries into the CMS.It is just me doing the data entry so I wanted to be able to copt / paste from each store website and past their a-z of brand into one box but I've been told by my website designer that it isn't possible to do this as the results get mixed up ? Is this the case and how can I avoid months of manual entry and possible human error ?

# Answer
I would look at creating a channel to store the brands in and a channel to store the stores in. This way you can use the relationship fieldtype to link the pair together.

Dave.
> 1 votes

# Answer
If you just paste all data into one single form field, is going to be really hard to:

* to filter entries by this data;
* to format the presentation of the this data;
* to edit part of this data;

Imagine that one brand closes or change its name. How will you edit all stores at once? How will you list all stores by brand?

And copy/paste process isn't a good way to avoid possible human error.

I believe the best way is to use categories as brands and hire an backend developer, **not a designer**, to code a program that grab the data and turns into categories.
> 0 votes

---
Tags: custom-fields
---


# Question
Title: EE1 plugin that outputs data from third-party oracle database, can I cache?
I developed a plugin that pulls data from an oracle (oci8) database.

One function in the plugin returns hundreds of rows and the page takes about 5 seconds to load. I have caching turned on, so when you refresh the page, it takes .03 seconds to load.

I was wondering if there is any other things I could do to speed up or cache the data.

# Answer
> 0 votes
I implemented apc cache.

I stored the data apc\_add($key, $value, 600); and fetch it $value = apc\_fetch($key);

Works like a dream.

---
Tags: php, plugin, ee1, performance, cache
---