# Question
Title: Removing part of EE urls with .htaccess or via other methods?
I've had a similar question up on Stack Overflow, but now that we've got this shiny new site, I figured I might as well bring it here.

With EE 2, is it possible to remove anything other than index.php from the URLs via .htaccess rewrites? I am thinking of, for example, a non-default template group or part of a Page URI.

Both these things could be done in EE 1 but no longer work for me in EE 2. I have tested my rewrites using http://htaccess.madewithlove.be/ and as far as I can tell, they do result in the correct URLs. However, attempts to access the pages lands me on my default page.

My original setup was this:

```
RewriteRule ^/?((403|404|About|Chat|Contact|Copyright|Search)(/.*)?)$ /Westeros/$1 [L]
RewriteRule ^/?((ASoIaF|Digest|Images|Login|Store|Updates|Westeros|member)(/.*)?)$ /index.php/$1 [L]

```

I've also tried this:

```
RewriteRule ^/?((403|404|About|Chat|Contact|Copyright|Search)(/.*)?)$ /index.php/Westeros/$1 [L]
RewriteRule ^/?((ASoIaF|Digest|Images|Login|Store|Updates|member)(/.*)?)$ /index.php/$1 [L]

```

There's a couple of different things going on and some work and some don't, in both of these scenarios.

1) domain.com/Updates/ works fine. Updates is a template group. So, no problems with just removing index.php.

2) domain.com/Search/ does not work. Search is a template within the Westeros template group. It does work to access it as domain.com/index.php/Westeros/Search/. The reason for this rewrite is that I wanted to avoid creating several single-template template groups to handle things like Search, Contact, etc. At the same time, its important that these segments come right after the domain given the overall structure of the site.

3) domain.com/About/ does not work. About is a Page with its URI set to /Westeros/About/. It does work to access it as domain.com/index.php/Westeros/About/. Again, I need these Pages to display right after the domain to fit into the overall structure of the site, but since I am running multiple sites using the old method (multiple index.php files) rather than MSM, I cannot simply make the URI /About/ for the Page since I have an /About/ Page for each site/subsite.

In case .htaccess can't be used for this any longer in EE 2, are there any other options available for these sort of behind-the-scenes URL changes?

Edited to add: I have now received a support answer from EE on this matter and even though removing the template group is unsupported, they pointed to a config option that has restored the EE 1 behaviour for me. This is the URI Protocol option in config.php; default in EE 2 is "auto" but if I set it to "path\_info" instead, the rewrites work as they did in EE 1.

# Answer
You should do this inside ExpressionEngine rather than trying to do it with messy htaccess rules - far more maintainable and guaranteed to work across servers.

I use Freeway which allows you to set up complex routes to map URLs to specific templates, and in your case it would also let you remove the first segment from specific URLs.
> 9 votes

# Answer
If I'm understanding you right, you should be able to get it to work with the basic remove index htaccess rule. You said that you want to

> avoid creating several single-template template groups

if thats the case, you can just create a search template in your default template group (lets say westero) and as long as there isn't a template group named the same "/search/shirts" should direct to the 'westero/search' template and pass shirts as a segment\_2 variable that you could search on.
> 3 votes

# Answer
Yet another way to do this would be to disable "Use Strict URLS" in global template prefs and set "Westeros" as your default template group - you can then access any template in that group at `/<template-name>`: see What does “Enable Strict URLs” really mean? for details and caveats
> 1 votes

# Answer
I have not used this so can not comment on how suitable it is for your needs. http://devot-ee.com/add-ons/router
> 0 votes

# Answer
I'm using this:

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

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

# Redirect search results Requests
RewriteRule ^search/results(.*)$ http://www.mysite.com/zoek/resultaat$1 [L,R=301]

# 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]

</IfModule>

```

I thought this might come in handy in scenario 2 - search. My search didn't work either and i also needed a single search page.
> 0 votes

---
Tags: url, htaccess
---


# Question
Title: Exp-resso store, iDeal payments: AP1200: IssuerID unknown
First things first: I'm running on EE 2.5.3, Expresso Store 1.6.1. All certificates are in place.

On the final step of the checkout process, after choosing "iDeal" and an issuer, i get an error:

> IssuerID unknown (AP1200: Field generating error: IssuerID unknown)

I think this means the issuerID is incorrect.

The code i'm using:

```
<select name="payment[issuer]">
<option selected value="">Selecteer uw bank...</option>
<option value="0031">ABN AMRO</option>
<option value="0091">Friesland Bank</option>
<option value="0721">ING</option>
<option value="0021">Rabobank</option>
<option value="0751">SNS Bank</option>
<option value="0761">ASN Bank</option>
<option value="0771">SNS Regio Bank</option>
<option value="0511">Triodos Bank</option>
<option value="0161">Van Lanschot</option>
</select>

```

How can i make sure Expresso Store supplies my bank with the correct issuerID?

# Answer
> 4 votes
Where are you getting that list of issuers from?

You should be using this, it will automatically load the list of issuers and cache it:

```
<select name="payment[issuer]">
    {ideal_issuer_options}
</select>

```

Mostly likely, I'm guessing you have the gateway in test mode, and it will be expecting you to use the test issuer (which the iDeal gateway will output when you use the snippet above), rather than one of the live issuers.

---
Tags: add-on, expresso-store, checkout
---


title: Logger.php throwing PHP errors

text:
# Question
Title: Logger.php throwing PHP errors
I'm getting some issues with some EE php errors, i believe its related to the EE Zoo Triggers Add On, but im finding it really tricky to debug and get the feeling I may be searching in the wrong place.

```
A PHP Error was encountered
Severity: Notice
Message: Undefined index: timestamp
Filename: libraries/Logger.php
Line Number: 121

A PHP Error was encountered
Severity: Notice
Message: Undefined index: log_id
Filename: libraries/Logger.php
Line Number: 127

Error Number: 1054
Unknown column 'year' in 'field list'
UPDATE `exp_developer_log` SET `year` = NULL, `month` = NULL, `count` = '0', `viewed` = 'n', `timestamp` = 1354016532 WHERE `log_id` IS NULL
Filename: libraries/Logger.php
Line Number: 128

```

There is a little more info, error lines etc on a ticket in the devotee forums but i wanted to put it out to the EE community, see if any of you guys have come across similar errors and might be able to help resolve

Here is a little more info on what we have investigated so far:

> Im running EE 2.5.3 & PHP 5.2.17. Its triggered when I add the achieve or categories list tags:
>
> ```
> {exp:zoo_triggers:categories
>     channel="tours"
>     path="{structure:page:uri}/region"
>     show_counter="yes"
>     style="list"
> }
>
> ```
>
> OR
>
> ```
> {exp:zoo_triggers:archive
>     channel="blog"
>     path="/blog/archive"
>     type="monthly"
>     style="list"
>  }
>
> ```
>
> I use stash so these calls i from within Stash set / append tags etc. Only other strange issue is that it some cases (when logged in) it loads in the first instance and then breaks on refresh or when clicking through to an archive link for example, then the error persists. Clearing the ee cache or removing / reassigning the structure listing resolves for that first visit again.
>
> ...
>
> It’s somewhat strange because the function where the errors occur must be directly called, and that isn’t so in Zoo Triggers nor in the version of Stash that I’m currently testing. Can you do a project search on: -\>developer( So we can have a better look what add-ons are calling the function directly.
>
> ...
>
> Its odd, only references i can find are from the ee core: system/expressionengine/core/EE\_loader.php - line 136 system/expressionengine/libraries/EE\_Form\_validation.php - line 438 system/expressionengine/libraries/Logger.php - line 186 system/expressionengine/modules/search/mod.search.php - line 186
>
> ...
>
> Source http://devot-ee.com/add-ons/support/zoo-triggers/viewthread/7935

Many thanks,

Sam

# Answer
> 2 votes
The best way to diagnose PHP errors is to dig into the code and report the culprit. Do this:

Open `system/expressionengine/libraries/Logger.php`

At line 120 (right before your first error message), add this:

```
if ( ! isset($duplicate['timestamp']))
{
    debug_print_backtrace();
    exit;
}

```

Now taking a look at that particular part of the EE code, I really can't see what would cause those PHP errors you're seeing. Some code is trying to create a developer log entry and making a mess of things. It's likely to be an EE bug.

At least this should help you figure out what add-on is responsible for the problem!

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


# Question
Title: Is it possible to search by entry number on the front-end?
Is there a way to allow logged in users to search on the front-end by ID number?

I’ve got a list of entries here (http://dev.andover-tc.gov.uk/allotments/maintenance).

What I need to do is setup the search box at the top of the page to allow logged in users to type an entry\_id number in and only that entry be displayed.

I’m thinking I may be able to use the URL to control this (i.e. allotments/maintenance/147) but can’t work out how to take the data from an input field and use this to create a URL.

Alternatively, if there’s an easier way I’m open to that too.

Thanks in advance,

Tom

# Answer
> 2 votes
You could use EvoPost to take the submitted value and send the user to a link. I wrote up a blog post about doing that here. But essentially you'll create your form and have the action url for that form go to a template in your site that has the following or similar code:

```
{exp:evopost:getpostdata}
  {redirect="/template_group/template_name/{ep_entry_id}/"}
{/exp:evopost:getpostdata}

```

And voila you'll be pulling up the correct entry.

Hope this helps.

# Answer
> 2 votes
You could use something like Mo Variables to access $\_GET, then do something like this in your 'search' template:

```
{redirect="/entry/path/{get:entry_id}"}

```

Then just have your search form do this:

```
<form action="pathto/quicksearch-template" method="get">
  <input type="text" name="entry_id">
</form>

```

---
Tags: search, entry
---


title: Calendar tag and ajax/jquery

text:
# Question
Title: Calendar tag and ajax/jquery
Im using the calendar tag on a page and an iframe below it to display an event page. The iframe displays the latest event. When you click on a day in the calendar it calls that days event into the iframe.

Here is the code to call up the day event:

```
<a href="{day_path='events'}" target="cal_frame">{day_number}</a>

```

Here is the existing iframe:

```
<div class="colThree_event_container">
  <iframe name="cal_frame" scrolling="no" src="{site_url}events"></iframe>
</div>

```

I have been trying to do away with the iframe and have the same functionality using just a div and ajax/jquery with no luck.

Any pointers? :-)

# Answer
Ok, here's the code:

Javascript:

```
$(function(){

    $('.ajax_link').on('click', function(e){ // catch the click, and bind that click-event to the variable "e"
        e.preventDefault(); // stop the event from firing (so user doesn't get forwarded to the actual link)

        var elem = $(this),
            link = elem.attr('href'),
            target = elem.attr('rel');

        $.get(link, function(data){ // do a GET-request
            $(target).html(data); // put the results in the target-element
        });

    });

});

```

I've made a Gist (which also includes the HTML): https://gist.github.com/4188501

Does that help?

Edit: updated code.
> 4 votes

---
Tags: channel, ajax, jquery
---


# Question
Title: Can Expresso Store pass billing details to Worldpay?
Is it possible for Expresso Store to pass billing details on to Worldpay so the buyer doesn't have to add them again?

# Answer
According to the docs, it looks like it can: https://exp-resso.com/docs/store/payment\_gateways.html#worldpay
> 1 votes

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


# Question
Title: mx_jumper contents not available outside channel:entries tag
I'm trying to set some `mx_jumper` content from within an `{exp:channel:entries}` tag, and then output it somewhere else on the page. The page is an entry page and available on a url such as:

```
 /blog/entry/the-blog-entry-url-title

```

I created a simple test page to eliminate anything that might interfere with the functionality, and the code looks as follows:

```
{exp:channel:entries channel="blog"}
    <h1>{title}</h1>
    {exp:mx_jumper:put name="test"}Move this content to outside the loop{/exp:mx_jumper:put}
{/exp:channel:entries}

{exp:mx_jumper:out name="test"}

```

The problem is, that the contents of the mx\_jumper test content only shows up when the exp:mx\_jumper:out tag is inside the `{exp:channel:entries}` loop.

Any ideas what could be wrong?

# Answer
Did you try using out\_global like so:

```
{exp:mx_jumper:out_global}

{exp:channel:entries channel="blog" limit="1"}
<h1>{title}</h1>
{exp:mx_jumper:put name="test"}Move this content to outside the loop{/exp:mx_jumper:put}
{/exp:channel:entries}

{/exp:mx_jumper:out_global}

{exp:mx_jumper:out name="test"}

```

or you could also do:

```
{exp:mx_jumper:out_global}

{exp:channel:entries channel="blog" limit="1"}
<h1>{title}</h1>
{exp:mx_jumper:put name="test"}Move this content to outside the loop{/exp:mx_jumper:put}
{/exp:channel:entries}

{exp:mx_jumper:out name="test"}

{/exp:mx_jumper:out_global}

```
> 4 votes

# Answer
This is a parse order issue I believe. The parse order is a tricky thing to get right. I believe what's happening is that the parse order is hitting the outermost tags first, and then goes back and hits the inner layers. If you turn on your template debugging, you will be able to verify this by viewing the order in which the tags are parsed.

I have a funky trick I have used in the past to deal with this issue myself.

Surround the second tag (the out tag) with another plugin which doesn't manipulate the output. For example, look for the ifElse tag from Croxton. That puts the Mx Jumper "out" tag on the same nested level (one level) as the Mx Jumper "put" tag. Again, the plugin (or module tag) that you use doesn't matter as long as it doesn't change the output. This sounds funky, but it works!

Example:

```
{exp:channel:entries channel="blog"}
    <h1>{title}</h1>
    {exp:mx_jumper:put name="test"}Move this content to outside the loop{/exp:mx_jumper:put}
{/exp:channel:entries}

{exp:ifelse}
  {exp:mx_jumper:out name="test"}
{/exp:ifelse}

```
> 2 votes

# Answer
Try adding `parse="inward"` on your `{exp:channel:entries}` tag. I've never used that plugin but it looks similar to stash, and the parse thing works 9/10 times.
> 0 votes

# Answer
I'd also try adding limit="1" to your entries loop - if used as it is right now, it could be trying to set multiple jumper variables with a name of "test".
> 0 votes

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


# Question
Title: Members upload photos into their own subdirectory?
We are working on a site with 350 or so businesses. They are able to upload 5 photos and a logo to their front-end profile. It would be nice (for organization-sake) if they could upload images into their own subdirectory. "/images/members/{member\_name}/image.jpg"

Is there any way to achieve this? less manually creating 350 upload directories...

Currently using P&T Assets.

# Answer
If a member is a channel entry (or tied to a channel entry) and you are open to using an add-on other than Assets, then Channel Images would be a good route. It automatically creates a separate upload subdirectory per entry. *But* it uses `entry_id` for the name of the subdirectory, so wouldn't quite be the setup you wanted for the subdirectory name.
> 6 votes

# Answer
Brandon of P&T put out this extension for Wygwam a while back. It could be a place to start looking for appropriate hooks to accomplish this.
> 2 votes

---
Tags: safecracker, uploads
---


title: Multi Language site with Structure

text:
# Question
Title: Multi Language site with Structure
I'm looking to build upon a existing Structure built site and integrate another language. It doesn't necessarily need to be built upon using Structure, but as it's already using it and it works ok, then that makes sense.

Preferably i'd have one entry screen with an override if the existing language was entered show that body field, if not show default body. My preference for this data entry design is for client UX.

What the best way these days?

Thanks!

# Answer
> 9 votes
Have a look at transcribe. i am currently using it with structure and am pretty satisfied with it. The way you are proposing to do this will probably end up confusing visitors, as they will be seeing 2 languages mixed. With transcribe you will be creating different entries, and content of the site does not have to be equal. Each language will have it's own structure tree. If a user clicks on the language switch on a page that has no equivalent in the second language, it will show the homepage of that language version.

# Answer
> 6 votes
I don't use Structure that much so here is the process and add-ons I use to develop multilingual sites in EE in case someone is looking for an alternative:

**Language Framework:**

I usually use Biber Multi Language Support for this although I will probably be trying Transcribe on my next project. In the case of Biber it will allow you to define your languages and appends the languages' two character ISO code to your URL, Example: "http://example.com/es/". The language code is then also available as an early parsed variable `{language_code}` which you can use in your entries tags. Biber also includes the option to include static content variables for bits of text that you would not put into a channel (more on that below).

**Channel Content:**

I first define what channel content will be "mirrored" (content will be translated 1-to-1 in all languages) and which is not. From here I begin to plan out channels and field types.

If I know the content will be mirrored, I will create one channel for it and assign a field group to it that has separate text fields for each language. To avoid confusion for the content editor I usually group these fields in a tab for each language in the edit form, separating them from any non-language specific fields in that channel as well. The naming convention for fields I use would be, as an example: "product\_summary\_xx" with the "xx" part being the two letter ISO language code for that language. In your template you would then call the appropriate language field in your entries tag with the name of the field and the language variable : `{product_summary_{language_code}}`

If the content will be different for each language, I will create a channel for each language and then assign 1 field group with the text fields necessary to all the language channels. The naming convention for the channel would then be for example: "products\_xx", again with the "xx" being the language code. To call the correct language channel in the entries tag you would then use something like this: `{exp:channel:entries channel='products_{language_code}' ...}`

**Static Content**

Static content that needs to be in multiple languages (i.e.; "Send", "Your Name", "Back", etc... basically all the bits of static texts included in your templates).

Depending on the complexity, and necessary access to the content editor of this data, I will usually use a combination of the following Add-ons:

1. Low Variables \- If the project has content that will need to be editable by the client but it does not warrant a channel all to it's self, I will usually use Low Variables to group the multilingual semi-static data here by language, again to prevent confusion. Since you can specify early parse orders on variables you can also setup date, and number formatting strings for each language as well here. Again, the naming convention for these variables would be something like "lv\_home\_intro\_xx" and you would call the correct language in your template like so: `{lv_home_intro_{language_code}}`
2. Biber Multi Language Support \- For all remaining static texts that the client does not need to be meddling with, I use Biber's functionality for static multilingual phrases and close it off for only Super Admins and any higher level Member groups that would require access to it or member groups for translators. To output in the correct language in your templates you don't need to worry about the language code here, just the Biber variable name : `{bbr-mls-special_offers}`

**Navigation**

For creating multiple language navigation schemes I have been using Navee to create separate ones for each language. The interface is pretty intuitive which is great when you need to allow your client access to it. Creating separate navigation menus will also cover you if the site requires non-mirrored content in the navigation. You then would use the `{language_code}` variable again to call the correct navigation menu in your template. Example: `{exp:navee nav_title='main_navigation_{language_code}'}`

For language switching, the Biber add-on includes tags to output a language switcher and listings of all current languages that you can iterate through if you want to create your own markup for it.

# Answer
> 5 votes
Going to toot my own horn here. Publisher supports Structure and doesn't require any funky conditionals or nonsense in your templates to get the navigation to render.

http://boldminded.com/add-ons/publisher

# Answer
> 4 votes
**Taken directly from Structure's Docs: ( http://buildwithstructure.com/documentation/multi-language\_sites/ )**

The recommended method is to have your default language at the top level and make separate branches for your alternate languages like this:

* /about
* /services
* /contact
* /es/about
* /es/services
* /es/contact
* /fr/about
* /fr/services
* /fr/contact

You can then use the nav\_sub tag and either the start\_from or exclude\_status parameters. When using exclude\_status you can assign statuses by language to control the output.

**Example nav\_sub code:**

```
{if segment_1  'es' OR segment_1  'fr'}
    {!-- START FROM SEGMENT 2 IF NOT DEFAULT LANGUAGE --}
    {exp:structure:nav start_from='/{segment_1}/{segment_2}'}
{if:else}
    {!-- START FROM SEGMENT 1 IF DEFAULT LANGUAGE --}
    {exp:structure:nav start_from='/{segment_1}'}
{/if}

```

This method does not require different custom fields per language as they’re all separate pages powered by the same code and quite often the same templates.

# Answer
> 3 votes
If you're already using Structure then a simple and straightforward method would be just to create new pages for each language. This might work for you. I used it on a couple of micro-sites and the client was very happy with the results.

So your Structure tree might look something like

```
Home - /
Products - /products
Contact Us /contact-us
Polski - /pl
    Strona główna - /pl/strona-gowna
    Produkty - /pl/produkty
    Kontakt - /pl/kontakt
Francais - /fr
    Page d'accueil - /fr/page-daccueil
    Produits - /fr/produits
    Contactez-nous - /fr/contactez-nous

```

So each language effectively has its own "root" page which has the strucuture/url title of the language abbreviation then a collection of subpages.

To prevent people hitting the root pages of each language, I made a template that contains a single tag which redirects to the first child page of that root page.

The upshot is that whilst not sophistacted, you've got a very easy to manage site that makes it possible to provide different content or even pages on a per-language basis.

You get the idea.

EDIT: And now I see that basically someone has already given this answer!

# Answer
> 1 votes
Republic Factory wrote a great article on EE Insider about how they create multi-lingual sites - I've used this method and found it very easy to set-up. Also recommend Low Variables for handling translated content not stored in entries.

---
Tags: add-on, custom-fields, structure, multi-language
---


# Question
Title: Why would Freeform give me a full webpage back in the ajax response rather than a json message?
I've got a freeform form that is setup to be ajax submitted. However, even though it all works and it sends an e-mail without page refresh, i don't get a json message back, it gives me a full webpage in the response.

My freeform code is like:

```
{exp:freeform:form
collection="Single Product Enquiry"
required=""
notify="me@me.com"
template="single_product_enquiry_form"
ajax="yes"
form:id="ajax_form"
}

```

and ajax code like this:

```
$('#ajax_form').ajaxForm(function(data) {
                if(data.success === true)
                {
                    $("#modal-action").hide();
                    $("#modal-reaction").show();
                }

                if(data.success === false)
                {
                    //$(".form-error-holder").html("<label class='error'>"+data.errors.join(', ')+"</label><input type='text' class='error' /><small class='error'>Invalid entry</small>");

                    $.each(data.errors, function(i, item)
                    {
                        $(".form-error-holder").append("<small class='error'>"+i+": "+item+"</small>");
                    });
                }
            });

```

But i'm just not getting that json response. Any idea why?

# Answer
> 6 votes
Are you sure that ajax="yes" is required?

I believe freeform autodetects that (for graceful degradation on the client).

I haven't checked the FreeForm source but I suspect it could be that you're actually accidentally triggering ajax="no" with that param.

---
Tags: ajax, forms, solspace-freeform, solspace
---


# Question
Title: Expresso Store: Updating product price listing based on current modifier chosen
I've seen in the documents that you can wrap `<span class="store_product_price"></span>` around the price to make it dynamic. However, I absolutely cannot get this to work. It will display the starting price but will not update the price after you choose a modifier with a price adjustment.

I've also tested this in the store\_example templates by wrapping the same span tag around the price list on the product template.

Is there something I am missing to make this work?

# Answer
If you are using version 1.6 or lower of Store there is a known bug with dynamic product variables that was fixed in version 1.6.1. (Release Notes). Could you update to the latest version of Store and see if the issue still persist.
> 6 votes

---
Tags: add-on, expresso-store, modifiers
---


title: Trade prices in exp:resso Store

text:
# Question
Title: Trade prices in exp:resso Store
Is it possible to specify different prices for products in Store depending on the member group logged in.

For example, on our EE/Store site (currently only selling Retail) our client wants now to sell to Trade and Retail requiring two different prices. We could specify two inventories but obviously these would then cause problems as we would have multiple products with the same SKU.

# Answer
> 6 votes
It is not something that is built into Store at the moment but there are 2 ways that you can implement the functionality depending on the complexity of your product data.

* If your products are fairly simple and wont have modifiers effecting the price you can create the different price levels as modifiers per product then use a conditional in your template to preselect the proper modifier in a hidden field. The only downside to this is that the product modifier names would need to be the same so the in template conditionals worked without any problems.
* The second option would be to create 2 channels for your products. Lets call the first channel "product\_details" which would house all of your details about the product but would not contain a Store fieldtype. In the second channel lets call it "product\_prices" you would want to create 3 fields a Store fieldtype, Playa, and a dropdown or select field that would allow you select which member group the entry would apply to. Then in your template you would list the items on the site using the product\_details channel and would then need to have the playa field search for the related entries where you dropdown or select had a value of the currently logged in member.

Lastly if you are experienced with PHP you could easily write an extension that would be able to handle this. If you were to write an extension you would want to use the store\_process\_product\_tax hook to modify the product based upon the users member group before it is presented to the user.

# Answer
> 3 votes
I don't believe that exp:resso store can do this (or couldn't last time I checked). If the discount is standard you could set up a coupon code that will allow you to X% off a orders total.

If you're early on in development you may want to consider CartThrob as this functionality is included.

---
Tags: expresso-store
---


# Question
Title: "Word Separator for URL Titles" hidden config variable
Is there a hidden config variable for the "Word Separator for URL Titles" setting? What other hidden config variables remain undocumented in the ExpressionEngine User Guide?

# Answer
Yes, there is `$config['word_separator'] = "dash";`

or `$config['word_separator'] = "underscore";`
> 13 votes

# Answer
Devot:ee has a page dedicated to this: http://devot-ee.com/ee-config-vars
> 8 votes

# Answer
You can also see any hidden config values that add-ons might have if you turn on the Output Profiler and then on the front end of the site you click Show on "Config Variables" which will show all the config items and their values.
> 2 votes

---
Tags: config
---


# Question
Title: How to insert captions with images in a WYSIWYG editor
Has anyone figured out a good way to insert captions alongside images in a client-friendly way? This is one thing WordPress makes very easy but EE doesn't seem to have an answer for. I'm currently using Redactor on the project, but would be open to switching to another editor if I could get this working. Ideally, I would want it to output markup like this:

```
<figure>
  <img src="..." alt="..." />
  <figcaption>This is the caption</figcaption>
</figure>

```

The only way I can think to do this is to upload the images and captions into a separate Matrix field and then insert some kind of code into the text that would later be replaced in the template with the image/caption. Workable, but kludgy at best.

# Answer
The 'kludgy' technique you describe is exactly what we use on several major publishing websites.

It's good to abstract your content images from the actual Wysiwyg field - it gives you much finer grained control and the ability to present images in different formats (slideshow for example). Our content teams love it.

Then you use an {image\_1} token to place your images in the wysiwyg fields. I use MX Jumper.

The approaches are summarised well here.
> 4 votes

# Answer
I would use jQuery to apply the caption using something similar to the code below:

```
<script type="text/javascript">
jQuery(function($){
  $('#content img').each(function(index) {
    $this = $(this).wrap('<div class="img-caption" />');
    $('<p class="caption">' + $this.attr("alt") + '</p>').insertAfter($this);
  });
});
</script>

```

This way the client doesn't have to do anything other than fill in the alt field in the WYSIWYG editor. If using Expresso you could ask the client to apply an extra class to images requiring captions.

OR

If you want an EE solution, I would use a Matrix field for the content - for example each row in the matrix field would represent a paragraph of content on the page with the ability to have an image and caption if required:

Paragraph copy Image Caption Image alignment (left, right, Center)

The last 3 Matrix fields would be optional so if an image was unavailable a paragraph would be displayed as normal.

A couple of options for you ...
> 3 votes

# Answer
I've been meaning to try Entry Widgets:

https://github.com/iainurquhart/entry\_widgets

It's currently in beta though, could be a great fit for what you are trying to accomplish assuming it's far enough along at this point.

It's a tiny bit different from WP though, I think it gives you the dev and your clients more control at the end of the day for setting up the fields exactly how you want them and allowing your clients to place the widgets exactly where they want them.

The argument could be that WP makes assumptions and ExpressionEngine does not in the case of figure and figcaption (I realize WP is making a decent assumption here for figure/figcaption though, just thought I'd mention it FWIW.)

Check out the screenshot:
> 3 votes

# Answer
This can be done with any CKEditor-based WYSIWIG using the templates button, but beware as support for HTML5 (specifically figcaption) is spotty.

I've personally worked around this by using a div.figcaption until CKEditor supports more tags.
> 3 votes

# Answer
I've done this sort of thing using Matrix for the content as a whole, as avenue6 suggested, and it's worked out great for the client, abstracting the images from the RTE field while easily giving me specific image field targets to use either native image manipulations or plugins like CE Image to create and store the different sizes needed.

Each Matrix row is a "row" of content for the client to enter. One row could be one paragraph or ten, for example. The basic idea is that you would simply create a new row at each point at which an image needs to be injected into the flow of the content. SO the Matrix might include several columns, such as paragraph text, image, image position/class, image caption. Each time an image is needed, you would start a new row, completing all the relevant fields.
> 0 votes

---
Tags: custom-fields, wysiwyg, redactor
---


title: Relate Files like Playa fields

text:
# Question
Title: Relate Files like Playa fields
I’m stuck into something about File and Relationship and looking for help. I’m wondering if there is a way in EE2 to have something like Playa but for file relationship.

Basically, I have a bunch of images updated on a folder “my\_images” via the File Manager. I would like to get a field on a channel that could list all the files of that specific folder so admins could pick one of already stored images. The same way for instance, Playa is doing when you want to create a relation between an entry to another entry. But in that case it would be between a file and an entry.

I know there are numerous ways to handle that using channel images for instance but the thing is we already have a bunch of images stored on the folder “my\_image” uploaded via the file manager plus, we don’t really want to have an “Upload” functionality on the channel entry. Only a way to select a stored image of the folder “my\_image” that would create a relationship.

If someone knows something about it, a module or a direction to look into, it would be greatly appreciated.

# Answer
You could use MX Select Plus to accomplish this. Then in the settings for that custom field use the DB request and run a query like below. Make sure to define the `upload_location_id`. You may need to modify the query to your needs:

```
SELECT file_id AS option_name,
file_name AS option_label
FROM exp_files
WHERE upload_location_id = X
ORDER BY file_name ASC

```
> 4 votes

# Answer
If having the upload functionality is not a killer then you could accomplish this quite easily with SafeCracker File. Of course if you are wanting to prevent any further uploads then this won't be an option without altering the fieldtype (which wouldn't be too hard).

Update:

Editing ft.safecracker\_file.php and replacing line 77 will remove the upload option from the fieldtype.

I have commented out the line below and added a line to prevent PHP notices.

```
$vars = array(
        'data' => $data,
        'hidden' => form_hidden($this->field_name.'_hidden', $data),
        //'upload' => form_upload($form_upload),
        'upload' => '',
        'placeholder_input' => form_hidden($this->field_name, 'NULL'),
        'remove' => form_label(form_checkbox($this->field_name.'_remove', 1).' '.lang('remove_file')),
        'existing_input_name' => $this->field_name.'_existing',
        'existing_files' => $this->existing_files($this->settings['safecracker_upload_dir']),
        'settings' => $this->settings,
        'default' => FALSE,
        'thumb_src' => $thumb_src
    );

```
> 3 votes

# Answer
Why not use Assets? Has an excellent UX, and file uploading can be disabled per usergroup, and it should work with files that were already uploaded via the file manager.
> 0 votes

---
Tags: playa, fields
---


# Question
Title: Computing word, image, video and audio file counts in a scalable way?
I am attempting to gather as much interesting metadata as possible to display for readers of an EE site I'm developing and am looking for guidance on methods (or indeed the feasibility) of computing specific bits of this metadata in a scalable way.

EE allows for quite a few bits of data to be gathered and displayed natively, for example post totals and dates, comment totals and dates, tag totals (via a plugin), etc. However **I'm specifically interested in methods to count and display totals for data like number of words, images, videos, or audio files, not only included within individual posts but cumulatively across a channel, as well as an entire site.**

These totals would be displayed contextually depending on where they were accessed.

So for example search results would display the number of words/images/etc contained in individual posts, while a channel's "About" page would display totals for that channel, and the site's "About" page would display site-wide totals. I'm not clear on the best approach or indeed whether this is even really feasible.

I've pondered:

* Entering these numbers in custom fields on a per-post basis, but am not clear on how they'd then be added together or output for channel and site-wide totals.
* Using PHP's "count" method, but am not very familiar with PHP so unsure of it's appropriate.
* Using some mySql method to query the database, again unfamiliar and unsure.
* Utilizing the ExpressionEngine "Query Module" somehow.
* Using some Jquery plug-in to do the counting individually and then adding after the fact.

It may be that the counting of words, images, video, and audio files and the scalability are different questions all together but the truth is I'm not sure what avenue would even be best to explore at this point.

This is not a mission-critical question but any and all suggestions are appreciated. In fact suggestions regarding any bits of metadata (with the exception of member-related data) that is retrievable and displayable on the front end, beyond what I've laid out here, would interest me. Thanks.

# Answer
Probably not the specific implementation answer you want, but speaking generally, the sane way to do this is if you really feel the need is to store/cache this information per entry on entry publish/update, as:

* It ain't gonna change unless an entry save happens
* It's potentially computationally expensive to generate
* It's probably not the end of the world if these values are a little bit off. (See the slight variations in SX meta scores in the users tab vs viewing a user's profile)

Then when you need the summary data (for your "about" section or similar) sum your per-entry values and again cache it aggressively.

As for calculating the per entry data, you'd need a custom extension, though it wouldn't need to be very complex. The hook you probably want is `entry_submission_absolute_end`

For storage/retrieval I'd suggest a separate table managed via a custom module \- you don't need the overhead of storing this in channel data, and you'll get far better performance by just storing what you need against `entry_id`'s.

Text should be *relatively* straightforward, though images/video/audio etc are going to be pretty hard to decouple from their fieldtype implementation (will/are you using Matrix, Channel Images etc etc etc).

Oh and I really wouldn't even think about doing this kind of thing with jQuery. Using JavaScript for string manipulation/iteration when you've got the option of doing it server side is not a good idea in performance terms.
> 2 votes

---
Tags: custom-fields, php, database, jquery, mysql
---


# Question
Title: Is there an add-on that will export entry content as flat file on submit?
We are looking to convert an EE site to a static site, but leaving two sections of the site in ExpressionEngine. For these two sections, we want to use EE control panel to publish content, but it would be great if on submission of the new entry, the content could also be exported as a flat file (preferably with markdown). Has anyone ever come across such an add-on that will allow for this?

# Answer
I don't believe there's an add-on that does that but you could write a simple extension to do this using the "entry\_submission\_absolute\_end" hook or a similar hook.
> 5 votes

# Answer
I haven't used it yet, but this looks like exactly what you need: http://devot-ee.com/add-ons/vl-file-generator
> 3 votes

---
Tags: entry, .html
---


title: Variables in templates w/o PHP enabled

text:
# Question
Title: Variables in templates w/o PHP enabled
I have a problem where I need to increment a variable if it satisfies a conditional like so:

```
{matrix_tag_pair}
  {if matrix_column_name}
    $increment++
  {/if}

  {if $increment > 9}
    do this...
  {if:else}
    do that...
  {/if}
{/matrix_tag_pair}

```

Is it possible to do this without enabling PHP in a template? I don't see where you can create throwaway variables like counters using just EE template tags.

**Solution:** Increment was close enough that I modified the source so it could also return the count without incrementing.

```
{exp:pvl_increment start="0" step="1"}
{matrix_tag_pair}
  {if matrix_column_name}
    {exp:pvl_increment random}
  {/if}

  {if {exp:pvl_increment increment="no" random} > 9}
    do this...
  {if:else}
    do that...
  {/if}
{/matrix_tag_pair}

```

Thank you for pointing me in the right direction. This was enough that I didn't have to enable PHP in my template. This slightly modified version of Increment combined with Loop Plus could be a very useful combination.

# Answer
> 6 votes
I haven't used it myself, but perhaps the Increment plugin could do what you need? Or at least provide a basis for development. At the moment it always returns the current increment value, but it would be pretty easy to add a param to surpress this. Shout if you need help with that.

You would then do something like:

```
{matrix_tag_pair}
  {if matrix_column_name}
    {!--contains pseudocode! supress_output param doesn't exist in linked plugin as is, but could easily be added--}
    {exp:pvl_increment random id="my_id" supress_output="yes"}
  {/if}

  {if {exp:pvl_increment id="my_id"} > 10}
    do this...
  {if:else}
    do that...
  {/if}
{/matrix_tag_pair}

```

---
Tags: ee2, templates, variable
---


# Question
Title: Allowing users to mark any entry on the site as a feature
I'm building a site with approximately 5 different channels and five different field groups. The home page of the site has multiple "feature" areas that can feature any of the entries from any of those channels. I need a way to allow users to "flag" an entry as a feature for the home page, then for an admin to take that entry and place it in any one of the 5 feature areas of the home page.

I have the second part of this equation (the admin placing the feature) figured out — I'm using Low Variables and Playa for that and it's amazing. It's the first part (users flagging entries as features in the control panel) that I haven't been able to hammer down a great method for.

As I mentioned, any one of the 5 or so channels can have entries flagged as a feature, and each of those channels has a different field group. When flagging any entry as a feature there are a few required things:

1. Feature Image
2. Excerpt
3. Department

That goes for any entry in any channel. The tricky thing for me is the fact that I can't have similarly titled fields in different field groups.

Any ideas on ways to pull this off so it's not a convoluted process for the user?

# Answer
Can't you use statuses for that ? After all, that's why we have them.

It's standard EE, easy to use across different channels and easy to output the featured entries in your front-end:

```
{exp:channel:entries channel="#" status="featured"}

```
> 4 votes

# Answer
I would either use `make entry sticky`, which is a flag that can be retrieved in a channel entries tag, or I would set up a custom 'Featured' status in the `Default Statuses` status group and use that. (**Note:** if you do that, make sure to go into `Admin -> Channels`, then pick `Edit Group Assignments` for each channel and explicitly select `Default Statuses` (instead of `None`) from the `Status Group` dropdown.

Categories are WAY more overhead that you don't need for this use-case.

**Update:**

If you use a Status instead of the Sticky flag, you also need to make sure that all of your `exp:channel:entries` tags and Playa tags contain the parameter `status="not closed"`, because if you do not specify that it will default to showing `Open` entries only (and therefore not your `Featured` entries!)
> 3 votes

# Answer
One option could be to create a "Featured" Category group all of those 5 channels could use. A user would select entries they would like featured using this category.

You would change the Playa settings to only show the Featured category, so that the admin would only see entries filtered by this category when they are selecting content to feature.
> 2 votes

# Answer
You could create a category group specifically for featured, then set up your Playa field to only show items from that category.

As far as the additional fields, if you don't want similar fields in multiple channels, and if you don't want to create a new channel specifically for featured fields, you could create a matrix with:

* Featured Item (Playa to your 5 channels filtered by featured category)
* Feature Image
* Excerpt
* Department
* Any other custom fields you need

This would also allow you to use Matrix's settings to set min and max number of required featured entries for the home page.

This would change the workflow a bit in that flagged entries will need the additional info added when they are assigned to the homepage.

I generally avoid using sticky for this situation because I don't necessarily want a featured item to always be listed before non-featured items.
> 2 votes

# Answer
Can you just use the 'Make entry sticky' checkbox in the entry?

Otherwise I would go down the route of having to add a custom field to each channel :/

**OR**

You create another channel called 'featured items' with a Playa field and the Feature Img/Excerpt/Dept. fields in it. Then the users choose an entry + add these details and by default, an entry in this channel is 'meant' for the homepage.
> 1 votes

# Answer
User accessible low variables in a homepage "group" (one per featured "zone") and a low variable using select entries?

No real need for Playa here IMHO. Simplified process. Maybe users can do it themselves, provided that if nothing is selected, the latest entry or some other fallback gets displayed instead.
> 1 votes

---
Tags: ee2, add-on
---


# Question
Title: How to tell what page I am on inside a template?
Is there a variable I can use to determine that name of the template that is currently being accessed/displayed? For example, if I have a `/pages/home/` template, inside the `home` template I'd like to know it's called "home". Possible?

I plan to use this variable for the following:

* assigning an id to the `<body>` tag
* determining if the navigation is "active" or not (it's active if user is on the page where the navigation points to)

# Answer
I typically accomplish this based on URL, using segment variables. For instance:

```
<body id="{segment_1}">

```

You can also use if statements to add classes to your navigation, then target those classes in CSS:

```
<a href="" class='{if segment_1 == "foo"}foo{/if}'>

```

Additionally, if you're using embeds and want to carry info about the template in question into the embedded template, you can use embed variables:

```
{embed="template" section="foo" title="bar"}

```

In the above example, section and title are custom defined, you can call these variables whatever you want, then access them in the embedded template like this:

```
{embed:section}

```
> 4 votes

# Answer
Would NSM Body Class work for you? http://ee-garage.com/nsm-body-class

It "generates a class='' attribute value from embed template parameters allowing greater CSS styling of templates."
> 1 votes

# Answer
In addition to {segment\_1}, {segment\_2} ... {segment\_9}, there is also a {last\_segment} variable in EE 2. There are a lot of ways that these can be used, but a few potential uses would be:

```
{if segment_1 = last_segment}{redirect="/"}{/if}

<a href="{segment_1}/{segment_2}/step_2">Move along to Step 2</a>

{if last_segment = 'home'}
    ...
{/if}

```

Sitenote: As you become more experienced with ExpressionEngine, you may learn that some {if} blocks are parsed early, and others are parsed later. Both of the blocks in the sample above are parsed early.
> 1 votes

# Answer
Based on your example, use {segment\_2} to identify the template in use.

If using the template for different pages, or using Structure, I may also add an html comment to identify the template - while in dev.
> 1 votes

# Answer
Would {segment\_2} variable do the job you are asking? You could also do simple check

```
{if segment_2 == "home"}Do happy dance{/if}

```
> 0 votes

# Answer
For the two scenarios you posted you could do:

```
<body {if segment_1}id="{segment_1}"{/if}>

```

So if you are on yoursite/about then you'd see id="about". If you are on yoursite.com/contact then you'd see id="contact". If you were on the home page, there would be no id.

For the second, you could do the same with the {segment\_#} parameter:

```
<li {if segment_1 == "about"}class="active"{/if}><a href="/about"></a></li>

```

There are more advanced/dynamic ways of handling the active class as well.
> 0 votes

# Answer
There is an add-on that might help for setting the body class:

http://devot-ee.com/add-ons/clasee-body

Using a url segment variables and conditionals is another option for setting the body class and the active stage though, I see other have posted that option right as I was typing so, I won't add the code again.
> 0 votes

# Answer
If I were to look at this question in a more general sense, it's possible that you are in fact accessing / viewing the output of several templates because of embeds.

One of the best ways to determine which templates are being used in a page view is to enable template debugging and look through the list.

http://ellislab.com/expressionengine/user-guide/cp/admin/output\_and\_debugging\_preferences.html

In that list you will see which templates are being loaded (the main template as well as the embeds) and which order they are being loaded in. You will also see a list of tags which are being loaded.

However, in your example, you are really looking at segment variables, which aren't always coupled directly to specific templates. There are lots of methods which may make URL segments unreliable indicators of which templates are being used. For example, the pages module allows for custom URL segments.

In your case, I would typically do something like what Pat Brumfield mentioned. I would create an embedded template for the navigation and then from the main template (the one referencing the embed) I would use a embed variable to indicate which section the site is in.

```
{embed="includes/sidebar" section="home"}

```

And then, in the sidebar I would have a conditional which would look something like this.

```
<li{if embed:section == "home"} class="active"{/if}>Nav Item</li>

```
> 0 votes

---
Tags: templates, template-scripting
---


title: How to manage EE Cache files in Git?

text:
# Question
Title: How to manage EE Cache files in Git?
I'm using Git for version control and have been battling with the system/expressionengine/cache folder a bit. Someone had removed it from the repo using an ignore, but then we got php errors because the latest version file could not be found. Add ons like Channel Images use this folder to cache some files. I've been putting git ignore files in these folders:

```
# Ignore everything in this directory
*
# Except this file
!.gitignore

```

This leaves the folder in the repo, but keeps it empty. Seems to work, but wonder if there is a better way.

# Answer
> 10 votes
Since Git can currently only stage files and not empty directories, the only purely Git based solution is to do as you are now.

An alternative approach is to include a bash script in your repo that creates any required cache directories if the do not exist and (importantly) sets permissions on these directories (which often needs to be `755`/`777`).

The advantage of this approach comes when you need to deploy to a new server/get a new dev up and running on an install - you no longer have to manually check permissions etc - just run the script and everything will be in it's right place. I use DeployHQ's post-deploy script functionality to do this when deploying EE.

# Answer
> 9 votes
The other answers are going about this a slightly convoluted way. You don't need a special .gitignore in each folder, and that makes it hard for other developers to figure out what's going on (or you in a few months).

Just ignore the whole cache folder in your root `.gitignore`:

```
$ cd /path/to/root
$ echo "system/expressionengine/cache/" >> .gitignore

```

Then, the standard git practice for empty directories is to add an empty file named `.gitkeep`:

```
$ touch system/expressionengine/cache/.gitkeep

```

Since EE ships with an `index.html` file in the cache directory, you can use that instead. As long as the directory has at least one file in it, it will get created on your live server.

You also don't need to add any extra gitignore rules to exclude this file. Just add that particular file using `--force` (which overrides any gitignore instructions):

```
$ git add --force system/expressionengine/cache/index.html
$ git commit -m "Add index.html file to cache directory"

```

Now your folder will always get created, but git won't ever bother telling you about changes to that directory. You should do the same thing for all the `images/` directories as well.

# Answer
> 8 votes
A possibly *cleaner* way would be to have it in your .gitignore at the root level of your repo...

```
system/expressionengine/cache/*
!system/expressionengine/cache/.gitignore

```

... that way everything's centralized in that one .gitignore. However it's *my* preferred method to have multiple .gitignore files (like your example above), one in each "empty" directory that I want to have tracked in the repo.

I'd say it boils down to personal preference.

---

**Updated / Extended Answer:**

It's been pointed out by @DomStubbs below that it would be cleaner to globally track all .gitignore files with:

```
!.gitignore

```

If you do that, then you can remove:

```
!system/expressionengine/cache/.gitignore

```

Globally tracking all .gitignore files also means that the .gitignore in each "empty" directory *should* be a blank file, as it effectively turns into a placeholder like the .gitkeep file that @AdrianMacneil mentions in his answer.

So that all said, here's an example of what the "Ignore Cache Files" section of your root-level .gitignore could look like if you used the "empty placeholder .gitkeep/.gitignore" method:

```
# Track all .gitignore files
!.gitignore # or !.gitkeep if you prefer

# Ignore all cache files
system/expressionengine/cache/*
some/other/path/cache/*
yet/another-path/cache/*

```

But that's only if you want to 1) explicitly define all "empty" directories that you want to track in the root .gitignore *and* 2) put a **blank** placeholder .gitkeep/.gitignore in every "empty" directory.

I think that it's much easier to manage which "empty" directories to track by using the .gitignore that @Doug refers to in the original question. Want to declare a directory as "empty" and ignore its contents? Throw in the .gitignore file. Want to start tracking the contents? Delete the .gitignore file. Want to stop tracking the directory entirely? Delete the .gitignore file and exclude the directory in the root .gitignore file. This is more efficient because there is only ever one point of reference for the tracking state of these "empty" directories.

I have now spent far too much time thinking about this topic. :-) However, I am now much more pleased with the "exclude-everything-but-me .gitignore" method. Thanks, everyone!

# Answer
> 4 votes
We use a single .gitignore file in the root directory, and we specifically list all subfolders. This way, the cache folder can contain the default index.html file, and will be indexed by git.

```
system/expressionengine/cache/ee_version/
system/expressionengine/cache/ee_version/current_version
system/expressionengine/cache/tag_cache
system/expressionengine/cache/tag_cache_delete
system/expressionengine/cache/lg_cache
system/expressionengine/cache/db_cache
system/expressionengine/cache/magpie_cache/*
system/expressionengine/cache/page_cache
system/expressionengine/cache/page_cache_delete/

```

We set permissions on the main cache folder, and EE is able to create cache folders on its own. This has worked well for us!

# Answer
> 2 votes
You probably got errors because EE couldn't find the cache folder. I'm new to git, and I have all my ignore rules in one file in the root and there I have this

```
# Cache
/ee-admin/expressionengine/cache/*
/public_html/cache/*

```

---
Tags: git, cache, repo, cache-folder, .gitignore
---


# Question
Title: How to link JS in template files ala CSS?
I like this feature for linking CSS within the templates:

```
<link href="{stylesheet='styles/main'}" rel="stylesheet">

```

The great thing about this is that it does versioning automatically, which means I don't have to worry about old styles being cached, or trying to rename my CSS files, etc.

Is there a way to do the same for JS files? Right now, I do this:

```
<script src="{path="scripts/main"}"></script>

```

It doesn't do the versioning thing.

# Answer
Yeah, the smart cache-busting is a useful feature of keeping your CSS in EE. But add-ons will let you do the same and keep your CSS outside of EE.

**To get similar behavior for your JS files you need an an add-on**.

I recommend **Minimee**. Not only does it combine and minify CSS and JS, creating a cached file with a unique name, it also automatically creates a new version of the file if there are changes to your CSS or JS. It has useful config overrides and a ton of other features to boot. It will also free you up to have this same smart cache-busting benefit while keeping your CSS and JS outside of EE.
> 15 votes

# Answer
I generally keep my CSS & JS outside of the EE template parser. That said, you could do something like this:

```
<script src="{path="scripts/main"}{current_time}"></script>

```

on each refresh that will change.
> 1 votes

# Answer
Unfortunately there's no way to version javascript templates natively.

Your best bet is to go with the add-on Alex mentioned.
> 1 votes

---
Tags: templates
---


# Question
Title: Uploaded Image: how to get height and width? Restricting height and width?
One of my channels allow users to upload images. Two problems:

1. I've defined a max width and height in the file upload preferences (and my channel field uploads to that). However, I am able to upload images beyond the max width and height.
2. When I am displaying this image to the browser, how do I get the image's width and height? The following doesn't work:

`<img src="{banner_image}" width="{width}" height="{height}" alt="{alternate_text}"></img>`

# Answer
> 6 votes
Assuming you are using the ExpressionEngine File Fieldtype... In answer to #2, take a look at the documentation for the file field.

Specifically, the variable pair usage will allow you to pull in the `width` and `height`.

```
{banner_image}
    <img src="{url}" width="{width}" height="{height}">
{/banner_image}

```

---

I can't speak with much experience to question #1 since I've long disregarded the setting for max width and height in file upload preferences in favor of using plugins like CE Image (highly recommended!), but if you need specific sizes without using an add-on you can use the Image Manipulations feature that is built into EE. Once you have those set up, an image at a particular size is available by name like this `{banner_image:custom_size_name}`.

---
Tags: templates
---


# Question
Title: Playa tag outputting relative fields in multiples
I have the following code:

```
{exp:channel:entries channel="blog" require_entry="yes" limit="1"}
<div class="row related-articles">
    <div class="grid_12">
        <h2>Related Articles</h2>
        <ul class="unstyled inline">
            {exp:playa:children entry_id="{entry_id}"}
                {cf_general_related}
                <li class="grid_3 alpha omega">
                    <h3>{title}</h3>
                    <img src="#" alt="#"/>
                    <span class="clear"></span>
                </li>
                {/cf_general_related}
            {/exp:playa:children}
        </ul>
    </div>
</div>
{/exp:channel:entries}

```

The problem I'm finding here is, my related entries are outputting in multiples, so if I have 2 relative entries, I get 4 results in the template, if I have 4 relative entries, I get 16 items output. And each item repeats so many times.

Why?

# Answer
> 2 votes
Everything is sorted now. It turns out I only needed to update Playa to the latest version, and all my troubles disappeared.

# Answer
> 4 votes
You are getting duplicate content cause playa is being called twice

First by (the direct call to the playa module)

```
{exp:playa:children field="cf_general_related"}

```

Secondly by (the field name tag pair option)

```
{cf_general_related}
    <li>..</li>
{/cf_general_related}

```

which produces

```
{exp:playa:children field="cf_general_related" entry_id="{entry_id}"}

```

I prefer field name tag pair (keeps the template clean)

```
{cf_general_related}{/cf_general_related}

```

\*assuming that your playa field is {cf\_general\_related}

P.S. Upgrade to the latest version of Playa as there are some issues that have been addressed, one annoying one is

> -Fixed a bug where closing Playa module tags would show up on the front end of the site

# Answer
> 1 votes
You need to set up your entry something like this:

```
{exp:channel:entries channel="fact_sheets" limit="1" disable="categories|category_fields|member_data|pagination" }

 {exp:playa:children field="press_photos" }

      {if full_size_photo == ""}

         <img src="{press_thumbnail}" alt="{title}" />

      {if:else}

         <a href="{full_size_photo}"><img src="{press_thumbnail}" alt="{title}" /></a>

      {/if}

         <p>{caption}</p>

  {/exp:playa:children}

{/exp:channel:entries}

```

You pull the entry in with the channel entries and you reference the field in the Playa tag.

# Answer
> 0 votes
I think it's because you nested 2 playa tags:

```
{exp:playa:children entry_id="{entry_id}"}
{cf_general_related}

```

The corrected syntax is:

```
{exp:playa:children field="cf_general_related"}
    <li>...</li>
{/exp:playa:children}

```

**You can find more info in the docs:** http://pixelandtonic.com/playa/docs/templates#playa:children

**EDIT:**

Seems like you're just trying to get the related fields of your entry. All you need to do is this:

```
{cf_general_related}
    <li>..</li>
{/cf_general_related}

```

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


# Question
Title: ExpressionEngine - displaying most recent 3 entries of each channel, followed by random (but non-repeating) entries
I need to output the most recent 3 entries from 4 different channels, followed by random entries from any of the four channels, but not including any of the most recent entries. Any idea how to accomplish this? I know how to display random entries, and I know how to display the 3 most recent entries of a channel, but not how to do the two things combined.

# Answer
> 9 votes
Pulling everyones answers together (including post from original StackExchange) and utilising Stash (https://github.com/croxton/Stash/tree/dev) as Jim suggested:

```
{exp:channel:entries channel="about" orderby="date" limit="3"}
   ..content..
   {exp:stash:set name="exclude" append="yes"}{entry_id}|{/exp:stash:set}
{/exp:channel:entries}

{exp:channel:entries channel="news" orderby="date" limit="3"}
   ..content..
   {exp:stash:set name="exclude" append="yes"}{entry_id}|{/exp:stash:set}
{/exp:channel:entries}

{exp:channel:entries channel="services" orderby="date" limit="3"}
   ..content..
   {exp:stash:set name="exclude" append="yes"}{entry_id}|{/exp:stash:set}
{/exp:channel:entries}

{exp:channel:entries channel="products" orderby="date" limit="3"}
   ..content..
   {exp:stash:set name="exclude" append="yes"}{entry_id}|{/exp:stash:set}
{/exp:channel:entries}

{embed="includes/random-entries" exclude="{exp:stash:get name="exclude"}"}

```

In a new template "random-entries", in an "includes": group...

```
 {exp:channel:entries channel="about|news|services|products" entry_id="not {embed:exclude}0" orderby="random" limit="10"}
    ..content..
 {/exp:channel:entries}

```

# Answer
> 3 votes
You might be able to do it using Stash.

You could try doing your first entries tag with the limit of 3 and order by date descending. In that loop, you could create a stash var of the piped result IDs, like "123|122|110".

You could then do a second entries tag and set the entry\_id parameter to "not {exp:stash:your\_var\_name}" and filter by random. You may have to play around with {exp:stash:parse} for the second entries tag to get the parse order right.

# Answer
> 0 votes
I think you can probably do that with the offset parameter.

---
Tags: channel-entries
---


# Question
Title: How do I hide a div when the channel entries tag it contains has no results?
In the margin of my blog, I list featured articles. This is the code. My problem: I don´t always have stuff to feature. When the channel entries tag is empty a grey box with the title Featured is left over. I dont want to use a conditional, that says "if no entry, then print "Nothing to feature yet"."
I want to get rid of the entire box. How can i do this?

```
<div class="panel">
  <h5>Featured</h5>
  {exp:channel:entries channel="blog" limit="2" status="featured"}
    <p><a href="{url_title_path='eintrag/index'}">{title}</a></p>
  {/exp:channel:entries}
</div>

```

# Answer
Bring the `<div>` inside your channel entries tag and do something like this:

```
{exp:channel:entries channel="blog" limit="2" status="featured"}
  {if count == 1}
  <div class="panel">
    <h5>Featured</h5>
  {/if}
      <p><a href="{url_title_path='eintrag/index'}">{title}</a></p>
  {if count == total_results}
  </div>
  {/if}
{/exp:channel:entries}

```

ie, output the opening `<div>` and `<h5>` only on the first item in the loop, and only output the closing `<div>` on the last item in the loop. This way no content is output if there are no results.

You can also optionally handle the `no_results` condition specially using the `{if no_results}` conditional.
> 25 votes

---
Tags: ee2, tags
---


title: CE Tweet Plugin set up issue

text:
# Question
Title: CE Tweet Plugin set up issue
Unfortunately the documentation for CE Tweet is unclear so I would like to query the set up and to be guided in the right direction. How do I configure my twitter account details into the plugin?

As mentioned in the CE Tweet documentation I have a created a channel named `twitter` and a channel field group titled `{tweet_feed}`. I am trying to setup a single tweet feed on my site. First I have added `<script type="text/javascript" src="//platform.twitter.com/widgets.js"></script>` into my template, then I have embedded the following code into my template:

```
{exp:ce_tweet:user_timeline field="tweet_feed" screen_name="CharlesCompany" lang:en' count="1"}
  <div class="ce_tweet">
    <div class="ce_tweet_left">
      <a class="ce_tweet_username" href="http://twitter.com/{user_screen_name}" target="_blank"><img src="{user_profile_image_url}" alt="{alt}" /></a>
    </div><!--CE TWEET LEFT ENDS HERE-->
    <div class="ce_tweet_right">
        <div class="ce_tweet_row">
            <a class="ce_tweet_username" href="http://twitter.com     user_screen_name}" target="_blank">{user_name}</a>
            <a class="ce_tweet_name" href="http://twitter.com/{user_screen_name}" target="_blank">{user_screen_name}</a>
        </div><!-- .ce_tweet_row -->
        <div class="ce_tweet_row ce_tweet_text">{text}</div>
        <div class="ce_tweet_row ce_tweet_actions">
            <a class="ce_tweet_time" href="https://twitter.com/{user_screen_name}/statuses/{id_str}" title="{created_at format="%g:%i %A, %M %j%S (%T)"}" target="_blank"><span class="icon-twitter"></span> {created_at_relative}</a>
            <a class="ce_tweet_reply" href="https://twitter.com/intent/tweet?in_reply_to={id_str}" target="_blank"><span>Reply</span></a>
            <a class="ce_tweet_retweet{if retweeted} ce_tweet_retweeted{/if}" href="https://twitter.com/intent/retweet?tweet_id={id_str}" target="_blank"><span>Retweet</span></a>
            <a class="ce_tweet_favorite{if favorited} ce_tweet_favorited{/if}" href="https://twitter.com/intent/favorite?tweet_id={id_str}" target="_blank"><span>Favorite</span></a>
        </div><!-- .ce_tweet_row -->
    </div><!-- .ce_tweet_right -->
  </div><!--CE TWEET ENDS HERE -->
{/exp:ce_tweet:user_timeline}

```

My confusion is what else I need to add in order for my tweets to be visible on my site?

# Answer
A few thoughts:

* Have you read the plugin's user timeline documentation? It makes no reference to a `field` parameter nor is there any indication that the plugin integrates with the channel module. I'm not sure why you've created a `twitter` channel but it sounds as though you're trying to do something that the plugin doesn't support.
* If ever you're debugging something the first step is usually to remove all extraneous code. The same applies when posting questions to StackExchange. I'd suggest removing everything within the `{exp:ce_tweet:user_timeline}` tags and replacing it with a simple `{text}` var (since that should output the text of individual tweets).
* Recent versions of the Twitter API require OAuth credentials for all requests. I'm not sure which API endpoint this add-on uses but the installation instructions make it clear that you need to setup OAuth tokens. Have you done that?
> 3 votes

# Answer
You need to configure your API access via ExpressionEngine's config.php file, where you'll need to add this:

```
//CE Tweet
$config['ce_tweet_consumer_key'] = 'consumer_key_here';
$config['ce_tweet_consumer_secret'] = 'consumer_secret_here';
$config['ce_tweet_oauth_token'] = 'access_token_here';
$config['ce_tweet_oauth_secret'] = 'access_token_secret_here';

```

http://www.causingeffect.com/software/expressionengine/ce-tweet/installation
> 3 votes

# Answer
If you want tweets made by user CharlesCompany then you should be using the `user_timeline` tag which can be found here:

http://www.causingeffect.com/software/expressionengine/ce-tweet/tags/user\_timeline

The search tag is for making search queries and is what you seem to be using in your code.
> 2 votes

# Answer
For the search query, you would need to have additional tags withing {results}{/results}. see: http://www.causingeffect.com/software/expressionengine/ce-tweet/tags/search
> 0 votes

---
Tags: templates, plugin, tags
---


# Question
Title: Fieldtype for radio buttons with extra option to provide input from user
I need a Fieldtype that shows radion buttons for a user.

However I want an extra option for the user to provide text to a textfield if one of the options for the radio buttons is "other, ..."

Is this possible or is there a addon that can do this?

# Answer
Sounds like you are looking for an field type add-on I use all the time called *Entry Type*. It provides *P&T Pill* buttons if you have that field type installed or Radio Buttons (I prefer P&T Pill), and hides or shows fields depending on which button is active.

Personally, I don't remember how on earth I got along without *Entry Type* before. Hope it works for you.

Here's a screenshot of the admin interface so you can get a feel for how it works:

http://devot-ee.com/add-ons/entry-type
> 7 votes

# Answer
I don't know of a fieldtype that would do that natively, but it would be pretty straightforward to do this with two fields and a sprinkling of jQuery for some UI sugar.

Just create a second (text) field to hold your "other" content, then in your template do:

```
{if radio_field != "other"}
  {radio_field}
{if:else}
  {text_field}
{/if}

```

To make things a bit friendlier in the CP, you can take advantage of the fact that field instructions can contain HTML, *including* JavaScript. Basically we'll attach an event handler to the radio button's `change` event, inspect the current value of the radio button at that point, and toggle the visibility of our text field depending on whether that value is "other" or not. Something like this should do it (not very tested):

```
<script>
$(function() {
  var radioField = "your_radio_field_id",
      textField = "your_text_field_id",
      textFieldWrapper = "hold_field_" + textField.slice((textField.lastIndexOf("_")+1));

  $(document).on('change', '[name='+radioField+']', function(e){
    var $textFieldWrapper = $('#'+textFieldWrapper);
    if ($(this).val() = "other"){
      $textFieldWrapper.show();
    }
    else {
      $textFieldWrapper.hide();
    }
  });
});
</script>

```

***NB** for this to work you'll need to look up your fields' `field_id` values in the database, as that's what's used in the publish/edit page markup. If this is too fragile for you or you want to do this with a large number of fields then you'd probably need a custom fieldtype.*
> 0 votes

---
Tags: fields
---


# Question
Title: Super Search, query strings and pagination after EE1.x->2.5.3 upgrade
I'm currently in the process of upgrading a pretty complex EE1 site to 2.5.3. One of the thornier issues I've hit concerns EE2's handling of query strings and the interaction of this with native pagination.

The site uses Solspace's Super Search module and I'm removing index.php via the standard exclude method, on EE1 I therefore had URLs of the format:

http://example.com/path/to/search&key=value&key2=value2.

On EE2.5.3, though super search works fine with URLs of this format, EE shows the $\_GET array as empty (as shown in the template debugger output). I need to be able to access values in GET in my templates (I'm using Mo'Variables for this), so have reformatted my search URLs to use a "?" instead like so:

http://example.com/path/to/search?key=value.

This works great for both super search and mo variables, but breaks on paginated output, as the pagination segment is appended to the end of the query string, like so:

http://example.com/path/to/search?key=value/P15

Which breaks Super Search, whereas what I need is to prepend the pagination segment to the query string:

http://example.com/path/to/search/P15?key=value

I'm reasonably sure there must be a way around this, even if it involves an addon instead of native pagination: devot-EE also uses Super Search and has a URL structure/pagination just like what I'm looking to achieve, but I'm running up against a brick wall at the moment. Any and all bright ideas gratefully received.

*Edit: as noted in the comments to below Devot-ee now uses Low Search instead of Super Search*

# Answer
> 1 votes
Unfortunately I was unable to resolve this with SuperSearch, so ultimately I decided to migrate to Low Search instead, which was a reasonably painless process and seems to be working well.

# Answer
> 1 votes
Did you try with the 'paginate\_base' parameter in the exp:super\_search:results tag? Weirdly, I don't find any reference to this parameter in the documentation, but I'm using it in all my sites.

---
Tags: supersearch, get, querystring
---


# Question
Title: PHP Error on Structure manage entries page
I'm experiencing the following PHP error on a site running Structure (3.3.6), and am having some trouble debugging it.

The text of the error is:

> A PHP Error was encountered
>
> Severity: Notice
>
> Message: Undefined offset: 106
>
> Filename: views/index.php
>
> Line Number: 45

It is being output inline in my entry tree like so:

The code on line 45 of structure's `views/index.php` is:

```
$add_url  = BASE.AMP.'C=content_publish'.AMP.'M=entry_form'.AMP.'channel_id='.$page['channel_id']
.AMP.'parent_id='.$eid.AMP.'template_id='.$site_pages['templates'][$eid];

```

*(Line break added for readability)*

I can't see anything unique/wrong with the entry that is triggering this notice, and Structure is otherwise working fine. The only real reason I want to clean it up is that it's visible to the client in the CP (not my server and I can't edit PHP error prefs unfortunately).

Has anyone seen this before/know how to fix this?

# Answer
> 4 votes
The culprit is probably `$site_pages['templates'][$eid]`. A couple of obvious things to check would be:

* What's in the templates array? Find out with `var_dump($site_pages['templates']);`
* Check where `$eid` is set.

It's a bit of a leap of faith, but since the error looks like it relates to a template that isn't there, is there any chance you've assigned that page to a template which has since been deleted?

# Answer
> -3 votes
If you really just want to suppress the error message, add an "@" before the PHP code wich is responsible for your error.

I think $site\_pages\['templates'\] just does not have an index with number 106, so in this case you could change line 45 into:

```
$add_url  = BASE.AMP.'C=content_publish'.AMP.'M=entry_form'.AMP.'channel_id='.$page['channel_id'].AMP.'parent_id='.$eid.AMP.'template_id='.@$site_pages['templates'][$eid];

```

Please consider another option as this is not the best solution ;)

---
Tags: php, error, structure
---


# Question
Title: Google Maps: Show results with multiple statuses
In Google Maps, I'm using `{exp:gmap:search}` and `{exp:gmap:results}` to create a search form and results listing.

How can I show entries with multiple statuses?

I know I can put a hidden field in the search form to specify a single status: `<input type="hidden" name="status" value="pending" />`, but I'm not sure how to search multiple.

# Answer
Actually, the current version doesn't allow OR modifiers to the search. I think this would be a good feature request, and I can definitely work into the release after next. (v3.2)

In theory, the markup would be:

```
<input type="hidden" name="status[]" value="pending" />
<input type="hidden" name="status[]" value="open" />

```

But currently (as of 3.0.17), this would search `status = 'pending' AND status = 'open'`.
> 7 votes

---
Tags: forms, google-maps, status
---


title: Restrict number of entries per user

text:
# Question
Title: Restrict number of entries per user
I there a way to restrict the number of entries by a user to one active entry at a time?

I'd love to create some kind of freemium model for my classifieds site, which only allows for one active ad by any free user.

# Answer
> 4 votes
Are you using a SAEF to let people post the classified ad? If so you can use conditionals to check to see if that user has an entry already. Something like:

```
{exp:channel:entries channel="classified_ads" author_id="CURRENT_USER" dynamic="no"}

{if no_results}
{embed="_forms/.saef_form"}
{/if}

{if count == 1}
You currently have an active classified ad.
{/if}

{/exp:channel:entries}

```

You could also drill down further with conditionals and check for an entry over a specific time period, for example, within the last day:

```
{if "{entry_date format='%Y%m%d'}" !=  "{current_time format='%Y%m%d'}"}

```

# Answer
> 1 votes
If you are having your members add entries by safecracker this shouldn't be too tough. You would just need to restrict them from publishing to safecracker by how many entries they have.

Just test if you have a valid entry, if not show the form, if so then show a message saying they can only have one entry at a time.

Brad

---
Tags: channel-entries
---


# Question
Title: Display selected categories at top of publish category tab
We have over 1000 categories visible on the Publish Form (inherited!). I want to be able to show the moderators the selected categories at a glance instead of them having to scroll through all 1000. Is there an extension out there that does this, or will I have to roll my own?

# Answer
> 3 votes
Unfortuantely I don't know of any addons that will do this, however using the instructions field you could inject some javascript into the publish page. Something like this would probably get you a good chunk of the way there.

---
Tags: categories
---


# Question
Title: Showing native 'child' entries for an entry in the CP
Is anyone aware of an #eecms extension which adds a list of 'child entries' to a parents edit screen in the control panel? I'm sure I've seen an extension that does this in the past but I can't locate it. :/

Edit: I should add, this is for EE1.x but I would happily reverse migrate a EE2.x extension (if possible).

# Answer
> 4 votes
I think you want Introvert by @iain http://devot-ee.com/add-ons/introvert

---
Tags: entries
---


# Question
Title: Load entries with Ajax and offset existing entries
So, i've got a page where it shows 2 news entries. Then there is a link that when clicked, loads in via ajax more entries until they run out.

My template that gets pulled in via ajax looks like this:

```
    {exp:channel:entries
      channel="news"
      disable="categories|category_fields|member_data|trackbacks"
      dynamic="no"
      limit="2"
      paginate="bottom"
      orderby="date"
      sort="desc"
    }
     <h1>{title}</h1>
{content}
          {paginate}
            {pagination_links}
                {next_page}
                    <li class="example"><a href="{pagination_url}" title="example" class="news-ajax-link">More news →</a></li>
                    {/next_page}
            {/pagination_links}
        {/paginate}

      {/exp:channel:entries}

```

Which works and is fine, but, how do i get it to not pull in the first two articles (as they are already on the original page) but still be able to keep calling that page to load in more entries normally?

# Answer
Would the offset param set to 2 work?

http://ellislab.com/expressionengine/user-guide/modules/channel/channel\_entries.html#offset
> 0 votes

# Answer
You just need to add entry\_id="not 45|46" if 45 and 46 were your entry ids for those two.

I have done this before with jQuery. You just need to bring those two entry ids over to your load. You could probably add them easily via the segments.

Brad
> 2 votes

# Answer
I think these suggestion would work but (and correct me if I'm wrong) I think each subsequent click should returns 2 more entries not from any of the other prior results. So each click needs to return 2 more results that get added to the results from ALL previous requests. If that is the case then in Nate's offset solution you'd need to track how many times the link was clicked and adjust the offset up each time. 1st click offset = 2, second offset = 4, etc. A similar trick would be required for Parscale's solution. not 45|46 on the second request which may return ID 78 and 79. The next (3rd) request would need to set entry\_id="not 45|46|78|79" to avoid picking up 45 and 46 again. Or am I misunderstanding the question?
> 2 votes

---
Tags: ajax, entries
---


title: Paypal Express Checkout

text:
# Question
Title: Paypal Express Checkout
I am trying to set up my paypal account for express checkout. It's asking me for the Third Party Permission username. What do I type in for that?

# Answer
It sounds like you're in the wrong place in the Paypal settings. There is no "third party permission username".

Take a look at the instructions to set up Paypal Express with Store:

> PayPal Express Checkout requires an API Username, Password, and Signature. These are different from your PayPal account details. You can obtain your API details by logging in to your PayPal account, and clicking Profile \> My Selling Tools \> API Access \> Request/View API Credentials \> Request API Signature.
> 1 votes

---
Tags: expresso-store, paypal, paypal-express-checkout, payment-gateway
---


# Question
Title: If url_title doesn't exist, display random entry
Edited to be more specific in regards to my other modules/plugins:

I have a site that is basically set up like a printed calendar with an image on top and the content for the month below. The image and content come from two separate channels. The main page content is dynamic based on the url, and is working fine. I'm having trouble getting the image channel to display the way I want it to.

My url structure looks like this: events/calendar/date

I'm using Structure, Low Events to display the main page content, and Freebie to tell EE to ignore the date segment of the url, so that Low Events plays nice with Structure.

My Images channel is set up so that the url\_title of my image entries is the same as the date segment of my page url for the month when i want the image to display. For example, my December 2012 calendar page url is events/calendar/2012-12 and my December image's url title is 2012-12. With this setup, i can use url\_title="{freebie\_3}" on my entries tag to display the proper image each month. This also works fine:

```
{exp:channel:entries channel="calendar_images" limit="1" url_title="{freebie_3}" dynamic="no"}

```

My problem is that there may be months when I don't have an entry in the images channel, but I still want to display a random image, rather than just leaving it blank.

As it is currently set up, if my freebie\_3 segment doesn't match an existing url\_title in my images channel, I get no result. Is there some way that I can get EE to display a random entry instead?

# Answer
This is actually simpler than it seems. For this URL, events/calendar/2012-12 , use this code:

```
{exp:channel:entries channel="calendar_images" limit="1" orderby="random" dynamic="yes"}
Content
{/exp:channel:entries}

```

Assuming there's a template group called events, and a template called calendar, it'll display the entry matching the url\_title 2012-12 automatically (ordered randomly, yes, but because it's already selecting just the right one, this doesn't matter).

If there ISN'T a match, it will display a random one from the channel.

If you want more control, you'll have to get more complicated, but this will work for what you describe.

ps Be careful with that url\_title -- you can't have url\_titles that are just numbers, so the "-" is very important in this case.
> 8 votes

# Answer
You should be able to use the "require\_entry" parameter (see docs) to see if the url\_title is valid. Combined with if no results you'd get something like:

```
{exp:channel:entries channel="calendar_images" limit="1" url_title="{segment_3}" dynamic="no" require_entry="yes"}
content
{if no_results} alternate content {/if}
{/exp:channel:entries}

```
> 1 votes

---
Tags: channel, entries
---


title: Hide template_group segment in URL

text:
# Question
Title: Hide template_group segment in URL
I've seen this question in Google but the link ended up dead on the Ellislab page.

I have a not too big site which resides all in one template group.

Is it possible to remove the template group from the url so instead of `http://domain.com/site/contact` it should be `http://domain.com/contact`

I already stripped the index.php via .htaccess

I once removed the template folder by linking to subpages with: `{path='contact'}` instead of `{path='site/contact'}` but I'm not sure if this is a good practice and doesn't mess up the site in one way or another.

# Answer
Few days ago there was a question about Strict URLs in EE, enabling Strict url you have option to link directly to template jumping over template\_group What does "Enable Strict URLs" really mean? does this solves your issue?
> 4 votes

# Answer
Using `{path=contact}` to link to a template in `site/contact` is definitely a safe practice. Is it a "good" practice? There's no real downside to it, so I'd say yes.

There's also nothing 'bad' about having multiple template groups (within reason!), so you could also use `contact/index` as your template and link to it with `{path=contact}`
> 2 votes

# Answer
The default template group should not be showing in the first segment. Has this been set for the `site` template group?

Typically on small sites I just hard code the main navigation.
> 0 votes

---
Tags: tags, segments
---


# Question
Title: Strange URLs appeared in Webmaster tools
Got a very weird issue with an old EE (1.7) site, not one i've seen before.

After a server migration, we started getting a number of odd URLs being reported in Webmaster tools, all throwing errors (301 mainly)

The URLs were structured differently, but nearly all contained a web or email custom field in there somewhere - something like this

category/post-type/www.url.com/P0/

I've absolutely no idea how these URLs are being generated or how they are being formed. Anyone got any ideas where I could start to look? Completely at a loss.

Cheers Matt

# Answer
I have seen this several times over the years. If you don't properly have your 404 pages some other website out there is generating these urls and they are coming back valid. Then when google indexes those sites the urls show up. Google doesn't know these are invalid URLs. The best way to prevent this is to make sure you tighten your 404s. Make sure you have any wrong group and/or page go to a 404 page.

Here is a good article on it:

http://joviawebstudio.com/index\_ee.php/blog/guide\_to\_404\_pages\_with\_expressionengine/

Big thing is using Strict URLs and having require\_entry="yes" set in your channel entry tags.

Hope this helps!

Brad
> 9 votes

# Answer
Usually this happens when:

1. A client has a field that is supposed to contain a URL starting with http:// and they enter data without the http://. so it becomes a relative URL
2. There no error checking in the template to ensure that crazy long URLs are avoided.

It's actually not that hard to fix.

1. Do a quick look at all the values in the database for that field (or create a quick template that outputs that field for all entries ; add http:// to the entries. (Bonus: Add instructions to that URL collecting field that tells people to remember the http
2. Add this to the /category/post-type template, anywhere:

{if segment\_4 != ""}{redirect=404}{/if}

This says, if there's extra segments on the end of the URL (i.e. you'd never expect a valid segment\_4 for that part of the site) then display the 404 page.

You can clean up some more of the bad pages with Strict URLs and having require\_entry="yes" set, as another responder says, but the quickest fixes and likely causes are these.
> 1 votes

---
Tags: ee1, url, google-webmaster-tools
---


# Question
Title: Exp:resso Store Download error "Unable to locate file ID"
I keep getting a "Unable to locate file ID" when providing a file URL to the store:download tag. I believe this is because I am passing in the URL vs the actual server path.

If my assumptions are correct, how do I get the server path instead of the entire URL?

I've tried using all of the obvious available path variables within the file fieldtype pair and none of them seem to work.

# Answer
> 4 votes
If you're using the File Manager to upload then Store should properly create the download URL the file. Make sure the file is visible in the EE File Manager.

Per the Store docs:

> The real URL to the file the user needs to download. You will usually retrieve this from a custom field in your products channel. The download tag will securely provide access to this file for paid orders. Note that internally this is looked up and traced back to a file ID. Therefore, if the file isn’t visible in the EE File Manager, the download tag won’t work.

# Answer
> 2 votes
Something along the lines of:

```
{exp:store:orders member_id="CURRENT_USER"}
    <h1>Thank you for your Order:</h1>

    <h2>Ordered Items:</h2>
    <ul>
    {items}
    <li>
        <h3>{title} -- {price}</h3>
        {exp:channel:entries entry_id="{entry_id}"}
            {exp:store:download url="{download_custom_field}"}
                Download
            {/exp:store:download}
        {/exp:channel:entries}
    </li>
    {/items}
    </ul>
{/exp:store:orders}

```

Would create downloads links for all items purchased in all orders for the currently logged in user.

---
Tags: expresso-store, ecommerce, expresso, file-uploads
---


# Question
Title: Some Form submits from Discussion Module always return generic error message (Updated)
I'm using the EE Discussion module (3.1.8) under EE 2.5.2 and when I submit certain forms, say from the 'Ignore' template for example, the form submits and processes fine, but the returned page shows this error:

```
Error
The following errors were encountered You are not authorized to perform this action

```

The form posts to this URL:

```
http://www.macobserver.com/tmo/forums/do_ignore_member/47211/

```

There is almost NO documentation for the Discussion Forum module so I'm not sure even what controls the form or the message.

The ignore form template code I'm using is:

```
{form_declaration}
<div class="fm-header-wrapper">
    <h3>{lang:ignore_member_confirmation}</h3>
</div>

<div class="fm-message">
    {if member_is_ignored}
        <p class="fm-notice">{lang:already_ignored}</p>
    {/if}

    {if member_not_ignored}
        <p>
            <label for="fm-ignore-member">
                {lang:ignore_member}: <strong>{name}</strong>
            </label>
            <input type='radio' name='action' value='ignore' checked="checked" id="fm-ignore-member" />
        </p>
    {/if}
    {if member_is_ignored}
        <p>
            <label for="fm-unignore-member">
                {lang:unignore_member}: <strong>{name}</strong>
            </label>
            <input type='radio' name='action' value='unignore' checked="checked" id="fm-unignore-member" />
        </p>
    {/if}
    <p class="fm-submit">
        <input type="submit" name="submit" class="submit" value="{lang:submit}" />
    </p>
</div>
</form>

```

**UPDATE** I did some more digging on this and it seems that what is adding the duplicate info to the redirected URL is some lines in the /system/expressionengine/modules/forum/mod.forum\_core.php code. Specifically in the 'do\_ignore\_member' function at line 8481

```
$return = str_replace('/'.$this->trigger, '', $this->EE->session->tracker[2]);

```

The $this-\>EE-\>session-\>tracker\[2\] variable is used on the next line and passed to the redirect call using a $this-\>forum\_path($return); call. The forum\_path method checks for the site basepath and then adds the URI value if one is passed in.

```
/**
 * Compiles a path string
 */
public function forum_path($uri = '')
{
    if ($this->basepath == '')
    {
        $this->_forum_set_basepath();
    }

    return $this->EE->functions->remove_double_slashes($this->basepath.$uri.'/');
}

```

**UPDATE #2** So from my testing I think what is going on here is that the 'needle' value on the str\_replace() is incorrect. EE adds a beginning slash '/' to the trigger word and then searches the `$this->EE->session->tracker[2]` value for that value and removes it. The trouble is, at least from what I can see, is that the `$this->EE->session->tracker[2]` value does NOT have a leading '/' so no match is found. I think the fix would be to change the line 8481 in the /system/expressionengine/modules/forum/mod.forum\_core.php file from:

```
$return = str_replace('/'.$this->trigger, '', $this->EE->session->tracker[2]);

```

to:

```
$return = str_replace($this->trigger, '', $this->EE->session->tracker[2]);

```

This seems to fix the trouble for me, but I ask. Is this a truly a bug that needs this fix or am I just missing another configuration setting someplace?

# Answer
> 1 votes
Try removing 'forums/' from the "forum url" setting...

So '/tmo/forums/' becomes '/tmo/'. You might have to remove the trailing slash as well.

---
Tags: add-on, error, module, messages
---