# Question
Title: Expresso Store: products listing with prices (in modifiers)
I have a product listing page which displays product title and product image as well product price. Part of the code related to product price looks like:

```
{if status == "retail"}
    {exp:store:product entry_id="{entry_id}" disable_form="yes"}
        <span class="store_product_price">{price}</span>
        {if total_stock == 0}<br /><span class="store_product_out_of_stock">Sold Out</span>{/if}
    {/exp:store:product}
{/if}

```

and it works for product without modifiers.

My question is how can I display product price which is stored as modifiers as product price range, something like $200-$400 (lowers - highest price)? I have try to use `price_inc_mod` within `{modifier_options}` and store all prices as an array, but somehow that last step wasn't working for me.

Thanks

# Answer
> 0 votes
Got this to work. Below code example

```
{exp:store:product entry_id="{entry_id}" disable_form="yes"}

<?php  $prices = array(); ?>
{modifiers}
{modifier_options}
    <?php $prices[] = str_replace('$', '', str_replace(' ', '', str_replace(',', '','{price_inc_mod}'))) ;?>
{/modifier_options}
{/modifiers}
<?php
sort($prices);
?>
<span class="store_product_price"><?php echo $prices[0]; ?></span>
{/exp:store:product}

```

# Answer
> 0 votes
If you wanted to do it without using PHP in your template you would be able to use the `{modifier_option}` tag pair along with some conditionals to get the price to display properly.

```
{if status == "retail"}
    {exp:store:product entry_id="{entry_id}" disable_form="yes"}
        <span class="store_product_price">
          {modifiers}
            {if modifier_options}
                {modifier_options}
                    {!--
                     --- use price_inc_mod if your items dont have tax
                     --- use price_inc_mod_inc_tax if you have tax inclusive pricing
                    --}
                    {if option_first}{price_inc_mod}{/if}{if option_last} - {price_inc_mod}{/if}
                {/modifier_options}
              {/modifiers}
            {else}
                {price}
            {/if}
            </span>
        {if total_stock == 0}<br /><span class="store_product_out_of_stock">Sold Out</span>{/if}
    {/exp:store:product}
{/if}

```

That should get it sorted out for you as long as the first and last modifiers have the the lowest and highest prices respectively.

---
Tags: expresso-store, modifiers, price-modifier
---


title: no_results in custom plugin?

text:
# Question
Title: no_results in custom plugin?
Is there a way to return 'no results' from a custom plugin with the standard conditional of:

```
{if no_results}{/if}

```

I have resulted to using:

```
if ($query->num_rows() > 0) {

} else {
    return $this->return_data = "<li><p>Sorry, no results</p></li>";
}

```

Thanks.

# Answer
Yes, of course!

```
return $this->return_data = ee()->TMPL->no_results();

```

Or this, on the versions before 2.6:

```
return $this->return_data = $this->EE->TMPL->no_results();

```
> 3 votes

---
Tags: plugin, no-results
---


# Question
Title: Jquery function undefined when logged in
I am working on development of a web app where users can use a Channel:form to submit/edit entries. I am Using mmenu for off-canvas menu. I had it working and then it stopped, reporting that function is undefined. After hours of debugging found out it works when not logged in to EE. However in order to add/edit entries, I need the visitor to be logged in. Is this a Channel:form problem/error? Anyone know of a work around?

# Answer
> 1 votes
I found the answer. I was loading my own JQuery in the head and the Channel form was loading a copy too. I hadn't seen include\_jquery option in the Docs before, just one for include\_assets (which I thought included jquerey). So once I set include\_jquery="no", everything worked!

---
Tags: safecracker, jquery, ee
---


# Question
Title: How do I link 2 css files in 1 wygwam entry? is that possible?
I'm using wygwam as a page building field and have a webpage built on dreamweaver attached to 2 css which are the main css and overlay tab panel css. I saw Wygwam Template links from p&t which I was thinking of linking 2 css template, is that possible?

# Answer
Not sure about Wygwam, but you can always use the @import option in CSS to internally link another CSS file within the other.
> 2 votes

# Answer
You could maybe create a custom style set per the P&T docs: https://docs.pixelandtonic.com/wygwam/using/style\_set.html
> 0 votes

---
Tags: ee2, pixelandtonic
---


# Question
Title: How to make 4 level static template url?
I can't understand how to made URL structure for page For eg

http://site.com/template\_group/temlate1/template2/template3

http://site.com/services/cleaning/reviews/best

In admin panel, at template group services we have 4 templates

index cleaning reviews best

Every template have url

http://site.com/services/index/

http://site.com/services/cleaning/

http://site.com/services/reviews/

http://site.com/services/best/

I need to display some templates like this

http://site.com/services/cleaning/reviews/

or

http://site.com/services/cleaning/reviews/best/

# Answer
> 1 votes
You can only nest one level of templates inside a template group. Therefore, templates generally may only extend to TWO segments into the URL. Any segments that follow (up to 7) are considered SEGMENT VARIABLES. The segment variables will be passed to the template inside the template group in the URL:

```
http://www.url.com/template_group/template/segment_3/segment_4/segment_5

```

(up to 9 segments)

You can use the segments as variables:

```
http://www.url.com/template_group/template/2014/04/16

```

In your template you can use:

{segment\_3} = 2014 {segment\_4} = 04 {segment\_5} = 16

For more information, see: https://ellislab.com/expressionengine/user-guide/templates/globals/url\_segments.html

# Answer
> 0 votes
While you can not embed multiple template folders deep. You have a couple of options. In your cleaning/services template you could do something along the lines of:

```
{if segment_3 == "reviews"}
     {if segment_4 == ""}
        Show just this content when reviews is in segment 3 and segment 4 is empty
     {/if}
     {if segment_4 == "best"}
        This shows is segment 3 is reviews and segment 4 is best
     {/if}
     {if segment_4 == "something"}
        You can do this as many times as you need to replicate the functionality you need.
        {if segment_5 == "more"}
            You can do this upto 9 segments
        {/if}
     {/if}
{/if}

```

Alternatively you could use template routes functionality if you are using newer version of EE.

In the control panel you would goto the Template Route Manager and as an example for `services/reviews` template you would set the route to `services/cleaning/reviews/`. Personally I would move the templates that you are routing into their own folder to avoid confusion down the road so it was me I would have `_routes/service_reviews`being routed to `services/cleaning/reviews/` and `_routes/service_best` routed to `services/cleaning/reviews/best/`

Your other option would be to use an add-on to manage the multiple depth functionality. This could be the built in Pages module or something like Structure. Each of these add-ons have advantages and disadvantages.

All of these options should get you the desired results one way or another.

---
Tags: ee2
---


# Question
Title: Adding class to iFrame parent container in Expresso isn't working
I have the Expresso field-type plugin and I'm using the Embed Media button to add iFrames to the page. I've been trying to add a class to the parent div container however I just can't seem to get it to work.

Expresso uses CKEditor and this is what I've tried so far:

```
(function() {
    CKEDITOR.plugins.add("mediaembed", {
        init: function(a) {
            CKEDITOR.dialog.add("MediaEmbedDialog", function(a) {
                return {
                    title: "Embed Media",
                    minWidth: 550,
                    minHeight: 200,
                    contents: [{
                        id: "iframe",
                        expand: !0,
                        elements: [{
                            id: "embedArea",
                            type: "textarea",
                            label: "Paste Embed Code Here",
                            autofocus: "autofocus",
                            setup: function() {},
                            commit: function() {}
                        }]
                    }],
                    onOk: function() {
                        var b = a.document.createElement("div");
                        b.setHtml(this.getContentElement("iframe", "embedArea").getValue());
                        b.className = "video-container"; //My addition
                        a.insertElement(b)
                    }
                }
            });
            a.addCommand("MediaEmbed",
                new CKEDITOR.dialogCommand("MediaEmbedDialog", {
                    allowedContent: "iframe[*]"
                }));
            a.ui.addButton("MediaEmbed", {
                label: "Embed Media",
                command: "MediaEmbed",
                toolbar: "mediaembed"
            })
        }
    })
})();

```

Towards the bottom of the function you will see the onOK function where I have added:

`b.className = "video-container";`

However when I add the iFrame code the parent div has no class. I have tried swapping the `var b = a.document.createElement("div");` to a span and this worked fine (still no class though) so I know it's the correct piece of code.

If anyone has any ideas as to why this isn't working it would make my Friday that ever-bit more awesome.

Thank you.

# Answer
Just in case anyone stumbles across this. For the onOk function add the following line of code:

`b.setAttribute("class", "video-container");`

Add this after the var declaration and before the insertElement function.

This should work for any of the CKEditor plugin functions but double check the variable name first.
> 0 votes

---
Tags: fieldtype, ckeditor, expresso-toolbar
---


title: Custom url with date and category_name

text:
# Question
Title: Custom url with date and category_name
is possibile to build an url like this without use third party module?

www.mysite.com/template\_group/2014/12/12/category\_name/url\_title

Thanks

# Answer
> 1 votes
Yes.

Although seg2cat will make your life easier.

The index template inside your template\_group will catch anything (depending on your use of other add-ons such as Structure or Pages and your strict 404 settings).

So in /template\_group/index you want to detect the relevant elements of the URL to then deliver your entry. IMO, your URL is a bit pointless - are you really going to have different entries in different categories on the same day to justified such a specific URL?

The only bit that counts is the url\_title, which has to be unique through EE anyway, so in your index template, {exp:channel:entries} with the parameters dynamic="no", require\_entry="yes" and the all essential url\_title="{last\_segment}", will display your entry. Everything else in the URL is not used and ignored, which then leads you to the problem of duplicate content.

Using the above approach will generate the same results for all these URLS...

* www.mysite.com/template\_group/2014/12/12/category\_name/url\_title
* www.mysite.com/template\_group/2014/12/12/url\_title
* www.mysite.com/template\_group/2014/12/url\_title
* www.mysite.com/template\_group/2014/url\_title
* www.mysite.com/template\_group/url\_title

So if you must have them in the URL, you'll need to check they're correct and in the correct place.

To validate the date in the landing template use the following:

```
{if "{segment_2}/{segment_3}/{segment_4}" != "{entry_date format="%Y/%m/%d"}"} {redirect="404"} {/if}

```

Instead of {last\_segment} you could use {segment\_6}, but you'll need to get the entry in the template to validate all th other bits - like dates, etc. The category\_name is a lot easier and faster if you utilise seg2cat (it's free) and then you can use it in the parameters of the channel:entries call which will make it more secure and unique (less possibility of duplicate URLs and content.

Also see this answer.

EDIT: To complete this answer I've incorporated Filippo's comment to resolve the date validation.

---
Tags: url, date, custom, template-routes, category-name
---


# Question
Title: Freeform Pro 4.1.3 and Google Event Tracking
I am trying to add Event Tracking to a FreeForm submit button so that when the user clicks the button it tracks the event in Google Analytics.

The problem I am running into is that regardless of how I try formatting the onClick event, it keeps getting stripped out.

Here's what I have tried:

```
{freeform:submit attr:class="btn btn--active" attr:value="Send" attr:data-ng-hide="formSent" attr:onClick="ga('send', 'event', { eventCategory: 'Contact', eventAction: 'Form', eventLabel: 'Project'});" }

```

And this:

```
{freeform:submit attr:class="btn btn--active" attr:value="Send" attr:data-ng-hide="formSent" attr:onclick="ga('send', 'event', { eventCategory: 'Contact', eventAction: 'Form', eventLabel: 'Project'});" }

```

Finally I just removed all of capitalization:

```
{freeform:submit attr:class="btn btn--active" attr:value="Send" attr:data-ng-hide="formSent" attr:onclick="ga('send', 'event', { eventcategory: 'contact', eventaction: 'form', eventlabel: 'project'});" }

```

# Regardless the outcome is always the same:

```
<input type="submit" name="submit" value="Send" class="btn btn--active" data-ng-hide="formSent">

```

As you can see, the onClick code is completely removed. Any ideas on what I am doing wrong?

# Answer
> 1 votes
As a work around you could consider using jQuery with Google Analytics, something like:

```
$('input').on('click', function() {
  ga('send', 'event', { eventcategory: 'contact', eventaction: 'form', eventlabel: 'project'});
});

```

---
Tags: solspace-freeform
---


title: "Ignore Wordlist" Not Functioning

text:
# Question
Title: "Ignore Wordlist" Not Functioning
Super Search Version 2.2.1, Expression Engine Version 2.8.1

My expectation with the Super Search Ignore Wordlist is that if I put a word on the list, that the term will be ignored completely, as though it were dropped from the search string. In other words, if someone searched "books on construction", and "on" was on the Ignore Wordlist, the search results would appear as though the search query was "books construction".

Is this correct? If this is not correct, then what exactly does the Ignore Wordlist do? If what I described is how the Ignore Wordlist is supposed to function, then for whatever reason ours is not working.

Here is the {exp:super\_search:results} portion of our search template:

```
    {exp:super_search:results
        channel="products"
        limit="12"
        show_future_entries="yes"
        use_ignore_word_list="yes"
        search_in="title|product_display_title|product_author|product_sku|product_isbn|product_hidden_search"
        search_words_within_words="yes"
        allow_repeats="no"
        paginate="bottom"
        fuzzy_distance="2"
        fuzzy_weighting="yes"
    }

        {if super_search_no_results}
            <div class="col-md-12">
                <p>No results matched your query.</p>
            </div>
        {/if}

        {if super_search_total_results==1}
            {redirect="product/{url_title}"}
        {/if}

        {if count == 1 OR count == 4 OR count == 7 OR count == 10}

        <div class="ad-col m-bottom">
            <div class="row ">

        {/if}
                <div class="col-md-4 ad-small">
                    <div class="well bg-1 ad-col-height">
                        <h4><a class="inherit-hyperlink" href="{url_title_path=product}">{title}</a></h4>
                        <div class="row m-top">
                            <div class="col-md-4">
                                <a href="{url_title_path=product}"><img class="img-responsive" src="{if product_thumbnail}{product_thumbnail}{if:else}/media/products/noi.jpg{/if}" alt="{title}"></a>
                            </div>
                            <div class="col-md-8">
                                {if product_tag!="" AND product_tag != "None"}
                                    <p class="{product_tag}">{product_tag:label}</p>
                                {/if}
                                {if product_author}<p><small>By {product_author}</small></p>{/if}
                                <p>Product Code: {product_sku}
                                <br />Price: {exp:store:product entry_id="{entry_id}" disable_form="yes" disable_javascript="yes"}{price}{/exp:store:product}
                                <br />{if product_binding != "Other"}{product_binding}{/if}</p>
                                <p><a href="{url_title_path=product}" class="btn btn-default">View Details</a></p>
                            </div>
                        </div><!-- /.row -->
                        <div class="row">
                            <div class="col-md-12 m-top">
                                {product_short_description}
                            </div>
                        </div>
                    </div><!-- /.well -->
                </div><!-- /.ad-small -->

        {if count == 3 OR count == 6 OR count == 9 OR count == 12 OR count == total_results}
            </div><!-- /row -->
        </div>
        {/if}

        {paginate}

        <div class="text-center">
        {pagination_links}
        <ul class="pagination">
        {first_page}
        <li><a href="{pagination_url}" class="page-first">«</a></li>
        {/first_page}

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

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

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

        {last_page}
        <li><a href="{pagination_url}" class="page-last">»</a></li>
        {/last_page}
        </ul>
        {/pagination_links}
        </div>

        {/paginate}

    {/exp:super_search:results}

```

# Answer
Are you using this in a Keyword search? The Ignore Wordlist feature only works with Keyword searches, and will NOT work for any other searches performed on custom fields, etc. :) http://www.solspace.com/docs/super\_search/results/#use\_ignore\_word\_list
> 0 votes

---
Tags: solspace, supersearch
---


# Question
Title: Advantage of ActiveRecord over plain sql query
Can someone tell me the advantage of using ActiveRecord vs writing a plain sql query?

# Answer
Reference: EE Database Class User Guide

The database class (IE CodeIgniter's ActiveRecord, which really isn't ActiveRecord, reference) does some nicities for you, like escaping your queries automatically. It also allows you to reference your table names without using whatever Expression Engine table-name-prepending that occurs at install (usually something like "exp\_table\_name"). See the reference.

It definitely makes your code cleaner to read, and I *only* not use it when I have to do some seriously complex SQL stuff, like building multitable search queries. I recommend it for its code cleanliness highly.

Also what @johnathan-waters said. Although I feel that this wouldn't apply to ExpressionEngine as it is built around MySQL, and I do not know if you can easily switch DB adapters for an EE install.
> 3 votes

# Answer
From the CodeIgniter docs:

> Beyond simplicity, a major benefit to using the Active Record features is that it allows you to create database independent applications, since the query syntax is generated by each database adapter. It also allows for safer queries, since the values are escaped automatically by the system.
> 2 votes

---
Tags: sql, activerecord
---


# Question
Title: expressionengine stopped parsing some tags after adding some content
asked this on stackoverflow before realizing there was a stackexchange site for expression engine, hope nobody minds i'm copying my question to here.

i am modifying an expression engine channel entry, there are a number of fields for this channel in a group and two are grids. in the template, i have loops that go through the rows in the grid and output various fields. this is all working as expected.

i recently wanted to add some content, and when i did my existing loops were no longer parsed, just output

```
{grid_name0}
    <div>stuff</div>
{/grid_name0}

```

and any `{grid_name0:fieldname}` were replaced with empty string/nothing. other tags continued to work correctly, including tags and a grid loop in the new content i added.

after debugging a bit, i discovered that there is a specific amount of text that will break it, i can add a comment to the template like `<!-- 01234567890123456789012345678901234567890123456789 -->` that when i get to a certain length it will break the page. this seems like maybe a memory limit is being reached before expression engine processes all the content, i checked various areas for memory limits and they seem to be set at reasonable values (and this is a pretty simple/light site), however i suspect there is a limit set somewhere that i am not aware of.

this is on expression engine 2.7.2 with php 5.2.17, i can provide additional details from phpinfo if desired but the php memory\_limit is set to 512M (which, frankly, seems like way overkill).

possibly related, but one of the things i was adding is an "advanced" condition with an `{if:else}`, if i have this present but less text than is required to break the page it will also break in the exact same way.

thanks in advance for any help!

# Answer
> 1 votes
huge thanks to ellis labs support, they pointed me to increasing the pcre.backtrack\_limit beyond the default 100000 and it now processes all the tags. in retrospect i should have checked that sooner, but run into issues with it so infrequently it never crossed my mind.

edit *system/expressionengine/config/config.php* and add this just after the initial line (or set in php.ini):

```
ini_set('pcre.backtrack_limit', 100000000);

```

---
Tags: grid, loop, parse
---


# Question
Title: Channel Form only accepting Image Uploads
I've configured a channel form with the goal of receiving applications for employment. Part of this process means the user should have the ability to upload a pdf or word document to the channel.

Currently the form only accepts image uploads. If a user chooses a pdf or word doc I get an error that the file type is not accepted.

My set up is:

```
{exp:channel:form channel="job_application" logged_out_member_id="2" include_jquery="no" include_assets="no" json="yes" return="/contact-us/careers"}
<label for="applicant_resume">Upload your resumé</label>
<input id="applicant_resume" name="applicant_resume" type="file">
{/exp:channel:form}

```

**Channel Field**

Allowed file type: All

Allowed directory: Resumes

**File Upload Preferences**

* Allowed File Types: All file types

**XSS Filtering: Off**

I've tried uploading as a guest, logged in as a Client, logged in as a Super Admin and no difference. Curiously, I can log into the admin area and manage pdfs, docs, etc just fine. The error only happens with Channel Form.

# Answer
```
<input type="hidden" name="job_resume_directory" value="1">
<input type="hidden" name="job_resume_hidden_file" value="{job_resume}{file_name}{/job_resume}">

```

That was the problem. The directory value should have been set to "2"

```
<input type="hidden" name="job_resume_directory" value="2">
<input type="hidden" name="job_resume_hidden_file" value="{job_resume}{file_name}{/job_resume}">

```
> 0 votes

---
Tags: safecracker, file-uploads, file-manager
---


# Question
Title: How to submit Expresso/DevDemon Store data via the Channel Entries API?
I've got a project where I need to automate the process of creating entries. I'm doing so using the ExpressionEngine Channel Entries API but as part of that I need to set a price for the entry in the Store field.

As it stands when a Store field is present in the channel I get PHP errors when submitting data, it seems that Store is being called somewhere along the line by the Channel Entries API and then doesn't have the data it's expecting so I get:

```
Invalid argument supplied for foreach()
Filename: Service/ProductsService.php
Line Number: 137

```

The code I'm using to inject new entries or update existing entries is as follows:

```
ee()->load->library('api');
ee()->api->instantiate('channel_entries');
ee()->api->instantiate('channel_fields');

$channel_entry_data = array(
    'title' => (string)$data['metadata']->title,
    'status' => 'open',
    'field_id_188' => (string)$data['metadata']->description,
    'field_ft_188' => 'none',
    'field_id_206' => strtotime($data['metadata']->date),
    'field_ft_206' => 'none',
    'field_id_189' => (string)$data['metadata']->type,
    'field_ft_189' => 'none',
    'field_id_190' => (string)$data['metadata']->format[0],
    'field_ft_190' => 'none',
    'field_id_208' => (string)$data['metadata']->format[1],
    'field_ft_208' => 'none',
    'field_id_191' => (string)$data['metadata']->identifier[0], // required
    'field_ft_191' => 'none',
    'field_id_192' => (string)$data['metadata']->identifier[1], // required
    'field_ft_192' => 'none',
    'field_id_193' => (string)$data['metadata']->source,
    'field_ft_193' => 'none',
    'field_id_194' => (string)$data['metadata']->rights,
    'field_ft_194' => 'none',
    'field_id_209' => $store_product_data,
    'field_ft_209' => 'none'
);

ee()->api_channel_fields->setup_entry_settings($channel_id, $channel_entry_data, FALSE);

if (ee()->api_channel_entries->save_entry($channel_entry_data, $channel_id, $existing_entry_id, NULL)) {
    return TRUE;
} else {
    return FALSE;
}

```

store\_product\_data is an array as follows:

```
$store_product_data = array(
    'price'=>1,
    'length'=>NULL,
    'width'=>NULL,
    'height'=>NULL,
    'weight'=>NULL,
    'handling'=>NULL,
    'free_shipping'=>1,
    'stock'=>array(
        array(
            'id'=>NULL,
            'sku'=>NULL,
            'track_stock'=>NULL,
            'stock_level'=>NULL,
            'min_order_qty'=>NULL
            )
        )
    );

```

But this doesn't work, I get the PHP error for every entry I insert and a bunch of empty rows for each entry in the exp\_store\_products table, but none of the actual product data (price and free shipping toggle).

Any thoughts/suggestions greatly appreciated. I want to use the channel entries API if I can but maybe I just need to resort to a quick and dirty DB insert.

# Answer
After having a phone call with DevDemon support last November, I resorted to using the CodeIgniter active record to update the entries instead. This is because the Store fieldtype uses Javascript to populate certain data when creating or updating an entry with the Store field type. When you use the channel entries API to create or update entries, it is completely unaware of the Store fieldtype JS. Channel Images is the same way FYI.
> 1 votes

# Answer
I don't think the Store field type gets it data from the data array that you pass to the channel entries call - I think it always expects to find the data in the $\_POST variable.

Make sure there is something in the field, eg:

```
$channel_entry_data['field_id_209'] = 'store';

```

and then create a $\_POST variable with your Store data:

```
$_POST['store_product_data'] = array(
    'price'=>1,
    'length'=>NULL,
    'width'=>NULL,
    'height'=>NULL,
    'weight'=>NULL,
    'handling'=>NULL,
    'free_shipping'=>1,
    'stock'=>array(
        array(
            'id'=>NULL,
            'sku'=>NULL,
            'track_stock'=>NULL,
            'stock_level'=>NULL,
            'min_order_qty'=>NULL
            )
        )
    );

```
> 0 votes

---
Tags: expresso-store, expresso, devdemon, channel-entries-api
---


# Question
Title: Expresso Store 2.0 Discount based on item quantity and {sku} modifier
In order to calculate a discount based on quantity of items in the cart that will take in consideration also the different weight of modifiers (suppose I sell the same product in different containers weighing from 1 to 210kg), I came up with an extension which grabs the $item-\>$item\_qty at every order update, multiplies that value with the $item-\>sku, adds to the total of Kg being orderd and, based on a table of different discounts hardcoded with conditionals in the extension's php file, calculates the discount to be applied.

I can't seem to pass the $order-\>$order\_discount to the actual order. When I submit the form, the order total doesn't take into account the calculated discount.

Here's my code

```
<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

/**
 * Store Discount Extension
 *
 * @package     ExpressionEngine
 * @subpackage  Addons
 * @category    Extension
 * @author      Milksamsa
 * @link        http://
 */

class Store_discount_ext {

public $settings        = array();
public $description     = 'Force discount based on item quantity and SKU multiplier';
public $docs_url        = 'http://';
public $name            = 'SKUdiscount';
public $settings_exist  = 'n';
public $version         = '1.0';

private $EE;

/**
 * Constructor
 *
 * @param   mixed   Settings array or empty string if none exist.
 */
public function __construct($settings = '')
{
    $this->EE =& get_instance();
    $this->settings = $settings;
}

// ----------------------------------------------------------------------

/**
 * Activate Extension
 *
 * This function enters the extension into the exp_extensions table
 *
 * @see http://codeigniter.com/user_guide/database/index.html for
 * more information on the db class.
 *
 * @return void
 */
public function activate_extension()
{
    // Setup custom settings in this array.
    $this->settings = array();

    // Add hooks
    $data = array(
        'class'     => __CLASS__,
        'method'    => 'update_cart',
        'hook'      => 'store_order_recalculate_end',
        'settings'  => serialize($this->settings),
        'priority'  => 10,
        'version'   => $this->version,
        'enabled'   => 'y'
    );

    $this->EE->db->insert('extensions', $data);
}

// ----------------------------------------------------------------------

/**
 * Disable Extension
 *
 * This method removes information from the exp_extensions table
 *
 * @return void
 */
function disable_extension()
{
    $this->EE->db->where('class', __CLASS__);
    $this->EE->db->delete('extensions');
}

// ----------------------------------------------------------------------

/**
 * Update Extension
 *
 * This function performs any necessary db updates when the extension
 * page is visited
 *
 * @return  mixed   void on update / false if none
 */
function update_extension($current = '')
{
    if ($current == '' OR $current == $this->version)
    {
        return FALSE;
    }

    $this->EE->db->where('class', __CLASS__);
    $this->EE->db->update(
                'extensions',
                array('version' => $this->version)
    );
}

// ----------------------------------------------------------------------

/**
 * Responds to the store_cart_update_end hook in Exp:resso Store
 * to apply a discount to each product, as needed
 *
 * @return array of cart items
 */
function update_cart($order)
{

    if ($this->EE->extensions->last_call)
    {
        $order = $this->EE->extensions->last_call;
    }

    // Get the number of products currently in the user's cart
     $order->order_discount = 0;
     $total_q = 0;

      foreach ($order->items as $item) {
                $sku = $item->sku;
                $item_q = $item->item_qty * $sku;
                $total_q = $total_q + $item_q;
            }

     if ($total_q >= 24 && $total_q < 30){
     $order->order_discount = $total_q  * 0.5;
     }

     if ($total_q >= 30 && $total_q < 60){
     $order->order_discount = $total_q  * 0.6;
     }

     if ($total_q >= 60 && $total_q < 100){
     $order->order_discount = $total_q * 0.95;
     }

     if ($total_q >= 100 && $total_q < 200){
     $order->order_discount = $total_q * 1.5;
     }

     if ($total_q >= 200 && $total_q < 210){
     $order->order_discount = $total_q * 1.55;
     }

     if ($total_q >= 210){
     $order->order_discount = $total_q * 1.7;
     }

     return $order_discount;
}
}

/* End of file ext.store_discount.php */
/* Location: /third_party/store_discount/ext.store_discount_batch.php */

```

//UPDATE

I've followed this procedure: https://gist.github.com/bryantAXS/10882383 Not sure where to go from here. I've not included the calculations for now, for testing purpose I've limited the discount amount to 4.

* I created a new folder in third\_party named store\_helpers
* I created a new folder in there named store\_helpers/classes
* I created a CustomDiscountAdjuster.php class inside it
* I created a ext.store\_helpers.php file in third\_party/store\_helpers

My CustomDiscountAdjuster.php file contains:

```
<?php

// Inside our custom third_party addon folder, /third_party/store_helpers, we have a folder called "classes."
// Within the classes directory we have this file, which holds our custom build Adjuster Class.
//
// You should be able to see how this class is passed our $order object, and then instantiates a new
// Order Adjustment object, which we use to make the adjustment. There are a few properties on the Order Adjustment
// object (nane, type, amount, etc..) that define the adjustment. The adjustment is then returned and processed.

namespace Store\Adjuster;

require PATH_THIRD.'store'.'/autoload.php';

use Store\Model\Order;
use Store\Model\OrderAdjustment;

/**
 * Calculate handling surcharge applicable to an order
 */
class CustomDiscountAdjuster implements AdjusterInterface
{
    public function adjust(Order $order)
    {

        $adjustment = new OrderAdjustment();
        $adjustment->name = "Custom Discount Adjuster";
        $adjustment->type = 'Custom Discount';
        $adjustment->amount = 10;
        $adjustment->taxable = 1;
        $adjustment->included = 1;

        return array($adjustment);

      return array();
    }

}

```

My ext.store\_helpers.php file contains:

```
<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

/**
 * Store Discount Extension
 *
 * @package     ExpressionEngine
 * @subpackage  Addons
 * @category    Extension
 * @author      Milksamsa
 * @link        http://
 */

class Store_helpers_ext  {

    public $settings        = array();
    public $description     = 'Force discount based on item quantity and SKU multiplier';
    public $docs_url        = 'http://';
    public $name            = 'Store Custom EQ Discounts';
    public $settings_exist  = 'n';
    public $version         = '1.0';

    private $EE;

    /**
     * Constructor
     *
     * @param   mixed   Settings array or empty string if none exist.
     */
    public function __construct($settings = '')
    {
        $this->EE =& get_instance();
        $this->settings = $settings;
    }

    // ----------------------------------------------------------------------

    /**
     * Activate Extension
     *
     * This function enters the extension into the exp_extensions table
     *
     * @see http://codeigniter.com/user_guide/database/index.html for
     * more information on the db class.
     *
     * @return void
     */
    public function activate_extension()
    {
        // Setup custom settings in this array.
        $this->settings = array();

        // Add hooks
        $data = array(
            'class'     => __CLASS__,
            'method'    => 'update_cart',
            'hook'      => 'store_order_adjusters',
            'settings'  => serialize($this->settings),
            'priority'  => 10,
            'version'   => $this->version,
            'enabled'   => 'y'
        );

        $this->EE->db->insert('extensions', $data);
    }

    // ----------------------------------------------------------------------

    /**
     * Disable Extension
     *
     * This method removes information from the exp_extensions table
     *
     * @return void
     */
    function disable_extension()
    {
        $this->EE->db->where('class', __CLASS__);
        $this->EE->db->delete('extensions');
    }

    // ----------------------------------------------------------------------

    /**
     * Update Extension
     *
     * This function performs any necessary db updates when the extension
     * page is visited
     *
     * @return  mixed   void on update / false if none
     */
    public function store_order_adjusters($adjusters)
    {
      $adjusters[40] = new Store\Adjuster\CustomDiscountAdjuster;
      return $adjusters;
    }

    // ----------------------------------------------------------------------

    /**
     * Responds to the store_cart_update_end hook in Exp:resso Store
     * to apply a discount to each product, as needed
     *
     * @return array of cart items
     */

}

/* End of file ext.store_discount.php */
/* Location: /third_party/store_helpers/ext.store_helpers.php */

```

Definitely something's going one, since taxes no longer get calculated when store\_helpers extension is enabled

# Answer
When the store\_order\_recalculate\_end hook is fired, all calculations have already taken place. See picture.

So you need to calculate and set the order\_total yourself.
> 2 votes

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


# Question
Title: The action you have requested is invalid on search with no result
I am using the simple search form on EE 2.8.1 with the following tag:

```
{exp:search:simple_form
                    channel="blog|products|faq"
                    where="any"
                    results="20"
                    form_class="et-search-form et-hidden"
                    no_result_page="/search/"
                    result_page="/search/results"

                }
                <input type="search" class="et-search-field" placeholder="Search …" value="" name="keywords" title="Search for:">
                {/exp:search:simple_form}

```

The form works as intended when there is a search result. If there is no search result the form will throw the error "**The action you have requested is invalid**".

Removing the **no\_result\_page** parameter will result in EE showing me "Your search did not return any results." message.

I suspect the secure form submission issue and included

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

```

But no luck.

Cheers

# Answer
Try to modify your no search results parameter to include the index template of that group

```
no_result_page="search/index"

```

The parameter should include the template group and template:

http://ellislab.com/expressionengine/user-guide/add-ons/search/simple.html#no-result-page
> 1 votes

# Answer
In order to make this work, and not get the "The action you have requested is invalid" message when there are no results, I also had to set the template in the no\_result\_page parameter to a different template than the result\_page template.

On further investigation, however, it seems that the problem specifically lies with the EE search engine returning "no results" and loading a template that uses the {exp:search:search\_results} tag. (So, potentially, you could re-use the same template if you had some sort of conditional.)
> 1 votes

---
Tags: search, simple-search
---


# Question
Title: Ampersand with certain spacing not allowed in Category name
When I use an ampersand (&) in a Category name with spaces **in a certain order** I get an error that does not allow me to submit the change. Using EE v.2.9.2.

**Error:** "The data you submitted did not pass our security check."
This seems to be the "invalid\_xss\_check" error.

I have tried to change the Category group to "Allow all HTML" and to also encode all HTML but I get the same results.

Here is what works and what doesn't work (screenshot below).

**Works:**

> 1. "One\[space\]&\[space\]Two"
> 2. "One&\[space\]Two"

**Does Not Work:**

> 3. "One&Two" ( \<--- This is the one I want )
> 4. "One\[space\]&Two"
> 5. "One\[space\]&amp\[space\]Two" - (going insane...)

**Screenshot:**

# Answer
> 2 votes
Try

```
One & Two

```

Note the semi-colon after the HTML entity - you missed that on your version.

---
Tags: categories
---


title: Can EE handle Millions of Users?

text:
# Question
Title: Can EE handle Millions of Users?
I’m new to the expression engine project at our business. We are being acquired by a large company and they’re worried that expression engine cannot handle traffic for a exp\_members table of 10M, and concurrent connections at about 10k.

I know that most people will naturally ask “It all depends on server resources, and how big is your database…”, and we can always have bigger boxes, I’m not really interested in theoretical limits, my question is a bit more practical than that.

Has anyone had experience with using EE for 5+ millions of users and approx 10k concurrent users, and what has been your experience been with it?

Please help me understand your experience.

It’s a classic “Executive Decision makers (and what they think they understand from a sales slick” versus Coders and EE fans.

Thank you.

# Answer
There's an old post (from 2012) here which might go some way to answer the question. You'll note that there are some major sites there.

Ultimately, as you've acknowledged, the matter is one of resources and network infrastructure and not one of software. No system will cope with 10K concurrent connections unless the network is built in such a way as to allow it.
> 1 votes

# Answer
I was working a site with ~60K users and 2-3K being active every day running on EE1 (that's been really a while ago). But we were really pushing EE to it's limits there. Can't say anything about EE2.
> 0 votes

---
Tags: performance
---


# Question
Title: Right way to list entries within a category (that's specified within a URL)
Going through old templates and trying to clean up some stuff.

One page I have is a category page. This displays a list of entries within a category that is specified within segment 3 of a url like so `example.com/walks/category/myexamplecategory`

My template is currently like so (some bits stripped out)...

```
{exp:gwcode_categories channel="walks" cat_url_title="{segment_3}" output_depth="1" entry_count="yes"}
<h5 class="headline">{cat_name}</h5>
  <p>We have <strong>{entry_count}</strong>
  {if entry_count == 1}walk{/if}
  {if entry_count != 1}walks{/if} in <strong>{cat_name}</strong>
  </p>
{/exp:gwcode_categories}
{exp:cat2:id category_url_title="{segment_3}" category_group="2" parse="inward"}
  {exp:channel:entries channel="walks" status="open" category="{category_id}" disable="member_data|category_fields" show_expired="yes" paginate="bottom" limit="12"}
    <h2><a href="{title_permalink='walks/view'}">{title}</a></h2>
    <p>{description}</p>
    {categories}
        <a href="{path='walks'}">{category_name}</a></span>
    {/categories}
  {/exp:channel:entries}
{/exp:cat2:id}

```

So as you can see, I'm using Cat2 and GWCode plugins. I'm wondering if theres a simpler way to achieve this, potentially using native tags as opposed to third party ones? Many thanks!

# Answer
> 1 votes
I may be missing something here but this seems really straightforward. The following EE code would display all entries in the myexamplecategory category:

```
  {exp:channel:entries channel="walks" disable="member_data|category_fields" show_expired="yes" paginate="bottom" limit="12"}
    <h2><a href="{title_permalink='walks/view'}">{title}</a></h2>
    <p>{description}</p>
    {categories}
        <a href="{path='walks'}">{category_name}</a></span>
    {/categories}
  {/exp:channel:entries}

```

That wouldn't get your count of entries in each category that you have in the first chunk of code, but I can't see the point of the cat2 add-on in your latter bit of code. So long as the URL is a valid EE category URL containing both the /category/ keyword and a valid URL title the channel:entries tag will dynamically filter to just returning entries in that category.

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


# Question
Title: Template code to determine if an Exp:resso Store order was placed by a registered member?
In the template that shows an order from the hash in the URL (via the `{exp:store:orders}` tag), I want to check if the order was placed by a registered member or not. If it wasn't placed by a registered member, then I want to show a message suggesting that they register to keep all their orders together.

My first thought was to see if the order has an associated `{username}`, and show the message if not. However, it seems like `{username}` doesn't work inside \`{exp:store:orders} tags, despite the docs claiming they do.

The only other thing I can think of is to pass the `{order_email}` field, which *does* work, on to some other tag that searches through members:

```
{exp:memberlist:fictional_tag search:email="{order_email}"}
    {if no_results}
    {!-- Order placed by non-member; show 'Consider Registering' message --}
    {/if}
{/exp:memberlist:fictional_tag}

```

As you may have guessed, such a tag does not appear to exist as far as I can tell.

Is there any other way to see if an order was placed by a registered member?

# Answer
> 2 votes
You can use the member\_id tag to see if the user is a member or not. Logged in members will have a their member\_id while guest members will return 0.

{exp:store:orders order\_hash="{segment\_3}"} {if member\_id == 0} Create an account to keep all orders {/if} {/exp:store:orders}

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


title: Query and Playa Field

text:
# Question
Title: Query and Playa Field
I'm running a query on a playa field and the output is grouping a few values together. I just want to be able to access the second and third parts but am a little confused how to do it.

Code:

```
{exp:query sql="SELECT DISTINCT field_id_200 AS brand FROM exp_channel_data WHERE channel_id=23"}
  {brand}
{/exp:query}

```

Output:

```
[125] [nike] Nike

```

Any ideas for how I can just access "nike" and "Nike"?

Thanks

# Answer
It looks like I don't even need to use the query module and can just use Stash to both match and display unique entries to create the secondary navigation.

You learn something new everyday with Stash!
> 0 votes

---
Tags: playa, query
---


# Question
Title: How to output Transcribe language in Search Results?
I need to filter search results on my expressionengine website, I currently have the transcribe plugin and am trying to get it to work with the ee default search tool so that the results are only in the current language chosen.

In the results page though i can't seem to output the language the entry is in. I guess I need to modify the core of search module, but simply don't have time.

Is there a simpler way of doing this?

# Answer
I just tried this and search results are displaying as expected, but I needed to have a few things in place:

* Language-specific channel entries that would show up within the search parameters.
* The language turned on (the language abbreviation segment had to be in the URL I was searching from).
> 0 votes

---
Tags: search, transcribe, language
---


# Question
Title: EE1 to EE2: Better to Upgrade or Migrate?
Looking to get some opinions form people who have "been there done that" on getting from EE1 to EE2.

I'm working on a site that's currently running EE 1.6.9. As a first step towards the redesign I'd like to get them on to the latest version of EE, and it seems I have a couple options:

1. Update to EE 1.7.2, then use the standard EE2 upgrade wizard, and do some cleanup on the EE2 end (if I get there).
2. Setup a new EE2 install with similar data structure, and pull over the data with something like Data Grab.

I seem to be finding horror stories from folks on both sides. There are a lot of (old) plugins in play … most have EE2 versions, but some very key ones don't:

* Gypsy
* Matrix
* Playa (which is holding a ton of relationships we'd hate to have to recreate)
* Wygwam
* Better Meta
* LG Image Manager (which I guess will have to switch to Assets)
* LG TinyMCE (which I guess we'll ultimately switch to Wygwam)
* nGen File Field

Initially, I started down the first path. But maybe the second option is cleaner (though I worry about if/how the playa relationships will be migrated, etc.)?

Honestly, it all feels like a mess, so before I venture any further figured I'd ping the community for advice. Thanks!

# Answer
> 0 votes
This will be a time-sink no matter how you approach it. Gypsy is the big red flag in the EE1 install as it fundamentally changed how EE works at a low-level. There is an "undo-Gypsy" add-on (https://devot-ee.com/add-ons/undo-gypsy) but as you can see it's unsupported. The nGen file field will also need some db-level SQL to change to a native file field.

It's tough to say based on the data you've provided (not sure what a "ton" of relationships means etc) but overall unless you are talking about thousands of entries I'd probably lean towards a fresh build in EE2, importing what you can, and then manual editing from there.

But you might try an upgrade approach on a copy of everything just to see what happens as well.

# Answer
> 0 votes
I never did a big upgrade, just small updates.

I guess it depends on the size of the database of the site (entries, relationships, members etc). If it's a small database, perhaps would be better to migrate (no headache with compatibility problems), but if it's a huge one, would be better to upgrade.

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


# Question
Title: Channel Entries displays all Entries on Single Entry page instead of one
I have a template that is supposed to display only one entry.

Instead it is pulling all entries from the particular channel and not paying any attention to the dynamic='no' parameter.

I have created many versions of this template, removing more and more code including changing the template group and name but nothing seems to work. It even ignores the "limit" parameter

Version: EE 2.9.2 using Switchee to parse segments 2 and 3

Channel Entries Tag:

```
{exp:channel:entries channel='products' dynamic='yes' disable='categories|category_fields|member_data|pagination|trackbacks'}

```

Sample Url:
http://example.com/products/wardrobes/cover
Segment 1: products - Template Group
Segment 2: wardrobes - Category not used by anything in channel entries
Segment 3: cover - URL Title

Switchee Template: products/index.html

```
{exp:switchee variable='{segment_2}' parse='inward'}
{case value="''"}
    {embed='products/_products-home'}
{/case}

{case default="Yes"}
    {switchee variable='{segment_3}' parse='inward'}
        {case value="''"}
            {embed='products/_products-category'}
        {/case}
        {case default="Yes"}
            {embed='products/_products-entry'}
        {/case}
    {/switchee}
{/case}
{/exp:switchee}

```

# Answer
Have you tried `url_title="{segment_3}"`?
> 2 votes

---
Tags: channel-entries
---


# Question
Title: Message: date() expects parameter 2 to be long, string given
I just installed Lamplighter v1.2.4 on ExpressionEngine v2.5.5 and when I view the Accessory, I see the following error. Any ideas?

```
Severity: Warning
Message: date() expects parameter 2 to be long, string given
Filename: core/Loader.php(727) : eval()'d code
Line Number: 144

```

# Answer
If I remember correctly, this might be because the cache folder isn't writable. Lamplighter checks the file time to determine the "last checked" value. If the file wasn't written correctly, it won't get a proper numeric value.
> 0 votes

---
Tags: add-on, error
---


title: cartThrob - Discount by Channel

text:
# Question
Title: cartThrob - Discount by Channel
I was wondering if there is a way or a plugin that I can apply a discount to a product that is related to another channel.

Basically the same way that 'Percentage Off Categories' type works.

On my site there are products that have a relationship with a channel called 'Maker'. This channel shows who made the product.

What I want, this that any product that is made by this 'Maker' to automatically discount 25%.

Is there any way of doing this using Discounts? Or will I have to take of the price manually for each product?

Many thanks,

Hugh

# Answer
Instead of having a "Maker" relationship field, what if you created a new "Maker" category group and then assign the products to the appropriate maker category? Then you could use the 'Percentage Off Categories' discount.
> 0 votes

---
Tags: cartthrob, discounts
---


# Question
Title: Cartthrob - Reserve inventory when in cart
Is it possible to reserve the item the user adds to their cart?

For example, if there is an inventory of 2 and one user adds 2 to their cart, show this product as out of stock unless this user removes the items from their cart.

# Answer
It does not appear that this functionality exists without extending CartThrob.

According to the documentation (as a note for the inventory:reduce tag), CartThrob does check the inventory when a product is added to the cart and when attempting to finalize the order. However, it does not appear that the inventory is modified when a product is added to the cart.

You could create an extension yourself that hooks into the many different hooks provided by CartThrob and updates the product's inventory when a product is added/deleted.

There are a couple of things you'll need to consider though:

* Carts persist until they expire. It's possible someone could wipe out all of your inventory by adding all the products to their cart and then not touching their cart again. Of course, you could have a really low cart expiration time set so this wouldn't wipe out other customer's ability to purchase the items for too long.
* Upon checkout, you would need to make sure that your modifications do not cause the math performed upon your inventory to be performed again upon checkout (when the inventory would be updated because it was purchased).
* You'd want to make sure you update the inventory in bulk instead of individual sql queries for each item added/deleted so there is not a drag on performance.
> 0 votes

---
Tags: cartthrob
---


# Question
Title: Ensure a product is always in a CartThrob cart?
I have a site with a CT store with 1 product. The customer never adds it to their cart, that happens automatically on the page that links them to the cart, using the following tags:

```
{exp:cartthrob:clear_cart}
{exp:cartthrob:add_to_cart entry_id="xxx" quantity="1" no_tax="yes"}

```

This code generally ensures that this will be the only item in the cart. The problem is that customers, by putting in the url for the checkout manually, can get past this page on occasion and end up on the checkout page with an empty cart. That should never happen with this site.

I get what the original developers of this site were doing with the above code, and it's 99% reliable, but I'd like to be 100% sure that when a user reaches my checkout page they have this item in their cart exactly once.

Ideas?

# Answer
Can't you place a small if statement to make sure there is something in the cart and if empty redirect to main page where its added automagically. {if cart\_empty}redirect{/if} not sure of syntax, purely demonstration
> 3 votes

# Answer
@stuartmcd69's answer is correct but it lacks additional details.

Upon redirecting to the new page, you'll want to use the {add\_to\_cart} tag.

More specifically, it might look something like this:

`{exp:cartthrob:add_to_cart entry_id="<product_entry_id>" quantity="1" return="return/page/here"}`
> 0 votes

---
Tags: cartthrob
---


# Question
Title: DIsplaying a list of months, with calendar summary of items
Is there an easy way to display a list of 12 months, with the events displayed for each month. Therefore, not dividing each month into days?

A parent summary view to the calendar month page, if you will?

Thanks, Ian

# Answer
> 0 votes
This can be done with the Calendar:Cal tag, using the {display\_each\_month} variable pair. Your code would look something like this:

```
<ul>
{exp:calendar:cal
    channel="calendar_events"
    date_range_start="today"
    show_months="12"
    pad_short_weeks="n"
}

    {display_each_month}
        <li>
            <h3>Month: {date format="%F"} ({month_event_total} events_</h3>
            <ul>
                {events}
                <li><a href="{path="calendar/events"}/{event_id}/">{event_title}</a>   {event_start_date format="%F %j, %Y at %g:%i%a"} - {event_end_date format="%F %j, %Y at %g:%i%a"}</li>
                {/events}
            </ul>
        </li>
    {/display_each_month}

    {if no_results}
        <li>No results</li>
    {/if}

{/exp:calendar:cal}
</ul>

```

---
Tags: solspace-calendar
---


title: Force search results order by category

text:
# Question
Title: Force search results order by category
I have a channel with a category group. I need the search to order results if a certain category has been selected by placing them at the top, and entries with the same category to be then ordered by date.

Is this possible using solspace search?

# Answer
> 2 votes
This isn't possible with Super Search as is. However, you could attempt to run a workaround with the Preparse add-on (free). What it allows you to do is parse other content into a new custom field (let's call it "my\_category\_field") from an EE template (used only for formatting/parsing the entry data) at time of publishing/updating of entry. So, you could have Preparse set to load the "my\_category\_field" field with the usual category tags in your Preparse template:

```
{exp:channel:entries entry_id="{preparse_entry_id}"}
{categories}{category_name}{/categories}
{/exp:channel:entries}

```

And Preparse will parse out the category data into a your "my\_category\_field" field, allowing you to then have Super Search results order the results by your "my\_category\_field" custom field + date.

Please let me know if that makes sense! :)

---
Tags: solspace
---


# Question
Title: ExpressionEngine 2.7.3 How do I directly execute a query against the database?
I navigate to Tools | Data | SQL Manager

Select "Database Query Form"

```
select table_name from information_schema.columns where column_name = 'flippityfloop'

```

I select "Enable MySQL Error Output" and hit \[Submit\] The response contains the text "The query you submitted did not produce any results."

I go back to the "Database Query Form" and execute the same query with a valid column\_name and I get no response. I get redirected to a root admin page with no route parameter in the QueryString.

Before I start inspecting Http Headers, can someone explain to me why this is happening? How do you get the following query to execute against the underlying database and display the results to the screen?

```
select table_name from information_schema.columns where column_name = 'title'

```

# Answer
Enable the Profiler (Admin \> System Administration \> Output and Debugging) so you can see what the query actually being executed is. If you aren't getting results from the second query, I would suspect some server security module is likely interfering with the request, which would be revealed somewhat in the query log, as the query you ran either won't be there, or will have been modified. FWIW, the second query should work fine, and for a default install with no optional modules installed should return 14 tables (v2.9.2)
> 1 votes

---
Tags: mysql, query, admin.php
---


# Question
Title: show expire date on rendered page, template code
This should be a simple one. I just want o show the the date a channel entry is set to expire on a rendered page as well as when it was made. The Entry is straight forward enough but I can't seem to find a way to show the end date?

Thanks for looking!

```
{end_date format="%F %j, %Y"}
{entry_date format="%F %j, %Y"}

```

# Answer
You were close, but not quite.

```
{expiration_date format="%F %j, %Y"}

```

Docs.
> 0 votes

---
Tags: templates, date
---


# Question
Title: Matrix field total_rows > 0 not working?
I'm trying to display a matrix field ONLY if it has data entered into it.

I've tried this by wrapping it in this conditional...

```
{if mymatrix:total_rows > 0}
  {mymatrix}
    data here
  {/mymatrix}
{/if}

```

But nothing is getting outputted. If I remove the conditional, the matrix is outputted fine. Any ideas? (I'm up to date with EE 2.9.2 & Matrix version 2.6.1)

# Answer
If you're having trouble with tags not working correctly in conditional statements try wrapping the them in double or single quotation marks.

```
{if "{mymatrix:total_rows}" > 0}{!-- Here --}
  {mymatrix}
    data here
  {/mymatrix}
{/if}

```

Thanks :)
> 3 votes

# Answer
I had the same issue. This should work for you (it did for me).

```
{if {mymatrix:total_rows} > 0 }
{mymatrix}
data here
{/mymatrix}
{/if}

```

Does the template work without the {if} statements? You may also try wrapping the zero in a single quote ( '0' ).
> 0 votes

---
Tags: matrix
---


# Question
Title: Issues migrating (no entries/channels/fields/template files)
Duplicating/ Migrating an EE site (used EERelocate)

Template files:

* updated template file locations
* everything is writable; e.g., 666/777
* followed all the migration walkthrough on ElisLab site - Won't let me sync the template files (no options appear - just blank)

Channel Entries:

* No idea what to do here...? Imported DB, don't see anything

Channels/Channel Fields:

* None of my channels or fields are showing up

I've never had to migrate/duplicate an EE site before. I've followed everything I can... Totally stuck.

# Answer
Read this tutorial, may it will help: http://www.creat-ee.com/tutorials/more/migrating\_your\_ee\_site\_to\_live\_server
> 0 votes

---
Tags: channel-entries, channel, migration, template-manager
---


title: SEO in URLs - dynamic template names?

text:
# Question
Title: SEO in URLs - dynamic template names?
I want to include certain field values in my URL's first segment. Since the first segment is the template file's name, I'm not sure how to do this. For example, say I have a template `products`. If the template is showing a "new" product, I'd like like the first segment to be `new-products`. And if the product is "old", then `old-products`. Assume there is no different in the output of the new and old products; I just wan the URL to be different. I don't want to do something like this `products/new/` because I "think" (I don't know for a fact) that is not as effective in SEO terms.

Is there a way to make segment one dynamic?

# Answer
Your default template group index can catch these URLs and embed the relevant template you want to display to list products.

But I'd be cautious on the amount of effort it will involve for little benefit and more complexity elsewhere - not to mention the usability from visitors.

Shallow/flat "directory" structure is good (source: numerous web articles and numerous SEO agency advice), but shouldn't be to the sacrifice of logical structure and usability. But compare that with loading keywords into the URL, which is more beneficial for SEO.

Also balance that the parent gains more weight from it's child pages - so "products" SEO value is diluted by having alternatives like "new-products", whereas "/products/new" maintains that value and is logical from build perspective and visitors.

SEO Investment would be far better placed in unique content text for the listing landing pages and what SEO agencies call "hub" pages. Don't forget to remove any unique content for paginated pages - better still ensure that the paginated links are no-follow and no-index. So based on this, remember that your products shouldn't be indexed on the listing page - as that's not what you want the Google index to point at, but the product page itself, so a short URL for the listing is irrelevant (in SEO terms) for the product itself, just the landing/hub page (the same as any other content page).

In all ecommerce builds I've worked on, they've all been heavily category based for listings, so "new" is just another category and translates/identifies (seg2cat) to the correct channel:entries output.

Lastly, think about the duplicate development code (although you can use embeds to create a single source) and how difficult that would be to maintain, track changes and for others/client to maintain.

Good answers and article links: https://webmasters.stackexchange.com/questions/60280/does-amount-of-url-parameters-affect-seo
> 3 votes

---
Tags: templates, url
---


title: WYGWAM Paste From Word Formatting

text:
# Question
Title: WYGWAM Paste From Word Formatting
We have some basic to complex formatting in our Word docs that conform to a corporate style guide, but am having problems getting that styling to copy over in the "Paste from Word" function. I got headings to convert using Word Styles to format them, but italics, lists, and text colors don't get copied over. Even using other Word Styles don't convert in the copy process.

How do I get these basic Word formatting and styles to copy over to my WYGWAM module? We have writers creating content to a specific style guide and then editors copying that content to the website are then having to manually re-apply those styles.

# Answer
> 1 votes
Alas Word places lots of junk into anything it copies out, so you're on to a loser to begin with. It will paste random sizes and spans that don't exist and then you have uncontrollable colours and sizes all over that can no longer be controlled by a single/master CSS file, as they're all in-line.

That said, you can try your best.

Set up custom styles in Wygwam: https://docs.pixelandtonic.com/wygwam/using/style\_set.html

Set both the CSS and JS (for the dropdown options).

Note the "Restrict allowed HTML" and "extraAllowedContent" options - you may need to play with these, but these may only kick-in when pasting normally, not pasting from Word. Wygwam is based on CKEditor, so you may need to tweak these files to do anything serious like add an additional plug-in \- see here for extending Wygwam with CKEditor plugins.

---
Tags: wygwam, formatting
---


# Question
Title: Getting control panel user data in javascript
Im working on a simple plugin that just needs to get the current logged users screen name, email address and username into some javascript and inject that js on every page.

My hope is to juse the exiwting CP CSS & JS plugin and past the javascript..

I found the EE global variable in the javascript and it looks like EE.username is the current logged in users name. Is there similar way to get email and/or screen name?

# Answer
The EE global only has username and shouldn't be relied upon as it's not a formal documented method to get information (and so could change or be manipulated).

If you're already writing a module/extension (a "plugin" is frontend only), then output your JavaScript from there instead of relying on the "CP CSS & JS" extension.

You can access all the user information via the session class:

```
ee()->session->userdata['screen_name'];
ee()->session->userdata['email'];
ee()->session->userdata['username'];

```

Add your own external JS file:

```
ee()->add_js_script('file', 'insert filename here');

```

The Docs on the CP class can be found here. Full Developer documentation here.

Consider using an Extension hook to inject your javascript - this would probably be the easiest route.

Note: These classes are automatically available from within your module/extension and don't have to be loaded.
> 1 votes

---
Tags: control-panel
---


title: Roll Your Own Social Media links?

text:
# Question
Title: Roll Your Own Social Media links?
Can anyone point me to some resources on hardcoding Social Media Links for EE channel entries? Basically Facebook, Twitter, Pinterest, etc..

I'm in a situation where it's not feasible for various reasons to use a plugin or module for this but not sure how best to approach it.

# Answer
This can be done using standard template code. All the various social media services have documented APIs for their javascript sharing widgets, and mostly you just need to use their default code. If you want to get more specific, you can hard-code URLs, text, etc, using EE tags within those widgets.

Examples:

So as a quick example, within a Channel Entries loop:

```
<script>(function(d, s, id) {
      var js, fjs = d.getElementsByTagName(s)[0];
      if (d.getElementById(id)) return;
      js = d.createElement(s); js.id = id;
      js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&appId=XXXXXXX&version=v2.0";
      fjs.parentNode.insertBefore(js, fjs);
    }(document, 'script', 'facebook-jssdk'));</script>

<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+"://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>

<div class="share">
    <div class="fb-like" data-layout="button_count" data-action="like" data-url="{title_permalink="news/entry"}" data-show-faces="false" data-share="true"></div>
    <a class="twitter-share-button" href="https://twitter.com/share" data-url="{title_permalink="news/entry"}" data-via="mytwitterusername" data-text="{title}: ">Tweet</a>
</div>

```

You maybe want to include the javascript in your global header or footer of course, and Facebook also requires you have an `fb-root` element on your page, but you get the idea.

You should also look at setting proper Open Graph tags, and activating Twitter Cards as well, to greatly enhance how your URLs appear when shared.
> 1 votes

# Answer
I'm assuming you just want to add social icons that link to your clients' social pages? Or are you trying to add "sharing" capabilities? If that's the case then that's a whole different situation :)

If you're just trying to link to social pages then why not just use a `grid fieldtype` or you could use a `matrix fieldtype` too? Set it up with a column for an image (a file/asset fieldtype works great) for the image and a URL. Then code that out in your template.

It's pretty easy to setup and I've never had to use a plugin or a module to do that. Of course it all depends on how your site is setup.
> 0 votes

---
Tags: social
---


# Question
Title: Does native EE caching support configurable redis db indexes?
After combing through the redis driver cache file (/system/libraries/Cache/drivers/Cache\_redis.php), it appears that an option doesn't exist to allow a user to specify a redis db index.

This is important in the event we use the same redis database for both a development and staging server.

Is this possible to accomplish another way? Or is anyone aware of plans to add this as an option?

# Answer
> 1 votes
After some research and digging into the actual Cache\_redis.php file, I've found that there is currently not a way to specify a DB index without modifying the ExpressionEngine Core.

The only way to handle multiple dev/staging servers would be to utilize a something like the Focus Labs Master Config and configure separate Redis servers for each install.

---
Tags: cache, caching
---


# Question
Title: Fatal error on checkout with shipping extension
I'm using the USPS shipping extension and receiving the below error on the checkout page:

`Fatal error: Uncaught exception 'Store\Exception\ShippingException' with message 'Authorization failure. Perhaps username and/or password is incorrect.' in /mypath/assets/third_party/store_usps/ext.store_usps.php:135 Stack trace: #0 [internal function]: Store_usps_ext->shipping_methods(Object(Store\Model\Order), Array) #1 /mypath/expressionengine/libraries/Extensions.php(262): call_user_func_array(Array, Array) #2 [internal function]: EE_Extensions->universal_call('store_order_shi...', Object(Store\Model\Order), Array) #3 /mypath/expressionengine/libraries/Extensions.php(119): call_user_func_array(Array, Array) #4 /mypath/assets/third_party/store/src/Store/Service/OrdersService.php(159): EE_Extensions->call('store_order_shi...', Object(Store\Model\Order), Array) #5 /mypath/assets/third_party/store/src/Store/Tag/CheckoutTag.php(61): Store\Service\OrdersService->get_order_shipping_methods(Object(Store\Model\Order)) #6 /mypath/assets/third_party/s in /mypath/assets/third_party/store_usps/ext.store_usps.php on line 135`

This error seems similar to this one. I am sure that I have the correct username in the extension. There's no field to place the password.

# Answer
> 1 votes
I ran into the same problem. I created an account with USPS.com and assumed that that was the username I should be using in the USPS Plugin for Store.

Turns out USPS has a separate registration for API access. You can find that here: https://www.usps.com/business/web-tools-apis/welcome.htm

They'll send you an email with a generated username that you can use for API access. Once you change the username in the USPS Plugin settings to the username they generate for you the error should go away.

I got some new errors, regarding the (package) container, but after I tweaked some settings in the extension it seems to be working fine.

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


title: A simple date fieldtype for Grid?

text:
# Question
Title: A simple date fieldtype for Grid?
I've looked all over for this and can't seem to find anything for this. I've also found an unresolved similar question about this in stack exchange from many months ago that wasn't answered, so I thought I'd put this forward again:

Is there a simple date picker that will work as a Grid field that will output ONLY the date without the time? All I need is Month, Day, and Year in any order so I can use the search: option in the Grid loop without having to use the "format" parameter.

I know there is a way to build a fieldtype to do this, but I'm not this advanced (yet) with PHP (still learning on Lynda).

I would HIGHLY appreciate any help!

# Answer
> 0 votes
Thanks to Werner from the EllisLab Community Boards for this one:

I was able to use the field type from Event Helper to achieve the solution that I was looking for:

```
{grid search:dateinfo="<?php echo strtotime('1/2/15'); ?>"}
        <b>date2: {grid:title}<br />
        <b>dateinfo: {grid:dateinfo}<br /><br />
    {/grid}

```

The actual Event Helper extension still needs to be updated for the new EE version (I'm running 2.9.2) or it will create PHP errors, so I recommend installing only the field type.

# Answer
> 0 votes
As far as I know there is no Grid-compatible date fieldtype which stores the date in anything other than a UNIX timestamp (as the native Date fieldtype does). Your best bet is to convert the values you want to search for into GMT UNIX timestamps and then search your Grid with those.

---
Tags: grid, date
---


# Question
Title: Pagination & Categories (Incorrect URL Generated)
I have a very standard news feature on the site i'm working on which has both categories and pagination for the entries. A problem i'm having is that the pagination is not filtering by category in the link it is generating.

When I am on a category URL (i.e. /news/category/general) this is not included in the {pagination\_url} tag, meaning when you click it goes to the non categorised second page. The link I would expect is /news/category/general/P5 and I'm getting /news/P5

Is this a bug or am I doing something wrong?

Here is a shortened version of the tags:

```
{exp:channel:entries channel="news" orderby="date" sort="desc" paginate_base="news" paginate="bottom" limit="5"}

    CONTENT

    {paginate}
        {pagination_links}
            <ul id="pagination">
                {first_page}<li><a href="{pagination_url}">← First</a></li>{/first_page}
                {previous_page}
                    <li><a href="{pagination_url}">←</a></li>
                    <li class="disabled">…</li>
                {/previous_page}
                {page}<li{if current_page} class="active"{/if}><a href="{pagination_url}">{pagination_page_number}</a></li>{/page}
                {next_page}
                    <li class="disabled">…</li>
                    <li><a href="{pagination_url}">→</a></li>
                {/next_page}
                {last_page}<li><a href="{pagination_url}">Last →</a></li>{/last_page}
            </ul>
        {/pagination_links}
    {/paginate}
{/exp:channel:entries}

```

# Answer
Found the answer, you cannot have pagination\_base set if you want it to include /category/general/ in the URL, it skips these otherwise.
> 1 votes

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


# Question
Title: CartThrob: Cannot access information in {exp:channel:entries channel="orders"} tag?
I am trying to display information in CartThrob's "orders" channel, but cannot seem to do so. I am able access other channels' information as expected with EE's channel:entries tag pair (including other CartThrob channels), but as soon as I enter "orders" as the desired channel, everything disappears. I'm not employing any crazy conditionals or anything. It's pretty straight-forward:

```
{exp:channel:entries channel="orders"}
<table width="80%">
    <tr>
        <td>
            #
        </td>
        <td>
            Buyer
        </td>
        <td>
            Deliver To
        </td>
        <td>
            Gift Message
        </td>
        <td>
            Options
        </td>
    </tr>
    <tr>
        <td>
            {title}
        </td>
        <td>
            {buyers_name}
        </td>
        <td>
            {recipients_name}
        </td>
        <td>
            {gift_message}
        </td>
        <td>
            <button>Print</button>
        </td>
    </tr>
</table>
{/exp:channel:entries}

```

Can anyone help me understand why this is happening and how I can output this channel's information? I assume I'm missing some sort of setting somewhere, but a search through CartThrob's documentation hasn't unveiled anything.

Thank you!

# Answer
> 1 votes
Depending on how you you have your order statuses setup you will need to ad the status parameter to the channel entries tag. By default you will only see status set to open. Adding `not closed` should do the trick.

```
{exp:channel:entries channel="orders" status="not closed"}

```

will show everything status but closed but you could also specify each status you want to show.

```
{exp:channel:entries channel="orders" status="open|pending|new|processing"}
{!-- whatever status names you have setup --}

```

# Answer
> 1 votes
Do you have any other params in your tag? Can you enter the entry\_id of the order in question and see a specific order? (or dynamic="no" to see more?)

---
Tags: cartthrob
---


title: Packaging slip and shipping modules

text:
# Question
Title: Packaging slip and shipping modules
Does any of the shipping modules provide a feature to print the package slip? This is not really clear when browsing through the documentation and feature overview on the website.

Kind reagards, Diederik

# Answer
The FedEx, UPS, USPS add-ons don't actually register the package with the provider but just calculate a possible rate. Therefore you would not be able to create a shipping label out of the box.

If you want to create a slip to include in the box to list the content you can either use the the built in PDF from the CP or create a template with the Orders tag pair.
> 0 votes

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


title: Search Store products by modifiers

text:
# Question
Title: Search Store products by modifiers
I'm building a shoe store using Expresso Store. Each product will use product modifiers to specify the sizes and colors that are available for that product. The user needs to be able to search/filter products by these modifiers (e.g. *I want a pair of **black** shoes in a size **12***).

Low Search is my go-to search module and looks like it is compatible with Store, but it doesn't appear to support the searching of modifiers. Likewise, Store's native Search tag doesn't seem to allow searching of modifiers.

Does anyone have any suggestions for how this might be achieved? It seems like the kind of functionality a lot of stores would require - I'm surprised it's not possible.

Thanks for your help.

# Answer
> 2 votes
I just updated Low Search Store, which allows for basic filtering by modifier. See the readme on Github for usage pointers. That should get you going for a bit at least:

```
{exp:low_search:results store:mod:color="black" store:mod:size="12"}

```

...or the dynamic equivalent, of course.

---
Tags: expresso-store, low-search
---


# Question
Title: Custom Date Format with Channel Form + Matrix + Date Fieldtype
We have a channel form setup and it's all working fine.

In the form is a matrix field called "job\_timings" and we call on it via `{field:job_timings}`

The matrix has two columns - one a text field and the other a date field. The datepicker works fine in the channel form it's just that is displays dates in the format of `2014-01-23 4:59 PM` to the end user.

In our case we don't need a time and we need the date formatted as dd-mm-yyyy.

Is there any way to control the format of this matrix date field?

# Answer
> 2 votes
I believe any date field in EE should have the `format` parameter available.

Correct syntax in this case would be something like `{field:job_timings format="%d-%m-%Y"}`.

# Answer
> 0 votes
I came across this post while attempting to solve a similar problem; hopefully this will be helpful to others who need the same functionality in the future.

Event Helper is a plugin that comes with a field type that allows for a simple date formatting WITHOUT a time stamp that can be used in GRID and MATRIX.

The actual Event Helper extension still needs to be updated for the new EE version (I'm running 2.9.2) or it will create PHP errors, so I recommend installing ONLY the field type.

---
Tags: ee2, matrix, safecracker, pixelandtonic, channel-form
---


# Question
Title: Can you remove the timestamp from the value generated by the EE date fieldtype?
I'm trying to remove the timestamp from the EE date fieldtype since for my application it isn't necessary. I need to be able to select two dates a start and end date that should be formatted like like this "%F %d %Y" and without any time stamping. I do need to also have a start and end time but they are not going to be the same as the current time the form is filled out as inserted by the date fieldtype. I plan on using dropdate for my start and end times but I first need to get these time stamps removed. I thought about having users just type the date in but the calendar selector is a nice feature to just ignore because of this time stamp. Is there anyway to accomplish the removal of the time stamp from the EE date fieldtype on EE 2.5.2? I'd rather not modify the core but willing to do so if I can achieve what I need, thanks in advance for any tips or suggestions!

# Answer
> 0 votes
I was able to achieve this by setting the field to text then I created a new snippet with the following jQuery:

```
<script>
$(function() {
$( "#datepicker-one" ).datepicker();
});
$(function() {
$( "#datepicker-two" ).datepicker();
});
</script>

```

I added that snippet to the header of my template and then set the ID's on the fields to datepicker-one and datepicker-two worked out great.

However now I want to do the same thing but for a column within a Matrix field and my problem is there isn't the option to declare an ID for this field. Perhaps I could adjust this jQuery to use the name value instead of an ID but not I'm not exactly sure how to do that. Any suggestions on how to also get this functionality within a Matrix field would be greatly appreciated!

# Answer
> 1 votes
Can you simply remove the timestamp after the fact with something like CE String?

Or, don't use the EE date field at all. Set up your own custom field, use a javscript calendar like jQuery UI Datepicker, and then you can format it exactly as you like.

# Answer
> 1 votes
I came across this post while attempting to solve a similar problem; hopefully this will be helpful to others who need the same functionality in the future.

Event Helper is a plugin that comes with a field type that allows for a simple date formatting WITHOUT a time stamp that can be used in GRID and MATRIX.

The actual Event Helper extension still needs to be updated for the new EE version (I'm running 2.9.2) or it will create PHP errors, so I recommend installing ONLY the field type.

---
Tags: fieldtype, date
---


# Question
Title: Freeform notification email to zoo visitor member's email address too
client would like to send notification not only to enquirer (ie email submitted in form) but also the Zoo Visitor member they enquired about 'title' gets passed to a field on the form so populates form automatically – but would somehow need to get the Zoo Visitor Member's email and use that in the notification too!

Its a music agency website and the Zoo Visitors are bands – the enquirer would be a person enquiring about the band, any ideas!? Thanks

# Answer
> 0 votes
Regardless of where you're getting the email address from, could likely accomplish the notification by feeding that email address into a parameter such as admin\_notify:

```
admin_notify="{email}"

```

Or directly into the recipient\_email\_user field:

```
<input type="text" name="recipient_email_user" value="{email}" />

```

---
Tags: solspace
---


title: Grid Conditionals not working

text:
# Question
Title: Grid Conditionals not working
I'm using a simple grid conditional to show academic references in a post. I only want to show it if someone has entered some references, but the conditional just isn't working. What am I doing wrong?

My code is:

```
{if references:total_rows > 0}
    <h5>Further Reading</h5>
    <ul>{references}
    <li>{references:names}, {references:pub-year}, {references:title-work}, {references:publisher}, {references:country} </li>
    {/references}</ul>
{/if}

```

I've also tried using " and brackets to surround the if condition but that doesn't work either.

# Answer
This is a known bug in EE 2.9. If you're using modifiers in conditionals, use the (otherwise not recommended) quoted-braced syntax instead:

```
{if "{references:total}" > 0} ... {/if}

```
> 0 votes

# Answer
Should that conditional even be needed? The tag pair shouldn't return anything if there isn't at least one row, so could you not simply do something like this:

```
{references}
{if references:count == "1"}<h5>Further Reading</h5><ul>{/if}
<li>{references:names}, {references:pub-year}, {references:title-work}, {references:publisher}, {references:country} </li>
{if references:count == references:total_rows}</ul>{/if}
{/references}

```
> 1 votes

# Answer
I am using this code in EE2.9 without the quotes and am having zero issues. The issue @Low is referring to is when you are comparing the variable as a string. AFAIK

```
{if service_page_copy:total_rows > 0}
    {service_page_copy}
        {if "{service_page_copy:headline}" != ""}
            <h4>{service_page_copy:headline}</h4>
        {/if}
        {if "{service_page_copy:copy}" != ""}
            {service_page_copy:copy}
        {/if}
    {/service_page_copy}
{/if}

```

I have run into a couple of oddities in the past. The only thing I can think of that you may want to try is this:

1. Try changing the name of your field to make sure it isn't a reserved or conflicting name.
2. Try changing your names from '-' hyphens to '\_' underscores to see if that resolves your issues.

If not, let me know and I can try to replicate it on a local test environment. :)
> 0 votes

---
Tags: conditionals, grid
---


title: Issues with EE update: language problem

text:
# Question
Title: Issues with EE update: language problem
I updated my EE install from 2.6 to 2.9. I can now see my homepage but when I click on any link I get this:

Unable to load the requested language file: language/english/template\_router\_lang.php

Any ideas?

# Answer
Solved! Updating instructions say to copy the entire system/language/english folder from the old system folder to the new, updated one. But the old one was missing a file: template\_router\_lang.php.

I was able to go back to the files I downloaded from EllisLab, find that file, and put it in my server. Voila.
> 1 votes

---
Tags: updating, update
---


# Question
Title: CartThrob 2.6.1 and EE 2.7.3 || Guest Add to Cart
I'm having a couple of issues with CartThrob 2.6.1 and ExpressionEngine 2.7.3. Are there any known issues with Guest Checkout with these versions?

Here's the setup:

`User Must Be Logged In?` NO

`Logged Out Member ID:` 383 (which relates to a guest member ID)

`Use Fingerprinting For Sessions?` NO (also tried all the other options too)

---

If I'm logged in as a Super Admin then I can add items to my cart, but guests cannot.

I did notice that the `member_id` field in the Database wasn't being set to `383` either. Another weird item is that `Show Debug Info (when using debug_info tag)` is set to `Show to SuperAdmins only` and the use of the debug tag in my templates shows for everyone!

Any help on this would be great!

# Answer
Upgrading both EE and CT fixed the guest checkout issues.
> 0 votes

---
Tags: cartthrob, guest
---


title: Creating a php variable for sql query

text:
# Question
Title: Creating a php variable for sql query
Can some tell me if I'm wrong, but it doesn't look like I can create a variable to store a query result into it where I leveraged EE's native {exp:query} functionality?

I want to use PHP native json\_encode functionality to output the contents of a complex query(some of the data I'm querying cannot be displayed using the Channel entries tag) to JSON. So either I have to create a pure PHP file outside of EE or "allow php" in my EE template.

# Answer
Create a plugin \- don't do this in the template. Then you can do whatever you like in pure PHP (with access to all of EE's helper functions, libraries, etc), create a variables array, and then return it for use as template tags.
> 2 votes

---
Tags: global-variables
---


title: freeform - Custom field, date format

text:
# Question
Title: freeform - Custom field, date format
We have a need for a date input. I want to use jquery UI date picker, and I'm building a third\_party plugin for freeform to use to create dates, with options for start and end dates selectable by the end user. These I'll pass to the front end no prob.

It's getting a little convoluted and It dawned on me that there might be an existing option out there? I can't be the first person ever to want to use dates in freeform... can I?

i'll carry on development, but if there are any pointers out there, I'll listen.

If I hear nothing I'll keep on developing and share my plugin later...

Cheers..

# Answer
I might be missing the goal here (you mentioned a plugin so this might be too simple), but you can very easily add a jQuery UI `Datepicker` widget to any custom form field in Freeform Pro. Just create a custom text field in the Freeform Pro control panel, lets call it **Start Date**:

Field Type: `text`

Field Label: `Start Date`

Auto-generated Field Name: `start_date`

Fully generated freeform field `id`: `freeform_start_date`

Then in your form template all you need to add is the following jQuery code (assuming you have already loaded jQuery and jQuery UI JS and CSS):

```
<script type="text/javascript">
    $('#freeform_start_date').datepicker();
</script>

```

You can add all the jQuery UI bells and whistles wherever you instantiate it.

Then the relevant part of my Freeform template becomes (here I have two Datepicker widgets):

```
{exp:freeform:composer form_name="myform" return="success"}
<script type="text/javascript">
    // Make text fields jQuery UI Datepicker Widgets
    // Add the ability to change Month and Year with built-in jQuery UI dropdowns
    $('#freeform_start_date, #freeform_end_date').datepicker({
        changeMonth: true,
        changeYear: true
    });
</script>

```

I hope that helps you and future SO viewers.
> 3 votes

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


# Question
Title: Exp:resso Store tax free no longer available in channel entry
Prior to Store 2.0 there was the option to have a product be tax free by selecting the option in the channel entries product details field. Why has this been removed and what is the best way to accomplish this task now?

This image shows the difference

# Answer
This has been removed from Store 2 in favour of category based taxes, which are much more flexible.

If you haven't already done so, I recommend reading the Store 2.0 Upgrade Notes, which covers this topic (as well as many other important points when upgrading from 1.6 to 2.0):

> Store 2 now allows for multiple taxes per order, and individual taxes may be applied to specific categories of products (using the built-in ExpressionEngine entry categories). Because of this more powerful tax system, the old “tax exempt” option has been removed from the publish page. If you have previously configured “tax exempt” products, you must create a new category for them which does not have any taxes applied to it instead.
> 1 votes

# Answer
In the Store settings, you can now define tax settings by category, so you can set up a new native EE category group for your products and define which categories will trigger which tax rate.

I found this a little confusing at first, but it makes it more flexible than simply taxable and non-taxable.
> 1 votes

# Answer
Does the category listing choose for applying tax choose to apply it on an 'or' basis? For example, I choose two categories for my product; 'scotland' and 'kids' and if both are checked in the category list, it should apply a certain tax %.

What is happening now is that if either category is ticked, it applies the %, which is no good to me based on the limitations I have in my product listing. Unless I am missing something?
> 0 votes

---
Tags: expresso-store
---


# Question
Title: freeform: Can I pass field's short name as admin_cc_notify parameters value
I have a contact form with a few checkboxes in it. An email address is associated with each check box and if the user selects a check box and email is sent to the corresponding email id. Now I want to show these email ids in the CC of the email. I have created a text field and I append all the selected emails to the value of this text field. The text fields short name is 'recipients\_list' and I gave the admin\_cc\_notify parameter as such:

```
admin_cc_notify="recipients_list"

```

The emails are getting sent but I cannot see the email ids in the CC of the email.

How do I get the CC to show in the email?

Thank you.

# Answer
> 0 votes
Unfortunately, you can't use the content of a Freeform field as a Freeform parameter value. The reason is because whatever is in your field comes *after* the parsing of the Freeform tag and its parameters. It's the same reason why you can't use the value entered in a custom field in a parameter in an EE Channel Form: the Channel Form would be parse when your page is loaded, and the content in your field comes after (and too late).

Although the functionality is not exactly the same (for example, emails wouldn't be CC'ed), the recipients feature in Freeform might come in handy here: http://www.solspace.com/docs/freeform/form/#recipients This would let you send notifications to email addresses selected in a checkbox list, for example.

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


# Question
Title: Specify order for {select_member_groups} output
So as the title states, I want to specify an order for the output of the `{select_member_groups}` tag pair within `{exp:user:register}`.

I am allowing users to register in one of three member groups with ids 5, 8 and 9. This displays in ID order, however I want to be able to have them output in the order 8, 9, 5.

So I tried to do:

```
{exp:user:register allowed_groups="8|9|5"}

```

but it still outputs in the order 5, 8, 9 on the front end. I've tried various parameters on the `{select_member_groups}` tag and none seem to work. Can't see anything about ordering it on the docs either.

Anyone know how I can do this?

Thanks in advance!

If it helps the EE version is 2.9.2 and User version is 3.5.0.

# Answer
> 0 votes
Unfortunately, as of this writing the ordering of the `{select_member_groups}` is based on default database order (i.e. increasing group\_id), and not the order set in the `allowed_groups=""` parameter. I recommend submitting this as a Feature Request under the specific add-on category. It'll also give other users the option to vote up the feature request, and help us prioritize features to add in upcoming versions of this add-on. :) http://support.solspace.com/support/discussions

In the meantime, using EE's `{exp:query}` module could get you similar data. For example:

```
<select name="group_id">
{exp:query sql="SELECT DISTINCT group_id, group_title
                FROM    exp_member_groups
                WHERE   group_id IN (8,9,5)
                ORDER BY FIELD(group_id, 8,9,5)"}
   <option value="{group_id}"}>{group_title}</option>
{/exp:query}
</select>

```

---
Tags: ee2, solspace-user
---


# Question
Title: How to create a Channel Field Group using API
I am creating an extension where on install I am creating a Channel and adding Fields to the Channel using the EE API. I have found all the API functions to do this but the one thing I have not found in the API is how to create the Channel Field Group that the Fields get added to.

Anyone know where to find documentation on how to create the Channel Field Group?

# Answer
So there is no way to do this with the EE API. You need to use the Database class and use the insert function like so.

```
    ee()->db->insert(
        'field_groups',
        array(
            'site_id'  => 1,
            'group_name'  => 'Group Name'
        )
    );

    $group_id = ee()->db->insert_id();

    return $group_id;

```
> 1 votes

---
Tags: channel, fields, channel-entries-api, field-group
---


# Question
Title: Different options and pictures in Expresso Store
I'm building a store with products that have multiple designs. I'd like to have pictures for each design, and possibly be able to click on, or have a drop down menu that would change the picture when the design is chosen. Is this possible?

# Answer
The short answer is you would need to add a field where you could upload the product images and then use some javascript to listen to your modifier drop down changes. When the user changes the product variation you would need to then fire an event and find the corresponding image that you uploaded.
> 1 votes

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