# Question
Title: Iterate child categories inside parent category loop
I have a simple two-level category structure like this:

* Fresh
    + Fresh Pre Packed
    + Fresh Bulk
* Frozen
    + Frozen Pre Packed
* Ready To Go
    + Meals
    + Condiments

I'm simply trying to iterate though the parent categories and for each parent loop through its children and then output the channel entries for that specific category.

I may have overthought this a bit, but right now what I have is this:

```
    {exp:channel:categories category_group="2" style="linear"}

    <?php
    if({parent_id} == 0) :
        $categories['{category_id}'] = array();
    else :
        if(isset($categories['{parent_id}'])) $categories['{parent_id}']['{category_id}'] = '{category_name}';
    endif;
    ?>

    {/exp:channel:categories}

    {exp:channel:categories category_group="2" style="linear" parent_only="yes"}

    <div id="products-{category_url_title}" class="products-row grayscale">
        <div class="products-cover">
            <div class="page-heading"><h1>{category_name}</h1></div>
        </div>
        <div class="row-content products-content">
            <div class="container">
                <div>
                    <p>{category_description}</p>
                    <div class="white-box">

                        <?php if(isset($categories['{category_id}'])) :
                        foreach ($categories['{category_id}'] as $category_id => $category_name) : ?>

                        <h3><?= $category_name ?></h3>

                        <ul>
                            {exp:channel:entries channel="products" category="<?= $category_id ?>"}
                            <li><a href="#" data-product="{entry_id}">{title}</a></li>
                            {/exp:channel:entries}
                        </ul>

                        <?php endforeach; endif; ?>

                    </div>
                </div>

            </div>
        </div>
    </div>

    {/exp:channel:categories}

```

This works fine in that it properly iterates though the children for each parent, but I can't output the channel entries since the parsing stage is set to output, so the category parameter is never set.

If I do extract that channel entries tag to another template, I run into the same issue as I'd need to pass the category id as an embed variable, which would fail for the same reason.

So right now I'm struggling to identify a reasonable solution or a simpler alternative. If possible, I'd like to avoid utilizing third party addons (not that I don't use them, I just like to minimize their use where possible).

**EDIT:**

I tried using GWcode Categories to replace the child category loop with the following code (replacing the inner PHP), but I get the same result:

```
{exp:gwcode_categories cat_id="{category_id}" incl_self="no" style="linear"}

    <h3>{cat_name}</h3>

    <ul>
    {exp:channel:entries channel="products" category="{cat_id}"}
        <li><a href="#" data-toggle="modal" data-modal="product" data-target="#product-modal" data-product="{entry_id}">{title}</a></li>
    {/exp:channel:entries}
    </ul>

{/exp:gwcode_categories}

```

# Answer
Use the parse="inward" parameter.

```
{exp:gwcode_categories cat_id="{category_id}" incl_self="no" style="linear" parse="inward"}

```

Which will ensure {cat\_id} is set prior to the channel:entries tag being run.
> 1 votes

---
Tags: categories, php, loop, nesting
---


# Question
Title: Redirect templates with native template routes
I have a template group called 'members' with two templates - 'male' and 'female'.

Now, I want the 'index'-template of the 'members'-group to redirect to the 'male'-template, whenever somebody types in the following URL:

`my_site.com/members`

I've setup a route in the CP like this...

`'members/index' => 'members/male'`

... and put this in my 'members/index'-template:

`{route="members/male"}`

I expected this to initiate a redirect, but it doesn't. So, how do the new native template routes actually work?

# Answer
OK, I've just discovered the following feature in the access-section of the template manager:

"When unauthorized users try to access this page, show this one instead"

This solves my problem perfectly!

Or, as an alternative, I can add this to the `members/index` template:

```
{if segment_2 != ""}
    {redirect="members/male"}
{/if}

```
> 0 votes

---
Tags: routing
---


# Question
Title: No email notifications being triggered after a successful CT test purchase with SagePay
After a successful test transaction with SagePay no email is triggered for admin or the customer. Also I cannot get the status change trigger to work either. Although the low stock trigger does work, so I know that emails in general are working ok.

I have checked that the email is stored correctly in the customer info tag (before being sent to SagePay) and it is. But the emails are not even being logged in the CT email logs.

Also, when I return from SagePay (and get the successful page with correct info etc) the cart still has items in it, so it's not being cleared as it should. I'm sure it's all related to something simple maybe?

Any ideas please?

# Answer
> 0 votes
Turns out it was my own silly mistake causing the issues here, whoops!

In the successful transaction email notifications I was using {exp:cartthrob:order\_subtotal} as opposed to {exp:cartthrob:cart\_subtotal}. This caused problems with the transaction authorisation process.

After talking through with Chris @ CartThorb, he realised my mistake. After changing the tags to the correct version all was OK.

Hopefully this will help someone else at some point!

Thanks for the great support Chris.

---
Tags: cartthrob
---


# Question
Title: How to integrate calendar module with structure module
We have setup calendar module and create calendar template (as below) but when i click on previous or next month rise an error "404 page not found"

Note: I'm using structure module to generate pages and navigation

```
 {exp:calendar:events limit="1"}<h1 class="page-title">{calendar_title}</h1>{/exp:calendar:events}
{exp:calendar:cal
    enable="custom_fields"
    pad_short_weeks="y"
    show_weeks="4"
    date_range_start="{embed:embeded_date}-01" date_range_end="{embed:embeded_date}-last"
    category="{embed:cat}"
    dynamic="no"
    parse="inward"
    status="not closed"
}
 {display_each_month}

<div class="event-cal clearfix">
<ul class="calendar-nav">
<li class="current-month">{date format="%F %Y"}</li>
<li class="prev-month"><a href="{structure:page:url}{prev_month format="%Y/%m"}">
                               Previous
                            </a></li>
<li class="next-month"><a href="{structure:page:url}{next_month format="%Y/%m"}/">
                                Next
                            </a>
</li>
</ul>
<div class="days-of-week">
    {display_each_day_of_week}
        <div class="cal-day">{day_of_week_short}</div>
        {/display_each_day_of_week}
</div>
    {display_each_week}
<div class="cal-week">
        {display_each_day}
        <div class="cal-date">

{if day_event_total !="0"}
                    <a href="#" data-options="align:right" data-dropdown="drop-{date format="%F-%d"}" class="button">{date format="%d"}</a>
                    <div id="drop-{date format="%F-%d"}" class="event-tooltip small content f-dropdown"  data-dropdown-content>
                    <h4>{date format="%F %d, %Y"}</h4>
                    <ul>
                    {events}
                        <li><a href="{page_url}">› {event_title}</a></li>
                    {/events}
                    </ul>
                    </div>
                    {if:else}
                   <span class="no-event">{date format="%d"}</span>
        {/if}

        </div>
        {/display_each_day}
</div>
    {/display_each_week}

</div>
{/display_each_month}
{/exp:calendar:cal}

```

# Answer
> 0 votes
According to Structure's developers you need to have the calendar tag in a non-Structure managed template for pagination to work.

https://structure.tenderapp.com/discussions/problems/1337-conflict-with-solspace-calendar-pagination-and-structure-3-attempting-to-find-workaround#comment\_9835986

---
Tags: structure, calendar
---


title: Wygwam 3.3.1 Add an <input> button

text:
# Question
Title: Wygwam 3.3.1 Add an <input> button
Since Wygwam 3 was released it has not had the form elements button reintroduced. I am in need of some guidance on how to add the button back for our editors, more specifically the field.

I have looked into adding plugins to CKeditor, and it appears I have followed the instructions but the integration with expression engine the button will not show.

I contacted Brandon Kelly about this back in September and he indicated the following...

> We removed those plugins for Wygwam 3.0, along with some others that were very rarely used, to cut down on Wygwam's overall file size. The next update will come with a way to bring them back if you really need them, but for now, the only way to get them is to go back to Wygwam 2.x.

The update to Wygwam 3.2 appears to have added this functionality, but the documention is unlear to me.

> Wygwam 3.2
>
> Released on Oct 1, 2013
>
> Added the wygwam\_tb\_groups, wygwam\_tb\_label\_overrides, and wygwam\_tb\_combos extension hooks, making it possible for other extensions to add new toolbar buttons to Wygwam’s toolbar configurator.
>
> http://docs.pixelandtonic.com/wygwam/changelog.html

Thanks for any help!

# Answer
I had a similar issue with adding back in the save icon as my users had become accustomed to using it.The icon was available as a plugin for ck-editor and got it working after a bit of a battle .The documentation on how to do so isn't very good and is difficult to follow. There is a lot involved in this in this so it might be best if i can email you what i have done and you can just copy it and make a few adjustments for your plugin
> 1 votes

---
Tags: wygwam
---


title: Using Product Tag In Checkout Tag

text:
# Question
Title: Using Product Tag In Checkout Tag
Is there some sort of way in Expresso-Store that I am able to use the `{exp:store:product}` tag inside of the `{exp:store:checkout}` tag without generating a 'product form' inside of the 'checkout form'? I need to use the {total\_stock} tag from `{exp:store:product}`.

I tried to use `{exp:store:product}` inside of `{exp:store:checkout}`, but then my submit button to go to the next checkout step did not respond at all and I think this might have been because there were two forms on the page?

I have this code within my `{exp:store:checkout}` tag:

```
{if total_stock > 0}
    <select name="qty">{exp:lb_cart:get_cart_stock t_stock="{total_stock}" item_qty="{item_qty}"}</select>
{if:else}
    <p>Out Of Stock ({item_qty}). Item will be removed from the cart.</p>
{/if}

```

Is it possible to user the `{total_stock}` referencing `{exp:store:product}`?

# Answer
You can add `disable_form="yes"` to the `{exp:store:product}` tag to disable the creation of the form. (Docs.)
> 5 votes

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


# Question
Title: Is there a variable available for user defined category trigger word?
I'm in a situation where **I have to** build a url like :

```
{path='template/group/category/{category_url_title}'}

```

Now, if someone changes the *category* trigger word in the control panel, this URL will lead to a 404. I wonder if there is any undocumented? variable that would give me the category trigger word, without enabling php in the template ?

# Answer
No, there isn't, but maybe you don't need one or, if you really need, you can create one.

The docs says:

> The category designation information will automatically be added to the end of the URL so that the target page will know which category to display.

So, inside of a {categories} variable pair, the necessary info will be added and you don't need to worry about it.

If you still want to prevent the user from changing this, you can override this setting on the `config.php` file:

```
$config['reserved_category_word'] = 'category';

```

Now, this setting can't be changed on Admin › Channel Administration \> Global Channel Preferences. But it can still be changed on Admin \> System Administration \> Config File Editor.

If you still need the variable, you can create it. Back on the `config.php`, after you set the `$config['reserved_category_word']`, add this before `// END EE config items`:

```
/**
 * @see  https://gist.github.com/464756
 */
global $assign_to_config; // Make this global so we can add some of the config variables here

// make sure our global vars config exists
if(!isset($assign_to_config['global_vars']))
$assign_to_config['global_vars'] = array();

```

And them create your variable:

```
$assign_to_config['global_vars']['cv-category_word'] = $config['reserved_category_word'];

```

I prefixed the variable with `cv-` to make it easier to remember where it was set, a Config Variable, but you can use the name you prefer.

You can access this variable on your templates: `{cv-category_word}`.

Remember that you can always set which parts of the CP the user can have access to.
> 0 votes

# Answer
Presumably, you're creating this URL inside of a `{categories}` loop - in which case you simply need to do this:

```
{path="template/group"}

```

This will output **/template/group/category\_trigger/category\_url\_title**.
> 0 votes

---
Tags: categories
---


title: Template Embed: how to embed JSON?

text:
# Question
Title: Template Embed: how to embed JSON?
I need to create a series of templates that output a JSON string for Ajax to consume and utilize in the frontend. My other templates could benefit from using this as it too needs the same data. Is there a way for a template to embed a template that outputs a JSON string and somehow use it (e.g. assign it to a variable, loop through it, access each index, etc.)?

# Answer
> 3 votes
Take a look at **JSON** by Rob Sanchez. It works very well if you need to output ExpressionEngine data in JSON format. It has a lot of useful parameters.

The plugin tag can go right into your template where you want your JSON object.

```
<script>
    var json = {exp:json:entries channel="programs"};
    console.log(json);
</script>

```

Or you could put it in its own template and then load it with jQuery `$.ajax()`.

# Answer
> 1 votes
For this you gonna need an add-on. EECMS can't do this by its own.

There are two good options:

* Rest \- it's a good option. Besides the developer, who has an excellent reputation, had abandoned the project, he continues to accept pull requests and the add-on is used by a lot of developers;
* AJW Feed Parser \- I usually prefer this, because of its caching functionality. It caches the source, so you can use the data on several pages without to fetch them again until the cache expires.

Both of them treat the source as an external one.

# Answer
> 1 votes
One answer is to create a new template and create your own custom implementation of JSON.This may be way easier than having to learn a huge api for something simple.

```
   //JSON STRING
   {entries:
    [
       {exp:channel:entries}
       {entry_title:{title},entry_content:{content}},
       {/exp:channel:entries}
    ]
   }

```

The way you would implement this in JavaScript would be to parse the returned AJAX string.

```
//EXAMPLE
myJSONObject.entries[0].entry_title;

```

To make this code multipurpose use if/esle statements and pass variables to the template when you embed it.

For instance,

```
   {if embed:isEmbedded == "yes"}
   //Javascript for embedded templates
   var myJSONObject =
   {/if}
   //JSON STRING
   {entries:
    [
       {exp:channel:entries}
       {entry_title:{title},entry_content:{content}},
       {/exp:channel:entries}
    ]
   }

```

In your template, the code would like this:

```
  <script type="text/javascript">
   {embed="embeds/jsonApi" isEmbedded="yes"}

    //Access the JSON object
    myJSONObject.entries[0].entry_title;
  </script>

```

---
Tags: templates
---


# Question
Title: Can I change the Field Label Length in Solspace Freeform
I have a composer template in freeform pro, thats being used as a survey. The field label needs to be a question which is quite long but there appears to be a limit on the field label in Freeform. Can this be changed?

# Answer
> 1 votes
There is a limit in the label field in the CP: if you look at the source code, you will see the input field has an attribute: `maxlength="150"`. That limits the field to entering 150 characters.

Even if you changed that value temporarily using the Web Inspector or Firebug in your browser, in the `exp_freeform_fields` database table, the field\_label column is VARCHAR(150), which means that beyond 150 characters, the database cuts off text to 150 characters. You would have to make a change in the database as well, which is something we would recommend being *very* careful with if you're not familiar with MySQL (we can't advocate doing that).

Since you need more text and instead of doing the above hacks, how about using the **Field Description** field to hold your label text? That field can hold a lot more text (65000+ characters actually), and you can swap it with your label in the template code.

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


title: Using PayPal during CartThrob checkout

text:
# Question
Title: Using PayPal during CartThrob checkout
I am new to EE. Can someone guide me how to include paypal in payment type during checkout. Currently we have visa,american express,Mastercard,discover

# Answer
> 1 votes
Since PayPal is an *off-site* payment gateway, whereas Stripe is an *on-site* gateway, you'll likely want separate checkout forms, since the final action of each will differ (the Stripe checkout form tokenizes the card and sends it for payment, whereas the PayPal checkout form sends the user to PayPal).

So, on the previous screen before the payment step, give users the option (credit card or PayPal), then send them to the respective template based on that.

Then you just need to use the `gateway` parameter (docs) of the `checkout_form` tag so that each gets processed properly.

This tutorial may also help: Allow the customer to select a gateway

---
Tags: cartthrob, checkout, paypal-express-checkout
---


# Question
Title: Not able to Edit Channel Fields or Templates. Gives Error: disallowed key character
Suddenly, We are not able to edit and Channel Fields. We are using: EE v2.8.1 - Build Date: 20140314

If we go to: Admin \> Channel Administration \> Channel Fields \> Example Group \> Slider Image and not even change any values but simply hit "Update" button

its giving error saying: disallowed key character

We did some google and we tried all different solutions: clearing Cookies, Cookie Prefix but nothing is helping

any help or pointers to solve this issue will be of great help. Also same error comes up if we edit any template and if that template has a word like name="fullname"

see screenshot attached for the page we are hitting update that gives us error.

# Answer
> 2 votes
I had a similar issue recently on a VPS account – the local version worked. It ended up being a mod security setting that was preventing this from saving with the same error you mentioned.

Oddly this is the first time this issue came up with ExpressionEngine, despite being an issue with other CMS before using the same provider (Liquidweb in my case.)

Hope that helps.

# Answer
> 0 votes
Thanks Everyone for your inputs

We finally figured out that is was a security settings which was activated by our hosting provider which was stopping any form to except characters like { } "

---

It was being blocked by security settings in Comodo WAF (which appears to be a little excessively strict in recent updates) and has been allowed now.

---

---
Tags: control-panel, php-errors, codeigniter, channel-fields
---


# Question
Title: Using Related Entries for Modular Content Entry
Does any one know if there's a way to use data from other entries for modular content entry?

Meaning a user is presented with a Matrix-like field and they add a row and select WYGWAM to begin typing. They get to a part of their article where they want to include data from another entry so they add another row and select a "Hotel" entry for example. Then they wish to continue writing and add another row and select WYGWAM and continue typing.

Then on the front-end the data is presented as:

1. WYGWAM Body Copy
2. Embed of data from a Hotel Entry
3. WYGWAM Body Copy

The thought behind this is that the data for the Hotel Entry no matter where it appears is controlled by an entry and when updated is updated across the site wherever it appears.

# Answer
> 1 votes
Put both field types in the Matrix, let users choose what to use by entering content or selecting an entry from the Playa field, and then have template-level conditionals checking the fields for content and applying appropriate markup.

---
Tags: channel-entries, matrix, playa, relationships
---


# Question
Title: Redirecting Joomla Links to New ExpressionEngine Links Fails
I'm running into an issue where 301 redirects on site I switched from Joomla to EE are not working. The link style on the old version of the site is:

http://example.com/index.php?option=com\_user&view=reset&Itemid=14

For the redirect, I'm using this line in the .htaccess:

`Redirect 301 /index.php?option=com_user&view=reset&Itemid=14 /contact`

Since index.php is valid with EE, my assumption is the issue revolves around the query string since a more basic redirect works as indended:

`Redirect 301 /about /`

routes traffic from the about page to the home page.

How can I redirect these links to the new ExpressionEngine-powered pages or, if the issue is more generic, links containing "index.php?"?

# Answer
You need to use **%{QUERY\_STRING}**

```
RewriteCond %{QUERY_STRING} ^option=com_user&view=reset&Itemid=14$
RewriteRule ^(.*) /contact? [L,R=301]

```
> 3 votes

---
Tags: redirects, redirection
---


# Question
Title: Advanced Conditions: {if:else} tag not getting read
So, I think I've caught on that advanced conditions and EE tags don't play like expected.

So, I downloaded Mark C's "IfElse" plugin and things are looking up.

However, my default condition, doesn't work. EE is NOT parsing the "last/default" condition so therefore the content is not appearing from the channel and only text versions of the field names (e.g. {title}, {body}) appear.

Any help would be appreciated.

```
{exp:ifelse parse="inward"}

        {if segment_3 =="1"}
           {exp:channel:entries channel ="about" entry_id="33"}

        {if:elseif segment_3=="2"}
           {exp:channel:entries channel ="about" entry_id="32"}

        {if:elseif segment_3=="3"}
           {exp:channel:entries channel ="about" entry_id="34"}

        {if:elseif segment_3=="4"}
           {exp:channel:entries channel ="about" entry_id="35"}

        {/if}
{/exp:ifelse}

{title}
{body}

{/exp:channel:entries}

```

Also, for the last condition, I've tried the normal:

```
 {if:else}
   {exp:channel:entries channel ="about" entry_id="35"}

 {/if}
 {/exp:ifelse}

```

But no cigar.

# Answer
You don't need any add-on to make this to work.

Take a look at the docs.

Segment variables as parsed before any module tags. Advanced conditionals are parsed after, but you can use simple conditionals.

So:

```
{exp:channel:entries channel ="about"
    {if segment_3 == "1"}
        entry_id="33"
    {/if}
    {if segment_3 == "2"}
        entry_id="32"
    {/if}
    {if segment_3 == "3"}
        entry_id="34"
    {/if}
    {if segment_3 == "4"}
       entry_id="35"
    {/if}
}

    {title}
    {body}

{/exp:channel:entries}

```

Isn't all that beautiful, I know, but is fast, simple and DRY.
> 1 votes

# Answer
Yikes! With all due respect, this is an extremely inelegant approach. You should never attempt to output different opening tags in this way. Even if you are able to somehow make it work, the next developer to look at this code will be cursing your name!

Here are some alternatives:

* Use the url\_titles or the entry\_ids directly in segment\_3 instead of 1/2/3, which would automatically show the right entry due to the default `dynamic` nature of the channel:entries tag.
* Use the native Pages module to assign whatever URI/template combination you like to an entry, which will also allow a single channel entries tag to work dynamically
* Alternatively, use Stash to set a variable which you then pass to the channel:entries tag like so:

--

```
{exp:stash:set name="the-entry"}
    {if segment_3 == '1'}31{/if}
    {if segment_3 == '2'}32{/if}
    {if segment_3 == '3'}34{/if}
    {if segment_3 == '4'}35{/if}
{/exp:stash:set}

{exp:stash:parse}
    {exp:channel:entries entry_id="{stash:the-entry}"}
        <h1>{title}</h1>
        {body}
    {/exp:channel:entries}
{/exp:stash:parse}

```
> 2 votes

# Answer
As someone else has said this is an inelegant approach and there are better ways to do it.

But for starters try putting the complete tag pair within each condition and see if that works. i.e.

```
    {if segment_3 =="1"}
       {exp:channel:entries channel ="about" entry_id="33"}
           stuff
       {/exp:channel:entries}
    {if:elseif segment_3=="2"}
       {exp:channel:entries channel ="about" entry_id="32"}
           stuff
       {/exp:channel:entries}
    {if:elseif segment_3=="3"}
       {exp:channel:entries channel ="about" entry_id="34"}
           stuff
       {/exp:channel:entries}
    (if:elseif segment_3=="4"}
       {exp:channel:entries channel ="about" entry_id="35"}
           stuff
       {/exp:channel:entries}
    {/if}

```

If that works you can then think about how to make the code more efficient. Try using stash, switchee or as someone said, use the entry IDs/url\_title in your URL which will negate the need for this approach.
> 2 votes

---
Tags: conditionals, ifelse
---


title: Magpie issue with HTTP status code

text:
# Question
Title: Magpie issue with HTTP status code
In attempting to use the Magpie RSS parser, I'm getting the below errors:

```
A PHP Error was encountered
Severity: User Warning
Message: MagpieRSS: Failed to fetch http://careercenter.gammaiotasigma.org/jobs/?display=rss&keywords=&filter=SHOW_AT%3A740037&resultsPerPage=12.
  (HTTP Error: connection failed (101))
Filename: plugins/pi.magpie.php
Line Number: 1387

A PHP Error was encountered
Severity: Notice
Message: Trying to get property of non-object
Filename: plugins/pi.magpie.php
Line Number: 104

```

In checking http status codes, 101 =

```
101 Switching Protocols
This means the requester has asked the server to switch protocols and the server is
acknowledging that it will do so

```

Why would that be considered an http ERROR?

Magpie tag that causes the error:

```
{exp:magpie url="http://careercenter.gammaiotasigma.org/jobs/?display=rss&keywords=&filter=SHOW_AT%3A740037&resultsPerPage=12" limit="12" refresh="720"}
<ul>
    {items}
    <li><a href="{link}">{title}</a><br>
        {description}
    </li>
    {/items}
</ul>
{/exp:magpie}

```

In THE SAME PAGE, I have this feed and it works:

```
{exp:magpie url="http://careers.independentagent.com/jobs?resultsPerPage=12&display=rss" limit="12" refresh="720"}
<ul>
    {items}
    <li><a href="{link}">{title}</a><br>
        {description}
    </li>
    {/items}
</ul>
{/exp:magpie}

```

What am I doing wrong? I ran both through the validator and they are both valid feeds.

# Answer
> 2 votes
Personally I wouldn't put too much reliance on Magpie. It's fine in simple use cases but if you want to grab an RSS/XML feed there are plenty of options to choose from. I would suggest Feed Parser as a good free alternative.

---
Tags: ee2, rss
---


# Question
Title: Tracking views in an entries loop with more than one result
I’m trying to use the ‘track\_views’ parameter to record impressions of banners which are being served on a website. Am I correct in thinking that track\_views is *only* supported on single entry pages, i.e. if I have a channel:entries loop that outputs more than 1 entry it will not track views?

# Answer
The short answer is yes. :) Your inkling is correct in that `track_views` is only supported on single entry pages specified by title or ID. Multiple entries can be output with the {view\_count} displayed but views will not be incremented. I'd love to expand a little but I can't really think of a good way around this as the entry tracking is pretty rigid.

For banner/advertising impressions however it would probably be better to go with a more versatile option such as Google Analytics.
> 1 votes

---
Tags: entries, tracking
---


# Question
Title: Using FreeMember to record interests (categories) to a member profile
I have a FreeMember based registration form where I want to record a users areas of interest at time of registration and also provide a mechanism to edit those interests after registration through a profile edit screen.

The areas of interest are ExpressionEngine categories so I can easily pull them out and display them as a list of checkboxes on the registration and profile edit screens. My question is two fold...

1) How should I approach storing this data in a custom member profile field? Ideally I want this to remain flexible so I’m envisaging storing the data as a a pipe delimited string of category\_ids or a JSONified array.

2) How am I best off processing the data, maybe using a bespoke extension for FreeMember or using jQuery to process the checkbox states on click and process that data and stuff it into a hidden field, then do the reverse on page load.

Thoughts much appreciated!

# Answer
> 2 votes
I've solved this by forking and modding the FreeMember add on. When passed an array type form field (i.e. where you name the field 'field\_name\[\]' and then have multiple inputs by the same name) FreeMember would throw a PHP error. I modified the module to simply detect an array type input and implode it and store is as a pipe delimited string.

Modified FreeMember model: https://github.com/nathanpitman/freemember/commit/e04a3142981281c125fb1417d8f9205b34c882e7

When returning the data I was able to use the PHP String Fun plug-in to parse the pipe delimited list and compare it the category\_ids in my channel:categories loop to 'check' the correct checkboxes. :)

Example template code to check categories based on a pipe delimited string is a custom member field:

```
<ul>
    {exp:channel:categories channel="content" parent_only="yes" style="linear"}
    <li><label for="Cat_{category_id}"><input type="checkbox" id="Cat_{category_id}" name="member_interests[]" value="{category_id}"{if "{exp:phpstringfun function='substr_count' par1='{category_id}'}{member_interests}{/exp:phpstringfun}" == "1"} checked="checked"{/if}> {category_name}</label></li>
    {/exp:channel:categories}
</ul>

```

# Answer
> 0 votes
I think as you have figured out, Freemember doesn't support this natively. Freemember is a simple solution, and is only really designed to work with the built in EE member field types. That said, you could definitely modify Freemember to suit your needs.

To be honest, with complex requirements like this I would look into a more full-featured solution such as Zoo Visitor which allows any custom member field types using regular EE channel entries, rather than trying to modify Freemember to do it.

---
Tags: categories, extension, freemember
---


# Question
Title: Expresso Store Hook store_order_complete_end
I am very new to EE2 and using Expresso Store in one of my websites in EE2 and need to use this hook when the order has completed and payment has been made successfully. The code I need to call is this: `ee()->extensions->call('store_order_complete_end', $order);`

What I would like to ask is what do I parse to the $data parameter?

When this hook runs, I need to call a function that generates a coupon code and add this code to the database, but what is the `$order` parameter in this piece of code and where exactly in the project would I call this piece of code?

# Answer
> 2 votes
You might find the EE Extension Development guide useful.

Basically, you need to create an extension which handles the `store_order_complete_end` hook. I'm not sure what you mean by the `$data` parameter, but the `$order` parameter is a Store Order model. You can access attributes on it like this:

```
$order->id;
$order->billing_address;
$order->order_total;

```

The attribute names match those found in the checkout tag.

---
Tags: expresso-store, ee2, extension, hook
---


# Question
Title: How can I provide a custom order shipping value?
I'm trying to create a plugin to allow shipping cost based on ranges of post codes. The post codes are hard-coded into the plugin. Due to my lack of experience developing for ExpressionEngine I'm unable to get the plugin to do anything.

Note that the cart only has **one** shipping option; the user shouldn't need to or be able to select a shipping option; this should be applied automatically based on their shipping post code.

Plugin: https://gist.github.com/anonymous/86838c02028faabfb404

# Answer
The problem is that you are trying to edit the order directly.

Instead, your extension should implement the `store_order_shipping_methods` hook to return your custom shipping rate, as the official Store shipping extensions do.

Inside the extension file, your hook method should look something like this:

```
public function shipping_methods($order, array $methods)
{
    if (ee()->extensions->last_call !== false) {
        $methods = ee()->extensions->last_call;
    }

    // implement your own shipping logic here
    if ($order->shipping_postcode == '12345') {

        // add a custom shipping method
        $option = new Store\Model\OrderShippingMethod;
        $option->id = 'custom';
        $option->name = 'My Custom Shipping Method';
        $option->amount = 10.00;
        $option->class = __CLASS__;

        $methods[$option->id] = $option;
    }

    return $methods;
}

```
> 1 votes

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


title: Abandoned Cart Emails (Expresso-Store)

text:
# Question
Title: Abandoned Cart Emails (Expresso-Store)
The website I am busy developing contains a shopping cart and after 2 hours of no user activity, the current cart is considered abandoned and should send the user an email regarding this.

I am using Expresso-Store as my shopping cart and considering the Postmaster add-on for handling my emails. Will the Postmaster add-on handle the sending of email after 2 hours of inactivity?

# Answer
I don't think postmaster supports this out of the box.

However, it should be fairly trivial to add support for. Store keeps all incomplete carts in the exp\_store\_orders table (with `completed_date` set to `NULL`), so it would be fairly easy to grab the most recent abandoned carts and send a follow up email to them.
> 3 votes

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


title: Bulk Import of Categories

text:
# Question
Title: Bulk Import of Categories
I have to import about 1,000+ Categories that are 4 levels deep. Is there an easy want to bulk import categories? I have DataGrab, but I don't think it handles Categories. I would also rather not mess with the database if I don't need to, as suggested here: What's the best way to bulk add or import categories?

# Answer
Data Grab does support category importing (See configuration grab) but as part of entry import (as far as I'm aware), so possibly discard entry information after import if it's not needed...? You could also possibly have all the categories imported with 1 entry?

If a category already exists, it won't create a new one but utilise that one.

By accident I discovered it handles multiple depths creation and assignment as I don't recall seeing any documentation on this. I had some categories with "/" in the title - it uses this as a category parent/child identifier. I've only stumbled on this as a 2 depth solution, so unknown if 4 levels would work, but if you already have DataGrab it's worth updating to latest version and giving it a test.

Example category names:

* Category1/Category1a
* Category1/Category1a/Category1a1/Category1a1a (unknown if this works)

If you import "Category1/Category1a" with first creating it's parent, the parent is automatically created with the url\_title generated automatically from the name.
> 2 votes

# Answer
There's Solspace Importer too but I don't think either that or DataGrab cater to categories with a structure that deep. :/
> 0 votes

---
Tags: categories, datagrab, import
---


# Question
Title: Using Stash to store a variable in the loop based on a conditional
I have this code.

```
{exp:channel:entries
    author_id="{segment_3}"
    channel="images"
    disable="categories|category_fields|pagination"
    dynamic="no"
}
    {if no_results}
        {exp:stash:set name="default_image"}http://placehold.it/200x200/{/exp:stash:set}
    {/if}

    {if count == 1}
        {exp:stash:set name="default_image"}{image}{/exp:stash:set}
    {/if}

    {if is_default == 'yes'}
        {exp:stash:set name="default_image"}{image}{/exp:stash:set}
    {/if}
{/exp:channel:entries}

```

The goal of the logic here is to get default image. Here is the logic

1. If there are no results, use a default image
2. If there is only 1 profile image, use it as default image
3. If there is a default image set, use it as a default image

I try to use Stash to make this happen but outputting the contents of

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

```

returns a blank string.

Am I doing something wrong with Stash? Is it even possible to do it?

# Answer
I see what you're trying to do and you're close, as most things it's a parse order issue, so some simple refactoring should suffice…

```
{exp:stash:set name="default_image" parse_tags="yes" parse_conditionals="yes"}
//Set stash here, so it parses conditionals
  {exp:channel:entries
    author_id="{segment_3}"
    channel="images"
    disable="categories|category_fields|pagination"
    dynamic="no"
}
    {if no_results}http://placehold.it/200x200/{/if}
    {if count == 1}{image}{/if}//This could do with some thought - '1' & 'is_default' could be similar, if not the same and may cause issues.
    {if is_default == 'yes'}{image}{/if}
  {/exp:channel:entries}
{/exp:stash:set}

```
> 1 votes

---
Tags: stash
---


title: Is Member Online?

text:
# Question
Title: Is Member Online?
Is there a native EE method to determine if a given member id is online? I'd rather not install an addon like http://devot-ee.com/add-ons/member-online to do this.

# Answer
> 1 votes
If you want to know if the user seeing a page is authenticated, you can use some global variables like:

* `logged_in_member_id`
* `logged_in_group_id`

Or, if you want to check for an specific member, you can use the Query module and look for the collumn `member_id` on the table `exp_sessions`.

---

If you want to list the current logged members, use the `member_names` variable pair of the Statistics Module:

```
{exp:stats channel="news|sports"}
    {member_names}
            {name}<br>
    {/member_names}
{/exp:stats}

```

---
Tags: add-on, members, statistics
---


# Question
Title: Load XML via jquery.ajax causes an error
But not a javascript error, I think its something internal to EE?

Bear with me as this is a strange error I'm seeing. I have a few pages in EE that are set type XML and they output XML dynamically using EE tags. I can click View Template next these pages and the XML loads great in a browser window. I validated the XML and it comes back with it not being valid XML. It does seem that there is a ton of blank space at the top of my outputted XML file after the xml declaration line. So, the fact that it is not validating might be the issue. (But let's not stop there with the details.)

Is there something special i need to remove the whitespace from the xml files? It does seem excessive.

Loading in a web browser works fine - check!

Loading via jquery.ajax shows an error when I am using Chrome and I look at the Response tab. So something odd is going on there.

--

Other details are when the page initial loads, the first xml page loads fine. Then i have these tabs on the page and when i click through them, the other pages fail to load. That's kind of odd.

--

This system of XML and jquery works fine on v2.5.2. We have now moved to v2.7.3. And for whatever reason, this stopped working.

We do use VZ Address, jQuery v1.11.

The other odd thing is that I dont get any javascript errors.

--

Anyone have any suggestions for settings that I should check?

--

**UPDATE** I found this thread on the EE forums.

Essentially, what it says is that each form that is submitted needs to send a XID. If you have a form you would want to add this line of code to your form.

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

```

I have a few forms that I'm going to add this too. But my main issue is adding it to the jQuery.ajax call and I guess I need to send it through to xml pages where i am loading xml data via ajax. I'll report back if this fixes my issue.

**UPDATE #2**

I wrote a function in js to get the XID value from my webpage, but this did not fix the problem. I still receive an error message when my jquery.ajax calls tries to load the XML data.

Here is what I added to the javascript to get the XID value:

```
function getXID(show) {
  var myxid = document.getElementById("xid").value;
  return myxid;
}

```

And then I call this function later on inside of another function:

```
params['XID'] = getXID(true);

```

It gets added as one of the params which is later passed to the jquery.ajax call.

I checked and I can see the XID param being sent to the jquery.ajax by looking in chrome network panel, i can see the query string it builds. So we are good there.

Here is my jQuery ajax call.

```
jQuery.ajax({
    url: url,
    type: 'POST',
    dataType: 'xml',
    data: params,
    success: callback
});

```

**Update #3**

Did some digging and I saw that its possible to disable csrf\_protection by adding this line to the config.php file.

```
$config['disable_csrf_protection'] = 'y';

```

However, my config.php already had this line in it, which is similar.

```
$config['csrf_protection'] = FALSE;

```

Uploaded the config.php file and this made no difference.

I also added this to my config.php file and this did the trick:

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

```

But I don't want to disable secure forms on my website because security is especially important on the website I am working on. Does it matter if the whole site is running under SSL? Our domain runs under SSL for the whole site.

**Update #4** Picking at straws here now. I had read that XIDs in EE2.7.3 are single use. So, i made a page template that generates a unique XID and i'm doing a "GET" to grab that XID value and i'm putting that in my function. So i get a fresh XID each time the function runs.

```
function getXID(show) {
// var myxid = document.getElementById("xid").value;
//return myxid;
$.get( "/?/Site/unique-xid", function( data ) {
var myxid = data;
    console.log(myxid);

    return myxid;

});
 }

```

This still doesnt work. What is problem here? Why doesnt this work?

Am I missing something here? Feeling defeated.

**Update #5** We got this fixed running in Chrome and Firefox. IE, you silly fool, why won't you work right? So, here is the solution I have so far.

In EE, I made a template to output a valid XID. That page template looks like this:

```
<?php header("Cache-Control: no-cache, must-revalidate"); ?>
<?php echo trim(XID_SECURE_HASH); ?>

```

Then in my JS file, i update the function I had listed above to this code:

```
function getXID(show) {

    var myxid = null;
  var scriptUrl = "/?/Site/unique-xid";
     $.ajax({
        url: scriptUrl,
        type: 'GET',
        dataType: 'text',
        async: false,
        success: function(data) {
            myxid = data;
        }
     });
     return myxid;
}

```

Then inside of another function I have this code, which run the function above and grabs that XID number and assigns it to the params array which is then sent to a $.ajax POST.

```
var params = {};

params['XID'] = getXID(true);

```

So, as far as i can see this solution works great in Chrome and Firefox. IE 11 is sort of random if it works or not. I installed the Telerik control and when i run that program everything in IE works great. When i exit Telerik and try the website, it sometimes crashes the browser and then IE stops responding. Not gonna lie there is alot going on here. The tabs trigger the functions which also load points into a Google Map.

So i read that IE has problems with AJAX "GET" requests and cache'ing problems. So i added that no-cache header in the XID template to correct that. I see in Fiddler i am getting that header i am sending.

It didnt solve the problem though. IE still flakes out.

**Completed**

Turns out the update #5 solution worked in all browsers. On my dev site there were some images that were trying to be loaded over https that it can't find and that was creating a delay for the points load.

I fixed these broken image issues on the preview site and then everything was running much faster. This was all inherited code so we are trying to fix this little by little.

I now have the solution running on our live site and appears to be working across the board in a variety of browsers. All good news.

# Answer
EE v2.7.3 requires a XID value be sent with every form submission and also every ajax request. Here's how I was able to fix this and also make a solution that I can reuse.

XIDs are single use in EEv2.7.3. I created a template in my site that outputs the XID number and also allows it to not be cached, which was a problem for IE. To fix that I added a header so it doesn't cache the page.

The template code looks like this and is set to allow PHP.

```
<?php header("Cache-Control: no-cache, must-revalidate"); ?>
<?php echo trim(XID_SECURE_HASH); ?>

```

Then, I needed a function to grab the HASH value and return its value:

```
function getXID(show) {

    var myxid = null;
  var scriptUrl = "/?/Site/unique-xid";
     $.ajax({
        url: scriptUrl,
        type: 'GET',
        dataType: 'text',
        async: false,
        success: function(data) {
            myxid = data;
        }
     });
     return myxid;
}

```

Then, with each link clicked on the map, i need to execute the function and send the HASH value along with the AJAX request that loads some XML and then plots points onto a Google Map. That code looks like this:

```
var params = {};

params['XID'] = getXID(true);

```

Finally the params array is sent via a ajax POST to get the xml file.

```
function downloadUrl(url, params, callback) {
    jQuery.ajax({
        url: url,
        type: 'POST',
        dataType: 'xml',
        data: params,
        success: callback
    });

```
> 0 votes

# Answer
> I checked and I can see the XID param being sent to the jquery.ajax by looking in chrome network panel, i can see the query string it builds. So we are good there.

It sounds like you are sending the `XID` in GET instead of POST data. CSRF tokens must be present in the POST data if POST data is received by ExpressionEngine.

2.7.3:
POST: `XID`

2.8+:
POST: `csrf_token`
or POST: `XID`
> 2 votes

---
Tags: jquery, ajax, xid, secureforms, csrf
---


# Question
Title: Page No Longer Prompting w/ USN & PSW on HTTP Authenticated Page
Page is set to "yes" for http authentication. Worked fine for the last week. Went to show a client how it worked during a training session and it was no longer working.

Thoughts? No errors, just not requested usn and password and is taking users to page that should be protected via password/usner.

# Answer
> 0 votes
@ Derek,

Thanks, that was the issue! I'll have to look into forcing the browser to not save tokens.

Thanks

---
Tags: password, http, template-manager
---


# Question
Title: Access Find & Replace Tool Without Template Warning
When saving a template with a syntax error, EE will issue a warning, with a link to a Find & Replace utility.

This utility is super handy, but only seems to be available when there is a problem (usually an open-ended tag pair). Is there any way to access this, normally?

I can't seem to find anything about it in the documentation.

Thanks!

# Answer
> 1 votes
This utility is not available outside the location where you are seeing it.

# Answer
> 0 votes
Yes, there is. The search and replace tool can be found at Tools \> Data \> Search and Replace. The available options are:

* Site Preferences
* Channel Entry Titles
* Channel Fields
* Templates

---
Tags: templates, editor
---


# Question
Title: Unable to retrieve entries created with Channel Form
I'm allowing users to create entries from the front end using Channel Form.

I can see those entries in the Control Panel. However they are not appearing when I try and retrieve the entries using the standard {exp:channel:entries} tag.

Anyone experienced that before? Any ideas why its happening?

# Answer
This problem turned out to be something with my Playa data not being saved. Once I had fixed that issue the entries created with Channel Form starting appearing in my templates. I guess the relationship was being lost which was causing the query to fail. Relieved to have it fixed.
> 0 votes

# Answer
Drawing from what Jeremy said, you need to make sure that the channel that they are posting to has a status group assigned to it.

After you're sure that they do have a status group,

go to Admin -\> Channel Administration -\> Channel Form

and choose the default status for the channel.

If you have any statuses other than "open" and "closed" you may need to add the "status" attribute to the entries loop

```
e.g.
{exp:channel:entries channel="news" status="open|pending"}
    <!-- Content -->
{/exp:channel:entries}

```

The code example above should show everything in the news channel, with a status of "open" or "pending".

Hope this answered your question.
> 1 votes

---
Tags: safecracker
---


# Question
Title: Upgraded to EE 2.8.1 from 2.7.3... site broke.
All prior upgrades were smooth so I'm surprised to be getting errors.

These are the errors I've seen so far:

```
A PHP Error was encountered

Severity: Warning

Message: array_merge(): Argument #1 is not an array

Filename: libraries/Functions.php

Line Number: 2373

A PHP Error was encountered

Severity: Notice

Message: Undefined property: EE_Template::$layout_conditionals

Filename: libraries/Template.php

Line Number: 3375

A PHP Error was encountered

Severity: Warning

Message: array_merge(): Argument #4 is not an array

Filename: libraries/Template.php

Line Number: 3375

```

Other pages are broken, can't seem to determine any errors even with error logging on.

A plain template works fine, no errors. I'll use this space to share other errors and what I figure out if anything at all.

Won't have time to take templates apart tonight so will pick up tomorrow.

# Answer
Stash 2.5.3 will stop this error notice with EE 2.8.x

The problem was: in EE 2.8 the Template::advanced\_conditionals() method assumes that the Template::$layout\_conditionals array exists, even if your template does not make use of the new 'layouts' feature. Is that a bug for Ellislab to fix? Arguably, yes.

Stash v2.5.3 adds a workaround for this problem, as does IfElse v2.0.1 if you use that as well.

It's possible there may be a small number of other add-ons affected if they call the advanced\_conditionals() method of the Template class.
> 6 votes

# Answer
Try to disable one by one your modules, addons and analyse the results after disabled each one.
> 2 votes

# Answer
We ran into this issue and it ended up being related to Stash. I'd start there if you have it installed.
> 2 votes

# Answer
I got this issue after upgrading to 2.8.1 from 2.7.3

I had Stash installed, but only got this error one one template that didn't use Stash.

I got this error on a page that had Switchee. Then inside the default Case of Switchee, I had Croxton's IfElse running around an advanced conditional.

I removed the IfElse tags around the advanced conditional and the error message went away.

UPDATE: Mark Croxton updated the IFELSE plugin to address this. There is a new safe="no" parameter in version 2.0.1. Updating and using this parameter works for me.

https://github.com/croxton/Ifelse/tree/feature/unsafe\_conditionals
> 2 votes

# Answer
In file **system/expressionengine/libraries/Template.php**

add variable

```
var $layout_conditionals = array();

```

before

```
public function __construct()

```
> 1 votes

---
Tags: 2.8
---


title: Text watermark in CE Image

text:
# Question
Title: Text watermark in CE Image
I see an option in CE Image to add watermark to an image, but that watermark -- based on the example I saw -- is an image. Is it possible to watermark an image with plain text?

# Answer
Yes, take a look at the text= parameter. :)
> 3 votes

---
Tags: ce-image
---


title: Modify htaccess to work in subfolders

text:
# Question
Title: Modify htaccess to work in subfolders
I'm trying to setup a multilanguage site using this solution http://eeinsider.com/articles/multi-language-solutions-for-expressionengine

I have to modify the .htaccess to remove index.php from URL event in the subfolder but I don't know how. The current .htaccess is this

```
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

# Removes index.php from ExpressionEngine URLs
RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
RewriteCond %{REQUEST_URI} !/system/.* [NC]
RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,NE,L]

# Directs all EE web requests through the site index file
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]
</IfModule>

```

This file is located in /en/ folder and should point to right index.php in the same folder.

Thanks

# Answer
Simply adding a `/en/` before `/index.php?/$1 [L]`

```
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

# Removes index.php from ExpressionEngine URLs
RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
RewriteCond %{REQUEST_URI} !/system/.* [NC]
RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,NE,L]

# Directs all EE web requests through the site index file
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /en/index.php?/$1 [L]
</IfModule>

```
> 0 votes

---
Tags: multi-site-manager, .htaccess
---


# Question
Title: Some missing channel entries in relationship fieldtype
I have added a multiple relationship field to a channel, however a few entries in the selected channels are not appearing in the relationship selection list, yet the entry is open and can be viewed in both the control panel and frontend. Any suggestions?

# Answer
> 2 votes
In Admin \> Channel Administration \> Channel Fields Add/Edit, check your Relationship Field Options and compare against the entries you are expecting to appear.

* Include in Selection
    + Expired Entries?
    + Future Entries?
* Limit entries by category
* Authors
* Limit entries by status
* Limit entries to X returned

---
Tags: channel-entries, relationships
---


# Question
Title: Expresso Store Fatal Error: FakePDO not found
Just attempted to install Expresso Store and I get the following warning and error and I am unable to proceed:

> A PHP Error was encountered
>
> Severity: Warning
>
> Message: Class 'Store\Illuminate\FakePDO' not found
>
> Filename: store/autoload.php
>
> Line Number: 50

and

> ...expressionengine/third\_party/store/vendor/expressodev/laravel-codeigniter-db/src/Illuminate/CodeIgniter/CodeIgniterConnectionResolver.php on line 24

I am running EE 2.8.1.

# Answer
> 4 votes
This is a known issue running Store on some servers (where PDO is not installed), and is fixed in the upcoming version.

In the meantime, you can open up `third_party/store/autoload.php`, and around line 50, change this line:

```
class_alias('Store\Illuminate\FakePDO', 'PDO');

```

to this:

```
class_alias('Illuminate\CodeIgniter\FakePDO', 'PDO');

```

---
Tags: expresso-store
---


# Question
Title: Multiple checkout with the same entry_id
I have a product which a visitor can enter your own amount. Now this product is several times can be ordered with a different amount.

Is this possible?

http://www.inescoffee.be/site/aankoopbon

Bert

# Answer
Yes you can add multiple of the same items to the same cart. If the item is exactly the same (i.e. Large Blue Shirt) they will show up under the same item:

> 2 - Shirt (Large, Blue) - $15/each - $30

If they have different modifiers or a different price Store does not consider them the same item so it would show up in 2 lines

```
1 - Shirt (Large, Blue) - $15/each - $15
1 - Shirt (Large, Red)  - $17/each - $17
Total                              - $32

```
> 1 votes

---
Tags: expresso-store, entryid
---


# Question
Title: how to display pagination like "previous 1 2...7 next"
i want to display pagination in blog section like following way

```
 <previous 1 2......7 next>

```

Can anyone help me for display pagination like above pattern

Thank You. Dhvanit N. Dave

# Answer
> 2 votes
If you check the documentation you'll find an example that is essentially exactly what you are looking for.

```
{paginate}
  {pagination_links}
    <ul>
      {first_page}
        <li><a href="{pagination_url}" class="page-first">First Page</a></li>
      {/first_page}

      {previous_page}
        <li><a href="{pagination_url}" class="page-previous">Previous Page</a></li>
      {/previous_page}

      {page}
        <li><a href="{pagination_url}" class="page-{pagination_page_number} {if current_page}active{/if}">{pagination_page_number}</a></li>
      {/page}

      {next_page}
        <li><a href="{pagination_url}" class="page-next">Next Page</a></li>
      {/next_page}

      {last_page}
        <li><a href="{pagination_url}" class="page-last">Last Page</a></li>
      {/last_page}
    </ul>
  {/pagination_links}
{/paginate}

```

---
Tags: pagination, ee
---


title: Parse order problem with CE Image?

text:
# Question
Title: Parse order problem with CE Image?
```
{exp:ce_img:single
    allow_scale_larger="yes"
    crop="yes|center,center|0,0|yes"
    filter="auto_sharpen"
    hash_filename="yes"
    height="{embed:height}"
    parse="inward"
    src="{exp:stash:get name='default-profile-image'}"
    url_only="yes"
    width="{embed:width}"
}

```

It seems like CE Image is ignoring the embed values for height and width. I've verified that the calling template is indeed passing the correct values and that the template that this CE Image tag is in can access those values. When I hard code numeric values for height and width, it works as expected. The problem only seems to occur when I try to use the embed variables.

I already have `parse="inward"`, which was needed for the Stash variable to work. Any ideas what is wrong?

**UPDATE 1:**

Since it appears that the Stash variable works, I decided to try setting the embed variable to a Stash variable:

```
{exp:stash:set parse_conditionals="yes" parse_tags="yes"}
    {stash:height}{embed:height}{/stash:height}
{/exp:stash:set}
{exp:stash:set parse_conditionals="yes" parse_tags="yes"}
    {stash:width}{embed:width}{/stash:width}
{/exp:stash:set}

```

Then I used the Stash variable as the parameter value in CE Image:

```
{exp:config_variables:get name='no_protocol_site_url'}{exp:ce_img:single
    allow_scale_larger="yes"
    crop="yes|center,center|0,0|yes"
    filter="auto_sharpen"
    hash_filename="yes"
    height="{exp:stash:get name='height'}"
    parse="inward"
    src="{exp:stash:get name='default-profile-image'}"
    url_only="yes"
    width="{exp:stash:get name='width'}"
}

```

It still seems as if CE Image is ignoring the parameter values for `height` and `width`.

Within the template with the CE Image tag, I see the proper values being outputted by these:

```
<h1>{embed:width}</h1>
<h2>{exp:stash:get name='width'}</h2>

```

**UPDATE 2:**

I enabled template debugger and noticed this:

```
Embed Variables (Keys): author_id|width|height
Embed Variables (Values): 175|{img_base_dimension_md}|{img_base_dimension_md}

```

`{img_base_dimension_md}` and `{img_base_dimension_md}` are snippets and are being passed from the embed:

```
{embed='test/get-image' author_id='175' width='{img_base_dimension_md}' height='{img_base_dimension_md}'}

```

If the values are just the string interpretation of the snippets, then I don't see how I am getting the snippet values when I output them in the `<h1>`.

# Answer
> 0 votes
The EE parser parses embed variables long before exp tags are parsed (see the EE parser rendering stages), so if the CE Image tag is in an actual embed template, then using the embed variables shouldn't be an issue. Are you including the embed with the normal {embed=''} syntax?

If you enable the template debugger, you can search through the output and see exactly what is being passed into the CE Image tag by the EE parser. Once you know what is actually being passed in, it is easier to work backwards and see where setting the variables is going wrong.

---
Tags: parse-order, ce-image
---


# Question
Title: How to fix improperly formatted URL strings entered by members
I allow members to enter their web address, facebook address, etc. for their member profiles as well as in directory listing entries. I instruct them to always include "http://" at the beginning of the URL but of course they don't always listen. So in many cases I'm getting URL formatted with no "http://" or "https://" which create bad links.

Is there a way I can essentially do a find a replace for NOT found? So if the URL string does not contain "http://" or "https://" then I can add it back in so the link isn't broken?

I use CE String plugin for other things and I have been trying to work out a way to use it for this purpose but haven't had any luck yet.

Here's the related part of my template:

```
{if website}<li class="web"><a href="{website}">{exp:low_replace multiple="yes" find="http://|https://"}{website}{/exp:low_replace}</a></li>{/if}
{if facebook}<li class="facebook"><a href="{facebook}">{exp:low_replace multiple="yes" find="http://|https://"}{facebook}{/exp:low_replace}</a></li>{/if}

```

I need to enter some logic at the beginning of each link's href to add in the "http://" if the member has not included it in their URL string. Would appreciate any help on how to achieve this.

# Answer
The EECMS has a "first party" plugin for this, but it isn't included in ExpressionEngine by default. You have to download it.

From the own add-on file:

> Makes sure that a URL has a protocol, that ampersands are converted to entities, and all other characters are properly URL encoded.

```
{if website}
    <li class="web">
        <a href="{exp:valid_url}{website}{/exp:valid_url}">
            {website}
        </a>
    </li>
{/if}
{if facebook}
    <li class="facebook">
        <a href="{exp:valid_url}{facebook}{/exp:valid_url}">
            {facebook}
        </a>
    </li>
{/if}

```

There's some useful add-ons available for download on the User Guide. They're all maintained by EllisLab itself.
> 2 votes

---
Tags: url, ce-string
---


title: Error In Core File

text:
# Question
Title: Error In Core File
In my cart (expresso-store), this error (underneath) gets displayed at the top of my page for every product in my cart i.e. if I have 2 products, 2 of these gets displayed, if I have 5 products in the cart, 5 of these gets displayed underneath each other. Is this a common mistake or am I missing something in my list of products in my code?

I am using the `{exp:channel:entries}` and `{items}` tags to iterate through the carts products.

# Answer
Fixed this. I had `{if modifiers}` and then displayed the modifiers. I changed this to `{if modifier_name}`. Seems like this fixed the problem.
> 0 votes

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


# Question
Title: Custom Module: Alternative to Using $this->EE->output->show_message($data) on a Form Submission
I've successfully created a custom module that takes customer information, submits it to Elavon (a payment gateway) and saves the data to a table in the Expression Engine database.

Currently, when a user submits the form, I have some jQuery validation to make sure the data is entered correctly, then once its submitted, I perform some server side validation to ensure that everything is as correct as it can be.

When someone submits the form, and their credit card is declined, I use

```
$this->EE->output->show_message($data);

```

to output my error message from Elavon. When they click back to go to the form, all of their data is missing. In my controller, I've added the following to save the data temporarily to a session, where I destroy it once the payment has been completed.

```
 $data = array(
     "full_name" => isset($_SESSION["full_name"]) ? $_SESSION["full_name"] : "",
     "item_description" => isset($_SESSION["item_description"]) ? $_SESSION["item_description"] : "",
     "amount" => isset($_SESSION["amount"]) ? $_SESSION["amount"] : "",
     "fname" => isset($_SESSION["fname"]) ? $_SESSION["fname"] : "",
     "lname" => isset($_SESSION["lname"]) ? $_SESSION["lname"] : "",
     "address" => isset($_SESSION["address"]) ? $_SESSION["address"] : "",
     "city" => isset($_SESSION["city"]) ? $_SESSION["city"] : "",
     "state" => isset($_SESSION["state"]) ? $_SESSION["state"] : "",
     "zip" => isset($_SESSION["zip"]) ? $_SESSION["zip"] : "",
     "email" => isset($_SESSION["email"]) ? $_SESSION["email"] : "",
     "phone" => isset($_SESSION["phone"]) ? $_SESSION["phone"] : ""
 );

 // Construct $variables array for use in parse_variables method
 $variables = array();
 $variables[] = $data;
 $tagdata = $this->EE->TMPL->parse_variables($tagdata, $variables);

```

I have placed custom tags, as defined above, in my value portions of my input fields.

```
 <input name="fname" id="fname" type="text" class="form-control" value="{fname}" />

```

This works fine for now. When a user submits the form, if there's an error, all but the sensitive credit card information is saved to a session and the form is re-populated.

However, from a UI standpoint, I would much rather show the form with an error message and never use the built in EE show\_message() function. My question is, instead of using

```
 $this->EE->output->show_message($data);

```

to show the error message, what is the best practice for re-directing back to my form with my error message? Also, I feel that using session variables is a hack way to do things and I feel like there is probably something built into EE that does this for me.

In the final section of my controller, where I call EE's built in show\_message() function, I've already tried to call the function I created to instantiate the form, but all I get is a PHP error page that gives me the following error:

**Fatal error: Call to a member function parse\_variables() on a non-object**

# Answer
Instead of module action, which posts a form to `/index.php?action_id=xx`, i rather post to the template itself (optionally with an extra segment \[1\] ) and catch the post-data in the add-on tag on the template itself.

Take a look at *freemember* and *channel-form* (formerly safecracker). Basically, inside your plugin / module you check that $\_POST\[submit\] is set and then process and handle the form. You can use `{message}` tags or tagpairs to output notices, again, you can take a look at the mentioned add-ons for this.

\[1\] As mentioned in this answer (secure form data) it is good practice to use post/redirect/get (wikipedia) pattern. This prevents multiple submits to a form when a user reloads the page. For instance, when a form sits on `/group/template` you can post to `/group/template/save/` and after success redirect back. The extra (dummy) segment can be helpful in this procedure.

As for the session, you can use $\_SESSION, since EE session is rather basic (cookie based?) However i would create an array, put that into the session and add a reference to it. That way you have more of a single point of reference (pun intended) where in the future you can replace the session handling system.

```
// reference session variable
session_start(); // important, otherwise reference doesn't work
$_SESSION['usersession'] = array();
$usersession &= $_SESSION['usersession'];

$usersession['name'] = 'john';
$usersession['info'] = '....';

```
> 0 votes

---
Tags: plugin, custom-system-messages
---


title: Parse isue with REST addon

text:
# Question
Title: Parse isue with REST addon
Yet another parse order problem!

I'm trying to use http://devot-ee.com/add-ons/rest. This works:

```
{exp:rest url="/api/get-default-profile-image/175/" format="json"}
    {default_profile_image}
{/exp:rest}

```

But this doesn't work:

```
{exp:rest url="/api/get-default-profile-image/{member_id}/" format="json"}
    {default_profile_image}
{/exp:rest}

```

(I changed the `175` with `{member_id}`. Any suggestions how I can get this to work?

# Answer
The easiest solution would be to use Mo Variables which provides an ***early parsed*** `{logged_in_member_id}` which will allow you to use it as a dynamic value in your URL path.

```
{exp:rest url="/api/get-default-profile-image/{logged_in_member_id}/" format="json" parse="inward"}
    {default_profile_image}
{/exp:rest}

```
> 2 votes

---
Tags: templates, parse-order, parsing, parse
---


# Question
Title: Advice for a user-friendly relationship dropdown
i have a channel screenings with a relationship with movie. The screening channel has date, place and movie relationship with dropdown.

the dropdown has now about 1000+ movies in it. Is there eg a choosen plugin on EE to replace the dropdown? (this one seems to be in beta http://devot-ee.com/add-ons/chosen-selects )

Best Dave

# Answer
Pixel & Tonic's Playa, which is a many to many relationship field, does have one seriously awesome benefit for you in this regard - filtering. It allows you to filter by category and search by keyword - so it may be that feature alone that makes it worth your while for this purpose.
> 3 votes

# Answer
If this is a true relationship field, then as Jean said, go with Playa's single select mode.

If this is just a plain old *select* field then take a look at the **Chosen Selects** fieldtype by John D. Wells. It's based on the Chosen jQuery plugin (demo here), which makes really long select menus easier to work with by adding filter as you type.
> 0 votes

---
Tags: relationships, control-panel
---


# Question
Title: Using Stash to get data from 1 of 2 fields
I'm currently using a template that displays an entry that could come from one of two channels like so;

```
{exp:channel:entries
    channel="channel1|channel2"
    status="open"
    limit="1"
    require_entry="yes"
}
    {exp:stash:set parse_tags="yes" parse_depth="3" save="yes" scope="site"}
        {stash:place_shortdesc}{cf_channel1_shortdescription}{cf_channel2_shortdescription}{/stash:place_shortdesc}
        {stash:place_desc}{cf_channel1_description}{cf_channel2_description}{/stash:place_desc}
    {/exp:stash:set}
{/exp:channel:entries}

```

I'm using Stash to create the variables, for example `{stash:place_shortdesc}` where the short description could come from 1 of 2 fields, depending on which channel the current entry is from.

I was wondering if this is the best way to approach this, particularly for performance? or whether it needs something like conditional loading of fields based on channel?

Thanks.

# Answer
> 2 votes
There's no need for conditionals as the fields are mutually exclusive. With Stash on the inside of `channel:entries` tags there's also no need for `parse_tags` or `parse_depth` since the enclosed content contains no *tags*. (The custom fields are variables, not tags). Otherwise it should still be fine the way you have it. Personally I prefer putting Stash on the outside of tags, and generally use `set_list` even for single entries, since this allows you to store a single named cache entry instead of lots of separate ones for each variable. I also find it simplifies any future parse order issues a bit:

```
{exp:stash:set_list name="cached-data-{segment_2}" parse_tags="yes" save="yes" scope="site"}
    {exp:channel:entries
        channel="channel1|channel2"
        status="open"
        limit="1"
        require_entry="yes"
    }
        {stash:place_shortdesc}{cf_channel1_shortdescription}{cf_channel2_shortdescription}{/stash:place_shortdesc}
        {stash:place_desc}{cf_channel1_description}{cf_channel2_description}{/stash:place_desc}
    {/exp:channel:entries}
{/exp:stash:set_list}

```

# Answer
> 0 votes
I would just use a conditional for which tags to use in the stash:set:

```
{exp:channel:entries
    channel="channel1|channel2"
    status="open"
    limit="1"
    require_entry="yes"
}
    {exp:stash:set
        parse_tags="yes"
        parse_conditionals="yes"
    }
        {if channel == 'channel1'}
            {stash:place_shortdesc}{cf_channel1_shortdescription}{/stash:place_shortdesc}
            {stash:place_desc}{cf_channel1_description}{/stash:place_desc}
        {/if}
        {if channel == 'channel2'}
            {stash:place_shortdesc}{cf_channel2_shortdescription}{/stash:place_shortdesc}
            {stash:place_desc}{cf_channel2_description}{/stash:place_desc}
        {/if}
    {/exp:stash:set}
{/exp:channel:entries}

```

I don't think performance would be an issue as you're only dealing with a single entry. One thing that would help though is not using additional parse\_depth unless it's needed for stash set. Also, pretty sure you need to add parse\_conditionals="yes" to the set parameters.

---
Tags: templates, stash, template-partials
---


title: Testing Custom Payment Gateway

text:
# Question
Title: Testing Custom Payment Gateway
I am trying to integrate PayU as payment gateway into my ExpressionEngine2 website, but battling to make the code fit and understand where I need to put what code (I wrote an extension for the gateway using the sample code I downloaded from PayU's website using sendData() and getData() functions in the gateway). How could I actually test that the payment gateway code is actually being read?

My page flow is as follows:

Credit Card Page -\> PayU Gateway -\> Success Page

# Answer
> 2 votes
PayU should be able to provide you with dummy credit card test details so you can test the whole process start to finish.

---
Tags: ee2, payment-gateway
---


# Question
Title: Wygwam 'read more' option without new paragraph tags
I am using the wygwam add on, and clicking the "read more" icon to create an excerpt. However, whenever I do this, it creates a paragraph tag around the text before the read more and starts a paragraph tag for the text after the read more. For instance, when I click view source, I see this:

```
<p>some text</p><!--read_more--><p>some more text</p>

```

I can view source and remove that /p before and p after, and that works fine. But if I wanted to stick to WYSIWYG, how do I eliminate those paragraph breaks. What I essentially want is a solid block of text without paragraph breaks when the extended portion is showing.

# Answer
I'm not sure if it will work as this is a special feature of Wygwam but try using a soft return (SHIFT+RETURN) instead of a hard return. This will use a
tag instead of a

tag pair.

Of course, this will still cause a new line but you might be able to mitigate that via css by setting the
tag to be inline.
> 0 votes

---
Tags: wygwam
---


# Question
Title: Add link for downloadable products in Expresso Store's emails?
Exp:resso Store 2.3.1 and EE 2.8.1.

How can I include a download link right in the Order Confirmation email that Store sends out for any downloadable products in that order?

# Answer
> 4 votes
Including download links is perfectly possible.

First, set the Email Formatting to "HTML", since Store's Download Tag outputs HTML.

Second, use the same code in the email template that you would use in a regular EE template to display download links. Here's an example:

```
<ul>
    {items}
    <li>
        {title}
        {exp:channel:entries entry_id="{entry_id}"}
            {exp:store:download url="{product_file}" order_id="{order_id}"}
                Download
            {/exp:store:download}
        {/exp:channel:entries}
    </li>
    {/items}
</ul>

```

If you have multiple product channels (eg. "Books", "Music", etc) instead of a single "Products" channel, you need to add in some conditionals to only show download links for products in channels that have them. In the following example, only the "Music" channel has a downloadable product field:

```
<ul>
    {items}
    <li>
        Title: {title}
        {exp:channel:entries entry_id="{entry_id}"}
            {if channel_short_name == 'music'}
                {exp:store:download url="{music__file}" order_id="{order_id}"}
                    Download
                {/exp:store:download}
            {/if}
        {/exp:channel:entries}
    </li>
    {/items}
</ul>

```

---
Tags: expresso-store, html-email, product
---


# Question
Title: Translate categories in custom built multi language site
Anyone knows how translate category names using this method?

http://eeinsider.com/articles/multi-language-solutions-for-expressionengine

# Answer
It's pretty easy.

Create a new Category Field and prefix its name with the language prefix related and use it for the translated name. For example, `pt-category_name`.

On your templates, inside categories variable pair, for example:

```
{if language == "pt"}{pt-category_name}{/if}
{if language == "en"}{category_name}{/if}{!-- being `en` your default language --}

```
> 2 votes

---
Tags: categories, multi-language
---


# Question
Title: Why Are Posts On One EE Weblog Bleeding Over To The Other
In EE 1.6.9, I've got two weblogs running on the same installation. Both use the same domain name as the base, but are different blogs. What I've found is that posts from the main blog are bleeding over into the sub blogs, so that Google is indexing the secondary site. Here's an example:

The first URL is the main site, where the post was actually published:

```
http://www.golfblogger.com/index.php/golf/comments/hyundai_genesis_test_drive_report/

```

The second is where it strangely bleeds over.

```
http://www.golfblogger.com/index.php/shopgolf/comments/hyundai_genesis_test_drive_report/

```

If I search the shop weblog from my control panel, the second page doesn't show up. Yet it appears in search engine results.

How do I keep the main site (first URL) from bleeding over to the other? I'm sure this is screwing up my search engine credibility.

As requested below, here is the EXP: Weblog code for the main site:

```
 {assign_variable:master_weblog_name="weblog1"}
    {assign_variable:template_group_name="golf"}

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset={charset}" />
    <meta property="og:image" content="http://www.golfblogger.com/images/uploads/GolfBlogger_sm.jpg"/>

    {exp:weblog:entries limit="1" rdf="off" disable="trackbacks|member_data|pagination|comments"}
    {Metatags}
    <title>
    {if customh1 != ""}
    {customh1}
    {if:else}
    {title}
    | {/exp:weblog:entries}Golfblogger: Michigan Golf Blog Featuring Golf Reviews, Golf Opinion and Golf Essays.
    {/if}

    </title>

    {embed="includes/header"}
    </head>

    <body id="secondary-page" class="comments-page">
    {embed="includes/design_top"}
         <div id="primarycontent">

    {exp:weblog:entries limit="1" rdf="off" disable="pagination"}

    <h2>{title}</h2>

    <div class="blogentry">
    <span class="date">{entry_date format="%F %j, %Y"}</span>
    {summary}
    <span class="class2">
    {body}
    {extended}
    </span>
    </div>
    <h8><b>Posted By {author}</b></h8>
    <br>

    <p>
    <h3>Golf Blog Category:<br />
    {categories weblog="{master_weblog_name}" backspace="7"} <a href="{path={template_group_name}/golfing-blog/}" title="Browse articles in {category_name}">{category_name}</a>, {/categories}
    </h3>

    <h4>Interact:<br />
    <a href="{title_permalink="{template_group_name}/comments"}" title="Permalink for {title}">Permalink</a> |
    <a href="http://www.golfblogger.com/index.php/golfforums" title="Golf Forums">Start a Forum Post on this topic or other golf topics</a> |
    <a href="#" onclick="window.open('{permalink={template_group_name}/friend}', '_blank', 'width=400,height=650')">Email this entry</a>
    </h4>

    <p>

    <div id="comments">
    <h2>Comments</h2>
    {exp:weblog:entries weblog="{master_weblog_name}" rdf="off"}
    {if comment_total == 0}
    <p>No comments yet.</p>
    {/if}
    {/exp:weblog:entries}

    <ul>
    {exp:comment:entries}
    <li>{comment}
    <p class="comment-posted">Posted by <a href="{url}"> {name} </a> on {comment_date format='%m/%d'}</p>
    </li>
    {/exp:comment:entries}
    </ul>

    <h2>Post a Comment:</h2>
    Note: All comments are moderated. Spam comments simply will not get through. So don't bother.<p>
    {exp:comment:form preview="{template_group_name}/preview"}

    <dl class="commentsforminput">

    <dt>Name</dt>
    <dd><input type="text" name="name" value="{name}" size="30" class="commentinput" /></dd>
    <dt>Email</dt>
    <dd><input type="text" name="email" value="{email}" size="30" class="commentinput" /></dd>
    <dt>Location</dt>
    <dd><input type="text" name="location" value="{location}" size="30" class="commentinput" /></dd>
    <dt>URL</dt>
    <dd><input type="text" name="url" value="{url}" size="30" class="commentinput" /></dd>
    </dl>

    <p>
    <a href="{path={template_group_name}/smileys}" onclick="window.open(this.href, '_blank', 'width=400,height=440');return false;" onkeypress="this.onclick()">Smileys</a>
    </p>

    <p>
    <textarea name="comment" cols="50" rows="12">{comment}</textarea>
    </p>

    {if not_logged_in}
    <p><input type="checkbox" name="save_info" value="yes" {save_info} />Remember Me?</p>
    {/if}

    <p><input type="checkbox" name="notify_me" value="yes" {notify_me} />Email Me When Someone Else Comments?</p>

    {if captcha}
    <p>Submit the word you see below:</p>
    <p>
    {captcha}
    <br />
    <input type="text" name="captcha" value="" size="20" maxlength="20" style="width:140px;" />
    </p>
    {/if}

    <input type="submit" name="submit" value="Submit" class="submit-button" />
    <input type="submit" name="preview" value="Preview" class="submit-button" />
    {/exp:comment:form}
    </div><!-- end comments -->

         </div><!-- end primarycontent-->
         <hr />

    {embed="includes/secondary_sidebar"}

    {embed="includes/footer"}

    </body>
    </html>

```

And for the one it is bleeding over to:

```
{assign_variable:master_weblog_name="ShopGolfBlogger"}
{assign_variable:template_group_name="shopgolf"}

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset={charset}" />

<title>

{exp:weblog:entries limit="1" rdf="off" disable="trackbacks|member_data|pagination|comments"}
{if customh1 != ""}
{customh1}
{if:else}
{title}
| {/exp:weblog:entries}Golfblogger Golf News, Reviews and Commentary
{/if}

</title>

{embed="shopgolfincludes/header"}
</head>

<body id="secondary-page" class="comments-page">
{embed="shopgolfincludes/design_top"}
     <div id="primarycontent">

{exp:weblog:entries limit="1" rdf="off" disable="pagination"}

<h2>{title}</h2>

<div class="blogentry">

{summary}
<span class="class2">

{body}

{extended}

{exp:magpie url="{RSS_URL}" limit="50" refresh="30"}

{magpie:items}
<li>
<a href="{magpie:link}">{magpie:title}</a><br>
{magpie:description}<p>
{magpie:about}<p>

</li>

{/magpie:items}

{/exp:magpie}

</span>
</div>

<h3>Golf Blog Category:<br />
{categories weblog="{master_weblog_name}" backspace="7"} <a href="{path={template_group_name}/golfing-blog/}" title="Browse articles in {category_name}">{category_name}</a>, {/categories}
</h3>

<h4>Interact:<br />
<a href="{title_permalink="{template_group_name}/comments"}" title="Permalink for {title}">Permalink</a> |
<a href="http://www.golfblogger.com/index.php/golfforums" title="Golf Forums">Start a Forum Post on this topic or other golf topics</a> |
<a href="#" onclick="window.open('{permalink={template_group_name}/friend}', '_blank', 'width=400,height=650')">Email this entry</a>
</h4>

<h2>Add Your Review of the {title} below:</h2>

<div id="comments">
<h2>Comments</h2>
{exp:weblog:entries weblog="{master_weblog_name}" rdf="off"}
{if comment_total == 0}
<p>No comments yet.</p>
{/if}
{/exp:weblog:entries}

<ul>
{exp:comment:entries}
<li>{comment}
<p class="comment-posted">Posted by {name} on {comment_date format='%m/%d'}</p>
</li>
{/exp:comment:entries}
</ul>

<h2>Post a Comment:</h2>
{exp:comment:form preview="{template_group_name}/preview"}

<dl class="commentsforminput">

<dt>Name</dt>
<dd><input type="text" name="name" value="{name}" size="30" class="commentinput" /></dd>
<dt>Email</dt>
<dd><input type="text" name="email" value="{email}" size="30" class="commentinput" /></dd>
<dt>Location</dt>
<dd><input type="text" name="location" value="{location}" size="30" class="commentinput" /></dd>
<dt>URL</dt>
<dd><input type="text" name="url" value="{url}" size="30" class="commentinput" /></dd>
</dl>

<p>
<a href="{path={template_group_name}/smileys}" onclick="window.open(this.href, '_blank', 'width=400,height=440');return false;" onkeypress="this.onclick()">Smileys</a>
</p>

<p>
<textarea name="comment" cols="50" rows="12">{comment}</textarea>
</p>

{if not_logged_in}
<p><input type="checkbox" name="save_info" value="yes" {save_info} /> Remember my personal information</p>
{/if}

<p><input type="checkbox" name="notify_me" value="yes" {notify_me} /> Notify me of follow-up comments?</p>

{if captcha}
<p>Submit the word you see below:</p>
<p>
{captcha}
<br />
<input type="text" name="captcha" value="" size="20" maxlength="20" style="width:140px;" />
</p>
{/if}

<input type="submit" name="submit" value="Submit" class="submit-button" />
<input type="submit" name="preview" value="Preview" class="submit-button" />
{/exp:comment:form}
</div><!-- end comments -->

<p>

     </div><!-- end primarycontent-->
     <hr />

{embed="shopgolfincludes/secondary_sidebar"}

{embed="shopgolfincludes/footer"}

</body>
</html>

```

# Answer
> 3 votes
The point is that sometimes you are limiting the `weblog` related to every template ( `{exp:weblog:entries weblog="{master_weblog_name}" rdf="off"}`), sometimes you aren't (`{exp:weblog:entries limit="1" rdf="off" disable="pagination"}`). Both your templates are loading entries from both weblogs.

Add the `weblogs` parameter to all `exp:weblog:entries` variables and on the first one add the require\_entry parameter and a `no_results` conditional.

```
{exp:weblog:entries weblog="{master_weblog_name}" require_entry="yes" limit="1" rdf="off" disable="trackbacks|member_data|pagination|comments"}
    {if no_results}
        {redirect="404"}
    {/if}
[...]

```

Set which template to use for 404. Now, every time the `exp:weblog:entries` doesn't find an entry for the given weblog, the user will be redirected to the 404 template.

---
Tags: ee1, multiple-sites
---


title: New Channel Entries Not Displaying

text:
# Question
Title: New Channel Entries Not Displaying
New channel entries have stopped displaying on the front end regardless of channel or MSM site.

I see the new entry in EE backend, but it's not showing on the front-end pages/site.

```
{exp:channel:entries channel="test" site="customers" show_expired="yes" show_future_entries="yes" dynamic="no" status="open|not closed"}
{title}
{/exp:channel:entries}

```

What's odd is if I add `limit="100"` (or any number for that matter, and even other tags as well) it will start displaying the new channel entry.

# Answer
I was able to resolve the issue by setting $config\['enable\_sql\_caching'\] = 'n'; in config.php (you can use the configuration file editor as well). Apparently the issue has to do with having multiple sites/embedded templates. I think EE isn't clearing the cache on new entries in cases where I am using multiple embeds/sites in templates. EE support is considering this a caching bug and has passed it off to the developers.
> 2 votes

# Answer
I have had a somewhat similar issue with EE 1.7.3 We just switched servers over the weekend... we had been on the previous server for about 5-6 years. All worked well. Then we put up a couple entries in different weblogs (now "Channels" in 2.x) and noticed that, even though you could put them up in the EE control panel, they did not appear on the website. ?? So. You could put up entries without problems. They showed in the EE preview. The entry data was placed in the database in the correct tables (checked). The entry did NOT show up on the web page. Yet no code had been changed. IF, however, I changed the Limit="\__" number from whatever it used to be (7 or 22 in the main two cases), the new entries showed up. ??!?? So on one template I changed the Limit="7" to Limit="8" and the other from Limit="22" to Limit="21" (a smaller number just to check) and, lo, it all works.

I'm not adding the code in here simply because the code is basic and has not changed in years. The only change was the server. Yet EVERYTHING works but that.

Why this happened / happens, I do NOT know. Just letting you know that it does.
> 0 votes

---
Tags: channel-entries
---


title: Linking an ACT ID To A Module Function

text:
# Question
Title: Linking an ACT ID To A Module Function
Currently I have a function called `redeem_coupon()` in one of my modules in a EE2 project. I also have the button in a `<form>` element to link the function to. I know I have to add the function to the database table called exp\_actions. I have the following code for the button:

```
<form action="./" name="redeemcouponform">
  <table>
    <tr>
      <td><input type="text" name="couponcode" maxlength="12"/></td>
      <td><input type="submit" name="submit" value="APPLY" class="button tiny success" /></td> </tr>
  </table>
  <input name="ACT" value="{AID:Lb_cart:redeem_coupon}" type="hidden">
</form>

```

Is there any specific way I need to connect the button to the ACT so it can fire the function when the button is clicked?

# Answer
> 2 votes
I assume this is a form on the front end, is that correct?

Assuming it is, and assuming clicking the button submits the form in the usual way, you just need to set the `action` attribute on your opening `form` tag to be a URL that includes the appropriate Action ID (the one tied to the `redeem_coupon()` method in your module).

The front end Action URL should look something like `http://example.com/index.php?ACT=123` where the "123" is your Action ID. You'll want to set that ID dynamically and it looks like you already have a method for doing that (guessing by the `{AID:Lb_cart:redeem_coupon}` tag in your example).

For a good primer see A Brief Introduction to ExpressionEngine ACTions

If this form is in the control panel then the idea is similar, but the approach is a little different. Let me know if this form is in the Control Panel not the front end and I will update my answer.

---
Tags: ee2, checkout, act
---


# Question
Title: Prevent product A from being purchased until product B is in the cart first
I have two product types "standard" and "addon" these are just a custom field flag. An "addon" product can only be purchased if a "standard" product in in the cart.

How would I go about coding this up? Ideally it'd be great to have a conditional that I can run to disable the add to cart button for addon products till a standard product has been added to the cart. Soon as one standard product has been added to the cart any number of addons may be added.

I have seen this question but it's not the same. In this case it has to be a specific *type* of product not just *any* product.

Thanks,

Andy

# Answer
> 1 votes
I am going to assume (hopefully correctly) you are working with logged in users at the time of purchase, so that there is a way to check if the member in question has previously purchased a standard product.

You could do this several ways I think, but here’s what jumped into my head using the regular channel entries tag and not the query tag or something more complex.

If you did a search on the Purchased Items (not orders) channel using the logged in user’s ID and `search:url_title="name-of-standard-product"` it should return all of the purchases for that user, who had already purchased a standard product, to run a comparison against.

So if the page URI that contained your standard and addon products ended with "my-product-name" and you placed the above concept into a LowVariable for example (snippets, etc. could work too), I think it would look like this.

***LowVar:***

```
{exp:channel:entries
  channel="purchased_items"
  status="not Closed"
  search:author_id="{user_id}"
  search:url_title="{url_segment}"
  dynamic="no"
  limit="1"
  disable="categories|member_data|pagination"
}
 true
{/exp:channel:entries}

```

***In your template with the add to cart tags:***

```
{if '{exp:low_variables:parse var="variable-name" preparse:user_id="{logged_in_user_id}" preparse:url_segment="{url_title}"}'=='true'}
**show the add to cart for addons**
{if:else}
**You must purchase the standard product first**
{/if}

```

You could do this with javascript too of course to disable the Add to Cart buttons, but hopefully this gets you started.

---
Tags: cartthrob
---


title: EE Upgrade Issue: MB_ENABLED

text:
# Question
Title: EE Upgrade Issue: MB_ENABLED
On the last couple of EE upgrades I've received a PHP error regarding MB\_ENABLED:

> A PHP Error was encountered Severity: Notice
>
> Message: Use of undefined constant MB\_ENABLED - assumed 'MB\_ENABLED'
>
> Filename: libraries/Encrypt.php
>
> Line Number: 367

This is repeated for each instance of `MB_ENABLED` in the system/codeigniter/system/libraries/Encrypt.php file.

If I wrap each instance of `MB_ENABLED` in single quotes then it resolves the issue but having to do this on each upgrade is a little annoying.

It seems to be mentioned on the EllisLab forums also but the solution is again to modify core files. Is this a bug? Has anyone encountered this issue in upgrading recently?

# Answer
This has been a long standing bug where the constant just wasn't defined. It's ***finally*** squished in EE 2.9:

> "Fixed a bug where MB\_ENABLED was undefined"
> 0 votes

# Answer
I have never seen this. I'm guessing there is something in your environment that EE doesn't like.

I found a PyroCMS thread which mentions this error. That CMS is (was) build on CodeIgniter. It mentions in that thread that you need to have the iconv extension installed. This extension is enabled by default in recent versions of PHP, so that would likely make this an uncommon error.

https://forum.pyrocms.com/discussion/comment/20605/#Comment\_20605

Check your PHPinfo to see if this extension has been enabled.
> 2 votes

# Answer
I just got this error when using channel:form, enabling 'iconv extension' fixed the issue.
> 0 votes

---
Tags: error, upgrade
---


# Question
Title: Low Replace - Change Case & Remove Space
Is it possible to change the case AND change spaces to underscores using Low Variables?

Basically I was trying to use...

```
{exp:low_replace find='\s+|\w+' replace='_|\l+' regex='yes' multiple='yes'}Flavours yo{/exp:low_replace}

```

But I tihnk I may have got the RegEx completly wrong (Not my strong point!)

Because this just outputs

> L

# Answer
> 0 votes
First off, I don't think Low Replace supports `multiple="yes"` for regex replacements. Considering the complexities allowed in regex expressions, it would be a difficult task indeed to allow *Replace A|B|C with X|Y|Z* type regex searches when each of *A|B|C* are individual regex searches.

I also don't see any Low Replace functionality to do the replace with case transforms. In straight regex it's pretty simple: prefix your replacement with `\U` (or something very similar, depending on your regex flavor), but Low's only implementing a regex subset, it seems. No matter the syntax I tried, I was not able to get the replacement to change case. Of course, I could be missing something obvious, wouldn't be the first time *(see some of my questions here on the Stacks. ;-)* If the resulting text does not *actually have to **BE** uppercase*, but can rather just *look* uppercase, then how about a little CSS `text-transform:uppercase`?

So, we're left with the basic replacement of spaces to underscores. That's achievable with

```
{exp:low_replace find="([\w\W+]) +" replace="$1_" regex="yes"}
  Lorem ipsum dolor sit amet. Nearly.
{/exp:low_replace}

```

You will note that the search is for both alpha-numeric characters (`\w`) as well as **non**-alpha-numerics (`\W`). This is to factor for the possibilities of commas, periods, etc. If you know that your case will never encounter these, you can leave the statement as

```
{exp:low_replace find="(\w+) +" replace="$1_" regex="yes"}
  Lorem ipsum dolor sit amet. Nearly.
{/exp:low_replace}

```

The first statement results in

> Lorem\_ipsum\_dolor\_sit\_amet.\_Nearly.

The second statement results in

> Lorem\_ipsum\_dolor\_sit\_amet. Nearly.

*(note the missing underscore before 'Nearly.')*

Now, for what it's worth, there's a utility by Causing Effect by the name of *CE String* that just completely kicks ninja string manipulation arse. For $10 it's a Bat Utility Belt of string manipulation the likes of which are endlessly joyous for a nerd. Worth a look. The beauty of it is that you can pile up your manipulations, so, say, do your regex search/replace, then UPPERCASE the whole thing.

FYI.

---
Tags: low, low-replace
---


title: UPS address check failure

text:
# Question
Title: UPS address check failure
Is there a technique with Expresso store that allows for a recourse if a user's shipping address fails the UPS address checker?

As it stands now if an address fails the UPS test, there is no shipping offered because UPS cannot locate the user's address, and so the user checks out without having a shipping method chosen and a potentially undeliverable address.

Has anyone built a recourse like this, and if so, what does it involve?

Thanks in advance.

# Answer
UPS has multiple APIs that can be used.

You would need to write an extension that uses the Address Validation - Street Level API (API Details) to pass the users shipping details to first check to see if the address is valid or not. If the address is not valid the API should return a list of possible address that might be correct (if I remember correctly) or allow the user to enter the address differently.

Once you have a valid address you will need to use the Rating API (Rating API Details) to request the actual shipping rates and options that the user can select. I don't have access to the Store UPS shipping module at the moment but I believe this is the API that is used to calculate rates.
> 3 votes

---
Tags: expresso-store, ups-shipping
---