# Question
Title: How can I detect a non-menu page in NavEE?
I'm working on a site with hundreds of imported pages. Many of them won't be in a menu and are findable by using site search. We have a contextual sidebar menu in the left column and when these non-assigned pages are viewed, the left column is empty.

I'd like to add a default menu (and breadcrumbs) for any un-assigned page. Is there a way to detect if a page isn't in a menu and use a conditional to load a default if no match is found?

# Answer
> 1 votes
I don't think if there is such a tag in NavEE so that you can check that current page is from the navigation of NavEE module. But you can try SQL with query module like:

```
{exp:query sql="SELECT COUNT(*) AS total_navs FROM exp_navee WHERE link LIKE '%{current_path}%'"}

{if total_navs == 0}

######
code
######

{/if}

{/exp:query}

```

{current\_path} is standard global variable (http://ellislab.com/expressionengine/user-guide/templates/globals/single\_variables.html#current-path)

I hope, it would work for you.

---
Tags: navee
---


# Question
Title: A fieldtype with adjustable number of rows & the ability to add or remove columns per row?
A client would like to be able to ‘build’ each detail page for their portfolio. The breakdown would be something like this:

Each row can have a combination of either a video block (embed), a text block or a photo block.

The elements themselves can be either full width, half width or quarter width, and so a row can accomodate from one to four elements depending.

There can be however many rows.

As a newcomer to expression engine, I’d love to get anyone’s thoughts on how best to execute on this using EE.

Thanks so much for any help!

# Answer
I'd say you'd want to look closely at Matrix or Content Elements for this purpose, depending on your exact requirements.
> 2 votes

---
Tags: matrix, fieldtype, dynamic
---


title: Styling a quote in a PM message reply

text:
# Question
Title: Styling a quote in a PM message reply
I need a bit of code help please.

I have a messaging module for PM's that is using the following code for outputting the message body when replying to a PM:

```
else if (isset($extra['replying']) || isset($extra['forwarding']))
    {
        $tagdata = $this->EE->TMPL->swap_var_single('message',
'[quote author="'.$original_author.'" date="'.$original_date.'"]'
.$original_body.'[/quote]', $tagdata);
    }

```

What I would like to do is have the quote moved to the bottom of the message so that the cursor automatically appears above it in the textarea and also I'd like to style the quote a bit with some line breaks between the author, date and original\_body.

# Answer
> 1 votes
I got the answer to this via the codeigniter stackexchange. Someone suggsted using PHP\_EOL as a predefined constant.

```
$tagdata = $this->EE->TMPL->swap_var_single
('message', '---- Original Message ---- '.PHP_EOL.' date: '.
$original_date.PHP_EOL.$original_body.' ---', $tagdata);

```

---
Tags: messages
---


title: Easy sitemap.xml url

text:
# Question
Title: Easy sitemap.xml url
I've been looking for an easy way to point search engines to the sitemap.xml file in the **root of the website**. I've been using **Google Sitemap Lite** in combination with Navee or Structure. And it's generating sitemap.xml output like a charm.

But I've put the code in a template group named "sitemap". So I need to edit the **.htaccess** file, so the **/sitemap.xml** url points to **/index.php?/sitemap**. I couldn't get it to work...

# Answer
> 2 votes
There is an easier approach to this!

In the template group, the one that contains the template that is used for the homepage of your site, I've added an **xml template** and named it **"sitemap.xml"**. The actual template filename becomes sitemap.xml.xml, and added the template code to generate the sitemap.xml structure.

This in combination with the **standard .htaccess file for "nice urls"** (see below), browsing to /sitemap.xml renders the sitemap.xml template I've just made.

```
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|robots\.txt)
RewriteRule ^(.*)$ index.php?/$1 [L]

```

This is not a great invention, but it could save some people some time.

---
Tags: templates, htaccess, xml, rewrite
---


title: exp:query - how to

text:
# Question
Title: exp:query - how to
I'm generating a large XML document daily which on busy days is falling over with memory issues and it's been suggested that instead of using exp:channel:entries I use exp:query tags.

So I think, GREAT, lets give it a whirl. Being an SQL n00b, has anyone any pointers on how to write a query that selects all entries in a particular date range, from a particular channel that **contains a Carthtrob ordered\_items matrix**?

This is the structure ATM

```
{exp:channel:entries disable="categories|etc"
  status="closed|completed"
  start_on="{stash:time}" //Stashed time = today - 24 hours
  orderby="event|products"
  sort="asc|desc"} //query the orders channel
  {stash:first_name} //stash the content
  {stash:lastname}
  {stash:nested_list}
    {order_items} //Grab ordered variations stored in CartThrob matrix
      {stash:qty}
      {stash:color}
      {stash:price}
    {/order_items}
  {/stash:nested}
{/exp:channel:entries}

```

**UPDATE#1**

So I've done some homework, I now have some rudimentary data being sourced, the data is spread over several tables, \*exp\_channel\_titles\*, \*exp\_channel\_data\*, \*exp\_cartthrob\_order\_items\* and the final one which is a biatch is the \*exp\_channel\_fields\*

For the sake of sanity I'd like to refer to the fields in use as their EE label not some field\_id\_XX

```
{exp:query sql="SELECT * from exp_channel_titles AS t
    JOIN exp_channel_data AS d
    ON d.entry_id = t.entry_id
    JOIN exp_cartthrob_order_items AS ct
    ON d.entry_id = ct.order_id
    WHERE d.channel_id = 4
    AND t.status = 'completed'
    ORDER BY d.entry_id DESC
"}

```

Is this the right approach ? If so how can i use the default titles in the results ?

# Answer
> 1 votes
That would certainly get the job done...

To use your titles, you'd need to specify them, eg;

```
{exp:query sql="SELECT *, field_id_20 AS my_custom_field_name, field_id_21 AS my_other_custom_field_name
                FROM exp_channel_titles t
                INNER JOIN exp_channel_data d using(entry_id)
                INNER JOIN exp_cartthrob_order_items ct using(entry_id)
                WHERE d.channel_id = '4'
                AND t.status = 'completed'
                ORDER BY d.entry_id DESC "}

{entry_id} | {my_custom_field_name} | {my_other_custom_field_name}

{/exp:query}

```

Using * and changing to custom field names using AS, kinda doubles up on the data... but will still be far more efficient than channels / carthrob etc etc.

If you're going to manually root these names out of the CP anyway, you may as well just comment your XML code...

```
{field_id_20}{!-- Custom NAme --}
{field_id_21}{!-- Other Name --}

```

---
Tags: stash, query, xml
---


# Question
Title: Incorrect no_results page returned for simple search
This site has been updated from 1.7.1 to 2.6.1, there are no known issues other than this one at present.

The problem is that the search no\_results page is from the old site (design, css, imagery etc), however, the template that is in both the db and the file system (saving templates as files) is a new one.

In the simple search form params we have

```
{exp:search:simple_form
  channel = 'blog'
  status = 'open'
  search_in = 'everywhere'
  no_result_page = 'search/no-results'
  results = '100'
}

```

The url that a no results search displays is

```
/search/no-results/27e28542d78e8e6c2cafef090a2007b5/

```

the hash (segment\_3 varies for different unfound terms)

and in both the db and the templates directory we have a search group,

```
search.group
    index.html (empty)
    no-results.html
    results.html

```

The content of the no-results.html is the new code, both in the db and the files.

A 'successful' search uses the results.html template above it's just the no-results that are coming out on the 'old' template.

In addition we have tested this

1. Logged in and logged out
2. After clearing cookies
3. After clearing all site caches
4. After synching templates and checking the content in the control panel, database and file system.
5. It happens on a variety of machines (eliminating browser caching)
6. There are no rewrite rules that match

We have no idea where the system is finding this template from. Any ideas?

Thanks in advance.

# Answer
> 1 votes
This is a silly mistake on my part.

What I hadn't noticed was that there was a stray search opening tag further up the template that should have been removed.

This was in fact throwing an error, and the template that was being displayed was the error template from

```
Design -> Message Pages -> User Messages

```

Once I tracked down the stray tag it was all working as it should. The reason it looked like the old site was that they had hardcoded all of the css into the head of the template.

---
Tags: search
---


# Question
Title: Matrix File Upload not displaying contents of directory, upload silently fails
EE v2.5.5 - Build Date: 20121220 Assets 2.0.5 Matrix 2.5.3 Safecracker 2.1 (not sure if relevant)

I am using (but was not the original developer for) a multisite EE installation. In each installation I have the same channel, field group (Matrix) and identically named image upload path. However, on one of the sites I cannot get images to actually upload to the image upload directory or appear in the file upload dialog, pictured below.

# Answer
> 0 votes
The problem turned out to be that I hadn't run Update Index to finish setting up the upload destination. I had only created the upload destination and created the matrix field in channel field groups. Hope this helps someone else.

---
Tags: matrix, assets, file-uploads, file-manager, server
---


# Question
Title: How can I control output order using Low Variables and Playa
I am trying to control the order of my products using Low Variables (2.3.4) and Playa (4.3.3).

I have a Low Variable of type Playa name lv\_product\_order which I use to output the ids in the following manner.

```
{exp:low_variables:parse var="lv_product_order"}{entry_id},{/exp:low_variables:parse}

```

This gives me entry ids that I selected in the correct order, also including hte additional unnecessary comma. So I tried to than include this in my channel entries loop in the following manner.

```
    {exp:channel:entries
        channel="product"
        disable="member_data|pagination|category_fields"
        dynamic="off"
        fixed_order="{exp:low_variables:parse var="lv_product_order"}{entry_id},{/exp:low_variables:parse}"}

```

This results in the all products being output - even though I only selected a few in the LV Playa field, and order is obviously not preserved either. Template debugging displays the following tag output:

```
{exp:channel:entries channel="product" disable="member_data|pagination|category_fields" dynamic="off" fixed_order="M40o93H7pQ09L8X1t49cHY01Z5j4TT91fGfr"}

```

Where does the following hash come from? I expect this to be a list of IDs.

> M40o93H7pQ09L8X1t49cHY01Z5j4TT91fGfr

I have the field set to early parsing so I figured this would parse before the channel entry tag. Is this a parsing order issue?

Any help would be greatly appreciated. Thanks, Thomas

# Answer
> 2 votes
This Stack Overflow post has an answer from Low that should work for you.

> > Here's how: make sure early parsing is enabled for that variable, and then use the variable syntax instead of the tag syntax:
>
> ```
> {exp:channel:entries channel="groups" entry_id="{lv-home-groups}"}
> code here
> {/exp:channel:entries}
>
> ```

# Answer
> 0 votes
Try an embed. In your main template put the embed code to a newly created embed template (in my example, it's 'embed\_product\_list').

`{embed="template-group/embed_product_list" product_ids="{lv_product_order}"}`

Then in the embed\_product\_list template, your opening tag would be:

```
{exp:channel:entries
    channel="product"
    disable="member_data|pagination|category_fields"
    dynamic="no"
    fixed_order="{embed:product_ids}"}

```

---
Tags: playa, parse-order, low-variables
---


# Question
Title: Using MVC with Stash - nested model embeds for related entries (playa)
Using Stash 2.3.6, EE 2.5.5, Playa 4.3.3...

I want to stash a list of related playa entries for `Model1`. I want to assign the variables for `Model2` based on my `Model2` embed.

See `{!-- THIS IS NOT BEING SET --}` below:

If I manually assign variables with `{exp:stash:set}` within the playa loop, the code works fine. It is the nested embed that is failing.

Anyone have any advice for me? I love the way the code is laid out, and I want to keep it DRY.

**Main landing page (EE template)**

```
{stash:embed:layout:main}

{exp:stash:parse}
    {exp:channel:entries
        channel       = "list"
        limit         = "1"
        require_entry = "yes"
    }
        {if no_results}{redirect="404"}{/if}
        {stash:embed:model:model1 process="start"}
    {/exp:channel:entries}
{/exp:stash:parse}

{exp:stash:content}
    {exp:stash:get_list name="list_of_related_model2" process="end"}
        <li>{title} - {url_title}</li>
    {/exp:stash:get_list}
{/exp:stash:content}

```

**Model 1 (stash template)**

```
{exp:stash:set name="title"}{title}{/exp:stash:set}

{exp:stash:set_list name="list_of_related_model2" parse_tags="yes"}
    {exp:playa:children field="cf_related"}
        {stash:embed:model:model2 process="start"}{!-- THIS IS NOT BEING SET --}
    {/exp:playa:children}
{/exp:stash:set_list}

```

**Model 2 (stash template)**

```
{exp:stash:set name="title"}{title}{/exp:stash:set}
{exp:stash:set name="url_title"}{url_title}{/exp:stash:set}

```

# Answer
> 1 votes
The first thing I'd suggest is that Model 2 should be a snippet. Capturing the standard entry fields (title, url\_title, entry\_id etc) is something I tend to do repeatedly in my viewModels, and I use a snippet called `{set_standard}` to do it so I don't repeat myself. The other issue here is that `process="start"` is relative to the processing of the root EE embed, NOT the immediate parent template of the embed (in Stash 2.3.6). As the embed is nested EE is already at the 'inline' phase of processing. Thus to get the above working would require including the embed in the root template (with output="no" so it doesn't display) and then referencing it as a placeholder `{stash:model2}` in the child template.

---
Tags: playa, stash
---


title: move member group after order completes

text:
# Question
Title: move member group after order completes
I've just been building a small commerce site using Store and Stripe.

It's all working pretty sweetly but I need to know if there's a way I can move the member to another group once their order has been placed successfully.

Is that possible?

# Answer
Derek hit the nail on the head - there is no way to do this automatically, so you will need to create a simple PHP extension to update the member's group in the database.

If you're not sure where to start, take a look at the EE Extension Development Guide, and you want to use the `store_order_complete_end` hook.
> 1 votes

# Answer
Have a look at the store\_order\_complete\_end extension hook. The `$order` array should contain the `member_id` of the customer, which you can then use in a query to change their member group assignment.
> 1 votes

---
Tags: expresso-store, checkout, orders, stripe
---


# Question
Title: How do I stop Expression engine from redirecting blog.mydomain.com to mydomain.com/blog?
Please help. I want to install a wordpress blog under the URL blog.mydomain.com but this seems to be getting in the way.

# Answer
> 2 votes
Per comments: The problem was caused by the `.htaccess` file, and not ExpressionEngine.

---
Tags: redirects
---


# Question
Title: Expression Engine Categories And Safecracker
I am using EE Core and have set-up a site so that when a new entry is published, you also select a category for it, and on the front end this simply outputs the category name. This works perfectly when you publish an entry from the back end, but I also have a safecracker form and when you post a new entry from that, the category name doesn't get outputted - but the drop down of categories is there and correct. Any ideas what could be causing this?

This is is outputting the name;

```
<h1>{categories}{category_name} {/categories}</h1>

```

And the safecracker form with just the category code;

```
{exp:safecracker channel="new_property" return="property/property-index" }
   <select name="my_custom_field">
{exp:channel:categories style="linear"}
<option value="{category_name}">{category_name}</option>
{/exp:channel:categories}
</select>
 {custom_fields}
{/exp:safecracker}

```

# Answer
> 1 votes
Are you using "Category Field" (http://devot-ee.com/add-ons/category-field) as custom field or storing category with any other field type.

You should just save the categories and that category field automatically populate category name like:

```
{exp:safecracker channel="new_property" return="property/property-index" }
   <select name="category[]">
{exp:channel:categories style="linear"}
<option value="{category_id}">{category_name}</option>
{/exp:channel:categories}
</select>
 {custom_fields}
{/exp:safecracker}

```

You can try above code. I hope, it would work for you.

---
Tags: safecracker, categories
---


# Question
Title: Expresso-Store: New Payment Plugins - Where do we find them?
What does one do if a payment plugin hasn't been developed yet for Beanstream. Does Exp-resso add updates to the payment gateways they support?

# Answer
> 1 votes
You could either develop your own custom gateway integration or contact Exp:resso to get a quote for building it for you. The payment library in Store, CI-Merchant, is open source so you can checkout the existing gateway integrations on github.

Adrian, the developer of Store, says as much in a similar question: Exp-resso Store Custom Payment Gateway / Sagepay Form

# Answer
> 1 votes
If you're familiar with a little PHP then it's not too too difficult to create your own payment gateway to integrate with Store. Beanstream's API seems to be well documented so you could either give it a go yourself or pass it on to another developer to build.

If you're having a go yourself then the best way to start is by taking a look at the existing payment gateways that come bundled with Store. They provide a good example of what you need to do and then you can edit the codebase to fall in line with the Beanstream documentation.

If a payment gateway proves popular enough then it may well be included in a future release of Store but that would go down to demand.

# Answer
> 0 votes
The other answers are correct - we don't generally add new gateways unless they are sponsored.

Our payment library is open source, so if you have PHP development experience it's possible to develop the gateway yourself.

Alternatively, email support@exp-resso.com if you are interested in a quote for custom development.

---
Tags: expresso-store, payment-gateway
---


title: Promotion Code Errors on Expresso Store

text:
# Question
Title: Promotion Code Errors on Expresso Store
I have promotion codes set to be used only once per user. I have tested them by entering the code on checkout1 and then updating the totals. I don't actually check out and pay. The next time I try to use the code I get an error saying the code is not valid. But I haven't actually used it. Interestingly, the error doesn't occur when i'm logged into the CP in another tab in the browser. I tested this because it happened with a buyer who loaded up her shopping cart and used the code, but then was called away from her desk. When she came back, she refreshed her page and got the error. She can no longer use the code, even though she hasn't used it to check out.

# Answer
This probably isn't because the promo code has been used - it's because the user is logged out. If you have the "per user limit" set on promo codes, then users must be logged in to use them.

It's possible that the customer who walked away from their desk was logged out in the meantime, which would explain why the promo code no longer worked.

Can you test this by making sure that you are logged in *before* adding the promo code to your cart?
> 0 votes

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


# Question
Title: Is it possible to import/export all the information of all products that i have in my inventory to an excel file?
So what i want is to export/import all the information, especially the price modifiers information, of all products that are in my inventory, to an excel file. So not to a PDF.

I've tried to do this using the Zenbu module. But this does not support Exp:resso Store. Is there any other module out there that is able to do this? Or is this maybe a feature within Store already? If not, maybe this is an interesting idea for a future feature in Store?

Any information is helpfull!

Thanks in advance.

# Answer
> 1 votes
Just to add a precision, exporting can be done from Zenbu, but through a Zenbu add-on called Hokoku, which exports the displayed data in HTML, JSON and CSV (Excel-readable) for now.

If Exp:resso Store isn't displaying as you want in Zenbu (and in consequence in the exported file), it could be that Exp:resso doesn't have Zenbu cell display compatibility yet. The fallback is to display the contents of the data stored in exp\_channel\_data instead. Better display/compatibility can be added by the third-party developer by adding a few functions in their ft.my\_field.php file.

Zenbu third-party add-on developer documentation to add this functionality can be found here.

# Answer
> 0 votes
As you mentioned, Store doesn't natively support Zenbu. Normally if you need to export data, the best way is to write a raw SQL query that will format the data exactly as you need it (this could vary a lot, because each product has a number of variations and SKUs which won't fit exactly into a two dimensional excel spreadsheet/CSV anyway).

---
Tags: expresso-store
---


# Question
Title: Expresso Store Shipping Error when Changing Shipping Method Before Shipping Details Entered
I have a store which ships to both the UK and to Australia (from the UK).

The default shipping plugin includes 4 methods – three are to the UK (Royal Mail First Class Standard, Next Day, Royal Mail Second Class Economy), and one for Royal Airmail to Australia. The three to the UK work fine, but the one to Australia returns this message on the checkout page when I change the shipping method in the dropdown box: Error calculating shipping: No rules match the current cart.

If I ignore that error message and continue to add my address in checkout two then continue on to checkout 3, the shipping is THEN calculated correctly, and I can continue on to payment.

How can I have the shipping calculated on checkout1 instead of returning the error (I don't mind that the user has to click update totals)? The buyer will not put in their address until checkout 2.

# Answer
Currently the best method is to let the customer put in their address before you show them the shipping options. You can't very well calculate the shipping costs without their address anyway.

Alternatively, you could change the rules for your Australia shipping method so that the cost applies worldwide. This means that if someone selects it before they enter their shipping address, they will still see the correct price, instead of an error message.
> 1 votes

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


title: Stock Management Workflow

text:
# Question
Title: Stock Management Workflow
I just purchased Store a few weeks ago and my clients added another request is that she want to be able to track the change in her stock, not just the remain stock number after order/sale but also the newly imported ones.

For example she has a product call T-Shirt, original stock level is 10. At the end of the month, she sold 9, has 1 remaining in stock.

Now she wants to add 9 more from a certain supplier to make sure the stock level at the beginning of next month is 10 again. How would you suggest her to do so and how we can track the number of T-shirt we have import from a certain supplier during a certain period of time?

Please let me know if I didn't explain clearly enough. Thanks!

# Answer
Store has simple stock tracking facilities, but it shouldn't be used as a replacement for a proper accounting system. It is designed to let you limit the number of sales to however many you have in stock, and if you get more stock in you can update this number to allow customers to purchase the item again.

However, tracking incoming stock from suppliers, or generating reports of how many items need to be ordered is really beyond what Store was designed to do. You should probably look at writing your own module / queries to generate this data, or look at off the shelf accounting software which has a full inventory management system.
> 1 votes

---
Tags: expresso-store
---


# Question
Title: is it possible to set the store product details field not required?
I have a site with a database of products and now I have added expresso store. I would like to make the product info field not be required. I have set the "Is this a required field?" option to no but once I try and edit or add a new product it still asks for a price and a SKU.

The problem is that the client does not want all of their products to be available on the shop. I want to have the custom field be available on all entries but only use those which will fill out the product details field filled out.

# Answer
> 1 votes
We will consider this, but it would need some major changes to how Store works, since every product would need to be marked as "for sale" or not. Generally the best idea is to put all of your products for sale in one channel, and if you have products which can not be purchased, create a separate channel for them.

I'd be interested to hear more about the use case for this - what sort of products does your site have where some are for sale and some are not?

---
Tags: expresso-store
---


title: RSVP Module install error on EE 2.6.1

text:
# Question
Title: RSVP Module install error on EE 2.6.1
Trying to activate open RSVP 1.22 module on EE 2.6.1 after installing and get this error:

```
A PHP Error was encountered

Severity: Notice

Message: Undefined property: Addons_modules::$channel_model

Filename: rsvp/mcp.rsvp.php

Line Number: 105

Fatal error: Call to a member function get_channel_info() on a non-object in /home/<user>/<system>/expressionengine/third_party/rsvp/mcp.rsvp.php on line 105

```

Any ideas for a fix?

Thanks

# Answer
> 1 votes
Installing latest version of RSVP (added today on Git) resolved the issue

# Answer
> 0 votes
It seems that channel\_model couldn't be loaded. You should have following line of code above line of error or above line number 105.

```
$this->EE->load->model('channel_model');

```

# Answer
> 0 votes
This appears to be happening because ExpressionEngine 2.6 doesn't load the channel model automatically.

I've just published a new version of RSVP (1.2.3) which fixes this issue:

https://github.com/expressodev/rsvp

---
Tags: expresso
---


# Question
Title: Problem with External S3 Source in Assets 2.1.3 and EE 2.5.5
I get the following error when attempting to save an external source using Assets 2.1.3 in EE 2.5.5:

```
Fatal error: Call to undefined method stdClass::result_array() in
/home/active/public_html/administrate-am/codeigniter/system/libraries/Javascript.php
on line 765

```

Anyone have any idea how to fix this? It looks like it's an issue with generating JSON, but I don't know how to fix it and it's kind of urgent.

PHP 5.3.x, in case it matters.

# Answer
This was a bug in Assets and will be fixed in the next release.

In the meantime, the patch is:

in mcp.assets.php in the save\_source() method, line 1000 is:

```
$data = array(
    'name' => $name,
    'settings' => Assets_helper::get_json((object) $save_data)
);

```

I changed it to:

```
$data = array(
    'name' => $name,
    'settings' => Assets_helper::get_json($save_data)
);

```
> 3 votes

---
Tags: ee2, assets, php, error
---


# Question
Title: Getting Stash and Solspace Tag to work together
So I have a channel called Campaign, which has a number of ordinary text Input fields like 'campaign\_twitter' and 'campaign\_twitterhashtag'. It also has a Solspace Tag field called 'campaign\_tag'.

This Channel helps to create a Campaign page, so that when you add a Solspace Tag, the page will then pulll in related content from the rest of the site, based on that Tag. What i'm having trouble with is getting that related content to display correctly. It is currently just displaying the custom field names on the page, so I'm assuming it's something to do with parse order or not setting up the stash correctly.

I was wondering if someone might be able to assist to get things displaying correctly?

So this is the list where I am setting all of the variables - Text Inputs and Solspace Tag;

```
{exp:stash:set_list name="campaign-vars" parse_tags="yes"}
    {exp:channel:entries
        channel="campaign"
        status="open"
        limit="1"
    }

        {stash:tag}{exp:tag:tags entry_id="{entry_id}" limit="1" websafe_separator="-"}{tag}{/exp:tag:tags}{/stash:tag}
        {stash:twitter}{campaign_twitter}{/stash:twitter}
        {stash:twitter_hashtag}{campaign_twitterhashtag}{/stash:twitter_hashtag}

        {stash:blog_entries}
            {exp:tag:entries
                channel="blog"
                status="open"
                orderby="title"
                sort="asc"
                tag="{tag}" {!-- This should be the tag retrived from {stash:tag} --}
            }
                {stash:blog_title}{title}{/stash:blog_title}
                {stash:blog_summary}{article_summary}{/stash:blog_summary}
            {/exp:tag:entries}
        {/stash:blog_entries}

    {/exp:channel:entries}
{/exp:stash:set_list}

```

This is where i'm displaying content in the page, notice the loop for the blog entries. Where the {blog\_title} should be, it's showing the title of the current page and all other tags are just displaying the actual tag, with the exception of {twitter} tag, which is displaying correctly.

```
{exp:stash:set name="content"}

    {exp:stash:get_list name="campaign-vars"}

        {!-- Loop through blog entries here --}
        {blog_entries}
            {blog_title}
            {blog_summary}
        {/blog_entries}

        {!-- Display Twitter handle --}
        <p>Follow us on twitter: {twitter}</p>

    {/exp:stash:get_list}

{/exp:stash:set}

```

# Answer
When you set your list you have two layers of nested tags to parse, so use `parse_depth="2"` to tell Stash to parse both layers. You are also trying to capture a nested list 'blog\_entries', but are not using a supported syntax. Please see the docs for an example of setting / getting nested lists.

https://github.com/croxton/Stash

(Sorry can't link to exact line in docs because I'm typing this on my phone - see the set\_list section)
> 0 votes

---
Tags: stash, solspace-tag
---


# Question
Title: Need help finding a way to set up a booking system for expressionengine
I'm looking for a good solution for setting up a reservation/booking system as part of an ExpressionEngine website I am estimating for a client. I am ideally looking for something that will integrate with Cartthrob for payment for reservations. If anyone has a suggestion I would greatly appreciate it.

Thanks,

Brian Rivet brian@odysseydesignstudio.com

# Answer
There is always moreEvents ( http://devot-ee.com/add-ons/moreevents ) that allows you to sell event registrations with CartThrob.
> 1 votes

---
Tags: cartthrob
---


# Question
Title: Using low search for custom field multiple select. A primer
I have been looking at using potentially Low Search to perform the following:

Example: A site that users can research high end stereo equipment.

Required: Create a structure listing/channel for these with 2 custom multiple select fields for manufacturer and type.

Create a front end page with a two dropdowns - Manufacturer and Type. Needs the potential to add other custom fields of the same multiple select field types such as colour or price range.

As I only have a couple of EE sites under my belt and never used Low Search, I was after an initial push to see if this is possible with Low Search and if Low or someone could help with the template code to get me going.

TIA.

# Answer
Using categories, like Stephen suggested, will be more accurate, as you'll be filtering by IDs instead of strings. The problem with searching directly into multiple-select fields, is that you might get issues with substring matches.

You can use `search:my_custom_field` fields for searching the multiple selects, and you could use Low Options to generate the list of options. You'd then get something like this:

```
<select name="search:my_custom_field[]" multiple="multiple">
  {exp:low_options:my_custom_field}
    {options}<option value="{option:value}">{option:label}</option>{/options}
  {/exp:low_options:my_custom_field}
</select>

```

This, by default, would be like setting a parameter `search:my_custom_field="option1|option2"` in the channel entries tag. You can change that to `search:my_custom_field="option1&&option2"` by adding `require_all="search:my_custom_field"` to the Form tag.
> 1 votes

# Answer
Yes, you can use Low Search for multiple select fields. However, for the way you're wanting to use dropdowns to create filters you'd be wiser to use categories with Low Search instead. Low Search has some solid documentation for searching categories.

Here's a site that I recently built using Low Search where all the filters are built from categories.
> 0 votes

---
Tags: low-search
---


# Question
Title: How to highlight 10 most recent entries from a channel?
I'm trying to find a way to highlight the 10 most recent entries within an alphabetically sorted list of entries from a particular channel.

I don't wish to change the order of the entries, just have the ability to put some custom markup around the most recent ones.

Is there a simple way to do that or am I going to need to use a custom query instead of using channel:entries tag pair?

I'm currently thinking along the lines of having to do a query to get the entry IDs of the most recent 10 entries, storing those entry IDs and comparing them to the entry IDs when outputting my full list.

There's got to be an add-on for this though right?!

# Answer
Try to use embed to set and pass ahead a variable:

```
{embed="template_group/.entries-list" eleventh="{exp:channel:entries offset='10'}{edit_date format='%U'}{exp:channel:entries}"}

```

On the embed template:

```
{exp:channel:entries}
    {if {edit_date format="%U"} < {embed:eleventh} }
        <custom markup>
    {/if}
        default markup (...)
    {if {edit_date format="%U"} < {embed:eleventh} }
        </custom markup>
    {/if}
{/exp:channel:entries}

```
> 2 votes

# Answer
You can probably do this with Stash.

I haven't tested this code, but it should work.

First, output/stash the entries by date.

```
{exp:channel:entries orderby="date" ...}
  {exp:stash:set_list name="entries"}
    {stash:title}{title}{/stash:title}
    {stash:is_recent}{if count < 11}true{/if}{/stash:is_recent}
  {/exp:stash:set_list}
{/exp:channel:entries}

```

Then instead, sort appropriately using the stash output.

```
<ul>
{exp:stash:get_list name="entries" orderby="title" sort="asc"}
  <li {if is_recent}class="recent"{/if}>
    {title}
  </li>
{/exp:stash:get_list}
</ul>

```
> 2 votes

---
Tags: query, entries
---


title: Group Entry Listing By Channel

text:
# Question
Title: Group Entry Listing By Channel
I feel like there's an obvious answer to this, but is it possible to have one channel entries tag with multiple channels and group the output by channel? For example:

```
{exp:channel:entries
    channel="blog|news|press_releases"
    dynamic="no"
    limit="50"
    orderby="channel"
}
    {!-- All Blog Entries First --}

    {!-- All News Entries Second --}

    {!-- All Press Releases Entries Third --}
{/exp:channel:entries}

```

# Answer
> 6 votes
Textbook use case for Stash:

```
{exp:channel:entries
    channel="blog|news|press_releases"
    dynamic="no"
    limit="50"
}
  {exp:stash:append_list name="entries" context="{channel_short_name}"}
    {stash:url_title}{url_title}{/stash:url_title}
    {stash:title}{title}{/stash:title}
  {/exp:stash:append_list}
{/exp:channel:entries}

<ul>
{exp:stash:get_list name="entries" context="blog" process="end"}
  <li><a href="{path='blog/{url_title}'}">{title}</a></li>
{/exp:stash:get_list}

{exp:stash:get_list name="entries" context="news" process="end"}
  <li><a href="{path='news/{url_title}'}">{title}</a></li>
{/exp:stash:get_list}

{exp:stash:get_list name="entries" context="press_releases" process="end"}
  <li><a href="{path='press_releases/{url_title}'}">{title}</a></li>
{/exp:stash:get_list}
</ul>

```

# Answer
> 0 votes
Something like,

```
{if channel_id=="Blog Entries ID #"} Content {/if}
{if channel_id==" News Entries ID #"} Content {/if}

```

etc. etc?

I do believe that the order of the conditionals top to bottom will output which you want to go first, next, etc.

# Answer
> 0 votes
To achieve it, you can use a small query to get the channel name and passing one by one in channel entry tag like:

```
{exp:query sql="SELECT channel_name FROM exp_channels WHERE channel_name IN ('blog', 'news', 'press_releases') ORDER BY FIELD(channel_name,'blog', 'news', 'press_releases')"}

{exp:channel:entries
    channel="{channel_name}"
    dynamic="no"
    limit="50"
    orderby="channel"
}

###### entries ########

{/exp:channel:entries}

{/exp:query}

```

I hope, it would help you.

---
Tags: channel-entries, orderby
---


# Question
Title: Is this how to redirect when using strict urls?
I've got a blog the url structure like this and strict urls's turned on.

www.site.com/blog This lists all the blog entries

www.site.com/blog/post/url\_title This is the single entry page displaying the entry

Now, if www.site.com/blog/foo they'll still get a full list of blog entries. Would it be a good practice to add this at the top of /blog to prevent it happening?

{if segment\_2 AND segment\_3 == ''} {redirect="404"} {/if}

# Answer
Personally I'd look to handle this at the server level in my .htaccess file so it keeps the template files a little cleaner and doesn't fire up EE's template parser when it's not needed.

Something like this should forward them on to the requested page but with the correct directory inserted into the URL:

```
RedirectMatch 301 /blog/(.*) http://domain.com/blog/post/$1

```

It's good for SEO purposes as it's set as a permanent redirect and it means they'll actually be forwarded on to the correct URL rather than meet with a 404.

You could then just maybe keep the `{if no_results}{redirect="404"}{/if}` in the template to catch anything which doesn't actually exist.
> 1 votes

# Answer
If there are only going to be 2 pages in your example, you could something like:

```
{if segment_1 == "blog"}
     {if segment_2 != ""}
          {if segment_2 != "post"}{redirect="404"}{/if}
          {if segment_3 == ""}{redirect="404"}{/if}
     {/if}
{/if}

```

---

(edited: removed incorrect parsing comment, see Ian's comment)
> 0 votes

# Answer
Also check the "require\_entry" parameter (http://ellislab.com/expressionengine/user-guide/modules/channel/channel\_entries.html#require-entry).

In one of my single entry blog templates I have a configuration like this:

```
{exp:channel:entries channel="blog" oderby="date" sort="desc" limit="1" require_entry="yes"}
{if no_results}{redirect="404"}{/if}
{if segment_4 != ""}{redirect="404"}{/if}

```
> 0 votes

---
Tags: templates
---


title: Using variables in if then

text:
# Question
Title: Using variables in if then
***EDITED FOR MORE CLARITY***

I have a really stupid problem I'm trying to fix... This is (a part of) template code

```
<dl class="tabs contained">
    {if "{products_related_products:total_children}"}
        <dd class="active"><a href="#simpleContained1"><!-- Gerelateerde producten -->{bbr-mls-54}</a></dd>
    {/if}

    {if "{products_related_lexicon:total_children}"}
        <dd class="hide-for-small">
        <a href="#simpleContained2"><!-- Gerelateerde lexicon -->{bbr-mls-57}</a></dd>
    {/if}

    {if products_additional_remarks_{language_code}}
        <dd class="hide-for-small"><a href="#simpleContained3"><!-- Bijkomende opmerkingen -->{bbr-mls-53}</a></dd>
    {/if}

    {if products_videos_{language_code}}
        <dd class="hide-for-small"><a href="#simpleContained4"><!-- Video -->Video</a></dd>
    {/if}

    {if {exp:playa:total_parents channel="downloads"}!="0"}
        <dd class="hide-for-small"><a href="#simpleContained5"><!-- Downloads -->Downloads</a></dd>
    {/if}
</dl>

```

This code is shown below a product detail page to show other related content like downloads and videos and so on...

As you can see I'm using a If Then statement to determine if there are any related records for this product and if there are a tab is shown, if nothing is shown.

The problem I'm trying to solve is the set the right tab to class="active". In the current example this is the case for the first tab in hardcoded way.

In other programming language I would include a variable to every if/then routine and it is executed (because there is content) I would set a variable e.g. ThereIsAnActiveTab to 1 After that I would put a conditional in every

As an example in non-working code this would the code

```
<dl class="tabs contained">
    {if "{products_related_products:total_children}"}
        <dd class="active"><a href="#simpleContained1"><!-- Gerelateerde producten -->{bbr-mls-54}</a></dd>
    {variable:ThereIsAnActiveTab = "1"}
    {/if}

    {if "{products_related_lexicon:total_children}"}
        <dd class="{if variable:ThereIsAnActiveTab=="1"}hide-for-small{if:else}active{/if}">
        <a href="#simpleContained2"><!-- Gerelateerde lexicon -->{bbr-mls-57}</a></dd>
            {variable:ThereIsAnActiveTab = "1"}
    {/if}

```

and so on ... But that does not work in EE due the way the template gets parsed. Any ideas on how to solve this?

rg,

Tim

# Answer
From your code samples, it looks like you have several different custom fields that generate the tabs–so there is really no *clean* way of 'hard-coding' in the first active tab. If your tab structure was within a custom field loop, it would be easy with the `{count}` variable.

If you're using jQuery, you could do this to add the class names:

```
$('.tabs dd:first').addClass('active');
$('.tabs dd').not(':first').addClass('hide-for-small');

```

### 2nd Option

Using advanced conditionals, but it gets messy quick:

```
<dl class="tabs contained">
    {if "{products_related_products:total_children}"}
        <dd class="active"><a href="#simpleContained1"><!-- Gerelateerde producten -->{bbr-mls-54}</a></dd>
    {/if}

    {if "{products_related_lexicon:total_children}"}
        <dd class="{if products_related_products:total_children == 0}active{if:else}hide-for-small{/if}">
        <a href="#simpleContained2"><!-- Gerelateerde lexicon -->{bbr-mls-57}</a></dd>
    {/if}

    {if products_additional_remarks_{language_code}}
        <dd class="{if products_related_products:total_children == 0 && products_related_lexicon:total_children == 0}active{if:else}hide-for-small{/if}"><a href="#simpleContained3"><!-- Bijkomende opmerkingen -->{bbr-mls-53}</a></dd>
    {/if}

    {if products_videos_{language_code}}
        <dd class="{if products_related_products:total_children == 0 && products_related_lexicon:total_children == 0 && products_additional_remarks_{language_code} == ""}active{if:else}hide-for-small{/if}><a href="#simpleContained4"><!-- Video -->Video</a></dd>
    {/if}

    {if {exp:playa:total_parents channel="downloads"}!="0"}
        <dd class="{if products_related_products:total_children == 0 && products_related_lexicon:total_children == 0 && products_additional_remarks_{language_code} == "" && products_videos_{language_code} == ""}active{if:else}hide-for-small{/if}><a href="#simpleContained5"><!-- Downloads -->Downloads</a></dd>
    {/if}
</dl>

```
> 3 votes

---
Tags: conditionals
---


# Question
Title: Expresso Store: Update Cart button is not updating the cart
I have a regular 'update cart button' on my basket (button type="submit" name="update\_cart"), which should obviously recalculate the cart when I click it.

The cart is reloading correctly, but any changes to quantity are being ignored and the original value reloaded.

Any pointers as to where this might be going wrong?

# Answer
> 2 votes
It turns out that there is no error with my site, just that 'limit stock' was turned on, and everything was set to '1' in the inventory! This means that only 1 item could be added to the cart anyway (but no error message meant that it wasn't clear what then issue was)

---
Tags: expresso-store
---


title: Form Submit Error Page and Success Page

text:
# Question
Title: Form Submit Error Page and Success Page
Does anyone no how to style the standard EE success/error page that appears after submitting a simple form? It would be nice not to have this default page and style.

# Answer
> 1 votes
You should go to CP -\> Design -\> Message Pages -\> User Messages

Here you can see the User Message template and can style accordingly.

---
Tags: simple-search
---


# Question
Title: Google Maps for EE field not displaying correctly in a jQuery tabbed form
I've got a tabbed SafeCracker form and one of the fields is a Google Maps for ExpressionEngine field. I've noticed an issue where the map only loads properly if it's on the first/selected tab when the page loads. If it's on another tab, then when you click that particular tab, the map doesn't display correctly.

I believe it's an issue to do with the map needing to be redrawn as the tab it's within is clicked, and it sounds like a similar issue this other question. But I can't figure out how to implement or adapt that other solution to fix my problem, though it might be because I'm using a SafeCracker field and different template code so the other solution might not apply completely to my situation.

So I'm posting this as a new question, and any advice on this would be appreciated. My stripped-down template code is below:

```
{exp:safecracker channel="event" include_jquery="no" datepicker="no" return="/events"}

  <div class="tabbed-form">

    <ul class="tabs">
      <li><a href="#tab1" class="selected">Tab 1</a></li>
      <li><a href="#tab2" class="tab-with-map" data-id="gmap_output_cf_event_map_location">Tab 2</a></li>
      <li><a href="#tab3">Tab 3</a></li>
    </ul>

    <div id="tab1" style="display: block;">
      <h2>Tab 1</h2>
    </div><!--tab1-->

    <div id="tab2" style="display: none;">
      <h2>Tab 2</h2>
      {field:cf_event_map_location}
      <input name="cf_event_map_latitude" type="hidden" value="{cf_event_map_latitude}" />
      <input name="cf_event_map_longitude" type="hidden" value="{cf_event_map_longitude}" />
    </div><!--tab2-->

    <div id="tab3" style="display: none;">
      <h2>Tab 3</h2>
    </div><!--tab3-->

    <input type="submit" value="Save" />

  </div><!--tabbed-form-->

  <script type="text/javascript">
    $('.tabbed-form .tabs').kosTabs();
  </script>

<script type="text/javascript">

$(document).ready(function() {

    // Trigger represents any selector you want to trigger the map to be redrawn

    $('.tab-with-map').click(function() {

        var $t     = $(this);
        var id     = $t.data('id');
        var map    = window[id+'_map'];
        var center = window[id+'_options'].center;
        var bounds = window[id+'_bounds'];
        var delay  = 500;

        /* Allows the animation to start before the map is redrawn,
           the 500(ms) can be adjusted for optimal performance.
           If no animation is present, use 0 or remove the delay
           entirely. */

        setTimeout(function() {
            google.maps.event.trigger(map, 'resize');

            for(var x = 0;x < markers.length;x++) {
                bounds.extend(markers[x].getPosition());
            }

            // This will center the map on the calculated bounds
            map.fitBounds(bounds);
            map.setZoom(options.zoom);

            /* Do not use setCenter and fitBounds, use only the one that works best for you */

        }, delay);

        return true;
    });

});

</script>

{/exp:safecracker}

```

Edit: I've updated my code to show how I've tried (unsuccessfully) to use Justin's code from the other answer linked to above.

# Answer
> 1 votes
There is actually a better answer to this question. Here is the updated code:

```
$(".tabs").tabs({
    show: function() {
        if(Gmap.instances.length > 0) {
            Gmap.instances[0].resize();
        }
    }
});

```

# Answer
> 2 votes
Here is an example of how to fix the issue using jQueryUI Tabs. It could work with any other tab library, you just need to change the callback and the conditional. Basically you just need to get access to the Gmap instance in question and resize the map, and then re-center it. It's really simple.

```
$(document).ready(function() {
        $('.tabs').tabs({

        show: function(event, ui) {
            if(ui.panel.id == 'map') {
                var instance = Gmap.instances[0];

                google.maps.event.trigger(instance.map, 'resize');
                instance.map.setCenter(instance.center);
            }
        }

    });
});

```

---
Tags: jquery, google-maps-for-ee
---


# Question
Title: If statement comparing two string ee variables won't return false
I have the following code in a template:

```
segment is: {segment_3} <br />
category is: {category_url_title}<br />
{if {segment_3} == {category_url_title}}
submenu goes here
{/if}

```

It gives the following output for categories that do not match the URL:

```
segment is: evaporated-apples
category is: frozen-apples
submenu goes here

```

If I compare to a string literal, e.g., `{segment_3} == "bacon"`, the conditional returns false. Why does comparing two variables that contain different strings return true?

# Answer
In your case, you were comparing 2 variables (string) without quotes so both variables will be considered as TRUE i.e `{if TRUE == TRUE} #### {/if}`. In the same way when you put a single variable tag in if condition like `{if variable_name} #### {/if} OR {if {variable_name}} #### {/if}`

Having the quotes (single or double), EE considers the variable/s tag value as single string value and get compared correctly like:

```
{if "{segment_3}" == "{category_url_title}"} ###### {/if}

```
> 3 votes

---
Tags: conditionals, categories, segments
---


# Question
Title: Safecracker: Use a select dropdown to enter a text field?
An easy one here, I think!

I have a channel field that is a text field. This field holds a numerical value, (between 1-12)

I am creating a safecracker form to add entires from the front end. Can I use a select drop down with the values 1-12 to complete this text field or does the actual channel field need to be a dropdown type?

# Answer
> 1 votes
Yep.

```
<select name="your_custom_field_name">
  <option value="1">1</option>
  <option value="2">2</option>
</select>

```

And if you're using safecracker to edit, this is what I use:

```
<select name="your_custom_field_name">
  <option value="1"{if '{your_custom_field_name}'=='1'} selected{/if}>1</option>
  <option value="2"{if '{your_custom_field_name}'=='2'} selected{/if}>2</option>
</select>

```

# Answer
> 1 votes
I've not directly tested but I'm fairly sure it's no problem to use a dropdown field on the front-end via a safecracker form to pass that value. Both a regular text input and the select boxes rely on the `value` parameter and this will be what's sent through on form submission so it should be fine.

---
Tags: safecracker
---


title: playa refering to another playa

text:
# Question
Title: playa refering to another playa
Ok, let's see if I can explain this question, I have a channel with a playa field which refers to channel which has other playa fields in it that I want to display on the given page. How do call the other playa field? on that playa selections channel since just calling them doesn't work of course.

I get about this far, but don't know the next step?

```
{exp:playa:children field="FROM CHANNEL A"}
    {title}
{/exp:playa:children}

```

**EDIT**

Hi Lisa, Thanks for responding I am somewhat new to playa and even to EE itself lets see if I can explain this better.

I have a channel called "data\_entry" with a playa list `{location_source}` the items on the list refer to another channel called "locations" which contains another playa field called `{second_order_location}` that I want to display right before the `{title}` of the first playa list. Does that make sense?

```
{exp:playa:children field="location_source"}
    {if first_order_location_parent}{first_order_location},{/if}
    {title}
{/exp:playa:children}

```

**EDIT** I wrote

```
     {exp:playa:children channel="data_entry" var_prefix="data_entry"}
        {data_entry:exp:playa:children channel="nwt_locations" var_prefix="first_order_location_parent"}
            {data_entry:title} - {first_order_location_parent:title}
        {/data_entry:exp:playa:children}
      {/exp:playa:children}

```

All I get is the same as if I wrote {title} am I missing something? I am not sure what to do about the parameters. Thanks So much for time

# Answer
> 1 votes
Edited answer based on the OP edited answer :)

```
 {exp:channel:entries channel="news"}
    <h3>Article Media</h3>
    <ul>
        {exp:playa:children channel="news" var_prefix="news"}
            {news:exp:playa:children channel="editors" var_prefix="editor"}
                {news:title} - {editor:title}
            {/news:exp:playa:children}
    {/exp:playa:children}
    </ul>
{/exp:channel:entries}

```

This is directly from the example for var\_prefix here:

http://docs.pixelandtonic.com/playa/templating/module/children.html

You'll need to update your channel= parameters, and if you want to change the var prefixes, make sure you change them wherever they're referenced. Does that help?

-Lisa, P&T

---
Tags: playa, pixelandtonic
---


# Question
Title: Migrating from Bucketlist (ee1) to Assets (ee2)
I have upgraded a site to EE2 that used Bucketlist extensively (over 8000 items) to serve content from S3.

Bucketlist was not updated to EE2, and won't be by the looks of things, so I need to find a way to migrate the urls from the Bucketlist tables to Pixel and Tonic's Assets. (Or alternatively Channel Files)

As far as I can see it will take a fairly complex (for me!) SQL query to achieve. Does anyone have experience of this process? It would be great to get some tips before I start the process.

# Answer
I know that channel files has an import function. Same with channel images if you needed that.

This might not be much of a useful answer, but it might be worth a chat with DevDemon. I haven't used the import feature yet.

As far as I am aware, you'll need create a list of entry ids, urls etc. Then you can import. You might need Export It or another exporting addon to help.

Hopefully it will halp and might be the way to go.
> 2 votes

---
Tags: ee2, assets, ee1, upgrade
---


# Question
Title: Get current category of channel entry corresponding to current URL
I have a channel, products, with a URL structure like this:

```
/product/description/categoryA
/product/description/item-in-categoryA
/product/description/item-in-categoryA2
/product/description/item-in-categoryA3
/product/description/categoryB
/product/description/item-in-categoryB
/product/description/item-in-categoryB2
/product/description/item-in-categoryB3

```

When I am on, for example, `/product/description/item-in-categoryB3`, I want to indicate that `categoryB` is the current category. However, I cannot find a way to do this. I have tried {if active}, which never returns true whether I am inside channel categories or channel entries (using version 2.5x). I have tried inspecting the URL segment but I cannot rely on this when I am on an item's page as the category does not appear in the URL.

# Answer
> 1 votes
If you're successfully showing the entry's data then you should be able to call the categories from within the channel:entries tag loop with the categories loop.

```
{categories}{category_name}{/categories}

```

Is that working for you?

---
Tags: conditionals, structure, url, categories
---


title: MySQL - Change Entry Category ID?

text:
# Question
Title: MySQL - Change Entry Category ID?
Looking for help doing what I hope is a simple task.

We have approximately 2500 entries that are need to be reclassified (choose new category ID). I am hoping that a simple MySQL script can identify all the records with a certain category id, and then change the record from that id - to a different id.

*Of course if there is an easier way than a script, let me know!*

Need to change all the entries that have ID:2 - to ID:4

Thanks EE community!

# Answer
1. Perform DB backup incase this goes wrong.
2. Execute the follow statement

`UPDATE exp_category_posts SET cat_id = 4 WHERE cat_id = 2`
> 2 votes

---
Tags: categories, mysql
---


title: Playa not working with Low Variables

text:
# Question
Title: Playa not working with Low Variables
I have just updated to Playa 4.4.3. I read there was bug with Low Variables and Playa, and that it was supposed to be fixed on the new Playa release.

I can't get Playa to work at all.

I've tried many many things. This is my basic code:

```
{exp:low_variables:pair var="lv_sidebar" multiple="yes"}
  {title}
{/exp:low_variables:pair}

```

# Answer
There is a bit of a bug in Playa that impacts Low Variables:

exp\_playa\_relationships has parent\_var\_id field. It's supposed to be either 0 or 1. Low Variables sets it to NULL due to an oversight in our code. The solution was to set the column to 0 for rows, that were not 1.

We'll have a fix for this included in Playa in the future, but for right now, modifying your database that way should fix this. Alternatively, there is a temporary hack you can utilize which doesn't require muddling in the database, and will be overwritten in the fixed version of Playa.
> 4 votes

---
Tags: playa, low-variables
---


# Question
Title: p-tags from RTE field getting stripped - but only after the first entry
So this is strange. Template code:

```
{exp:channel:entries channel="[channel_name]"}

    {rich_text_field}

{/exp:channel:entries}

```

For the first entry, the text in the field will return wrapped with p tags. For the rest of the entries, all p tags are missing.

If I switch the field to a normal textarea instead, p-tags will be returned as excpected, for all entries.

I can find no errors anywhere in any logs, and template debugging returns nothing unusual.

The text renders correctly with p tags within the 'view code' part of RTE inside the control panel.

Oh, and this is the newest, 2.6.1 version of EE.

Any pointers where I can start looking for errors?

EDIT (more info): So the problem seems to be that the string ($this-\>text\_format), during parsing, isn't marked as 'xhtml', but rather as 'none', and therefore isn't passed through to the auto\_typography() method (I think it's somewhere in EE\_typography.php, but I can't remember exactly). Again, this is *only* for the subsequent entries, and not the first.

# Answer
I've hacked core in order to fix this bug:

In system/expressionengine/modules/rte/ft.rte.php, find:

```
        array(
            'html_format'   => $this->row['channel_html_formatting'],
            'auto_links'    => $this->row['channel_auto_link_urls'],
            'allow_img_url' => $this->row['channel_allow_img_urls']
        )

```

Add this line in the array:

```
            'text_format'   => $this->row['field_ft_'.$this->field_id],

```

Feel free to report this bug with a link to this page.

---

Slightly related: I've also hacked this same method in order to avoid extra new lines to create empty `<p>` tags.

I changed:

```
ee()->functions->encode_ee_tags(ee()->typography->parse_file_paths($data))

```

to

```
ee()->functions->encode_ee_tags(trim(ee()->typography->parse_file_paths($data)))

```
> 1 votes

# Answer
There seems to be a suggested bugfix here.

It's also discussed here on Ellislab's support site.

Basically find this code (line 80 in system/expressionengine/modules/rte/ft.rte.php):

```
array(
    'html_format' => $this->row['channel_html_formatting'],

```

And replace with:

```
array(
    'text_format' => 'xhtml',
    'html_format' => $this->row['channel_html_formatting'],

```

I can confirm I had the same problem and this fixed it.
> 2 votes

---
Tags: templates
---


# Question
Title: Using EE as a data source for an iphone app
We're currently developing an html5 based iOS app using ExpressionEngine as the data source. So far it's working and looking great. However, we're unsure as to how approach the member side of things: we want to allow users to log in as they do on the main website. This appears to be somewhat of a challenge and we're wondering if anyone has come across a solution?

We're also using Zoo Visitor, but I don't think that's so relevant? It's the member authentication side of things we don't know how to tackle.

Any help would be much appreciated.

Jim

# Answer
> 2 votes
So after going to EEUK13 and seeing Ben Croker's talk, we're going to be using his lovely Open API module to deal with this stuff. If anyone wants to check it out, here's the link: https://github.com/putyourlightson/open-api

# Answer
> 1 votes
EE has it's in-built function to authenticate users.

```
$this->EE = & get_instance();

$this->EE->load->library('auth');
$this->EE->load->loadfile('member');

$session_user = $this->EE->auth->authenticate_username($username,$password);
// start the usersession
$session_user->start_session();

```

For subsequent calls, ensure that the session exists.

---
Tags: members, zoo-visitor, authentication
---


# Question
Title: Exp:resso Store & Fedex International Economy to UK
I have Fedex working for domestic (US) shipping calculations, if I enter a Japanese address the international economy option works but if I enter my home UK address I get a "Destination country is not serviced." error - anyone know why this might be happening? I've tried entering a postcode with and without a space. The country dropdown is the standard Store field.

# Answer
> 1 votes
Sometimes the packaging type, dropoff type, and residential delivery options affect whether or not Fedex can deliver to a specified location. Try different combinations of the settings to see whether you can get them to quote you a price for shipping to the UK.

---
Tags: expresso-store
---


title: How to disable expression engine URL

text:
# Question
Title: How to disable expression engine URL
want to disable the SEO URL structure of Expression engine, i don't understand how to do that

# Answer
> 1 votes
I presume what you're looking for is a way to break the strict template\_group/template structure that EE adheres to by default. If so then the easiest way would be to use Freebie (free addon).

Freebie will allow you to define URL segments which EE will ignore completely so you can build up your own custom URL structure, integrate with Structure or anything else you need to achieve.

---
Tags: php, url, seo
---


# Question
Title: Looking for Feedback on Cartthrob & Using Cartthrob Subscriptions with Realex Payments
Setting out on a new EE / E Commerce project. One requirement is to take registration payments, and we would like to be able to manage these as subscriptions. I see that Cartthrob now provide a subscriptions add on which appears to do everything necessary.

I havent used CT for a few years. The support was great but there were a lot of kinks in the system and it was difficult for a 'less technical' user to troubleshoot, while Brilliant Retail, though limited, was quick and relatively easy to get up and running.

Im looking for people's feedback on the current state of things with CT - has the reporting improved, can you get a general store set up quickly (as with Brilliant Retail)? Its expensive to get the whole suite (Cartthrob & Subscriptions) and Ive seen some reports of slow support.

Any feedback would be greatly appreciated.

K

# Answer
> 1 votes
If you haven't used Cartthrob for a few years then things have moved on quite a bit. There are now several supporting products such as Subscriptions but they don't come cheap. Previous issues with support are now being resolved.

Cartthrob is very flexible but can be considered more of a framework so it does take a little more work to get something up and running as you piece it all together yourself. If you want something simpler then Expresso Store is much simpler to get up and running and integrates seamlessly into ExpressionEngine. It's probably the most user friendly of the bunch. If you're looking to use a subscription model however then it may be a bit trickier with Store. In theory it may be possible to setup some kind of pseudo-subscriptions however but it isn't natively supported as of yet.

Another alternative would be Membrr for subscription billing and recurring payments. If subscriptions are your primary concern then this may be all you need. You may also be able to integrate one of the other ecommerce addons for your other regular product sales if desired.

---
Tags: ee2, cartthrob, ecommerce
---


# Question
Title: How to output variables such as the current page's entry_id in the script tag
One one of our sites, we have ChannelFiles add-on installed and in the control panel (when editing an entry) it outputs a useful set of variables (see attached). But this is only part of add-on and if it's not installed, those variables aren't outputted. Is there anyway I can output these variables without ChannelFiles?

Background: There are certain fields that I only want to ever appear when editing a specific entry so I include a bit of jquery in the field instruction to hide/show field by checking against the variables outputted by ChannelFiles add-on in the script tag.

http://imagebin.org/258416

Thanks

**UPDATE** (to clarify): I need this when editing the entry in the control panel of EE (see Background section on why) and not in the front end. As far as I know, I don't have access to the templates for the control panel (or do I?).

# Answer
> 0 votes
You can output entry ids from within the channel:entries tag pair like this:

```
{exp:channel:entries channel="my_channel"}
  entry_id: {entry_id}<br>
{/exp:channel:entries

```

The Channel Entries documenation at EllisLab provide all the variable options available to you.

**Update**

You can add this script to any of the field's Field Instructions section.

```
<script>
  $(document).ready(function() {
    entryId = (document.URL).split('entry_id=')[1].replace(/\D/g,'');
    $('.heading h2').append(' #' + entryId); // adds to heading at top of form
    alert("entry id = " + entryId);
  });
</script>

```

**Second Update**

The previous script wasn't removing numerical characters from the url that occurred after the entry\_id. The problem is that EE encodes the `&` as `&`. So here's this:

```
<script>
  $(document).ready(function() {
    firstPart = (document.URL).split('entry_id=')[0];
    entryId = (document.URL).split('entry_id=')[1].split(firstPart[firstPart.length -1])[0];
    $('.heading h2').append(' #' + entryId);
  });
</script>

```

# Answer
> 0 votes
I'd output the entry\_id to the page as a hidden value, much as Stephen suggested, and then look to grab that with JavaScript. If you're viewing a specific entry\_id for the page you're viewing then you made need to pass that in as a parameter:

```
{exp:channel:entries channel="my_channel" entry_id="{entry_id}"}
    <p class="hidden">entry_id: {entry_id}</p>
{/exp:channel:entries}

```

If you're just looking to use JS to show and hide specific fields depending on an entry ID however then you could do that purely on the server-side:

```
{if entry_id="10"} ... {/if}

```

This would have the benefit of being usable by those without JS enabled too.

---
Tags: add-on, control-panel, javascript, variable, channel-files
---


# Question
Title: content to display by month in archive always shows current month rather then the month selected?
on this http://ee2.acer.edu.au/rd/archive/2013/April

I have this code

```
{exp:channel:entries channel="research-developments" status="Featured|Open" orderby="entry_date" sort="desc"  dynamic="off" display_by="month" limit="1"}

```

but it always shows latest month so at the moment I have may for all archives when I need it to display each for each section , any ideas ?

# Answer
If dynamic is "off", the channel:entries isn't influenced by URL parameters.
> 1 votes

---
Tags: category-archive
---


title: Assets + Wygwam: Wrong URL on Front End

text:
# Question
Title: Assets + Wygwam: Wrong URL on Front End
I've got a Wygwam field that's using Assets for image uploads. I can upload images and they display fine in the entry form, but when I save the entry and then go look at it on the front end, the image URL is wrong. Here's an example:

```
Correct URL: /uploads/news/Picture_5.png
Actual URL: /uploads/news/Picture_5.pngPicture_5.png%7D

```

The strange thing is if I go back into the entry and just resave it, it fixes the problem.

I'm using the latest versions of Assets, Wygwam, and EE.

# Answer
> 0 votes
Looks like this is a duplicate question. This post has an answer which worked for me.

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


# Question
Title: Cartthrob - clear_cart tag is rendering/acting despite wrapping conditional returning false
I am using clear\_cart to clear the cart when a completed order returns to the site from Paypal Express. The Shop page has a link to /checkout to go make a purchase using the Paypal express gateway. The checkout\_form returns from Paypal to "checkout/order\_status" and is supposed to display one of the following messages.

I am getting a "too many redirects" error (error 310) anytime I try to go to /checkout because the clear\_cart tag is rendering and redirecting whether a transaction has been authorized or not. I can't even get to the checkout page usually to check my cart and be sent to Paypal. I have cleared the EE cache as well as Chrome cache multiple times with no success. Why is this tag acting when there is no order\_status in segment\_2 and also causing an infinite redirect?

Here is the full code I am using on the checkout page:

```
{!-- VIEW CART CONTENTS --}
                {exp:cartthrob:cart_items_info limit="1"}
                    {if no_results}
                        <p>There is nothing in your cart yet</p>
                    {/if}
                    <ul class="cart-table">
                        {exp:cartthrob:cart_info}
                        <li>Total Items: <span>{total_items}</span></li>
                        <li>Subtotal: <span>{cart_subtotal}</span></li>
                        <li>Shipping: <span>{exp:cartthrob:cart_shipping}</span></li>
                        <li>Tax Rate: <span>{cart_tax_rate}</span></li>
                        <li>Tax: <span>{cart_tax}</span></li>
                        <li><p class="lead"><strong>Total: <span>{cart_total}</span></strong></p></li>
                        {/exp:cartthrob:cart_info}
                    </ul>
                {/exp:cartthrob:cart_items_info}
{!-- Current items --}
                {exp:cartthrob:cart_items_info}
                    {if no_results}
                        <p>You have nothing in your cart. <a class="blue" href="/shop">GO SHOP »</a></p>
                    {/if}
                    {if total_items > 0}
                        {if first_row}
                        {exp:cartthrob:update_cart_form  return="checkout" class="cart_form" show_errors="yes" error_handling="inline"}
                        {/if}
                        <ul class="cart-table">
                            {errors}
                            <p class="error">{error}</p>
                            {/errors}
                            {if product_detail_image}
                                <img src="{product_detail_image:feed}"/>
                            {if:else}
                            <img src="{site_url}content/img/ride.png"/>
                            {/if}
                            <li><p class="lead"><strong>{title}</strong> <span>Qty: <input type="text" name="quantity[{row_id}]" size="1" maxlength="2" value="{quantity}" /></span></p>
                                <p>{exp:cartthrob:item_options entry_id="{entry_id}" row_id="{row_id}"}
                                    {if dynamic}
                                                <label>{option_label}</label>
                                                {input}
                                            {if:else}
                                                {if options_exist}
                                            {select}
                                                            {if "{inventory}" > "0"}<option {selected} value="{option_value}">{option_name} {option_price}</option>{/if}
                                                        {/select}
                                                {/if}
                                            {/if}
                                        {/exp:cartthrob:item_options}
                                <span><input type="checkbox" name="delete[{row_id}]"> Delete this item</span></p>
                            </li>
                        </ul>
                        {if last_row}
                            <select name="shipping_option">
                            {exp:cartthrob:get_shipping_options}
                                    <option value="{rate_short_name}" {if selected}selected{/if}>{rate_title} - {rate_price}</option>
                                {/exp:cartthrob:get_shipping_options}
                            </select>
                                <input type="submit" value="Update Cart" />
                        {/exp:cartthrob:update_cart_form}
                        {/if}
                    {/if}
                {/exp:cartthrob:cart_items_info}

{!-- CHECKOUT --}
                {exp:cartthrob:checkout_form return="checkout/order_status" gateway="paypal_express"
                    required="first_name|last_name|address|city|zip|country_code|shipping_address|shipping_city|shipping_zip|shipping_country_code|email_address"
                }
                    {if total_items > 0}
                        <h3>Payment:</h3>
                        {gateway_fields}
                        <input type="submit" value="Checkout with Paypal" />
                    {/if}
                {/exp:cartthrob:checkout_form}

```

*Quick note: I also tried*

```
{if segment_2 == "order_status"}
```
*but this is probably irrelevant*

# Answer
This is because EE will execute tags before parsing certain conditionals. You should stick your clear\_cart tag into it's own template and embed that template within your conditional. Embeds get executed at the very end, after conditionals are evaluated, so it will only execute if the condition is true.
> 1 votes

---
Tags: cartthrob, redirects, shopping-cart
---


title: Determine template from extension

text:
# Question
Title: Determine template from extension
Is there a good way to determine which page template was loaded for a given URI? I'd like to be able to use this information from an add-on.

For example, if my root template group is `home` and the user visits `/`, I want to see that `home/index` is being used. If the user visits `/foo`, does EE expose information about whether it has loaded `home/foo` or `foo/index` or something else?

When using Structure, I can check for a global variable named `structure:page:template_id`, and if that exists, I can easily query for that template. But if Structure isn't in use, I can't find a good way to determine which template is used.

# Answer
You'll have to use another hook, template\_fetch\_template, and cache the template\_id there:

```
public function template_fetch_template($row)
{
  if ( ! ee()->session->cache('your_extension', 'template_id'))
  {
    ee()->session->set_cache('your_extension', 'template_id', $row['template_id']);
  }
}

public function some_other_hook()
{
  $template_id = ee()->session->cache('your_extension', 'template_id');

  //do stuff here with your template_id
}

```
> 2 votes

# Answer
I literally just saw this plugin on twitter this morning: Template Info, which was originally developed by Leevi Graham for EE1, and then Sean ported to EE2.

Just add one or all of the following tags to your template:

```
{exp:template_info attribute="template_id"}
{exp:template_info attribute="template_name"}
{exp:template_info attribute="template_group_id"}
{exp:template_info attribute="template_group_name"}

```
> 2 votes

---
Tags: templates, add-on-development, structure, plugin, extension
---


title: P&T Playa and Var Prefix

text:
# Question
Title: P&T Playa and Var Prefix
I've got quite a bizarre setup to get the most recent "Rated" entries (Via Solspace Rating Module) and output the related Product & Video to that entry (Which is handled via Playa)

```
{exp:rating:entries
    collection="Video Reviews"
    orderby="rating_date"
    sort="desc"
    limit="1"
    dynamic="no"
}

    {exp:channel:entries channel="entry_video" orderby="date" limit="1" dynamic="off" entry_id="{entry_id}"}

        {title}

        {cf_video_related_products limit="1"}
            {title}
        {/cf_video_related_products}

        {cf_video_related_video limit="1"}
            {title}
        {/cf_video_related_video}

    {/exp:channel:entries}

{/exp:rating:entries}

```

Now when I run this, it works... Except I get something like this:

> Rating Title
> Rating Title
> Rating Title

When really I want it to be:

> Rating Title
> Product Title
> Video Title

Now I know what's happening... There is multiple title tags and it's possibly pulling the {title} from the Rating module or the Channel Entries loop for every {title} var.

I thought of changing this, so i use the var\_prefix parameter supplied by Playa, but this doesn't work:

```
{exp:rating:entries
    collection="Video Reviews"
    orderby="rating_date"
    sort="desc"
    limit="1"
    dynamic="no"
}

    {exp:channel:entries channel="entry_video" orderby="date" limit="1" dynamic="off" entry_id="{entry_id}"}

        {title}

        {cf_video_related_products limit="1"}
            {title}
        {/cf_video_related_products}

        {exp:playa:children field="cf_video_related_products" limit="1" var_prefix="product"}
            {product:title}
        {/exp:playa:children}

        {exp:playa:children field="cf_video_related_video" limit="1" var_prefix="video"}
            {video:title}
        {/exp:playa:children}

    {/exp:channel:entries}

{/exp:rating:entries}

```

But all this does is output:

> {product:title}
> {video:title}

Am I doing something wrong? I've tried `parse="inward"` but that doesn't help neither. Because I thought it might of been the parse order causing this.

# Answer
> 0 votes
I looks like you're using both the field tags and module tags for `cf_video_related_products` playa field.

Try removing the field tag and add the `entry_id="{entry_id}"` parameter to each of the `exp:playa:children` module tags. Typically the module tags defaults to the current entry's ID if within the `exp:channel:entries` tag pair, but that might thrown off because of the nested ratings and entries call.

If that doesn't work, you could always use an embed:

### Parent Template:

```
{exp:rating:entries
    collection="Video Reviews"
    orderby="rating_date"
    sort="desc"
    limit="1"
    dynamic="no"
}

    {embed="tmpl_group/tmpl_name" entry_id="{entry_id}"}

{/exp:rating:entries}

```

### Child Template:

```
{exp:channel:entries channel="entry_video" orderby="date" limit="1" dynamic="off" entry_id="{embed:entry_id}"}

    {title}

   {exp:playa:children field="cf_video_related_products" entry_id="{entry_id}" limit="1" var_prefix="product"}
        {product:title}
    {/exp:playa:children}

    {exp:playa:children field="cf_video_related_video" entry_id="{entry_id}" limit="1" var_prefix="video"}
        {video:title}
    {/exp:playa:children}

{/exp:channel:entries}

```

---
Tags: playa, pixelandtonic, solspace-rating
---


# Question
Title: Low Search Category Query on Results Page
I can not seem to find anything regarding listing what categories were selected in the search query on the results page for Low Search.

Here's an example of my code on the search page:

```
                {exp:low_search:form collection="eat" search_mode="all" result_page="eat/sort" require_all="category"}
                <select name="category[]">
                    {exp:channel:categories channel="eat" style="linear" category_group="1"}
                        <option value="{category_id}">{category_name}</option>
                    {/exp:channel:categories}
                </select>

                <select name="category[]">
                    {exp:channel:categories channel="eat" style="linear" category_group="6"}
                        <option value="{category_id}">{category_name}</option>
                    {/exp:channel:categories}
                </select>
                <button type="submit">Search</button>
                {/exp:low_search:form}

```

And here's the results:

```
                <ul id="things-inner-list">

               {exp:low_search:results query="{segment_3}" status="not closed" limit="1" paginate="bottom"}
                  {if count == 1}
                    <p>
                      {if low_search_keywords}Searched for <strong>{low_search_keywords}</strong>.{/if}
                      Total results: <strong>{absolute_results}</strong>.
                    </p>
                  {/if}

                    <li>

                        <div class="things-item-left">
                            <img src="{eat_business_image}" />
                            <h2> <a href="{title_permalink='business/bar-and-grill}">{title}</a></h2>
                            <p>
                               {excerpt}
                            </p>
                        </div>
                        <div class="things-item-right">
                            <a class="map-it" href="{eat_business_map_url}" target="_blank">Map it</a>
                            <br />
                            {eat_business_phone}
                            <br />
                            <a href="{eat_business_web_url}" target="_blank">Website</a>
                        </div>

                    </li>

                  {paginate}
                    <p>Page {current_page} of {total_pages} pages {pagination_links}</p>
                  {/paginate}

                  {if no_results}
                    <p>
                      Sorry, your query did not return any results.
                    </p>
                  {/if}

                {/exp:low_search:results}

                </ul>

```

***I am just looking to list what categories were selected on the search page, but I can't seem to get it and there's nothing in the documentation about it. I would also like to be able to have the option have the value selected on the results page, as I have the search form on the results page as well. Is this possible?***

# Answer
You can use the variable `{low_search_category}` in your Form, Filters and Results tags, as long as you feed it the `query=""` parameter (when encoding the URI). This will output a pipe-separated list of category IDs that were selected in the search form.

To "remember" which categories were selected in your Form tag, add the `query=""` parameter to it, and then use the Special Conditionals to add the `selected` attribute to the `<option>`:

```
<option value="{category_id}"{if category_id IN ({low_search_category}) selected="selected"{/if}>
    {category_name}
</option>

```

To show a list of selected categories elsewhere on the page, you're probably best off using the Filters or Results tag with a `{exp:channel:categories}` tag to output the category names.

```
{if '{low_search_category}' != ''}
    You selected these categories:
    {exp:channel:categories show="{low_search_category}" channel="eat" style="linear"}
        {category_name}
    {/exp:channel:categories}
{/if}

```
> 1 votes

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


# Question
Title: Internal pages not showing up locally on MAMP
I've started work on a site that's already live so I've..

* Copied all the files to my local machine and imported the .sql file into MAMP
* Adjusted the 'URL to the root directory of your site' under the 'General Configuration'
* Adjusted the 'URL to your "themes" folder' under the 'General Configuration'
* Adjusted the 'Theme Folder Path' under the 'General Configuration'
* Adjusted the 'Basepath to Template File Directory' under 'Global Template Preferences'
* Updated the following paths in database.php

Like so...

```
$db['expressionengine']['hostname'] = 'localhost';
$db['expressionengine']['username'] = 'root';
$db['expressionengine']['password'] = 'root';
$db['expressionengine']['database'] = 'clients_site';

```

The home page (localhost/) loads fine with the correct CSS and Images and the Control Panel (localhost/admin.php) loads fine but when I go to any internal pages (localhost/about/) I get a 404.

Is there something I've missed out?

# Answer
You should try localhost/index.php/about. If you want index.php removed, refer to the documentation.

http://ellislab.com/expressionengine/user-guide/urls/remove\_index.php.html

If you are able to get to admin and it load fine, your db is just fine. ExpressionEngine needs the index.php file to run properly, unless you hide it via the .htaccess.
> 3 votes

# Answer
Check for an .htaccess file in the root folder online and stick it in your local root.
> 0 votes

---
Tags: localhost
---


# Question
Title: How can I setup a table with ingredients in alphabetical order with a letter label and make it easy for client to update?
Please refer to the table at http://www.tomsofmaine.com/research/ingredients for reference. I currently have a Matrix field setup to add new ingredients and generate a table and it works beautifully. Now the client wants a letter label separating each alphabetical section. I can't think of an easy way to do this so it's easy to update for the client. I don't think I can use Matrix anymore, and the only other option I can think of is to build the entire form in Wygwam, but that would make it very tough for the client to update. Any ideas?

# Answer
> 2 votes
You could do this by creating each ingredient as an entry then building the table using an exp:entries tag pair.

You can then use Low Alphabet (http://gotolow.com/addons/low-alphabet) add on to create the alphabetic sorting links required.

If you didn't wish to pay for the add on then you could get the data out using a custom database query or number of queries to get the ingredients into groups.

Creating the ingredients as entries rather than rows of a matrix will also mean that you can make the whole thing more easily searchable should you wish to.

---
Tags: matrix, wygwam, table
---


title: Simple Search Form Tag

text:
# Question
Title: Simple Search Form Tag
I am using this tag pair for a website form. Two issues I have:

1. How do I make certain fields required without using CSS3 or jQuery. Does EE have a native way of doing this?
2. How do I get validation to work on iOS?
3. Are there any better third party form add ons that someone can recommend?

# Answer
To my knowledge, you can't make fields required.

The more popular search add-ons are Low Search and Solspace Super Search

Both of these add-ons have validation built in, as well as obviously many other features you won't find on the native EE search form.
> 2 votes

---
Tags: simple-search
---


# Question
Title: Preload replace not evaluating variable outside of pair
I am trying to get the current entry's category so I can make a comparison inside a menu elsewhere to see if the menu item is for the current page. I have the following code at the top of my template:

```
{exp:channel:entries}
    {categories limit="1"}
        {preload_replace:current_category="{category_id}"}
        {current_category}
    {/categories}
{/exp:channel:entries}

```

which gives an output of `56`

However, if I move `{current_category}` out of the pair so I can use it elsewhere, it does not evaluate:

```
{exp:channel:entries}
    {categories limit="1"}
        {preload_replace:current_category="{category_id}"}
    {/categories}
{/exp:channel:entries}
{current_category}

```

gives an output of `{category_id}`

How can I get the replace variable to save the evaluated category\_id inside of the pair so I can use it elsewhere? Or, is there a better way to be doing this?

# Answer
> 2 votes
There's a better way, though I'm not sure what where you're trying to insert the entry's category\_id.

Use Stash, you'll be glad you did.

```
{exp:channel:entries}
  {exp:stash:set name="category_id"}
    {categories limit="1"}
      {category_id}
    {/categories}
  {/exp:stash:set}
{/exp:channel:entries}

<!-- Then get it after entries loop -->
{exp:stash:get name="category_id"}

```

# Answer
> 0 votes
You can do this using an embed.

```
{embed="group/.template" current_category="{exp:channel:entries}{categories limit="1"}{category_id}{/categories}{/exp:channel:entries}" }

```

On the embed template, just call {embed:current\_category}.

I think it's better than install stash for use just once.

---
Tags: channel-entries, categories, variable, preload-replace
---


# Question
Title: GWcode Categories - show these three cats AND their children
I'm using GWcode Categories and I'm trying to figure out how to show, for example, 3 specific categories AND said categories children as well. I know of the show param though, it appears this needs to include the parent category IDs AND their children IDs to have both parents and children show up. Using show="1|2|3" I only get the 3 parent cats in other words.

That of course sucks because anytime a client adds a new child cat we have to update the show param IDs again.

It's almost like we are missing a `show_include_children="yes"` in the case of the show param. The next param (excl\_cat\_id) has something similar in fact.

I know there is the `excl_cat_id=""` along with `excl_cat_id_children="yes"` params which would work though, that would mean any time a new parent category is added I'd have to go in and excluded that one as well and it's children when added too. The opposite of show in other words though, the same issue.

I know about the cat\_id param though, this is only for one category and it's children and of course is only half of what I need. I tried piping here without success.

What about using conditionals or Switchee? Something along the lines of this: `{if parent_id == "1|2|3"} my vars {/if}` this would probably work though, seems like there should be a way to do this with out having to loop through 1000 categories just to check for 3.

With all that said, am I missing something, is there not a way to show 3 categories AND their children based on the 3 parent IDs?

Thanks!

# Answer
> 1 votes
I was just doing something with GW Categories that involved showing child categories. In the end I ditched it in favour of using the query module.

You could run a query something like

```
select * from exp_categories where parent_id='CURRENT CATEGORY ID'

```

and pass it your category IDs as required

---
Tags: filter, gwcode-categories, categories, children
---


# Question
Title: Is it possible to randomize the row output of a matrix field?
I would like to use a parameter like orderby="random" on a matrix field to randomize the order of the row output.

```
{matrix_field orderby="random"}
  {row_title}
{/matrix_field}

```

I tried this, but got a MySQL error. Is this possible?

# Answer
> 8 votes
You actually have to do sort="random" in Matrix. It's not like channel:entries in that way.

---
Tags: matrix
---


title: Stash output=yes vs get

text:
# Question
Title: Stash output=yes vs get
Is there any difference in processing/speed in using Stash exp:stash:set with output=yes vs. using Stash to set and then outputting via exp:stash:get? For example:

```
OPTION 1:
{exp:stash:set name="client_age"
    save="yes"
    output="yes"
    refresh="no"
    trim="yes"
    parse_tags="yes"
    parse_conditionals="yes"
    parse_depth="2"
    scope="user"
}
    {exp:channel:entries channel=".....}
        {PLUGIN}{content}{/PLUGIN}
    {/exp:channel:entries}
{/exp:stash:set}

VERSUS OPTION 2:
{exp:stash:set name="client_age"
    save="yes"
    refresh="no"
    trim="yes"
    parse_tags="yes"
    parse_conditionals="yes"
    parse_depth="2"
    scope="user"
}
    {exp:channel:entries channel=".....}
        {PLUGIN}{content}{/PLUGIN}
    {/exp:channel:entries}
{/exp:stash:set}

{exp:stash:get name="client_age" scope="user"}

```

# Answer
> 1 votes
Option 1 will be a tiny bit quicker, since EE only needs to process one tag. It's a good approach for caching arbitrary chunks of template code.

Unless you really do need to have a personalised cached item for *every* visitor to your site I would suggest you use `scope="site"`.

---
Tags: stash
---


# Question
Title: Removing index.php AND the subdirectory folder name
I'm developing a site at the moment and noticed when I uploaded it to my staging server, all my links show correctly in the address bar, but show the index template.

My folder structure is as follows

```
/
  /pub
    index.php
    .htaccess
  /system
  /templates
  .htaccess

```

My site runs inside /pub - Because I'm not able to specify with my host what the root directory of a site should be, they've advised that I use htaccess instead.

That .htaccess file sits in / and looks like this:

```
RewriteEngine on
RewriteCond %{HTTP_HOST} ^stage.domain.co$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www.stage.domain.co$
RewriteCond %{REQUEST_URI} !pub/
RewriteRule (.*) /pub/$1 [L]

```

I also have a .htaccess file in /pub/ which looks like this:

```
# Enable Rewrite Engine
# ------------------------------
RewriteEngine On
RewriteBase /

# Redirect index.php Requests
# ------------------------------
RewriteCond %{THE_REQUEST} ^[^/]*/index\.php [NC]
RewriteCond %{THE_REQUEST} ^GET
RewriteRule ^index\.php(.+) $1 [R=301,L]

# Standard ExpressionEngine Rewrite
# ------------------------------
RewriteCond $1 !\.(css|js|gif|jpe?g|png) [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]

```

I want to remove index.php, AND the pub directory so my site will serve up URLs such as stage.domain.com/exercises instead of stage.domain.com/pub/index.php/exercises

So two questions.. Should I be using two htaccess files like I am at the moment, one to redirect from /pub/, and one to remove index.php, or should they be in one file, and where should it be?

What needs to be in those files to make it work?! I've tried what EE suggested by removing the slash before index.php on the last line, and adding a question mark.

# Answer
> 3 votes
What you are doing doesn't make any sense. There is no point having a separate `/pub` directory if everything is still within the webroot.

The only reason you would have a separate `pub` (or `public_html`) directory is if you want to keep your system folder above the webroot. This adds an extra layer of security, though it only really protects against a misconfigured apache and isn't really worth the extra work on shared servers IMO.

Just move your `index.php` and `.htaccess` out of `/pub`, and stick to the convention:

```
/
  /system
  /templates
  .htaccess
  index.php

```

To remove `/index.php/` from your URLs, just follow Removing index.php from URLs, so your htaccess should look like this:

```
RewriteEngine On

# Removes index.php from ExpressionEngine URLs
RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]

```

---
Tags: htaccess
---