title: Order when item is out of stock

text:
# Question
Title: Order when item is out of stock
Maybe I'm overseeing this, but I can't see to work it out. Customer asks me if it's possible to add items to the cart even if there's no stock.

At the moment an error is generated, saying out of stock.

Any idea if this is somehow possible?

# Answer
The only way that you are going to be able to do this is by unticking the "Track Stock" checkbox.

When you click the Track Stock button you are telling CartThrob I only have "X" amount of items so it is going to only allow you to sell "X" amount of items.
> 0 votes

# Answer
You would most likely want to check your template for something like the following and remove those lines:

```
{if "{product_inventory}" > 0}
   ...
{if:else}
  This item is out of stock
{/if}

```

You could also try clearing the "Product Inventory Field Name" field within the "Products" configuration page. This would allow you to have no stock control.

Give the first one or both solutions a try to see if it suits your needs.
> 0 votes

---
Tags: cartthrob
---


# Question
Title: Freeform + Transcribe = Missing required valid POST variable - params_id
I've just upgraded to freeform 4.1.7 from version 3 and am now getting the following error on form submit

*The following errors were encountered*

*Missing required valid POST variable - params\_id Return to Previous Page*

the site is using Transcribe 1.6, If ii turn off transcribe the form submits fine. the site is using country codes so when the form is submitted it goes to /es/?ACT=82 or /en/?ACT=82

Anyone had this problem of know of a solution. Using EE2.7.3

many thanks!

Anyone? :'(

# Answer
> 2 votes
This Solspace thread describes probable causes for that error:

http://www.solspace.com/forums/viewthread/16547

> If you’re having issues with the params\_id error, I would look at whether EE and your server can read ACT URLs correctly (eg. http://mysite.com/index.php\_ACT=123). Also, make sure the form isn’t being cached: that’s a common cause for the error
>
> Had a lightbulb moment. Make sure the domain in the URL you’re using, the domain in the form’s action=”” attribute, and EE settings are all on the same domain. www. and non-www. domains are not the same domain.

# Answer
> 2 votes
I got this just now with a combo of Transcribe and Freeform.

I think Transcribe messes with the `fetch_site_index` function of EE. In any case the POST action in my form was:

example.com/////?ACT=86

I fixed this by modifying line 3473 in third\_party/freeform/addon\_builder/addon\_builder.php to just use site\_index instead of the native fetch\_site\_index function:

So, instead of `return ee()->functions->fetch_site_index(0, 0) .` on that line I use:

`return ee()->config->item('site_url') .`

This fixed the issue.

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


title: How to edit Expression Admin panel

text:
# Question
Title: How to edit Expression Admin panel
I need to customize the Admin Control Panel in Expression Engine I don't know how to do it. If any one knows kindly tell me.

**Updated**
Actually I want to show the channel data(any entries) in different UI inside EE2 Admin panel and I have my own module and I need to show that modules records also in EE2 Admin panel.

# Answer
> 3 votes
If you're looking to change the column layout as well as the look, try the module Zenbu. It will let you customize which columns are visible from the Edit Entries view. You can show expiration dates, edit dates, custom field data, etc. You can also vary what columns are shown based on member groups.

https://devot-ee.com/add-ons/zenbu

# Answer
> 1 votes
Your question is a little vague. But there are a couple of things you can do.

For style changes EE-Garage's override.css would be a good starting point:

http://ee-garage.com/override-css

You can also create your own by making a folder inside '/themes/cp\_themes/' So you'd have '/themes/cp\_themes/**yourcustomthemename**' Inside this folder you make duplicates of the existing system files you want to make changes to.

So for example if you wanted to make changes to: '/themes/cp\_themes/default/css/login.css'

you would make your own version inside your custom theme folder: '/themes/cp\_themes/**yourcustomthemename**/css/login.css'

You can also change files within the '/system/expressionengine/views/' folder. for example if you wanted to change: '/system/expressionengine/views/\_shared/footer.php' (the control panel footer)

you can make a folder in your own theme folder: '/themes/cp\_themes/**yourcustomthemename**/\_shared/footer.php'

You only need to make copies of the files you wish to change as expressionengine will 'fall back' to the default where it can't find the file in your custom theme.

Finally, most importantly, to get this to work you need to set your custom theme in the control panel: Log in to the CP \> Admin \> General Configuration \> Default Control Panel Theme \> choose your theme from the dropdown box

# Answer
> 1 votes
You mentioned in your comment...

> I have my own module and I need to show that modules records also in EE2 Admin panel.

In that case, what you need to do is use a module "Control Panel File" `mcp.module_name.php` in your module. This file in conjunction with some view files, will give you a way to present your module data in the Control Panel.

The module tutorial in the documentation gives an example of how to put it together.

> I want to show the channel data(any entries) in different UI inside EE2

You could add methods in your mcp file to display Channel data, too.

A really quick and easy way to generate the necessary files and boilerplate for a module or other ExpressionEngine add-on is to use this ExpressionEngine Add-On generator for Yeoman.

# Answer
> 0 votes
dashEE is another great plug in that allows you to alter the main dashboard and replace it with a lot of useful tools.

---
Tags: ee2, control-panel, add-on-development, admin
---


title: share custom font across sites

text:
# Question
Title: share custom font across sites
We have a custom font, and we're using MSM, but I can only get the font to work on the main site.

here's the css:

```
@font-face {
    font-family: 'customfont';
    src: url('/fonts/customfont.ttf');
}

```

I've tried copying the font to a 'fonts' folder under each site directory, but that didn't help.

# Answer
Load one of your sites. You can use the developer console in any modern web browser (Chrome or Firefox are best) to check the following (hit F12, and use the magnifying glass or investigate tool to look at a part of the DOM that should have that font, like a

```
<p> This should be in that font </p>

```

tag):

Is the CSS rule showing up on the Elements tabs style sub-tab?? If so, is there another CSS rule over riding it?

If the rule is definitely loaded, with the developer console open, go to the Network tab and reload your site. In this tab, you should look for your file 'customfont.ttf' and see what the Status code is. You're looking for 200 or 304 to verify the font was loaded.
> 1 votes

# Answer
Try a full path - src: url('http://mysite.something/fonts/customfont.ttf');
> 0 votes

---
Tags: multi-site-manager
---


title: Orders not showing up

text:
# Question
Title: Orders not showing up
Good morning,

i have a slight problem on a project i'm developing. Using EE2.9.2 and Store 2.5.0.

I have my templating setup for my products, cart, confirmation page. Currently using the MANUAL payment gateway since we're still in development.

When I complete an order everything works on the frontend. I receive de default confirmation email since i haven't changed that yet.

In de backend however I do see my customers appear but i DON'T see the orders appear. The order list is completely empty but the database does show the corresponding entries made by test purchased.

Perhaps an error in 2.5.0?

With kind regard, Bas van Ginkel

# Answer
Store by default shows orders with a Order Status of New and a Payment Status of Paid. Orders taken with the Manual Gateway are not marked as Paid by default so you will want to choose Any or Unpaid from the status dropdown.
> 0 votes

---
Tags: expresso-store
---


# Question
Title: channel form not visible for guests in EE 2.8.1
Got a weird one. My channel form is not appearing appearing for guests.

I have the Channel Form settings set to allow guests posts, with the username being a member in the guests member group.

My channel form code is:

```
{exp:channel:form
channel="testimonials"
return="test/thankyou"
return_3="test/thankyou"
include_jquery="no"
error_handling="inline"
rules:t_first_name="required"
rules:t_last_name="required"
rules:t_email="required"
rules:t_testimonial="required"
logged_out_member_id="3"

```

Any assistance pointing me in the right direction is appreciated. Of course, if I'm missing something obvious, definitely send me a textual dope slap!

Thanks

Peter T

# Answer
> 2 votes
Yes, just in case you were wondering...this one was totally operator error! Yep...me!

I had forgotten one basic thing. When I chose the default author for guest posts, I forgot to check and make sure that the author had the ability to publish entries! Yep. I'm a moron!

---
Tags: safecracker
---


# Question
Title: How does free_shipping conditional work?
I can't seem to figure out how this works.

`{if free_shipping=="True"} this {if:else} that {/if}`

`{if free_shipping} this {if:else} that {/if}`

`{if free_shipping} this {/if}`

None seem to work, whether I set free shipping on the product, or with a discount.

\*edit\* And this is in a exp:store:product tag where everything else is working okay.

# Answer
> 1 votes
Figured it out

```
{if free_shipping=="1"} Free! {if:else} Not Free!{/if}

```

or

```
{if free_shipping=="1"} Free! {/if}

```

etc...

---
Tags: expresso-store
---


# Question
Title: Subscriptions register_member during subscribing doesn't work
I'm setting up Subscriptions for a client; I've implemented the Subscriptions page, and it works for people who already have an account in EE, but it fails if you aren't logged in, despite register\_member="yes" being set.

The error returned is:

CARD\_CREATE: Email is required.

I verified that the email address is indeed in the form, and in fact, I get this error even with the Templates that come with Subscriptions. This makes the product unusable for my client.

If it matters, I also am using SolSpace User, and I have it set up to use email addresses as usernames on the site.

# Answer
Have you installed the included templates? If so, go to the template subscribe\_with\_register.html and it includes a fully working example.

The key is you must have register\_member="yes" as a parameter and you must have at minimum these four fields: username, email, password and password\_confirm. Custom fields can be added with m\_field\_id\_1 with 1 being the field id of the custom member field.
> 1 votes

---
Tags: devdemon, subscriptions
---


# Question
Title: How to update an existing card in Subscriptions?
I'm using DevDemon's Subscriptions to maintain a subscription service for a client site.

I see tags for adding cards and deleting cards, but I don't see anything for updating an existing card on an existing subscription?

In their docs, the allude to it:

http://www.devdemon.com/documentation/tag/subs-cards/

```
<a href="{path="subs/cards_edit/{subs:hash}"}">Edit</a>

```

...but there is no cards\_edit template in their examples, and I see no tags for accomplishing this?

# Answer
> 0 votes
Have you looked at the four different example templates included?

They are: cards.html, cards\_add.html, cards\_delete.html, cards\_add\_stripe.html. With cards add there is an optional parameter delete\_cards="yes" that will remove the other card if you wish to only have one card and not make the customer delete it first. This way they can never not have a card.

---
Tags: devdemon, subscriptions
---


# Question
Title: Setting Stash variables inside Channel entry loop - parse order problems?
I'm passing an embed variable to an email form. The email form can either send an email to one member or multiple members. If the embed variable is just one entry id, then it's an email for one member. If the ember variable is a piped list of entry ids, then it's an email for multiple members.

I'm trying to capture certain values in a Stash variable, but it's not working for me:

```
{exp:stash:set name="recipients"}{/exp:stash:set}
{exp:stash:set name="user_recipients"}no{/exp:stash:set}

{if {embed:advertisers_entry_id}}
    {exp:channel:entries
        channel="advertisers"
        entry_id="{embed:advertisers_entry_id}"
    }
        {if {absolute_results} == 1}
            {exp:stash:set name="recipients"}
                {author}
            {/exp:stash:set}
        {if:elseif absolute_results > 1}
            {exp:stash:set name="user_recipients"}yes{/exp:stash:set}
        {/if}
    {/exp:channel:entries}
{/if}

```

I've tried adding `parser="inward"` to the Channel entry loop and also `parse_tags="yes" parse_vars="yes"` in the Stash setters. No go.

**How do I set Stash variables inside the Channel entry loop?**

**EDIT 1:**

I wrote a test script, based on https://github.com/croxton/Stash/wiki/%7Bexp%3Astash%3Aset%7D#basic-usage:

```
{exp:channel:entries limit="1" disable="member_data|pagination|categories"}
    {exp:stash:set name="title"}{title}{/exp:stash:set}
{/exp:channel:entries}

{exp:stash:set name="recipients"}me@domain.com{/exp:stash:set}
{exp:stash:set name="user_recipients"}no{/exp:stash:set}

<h2>title: {exp:stash:title}</h2>
<h2>recipients: {exp:stash:recipients}</h2>
<h2>user_recipients: {exp:stash:user_recipients}</h2>

```

`{exp:stash:title}` outputs nothing. `{exp:stash:recipients}` and `{exp:stash:user_recipients}` outputs as expected. Does this mean that there is something about the setup of my environment that makes Stash not work as expected?

**EDIT 2:**

Once I have those variables set, I want to be able to use them in:

```
{exp:email:contact_form
    charset="utf-8"
    form_class="customer-email-form"
    recipients="{exp:stash:recipients}"
    user_recipients="{exp:stash:user_recipients}"
}

```

They aren't getting parsed. I have tried adding \`parse="inward". No go.

# Answer
> 1 votes
Thoroughly untested but this could work (in theory)

```
{exp:stash:set parse_conditionals="yes" parse_tags="yes"}
{if {embed:advertisers_entry_id}}
    {exp:channel:entries
        channel="advertisers"
        entry_id="{embed:advertisers_entry_id}"
    }
        {if {absolute_results} == 1}
            {stash:recipients}
                {author}
            {/stash:recipients}
        {if:elseif absolute_results > 1}
            {stash:user_recipients}yes{/stash:user_recipients}
        {/if}
    {/exp:channel:entries}
{/if}
{/exp:stash:set}

```

As for your test script, the `{exp:channel:entries}` tag is at the same level as your `{exp:stash:title}` tags hence the output. To address it, put the stash tag above the `{exp:channel:entries}` tag like this:

```
{exp:stash:set name="title"}
  {exp:channel:entries limit="1" disable="member_data|pagination|categories"}
    {title}
  {/exp:channel:entries}
{/exp:stash:set}

{exp:stash:set name="recipients"}me@domain.com{/exp:stash:set}
{exp:stash:set name="user_recipients"}no{/exp:stash:set}

<h2>title: {exp:stash:title}</h2>
<h2>recipients: {exp:stash:recipients}</h2>
<h2>user_recipients: {exp:stash:user_recipients}</h2>

```

---
Tags: templates, stash, parse-order
---


title: Output x twice then y, then x twice

text:
# Question
Title: Output x twice then y, then x twice
Excuse the title, couldn't really summarise the issue succinctly...

This is what I need to do...

I have a load of entries from various channels (E). And a series of tweets (T) (which are stored in another channel).

I need to output as follows

(E) (E) (T) (E) (E) (T)...

(also, if T doesn't exist output E).

So every third item that is outputted needs to come from the twitter channel.

I'm using stash but can't for the life of me figure out how to output the content like this.

Any thoughts/suggestions greatly appreciated.

Thanks Dave

**Follow on question** Paginate two stash lists in one

# Answer
> 2 votes
This builds on CreateSean's answer, since you're using Stash. You'll need a math plugin and in this example I'm using Math from Caddis.

```
{!--set main multi-channel entry list--}
{exp:stash:set_list
    name="one"
    parse_tags="yes"
}
    {exp:channel:entries
        channel="ONE_CHANNEL|ANOTHER_CHANNEL|ETC"
        dynamic="no"
    }
        {stash:entry_id}{entry_id}{/stash:entry_id}
        {stash:title}{title}{/stash:title}
    {/exp:channel:entries}
{/exp:stash:set_list}

{!--set tweet list--}
{exp:stash:set_list
    name="two"
    parse_tags="yes"
    parse_depth="2" {!--run 2x to parse the math plugin--}
}
    {exp:channel:entries
        channel="TWEET_CHANNEL"
        dynamic="no"
    }
        {stash:entry_id}{entry_id}{/stash:entry_id}
        {stash:title}{title}{/stash:title}
        {!--set a number to match every third count where the tweet should be output--}
        {stash:two_count}{exp:math formula="{count} * 3"}{/stash:two_count}
    {/exp:channel:entries}
{/exp:stash:set_list}

{!--output multi-channel list and tweet list--}
{exp:stash:get_list
    name="one"
    prefix="st1"
}
    {!--output tweet on every third loop--}
    {if st1:count % 3 == 0}

        {exp:stash:get_list:nested
            name="two"
            limit="1"
            match="#{st1:count}#"
            against="two_count"
            prefix="st2"
        }
            {!--if no results, output main channel entry--}
            {if st2:no_results}
                <li>{st1:entry_id} : {st1:title}</li>
            {/if}
            {!--tweet--}
            <li>{st2:entry_id} : {st2:title}</li>
            {!--3rd main--}
            <li>{st1:entry_id} : {st1:title}</li>
        {/exp:stash:get_list:nested}

    {!--otherwise output main channel entry--}
    {if:else}
        <li>{st1:entry_id} : {st1:title}</li>
    {/if}
{/exp:stash:get_list}

```

# Answer
> 1 votes
I would use conditionals and the modulus operator like this:

```
{exp:channel:entries channel="foo" limit=100"}

 {if count % 3 == 0}

    insert tweet here

 {if:else}

    insert entries here

 {/if}

{/exp:channel:entries}

```

---
Tags: channel-entries, stash
---


# Question
Title: Multiple tags separated by commas don't works in textarea fields
i've an issue using Tag with Channel Form in front. I've Tag v.4.2.8 and it's setted in the CP

and the code is

```
{exp:channel:form channel="spots" class="form-horizontal" return="spot/ENTRY_ID/URL_TITLE" }
      <div class="form-group">
        <label class="control-label col-xs-1">Titolo</label>
        <div class="col-xs-11">
          <input class="form-control" placeholder="Inserisci il titolo della tua domanda" name="title" type="text">
        </div>
      </div>
        <div class="form-group">
          {field:spot_desc}
        </div>
        <div class="form-group">
          <label class="control-label col-xs-1">Tags</label>
          <div class="col-md-11">
            <textarea class="form-control" rows="1" name="tags"></textarea>
            <p class="help-block">Separa ogni tag con la virgola</p>
          </div>
        </div>
        <div class="form-group">
          <input type="submit" value="Submit">
        </div>
    {/exp:channel:form}

```

But when try to submit tags commas separate

```
example, taga, commas

```

the results is only one tag with the commas

```
<a href="">example, taga, commas</a>

```

Where i'm wrong?

# Answer
> 1 votes
You could always just use the `{field:tag_fieldtype_short_name}` tag, which Solspace recommends in their docs. If that doesn't work you can always look at the page source after it parses and see the way Solspace requires the field.

Docs for using the Tag module in channel form.

# Answer
> 0 votes
As mentioned in another answer, you would need to use the **Tag Widget**, i.e. `{field:my_tag_custom_field_name}` to add tags from a Channel Form in which you're creating a new channel entry.

What happens in the background is that tags are added to a textarea field with `name="my_tag_custom_field_name"`, with each tag on a separate line (newline-separated). If you have a regular textarea field with your Tag field's name in the `name=""` attribute, you can also enter new tags as long as each tag is on their own line. This happens to be a coincidence that it works, since Channel Form should use the Tag Widget.

Alternatively, you can use `{exp:tag:form}` to add tags to a *pre-existing* entry: http://www.solspace.com/docs/tag/form/. In this case, you would have to create an entry first, *then* add tags to the newly created entry.

---
Tags: solspace-tag
---


# Question
Title: Has anyone used Expression Engine with Open Saas to sync membership profiles to a cloud based CRM?
I'm trying to sync new member registration and profile updates to a cloud based CRM. Has anyone done this? The CRM I'm using is Batchbook. It uses Open Saas.

# Answer
I know someone has done an integration between EE and Sugar before, so it must be possible. Maybe you could contact the developers of that add-on and find out if they could help you.
> 1 votes

# Answer
I realise this is a little late, but I'd recommend looking at the Batchbook API docs: http://developer.batchblue.com/, plus their php library: https://github.com/batchblue/batchbook-php.

You could create an EE addon harnessing this library which would do what you needed (or you could get someone else to build it for you).
> 0 votes

---
Tags: saas
---


# Question
Title: Adding Solspace Tag in Channel Form without need to hit return
I'm using Solspace tag as a 'subject' field in conjunction with EE's native Channel Form. We have set the field to required using the rules parameter...

```
rules:FieldYear="required"

```

If the user doesn't hit enter when inputting a subject tag (or select an existing tag from the list), i.e. it doesn't get added as a tag and just sits in the field as text - the form will not submit. It's basically not counting it as a valid field, as technically there is no tag selected.

Is there any simple way to just convert that text to a tag on submission? Would be really helpful!

Thanks!

*(p.s. The reason why we're using the rules parameter is it gives a lot more flexibility, as you can make a field required in a specific form rather than globally across the site)*

# Answer
> 0 votes
Sorry, that is currently not available. If you're using the **Tag Widget**, you must press \[Enter\] between each tag. I recommend submitting this as a Feature Request under the specific add-on category. It'll also give other users the option to vote up the feature request, and help us prioritize features to add in upcoming versions of this add-on. http://support.solspace.com/support/discussions

Alternatively, instead of the Tag widget field you could simply have a textarea field with `name="my_tag_field_name"`, and make sure each tag is on a separate line. That's essentially what the Tag widget does in the background, but in this case having a single tag in the field would submit that value with the form, and not trigger your required... requirement :)

Another idea could be to trigger some javascript before form submission, where fields with `name="my_tag_field_name"` are checked for any content. If the field is empty, fill the field with *something* then continue with the form submission.

Yet another idea would be to develop an extension which adds a value in the array of data being submitted to EE if the tag field is empty. This would have to happen before the Channel Form's validation kicks in.

---
Tags: solspace, safecracker
---


title: Calendar event in the past no showing

text:
# Question
Title: Calendar event in the past no showing
I'm using Solspace Calendar and this code for showing single events...

```
{exp:calendar:events event_id="{segment_3}"}

```

and it works find for showing events in the future, however for past events it's showing No Results.

The past entry status are Open and there is no expiration date.

# Answer
> 0 votes
If you're looking to display **upcoming or past events**, you should use `{exp:calendar:cal}` instead of other Calendar tags. `{exp:calendar:cal}` is the only tag that will display event data in a chronological way. With this tag, the following tag would display events from 1 month past to now:

```
{exp:calendar:cal
    date_range_start="1 month ago"
    date_range_end="today"
    pad_short_weeks="n"
}

```

(You could throw in an `event_id=""` in there as well if needed to limit the list to an event) More details about why {exp:calendar:cal} is the tag to use for chronological data can be found here (**Recommended read**): http://www.solspace.com/docs/calendar/getting\_started/

*Quick summary*: `{exp:calendar:events}` would be used for general information about the event entry (eg. event location, summary, start/end dates set in the entry), and `{exp:calendar:cal}` is used for most things related to *time* (eg. upcoming events, past events, events between X and Y, chronological order of events and their occurrences, etc).

---
Tags: solspace-calendar
---


# Question
Title: Can you add +$ for gifts in dev demon subscriptions?
> Conditionals - This allows customer information to increase or decrease the price of your subscription. For example the customer is in Canada and you are shipping a product to the customer each month. This would allow for an additional conditional charge if the customer chooses Canada in their customer information.

This seems limited to certain customer fields, like country or state, but is there any way to have a field 'tick to add this as a gift' +$ as part of a subscription?

# Answer
Currently you have to do this in the template and use a form field to send the price. We are working on an improved system that will work more like attributes in shopping carts.
> 0 votes

---
Tags: devdemon, subscriptions
---


# Question
Title: Adding quotes around a parameter causes error?
I have the following:

```
{exp:email:contact_form
    charset="utf-8"
    form_class="customer-email-form"
    recipients={exp:stash:get name='recipients'}
}

```

Notice that the `recipients` parameter's value is not in quotes. When I put quotes and try to send an email, I get "no recipients" error. However, if I replace the Stash with hard coded email address(es), I need the quotes to make the email form work.

Is there something wrong? Or is this expected behavior?

# Answer
> 3 votes
I believe you're running into problems with the parse order. When you add quotes, recipients becomes a valid parameter but it isn't parsed yet. When you remove the quotes, it becomes an invalid parameter and is ignored. You should be able to add `parse="inward"` to the contact\_form parameters to parse recipients first.

```
{exp:email:contact_form
    charset="utf-8"
    form_class="customer-email-form"
    recipients="{exp:stash:get name='recipients'}"
    parse="inward"
}

```

There is some documentation and examples about this problem here.

---
Tags: templates, stash, parameters, email-contact-form
---


title: Unserialize Error in drivers/cache

text:
# Question
Title: Unserialize Error in drivers/cache
Not sure really what type of issue this is, but I figure I'll ask here. I have a site that's running live on the server right now which has the following error:

```
A PHP Error was encountered
Severity: Notice
Message: unserialize(): Error at offset 0 of 326 bytes
Filename: drivers/Cache_file.php
Line Number: 74

```

This error does not happen locally, only live. The only difference I can see is that on the live server the templates are synched, whereas locally they are not.

I am running EE v 2.8.1, php 5.5.9. Permissions on my cache directory are 777.

# Answer
After speaking with Derek privately I was able to resolve the issue which is a permissions error. The steps taken to solve this are:

Via FTP/SSH navigate to system/expressionengine/cache and delete everything with the exception of .htaccess and index.html .

Afterwards, change your permissions on system/expressionengine/cache to be 777 then restart your server.
> 3 votes

# Answer
I would try clearing the cache from within the control pannel
> 0 votes

---
Tags: error, php-errors, cache, caching
---


# Question
Title: Thumbnails, channel_short_name and channel fields
I have a image "thumbnail" field in multiple channels, ie: "news\_thumbnail" "projects\_thumbnail" "editorials\_thumbnail"

With these images, I use EE's resizing feature to crop multiple sizes of the image.

I'm attempting to display the images using the following:

```
{{channel_short_code}_thumbnail}{path}_frontpage/{filename}.{extension}{/{channel_short_code_thumbnail}

```

This outputs to

```
{news_thumbnail}{path}_frontpage/{filename}.{extension}{/{news_thumbnail}

```

The {path} {filename} and {extension} variables aren't being processed properly.

However if I hardcode the channel field and use:

```
{news_thumbnail}{path}_frontpage/{filename}.{extension}{/{news_thumbnail}

```

{path},{filename} and {extension} are parsed to their proper values, and the image is displayed properly.

Any idea how to get this working properly?

# Answer
> 0 votes
You're trying to use the value of one variable (i.e., `{channel_short_name}`) to determine the key of another variable located at the *same level of processing* (i.e., `{news_thumbnail}`), which won't work.

I'd suggest using preload\_replace variables instead, since they are parsed before any module tags are processed:

```
{preload_replace:current_channel="news"}

{exp:channel:entries channel="{current_channel}"}
    {{current_channel}_thumbnail}{path}_frontpage/{filename}.{extension}{/{current_channel}_thumbnail}
{/exp:channel:entries}

```

---
Tags: thumbnails
---


# Question
Title: .htaccess remove index.php sort of works, but not the first time after browser cache is cleared
I don't know if this is a new thing or if it's been an issue all along, but the client just noticed and i recreated the issue myself. If I clear my browser cache and then visit my client's site at a URL like http://www.example.com/product/product1 it will redirect to http://www.example.com/index.php/product/product1. The page looks fine. After refreshing or visiting that URL again the URL will pull up correctly at http://www.example.com/product/product1. If I clear my browser cache again it will redirect to the index.php url again.

Here's my .htaccess file, any ideas why this might be happening? Thanks for any ideas!

```
RewriteEngine On

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

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

Redirect 301 /helpdesk http://helpdesk.example.com
Redirect 301 /splash http://example.com
Redirect 301 /webmail http://mail.example.com:32000
Redirect 301 /email http://mail.example.com:32000
Redirect 301 /timeclock http://timeclock.example.com:62345
Redirect 301 /signature http://signature.example.com

```

EDIT: I modified my .htaccess file to the recommended one from EllisLab and that seems to have fixed the index.php from showing up. Something is still a little wonky though. When I clear the browser cache and visit a url with a hash tag at the end (http://www.example.com/product/product1#tab3), the redirect removes the hash tag and the rest of the url after it. If I refresh the page it will work as expected. it only has issues with the first time visiting the url after a clean browser cache. Any ideas?

```
    RewriteEngine On
    RewriteBase /

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

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

```

# Answer
On further investigation, it appears that this redirect is coming from inside that template.

See the attached image

All of your header assets are being loaded just fine until something else triggers the redirect, in this example it happened after the server already responded to 15 gets from the generated page. What kind of addons does this template use? Try investigating that.

EDIT: To be clear, **anchor tags are never even sent to the server**. If it is the .htaccess setup, there is no way it's rewriting anything based on anchors.
> 2 votes

---
Tags: .htaccess, index.php
---


# Question
Title: Cartthrob adding package items while quantity is set to zero
I'm trying to only allow items to be added to Cartthrob's cart based on a selection made. However, before I can do that, I need to solve why the cart is updating with items even though their amount is set to zero.

How can I tell cartthrob to either/or give me a non-selected option, or to ignore adding an item whose quantity is 0, or both?

My code is as follows:

```
{exp:channel:entries channel="store_packages"}
    <select name="packages" id="packages-select" class='width-70 margin-bottom'>
        <option value="">Please Select</option>
        {packages_packages}
            <option value="{sub:row_id}">
                {sub:title}
            </option>
        {/packages_packages}
    </select>

```

I'm hoping to use the above to be able to hide/show package options based on this selection.

```
{exp:cartthrob:add_to_cart_form class='forms' entry_id="{entry_id}" no_tax="{no_tax}" no_shipping = "{no_shipping}" return="/store/view_cart"}

    {packages_packages}
        {exp:cartthrob:item_options row_id="{sub:row_id}" entry_id="{entry_id}"}
            {if dynamic}
                <label class="control-label" for="{option_field}">{option_label}</label>
                {input}
            {if:else}
                {if options_exist}
                    {select class='width-70 margin-bottom'}
                        <option {selected} value="{option_value}">{option_name} {if option_price_numeric != 0} +{option_price}{/if}</option>
                    {/select}

                    <label class="input-groups" id="quantity-modiphier">
                        <span class="btn-append">
                             <span class="btn btn-black" id="less-quantity"><i class="icon icon-minus"></i></span>
                        </span>
                        <input type="text" id="product_quantity" name="quantity" value="0">
                        <span class="btn-append">
                             <span class="btn btn-black" id="more-quantity"><i class="icon icon-plus"></i></span>
                         </span>
                    </label>
                {/if}
            {/if}
        {/exp:cartthrob:item_options}
    {/packages_packages}

```

Here I'm showing all options in their own select lists and setting the initial quantity to 0.

```
    <p>
        <button type="submit" class="btn btn-green">Add to Cart</button>
        <a href="#" class="btn btn-disabled">Checkout</a>
        <a href="#" class="btn btn-disabled"><i class="icon icon-shopping-cart"></i>View Cart</a>
    </p>

{/exp:cartthrob:add_to_cart_form}

{/exp:channel:entries}

```

Yet, when I hit "Add to cart" it adds the first option of each select list with a quantity of one.

# Answer
The answer to why cartthrob was adding items to the cart although the quantity was set to zero is that the cartthrob settings used the packages channel for pricing rather than the product options from the product channel. This is modified in cartthrob's products settings.
> 0 votes

---
Tags: cartthrob, ecommerce, shopping-cart
---


# Question
Title: Do unused custom fields affect performance?
If there are custom fields that are not used e.g., optional, in all entries, does this in any way affect performance? I am considering implementing a somewhat monolithic custom fieldset to be associated with various channels.

# Answer
For each custom field you add, it adds at least 2 columns to the `exp_channel_data` table, and if that table gets too big, it can affect performance in some respects.

I have a site with many channels and many fields, and my `exp_channel_data` table is up to 600 columns. This becomes a problem when I want to add new custom fields. I have over 200k+ entries in that table, and it now takes several minutes to add a new custom field.

I haven't, however, noticed any major issues with the reading of the data... just the actions that require modifications to that table. Hope that helps some!
> 1 votes

---
Tags: custom-fields, performance
---


# Question
Title: How can I download and archive my entire EE website?
My client is moving to a different platform and they want me to "download" their current EE site so they can have an archive of it.

Does anyone know how to do this? Thanks!

# Answer
You need to connect to the server the site is hosted, and either use ftp or ssh to copy the entire directory to a local machine. You will also need to export the database, which should be specified in `system > expressionengine > config > database.php`. You can do this in phpmyadmin by finding the appropriate database, select the export tab, and save as a sql file.
> 1 votes

# Answer
Do you mean an viewable archive of the whole site? If so HTTrack is what I use in such a case. Let's you grab the whole site and if you want you put it on an CD-Rom, DVD or USB-Stick to view and browse offline.
> 1 votes

# Answer
to make it user-readable, back in the day, I used to use a feature in Acrobat that allowed you to convert a site to a multi-page pdf. Links worked and everything. No Idea if its in the current version...

Why do they want move away from EE?
> 0 votes

---
Tags: backup
---


# Question
Title: Use Custom Field as Timezone Parameter in Date Field
I have a custom field where the publisher can choose what time zone they want the entry date to display as, but I'm having trouble when trying to use it in the template:

```
{exp:channel:entries
    channel='events'
}
    {entry_date format='%g:%i%a %T' timezone='{events_tz}'}
{/exp:channel:entries}

```

Since both tags are parsed at the same time, the `{events_tz}` field doesn't get parsed in time to be applied as a parameter to the date field.

How would I accomplish this? I'm willing to use Stash, if necessary.

# Answer
If I'm inferring correctly, there are events in multiple time zones and they want each to show in the time that is local to the location of the event. If so, I think what you want is Fixed instead of Localized, and just output the time zone next to the date.

If you must use entry date, which will always be localized, you could create a simple plugin that accepts the UTC timestamp and the timezone and return a formatted date, e.g.:

```
{exp:your_date_plugin timestamp='{entry_date}' timezone='{events_tz}'}

```
> 1 votes

# Answer
Following Derek's advice above, I wrote a quick plugin to handle the conversion. Here's the plugin method code (note: I used the EE Add-On Builder for Sublime Text to generate the plugin file and boilerplate code):

```
public function convert_timezone() {
    $timestamp = ee()->TMPL->fetch_param('timestamp');
    $timezone = ee()->TMPL->fetch_param('timezone');
    $format = ee()->TMPL->fetch_param('format');

    return ee()->localize->format_date($format, $timestamp, $timezone);
}

```

And the tag it uses:

```
{exp:site_utilities:convert_timezone
    timestamp='{entry_date}'
    timezone='{events_tz}'
    format='%g:%i%a %T'
 }

```
> 0 votes

---
Tags: custom-fields, parse-order
---


title: Zoo Visitor and Low Alphabet

text:
# Question
Title: Zoo Visitor and Low Alphabet
Is it possible to filter Low alphabet listings by member group with Zoo visitor?

Eg something like this:

```
{exp:low_alphabet:entries
    channel="members"
    alpha_ignore="the|a"
    numbers="after"
    group_numbers="yes"
    numbers_label="#"
    alpha_filter="{segment_3}"
    status="not closed"
    orderby="title"
    show_group="7"
    sort="asc"
    disable="categories|member_data|pagination"
}
  {if count == 1}<h1>Company A-Z</h1>{/if}
  {if low_alphabet_heading}
    <h3>{low_alphabet_label}</h3>
    <ul>
  {/if}
      <li>
        <a href="{url_title_path="a-z/detail"}">{title}</a>
        <img src="employer_logo" alt="{title}"/>
      </li>
  {if low_alphabet_footer}
    </ul>
  {/if}
{/exp:low_alphabet:entries}

```

# Answer
> 1 votes
Apart from Low Alphabet's own parameters, the Entries tag inherits all parameters from the native channel:entries tag. The `show_group` parameter is *not* present in either, so that won't do anything.

However, if I recall correctly, Zoo Visitor uses statuses to differentiate between member groups. That means you should be able to use the `status` parameter to target the member group you want to display.

---
Tags: members, zoo-visitor, low-alphabet, alphabetically
---


# Question
Title: Category filtering with combination of Not and Include Low Seg2Cat
I have the following code which doesn't showing any result if I combine these two together, is this the correct syntax?

```
{exp:channel:entries channel="people" orderby="date" category="{segment_3_category_id}&not51"   sort="desc"}

```

# Answer
> 0 votes
Combining the inclusion *and* exclusion of categories with the native channel:entries tag in a single parameter is not possible. The syntax you're using is therefore not supported.

You would either need to re-think your setup, use a custom query, or use Low Search and its Categories filter, so you can use parameters like this:

```
{exp:low_search:results
    channel="people"
    orderby="date"
    category:group1="{segment_3_category_id}"
    category:group2="not 51"
    sort="desc"
}

```

---
Tags: categories, filtering
---


# Question
Title: Stash & Low Search - Group results by releationship
I'm trying to group the results returned from Low Search using Stash. I started by creating a stash list of all the groups, I then tried to create a nested list containing the products for that group.

When I call the get\_list, I can return the groups just fine, but trying to fetch the products returns nothing.

Here is my code so far (Bear in mind I know that this will add ALL products into each group, but I'm taking this one step at a time)

```
{layout="includes/_layout"}

    {exp:stash:set parse_conditionals="yes" parse_tags="yes" trim="yes"}

        {!-- Set Other Page Data --}

        {!-- Results --}
        {exp:stash:set_list:searchRanges name="searchRanges" parse_tags="yes" trim="yes"}
            {exp:low_search:results query="{segment_3}" collection="products" keywords:lang="en" keywords:inflect="yes" keywords:loose="right" keywords:mode="all" limit="999"}
                {stash:itemRange}{products__range:url_title}{/stash:itemRange}

                {exp:stash:append_list:nested name="searchResults--{products__range:url_title}" parse_tags="yes" trim="yes"}
                    {stash:productTitle}sdfds{/stash:productTitle}
                {/exp:stash:append_list:nested}
            {/exp:low_search:results}
        {/exp:stash:set_list:searchRanges}

    {/exp:stash:set}

    {!-- Fetch the data --}
    {exp:stash:get_list name="searchRanges" unique="itemRange"}
        <p>{itemRange} - This is being returned.</p>

        {!-- Adding process="end" to this makes it return the correct amount, but adding process="end" to the nested get_list still returns nothing --}
        {exp:stash:list_count name="searchResults--{itemRange}" process="end"}

        {exp:stash:get_list:nested name="searchResults--{itemRange}"}
            <p>This content isn't being returned</p>
        {/exp:stash:get_list:nested}
    {/exp:stash:get_list}

```

**Edit**

Looking at the template debugger, I can see the get\_list is parsing the `name="searchResults--{itemRange}"` correctly, but I can't see the list being set anywhere, so looks like an it's an issue with the nested list not being set. I've tried adding process="end" to the nested append\_list but nothing still

# Answer
> 2 votes
You only need one list. You can use the `unique=""` parameter to output unique values of a given column, and the `match=""` & `against=""` parameters in a nested call to the same list to select products that match each unique value.

```
{!-- Capture search results --}
{exp:stash:set_list name="products" parse_tags="yes" parse_depth="2"}
    {exp:low_search:results query="{segment_3}" collection="products" keywords:lang="en" keywords:inflect="yes" keywords:loose="right" keywords:mode="all" limit="999"}
        {stash:item_range}{products__range:url_title}{/stash:item_range}
        {stash:product_title}{title}{/stash:product_title}
    {/exp:low_search:results}
{/exp:stash:set_list}

{!-- Output products grouped by range --}
{exp:stash:get_list name="products" unique="item_range" orderby="item_range" sort="asc"}

    <h1>Range: {item_range}</h1>

    <ul>
    {exp:stash:get_list:range name="products" match="#^{item_range}$#" against="item_range" prefix="range"}
        <li>{range:product_title}</li>
    {/exp:stash:get_list:range}
    </ul>

{/exp:stash:get_list}

```

# Answer
> 0 votes
**Edit**

See Mark's answer, it's much better.

---

I managed to sort the issue myself, I'm sure there is a better way of doing this, but it works for now.

## Setting

I first started by getting all the product ranges into a list. Notice the `parse_depth="2"` on the outer set tag. This does not work without it.

```
{exp:stash:set parse_conditionals="yes" parse_tags="yes" trim="yes" parse_depth="2"}

    {!-- Get all product ranges --}
    {exp:stash:set_list:productRanges name="productRanges" parse_tags="yes" trim="yes"}
        {exp:channel:entries channel="ranges" dynamic="no" limit="999" disable="categories|category_fields|member_data|pagination"}
            {stash:rangeName}{title}{/stash:rangeName}
            {stash:rangeShortname}{url_title}{/stash:rangeShortname}
        {/exp:channel:entries}
    {/exp:stash:set_list:productRanges}

{/exp:stash:set}

```

Now that we've got the ranges stored, we can then create a new list per range, and then using the `match` and `against` parameters, we can add products from the search results to each list if they are assigned to that product range.

```
{exp:stash:set parse_conditionals="yes" parse_tags="yes" trim="yes" parse_depth="2"}

    {!-- Get all product ranges --}
    {exp:stash:set_list:productRanges name="productRanges" parse_tags="yes" trim="yes"}
        {exp:channel:entries channel="ranges" dynamic="no" limit="999" disable="categories|category_fields|member_data|pagination"}
            {stash:rangeName}{title}{/stash:rangeName}
            {stash:rangeShortname}{url_title}{/stash:rangeShortname}
        {/exp:channel:entries}
    {/exp:stash:set_list:productRanges}

    {!-- Create a new list for each range, and add the products from the search results if they are assigned to that range. --}
    {exp:stash:get_list name="productRanges"}
        {exp:stash:set_list:rangeProducts name="results--{rangeShortname}" parse_tags="yes" trim="yes" match="#{rangeShortname}#" against="productRange"}
            {exp:low_search:results query="{segment_3}" collection="products" keywords:lang="en" keywords:inflect="yes" keywords:loose="right" keywords:mode="all" limit="999"}
                {stash:productName}{title}{/stash:productName}
                {stash:productRange}{products__range:url_title}{/stash:productRange}
            {/exp:low_search:results}
        {/exp:stash:set_list:rangeProducts}
    {/exp:stash:get_list}

{/exp:stash:set}

```

## Getting

Now that the lists are set it's easy to get them.

```
{exp:stash:get_list name="productRanges"}
    {if {exp:stash:not_empty name="results--{rangeShortname}"}}
        <p>{rangeShortname}</p>

        <ul>
            {exp:stash:get_list:nested name="results--{rangeShortname}"}
               <li>{productName}</li>
            {/exp:stash:get_list:nested}
        </ul>
    {/if}
{/exp:stash:get_list}

```

---
Tags: stash, search, low-search
---


# Question
Title: How to save the current url across page reload with Stash?
I'm trying the following code to save the latest visited url across a page reload:

TEMPLATE A:

{exp:stash:set name="latest\_url" scope="site" save="yes" refresh="60"}

{exp:current\_url:full\_url}

{/exp:stash:set}

TEMPLATE B:

{exp:stash:latest\_url}

or

{exp:stash:get name='latest\_url'}

--

There's no output, whatever I do!

But the current url is successfully grabbed in template A, which I can see, after turning output to "yes".

What's wrong?

# Answer
If you trying to make the saved url user-specific I would use scope="user", and add parse\_tags="yes" and replace="yes" to the parameters. See if this works:

```
{exp:stash:set
    name="latest_url"
    scope="user"
    save="yes"
    replace="yes"
    parse_tags="yes"
    trim="yes"
}
    {exp:current_url:full_url}
{/exp:stash:set}

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

```
> 1 votes

---
Tags: stash
---


# Question
Title: channel entries starting next at the month
I want to get all the channel entries for next next six months starting at the next month. I can use the month\_limit and set it to 6 and I can use the start\_on parameter to specify what date to start on but how do I get the 1st of the next month into that parameter? So today being April 1st I want the start\_on parameter to have 5/1/2015 00:00, how to do I get that into the start\_on parameter?

# Answer
> 1 votes
I would use an addon like this:

http://www.solspace.com/docs/date\_field\_filter/usage/

and you could throw on PHP parsing on that template and set a future date var:

```
<?php
$enddate = new DateTime();
$enddate->modify("+6 month");
?>

```

and your channel:entries tag would look something like this:

```
{exp:channel:entries
    date_field="entry_date"
    date_field_start="{current_time format='%m/%d/%Y %h:%i'}"
    date_field_stop="<?php echo $enddate->format("m/d/Y h:i"); ?>"
}

```

You can mess with PHP DateTime to get the 0 hour of the current date I believe, do some reading at the docs:

http://php.net/manual/en/class.datetime.php

---
Tags: channel-entries, date
---


# Question
Title: Set Stash variable in Channel entry loop, then use in email contact form? Parse order issues?
The following is part of an embedded template, which is passed `{embed:advertisers_entry_id}` that contains a string like `34|68|124|`:

```
{!-- Set defaults --}
{exp:stash:recipients}{/exp:stash:recipients}
{exp:stash:user_recipients}no{/exp:stash:user_recipients}

{!-- Set Stash variables for email contact form --}
{exp:stash:set parse_conditionals="yes" parse_tags="yes"}
    {exp:channel:entries
        channel="advertisers"
        disable="categories|category_fields|pagination"
        entry_id="{embed:advertisers_entry_id}"
    }
        {if {absolute_results} == 1}
            {stash:recipients}{if "{advertiser_email}"}{advertiser_email}{if:else}{author}{/if}{/stash:recipients}
        {if:else}
            {stash:user_recipients}yes{/stash:user_recipients}
        {/if}
    {/exp:channel:entries}
{/exp:stash:set}

{!-- Use Stash variables in email contact form --}
{exp:email:contact_form
    charset="utf-8"
    form_class="customer-email-form"
    recipients="{exp:stash:recipients}"
    user_recipients="{stash:user_recipients}"
}
{/exp:email:contact_form}

```

The goal is to setup the email contact form to send to either one recipient or multiple sender-specified recipients. Unfortunately, the above code is not working properly and I suspect it's a parse order issue.

It seems like the Channel entry loop is not occuring, and thus my Stash variables are not getting set properly for the email contact form.

**Questions:**

1. How do I make the Channel entry loop work?
2. Once the Stash variables are properly set within the Channel entry loop, how do I use it in the email contact form?

I've tried various combinations of `parse="inward"`, `process="end"`, `parse_vars="yes"`, etc. No go.

# Answer
Hmm,

Using `{stash:set}` in your example will only ever record your last record. You could be better off using `{exp:stash:append}`

```
{exp:channel:entries
   channel="advertisers"
   disable="categories|category_fields|pagination"
   entry_id="{embed:advertisers_entry_id}"}
    //This will give a comma separated string
    {exp:stash:append parse_conditionals="yes" parse_tags="yes"}
      {stash:recipients}
        {if {absolute_results} == 1}
          {if advertiser_email}{advertiser_email},{if:else}{author},{/if}
        {/if}
      {/stash:recipients}
    {/exp:stash:append}
     //This is just set on the last entry
     {exp:stash:set name="user_recipients"}
       {if '{absolute_results}' != '1'}yes{/if}
     {/exp:stash:set}
{/exp:channel:entries}

{!-- Use Stash variables in email contact form --}
{exp:stash:parse} //Wrapping this ensures all stash'ing takes place before we use the values.
{exp:email:contact_form
    charset="utf-8"
    form_class="customer-email-form"
    recipients="{exp:stash:recipients}"
    user_recipients="{stash:user_recipients}"
}
{/exp:email:contact_form}
{/exp:stash:parse}

```

Ignoring the form part for now, output the results:

```
recipients = {exp:stash:recipients}
users = {stash:user_recipients}

```

This is all top-of-the-head, so dont take it as verbatim solution :)
> 1 votes

---
Tags: templates, stash, parse-order
---


# Question
Title: Working with multiple categories group, show not empty from only one category group
I am having trouble showing a list of **map** categories that are not empty but they must work in conjunction with the **countries** category group

No children categories needed

---

My categories setup

* Map group
    + Topographic
    + Geophysical
    + Geology

---

* Countries group
    + Kenya
    + South Africa
    + Tanzania

---

**Eg:**

* Entry one - Kenya & Geology
* Entry two - Kenya & Geology
* Entry three - Kenya & Geophysical

---

My result should be on this address

url: `/maps/category/kenya`

* Geophysical
* Geology

---

Any ideas, no luck with native categories and Gwcode categories tags. Any help is appreciated.

# Answer
> 0 votes
Leaving my solution here

I have used low2seg plugin and query. Little messy but it works.

`{exp:query sql="select * from exp_categories as ec where ec.`cat_id` in (select distinct cat_id from `exp_category_posts` where entry_id in (select entry_id from `exp_category_posts` where cat_id = {segment_3_category_id})) and group_id = 1"}
<option value="{cat_id}">{cat_name}</option>
{/exp:query}`

---

At the end of the query, ensure you choose selected cat\_id and group\_id

`where cat_id = {segment_3_category_id})) and group_id = 1"`

---
Tags: categories, gwcode-categories, category-group
---


# Question
Title: Sorting pictures with matching dates into galleries
I am attempting to build galleries of photos based on {photo\_date}, a custom field containing the date on which each photo was taken. My list of photos looks something like this:

```
Photo#   {photo_date}
1        11/1/14
2        11/1/14
3        11/1/14
4        11/16/14
5        11/16/14
6        11/22/14

```

My goal is to have a loop that allows only one photo to appear from each date "group." This photo will serve as the photo group's cover image. So, after running the script, I will end up with this:

```
Group 1: Photo#1 (11/1/14)
Group 2: Photo#4 (11/16/14)
Group 3: Photo#6 (11/22/14)

```

I am attempting to use a php variable inside of an EE loop to check to see if it matches:

```
           <?php $clip = "0"; ?>
           {exp:channel:entries channel="event_photos" dynamic="no" sort="asc" orderby="photo_date" search:photo_date="not IS_EMPTY"}
            <div class="clear floatnone">
                {if "{photo_event}{photo_event:url_title}{/photo_event}" == "<?php echo $currentSegment; ?>"} <!-- filter only this event's photos -->
                    Before add: <?php echo $clip; ?><br />
                    {if "{photo_date format='%m/%d/%y'}" != "<?php echo $clip; ?>"}
                        {title}<br />
                        <a href="{photo}" data-lightbox="{photo_date format="%m/%d/%y"}" data-title="{photo_caption}"><img width="150px" src="{photo}" /></a>
                    {/if}
                    <?php $clip = "{photo_date format='%m/%d/%y'}"; ?>
                    After add: <?php echo $clip; ?><br />
                {/if}
            </div>
            {/exp:channel:entries}

```

I think this should work, but it doesn't. It seems that the PHP variable ($clip) is getting assigned at the end of the {if} loop, but gets erased at the beginning once the loops starts over. This prevents me from checking to see if the {photo\_date} in question has been used or not in the previous iteration. I'm wondering how to get the variable to retain the intended value?

I appreciate any thoughts or maybe a more elegant solution!

# Answer
Have you considered just using Channel Images?
> 0 votes

# Answer
OK - so after reading this a few more times I think I have a clearer sense of what you may be doing.

If you're relating the event photos in one channel to events in another (I'm guessing this based on your \[{photo\_event}{photo\_event:url\_title}{/photo\_event}\] code, I think I'd do it the other way.

Start by running a query to select the date in question - use select distinct (or the :activerecord plugin ) Then relate that date to your photo and limit the relationship field to one result (try limit="1") in the tag. That should give you your dates with an image for each to correspond - with no php in your templates.

Also - not sure what/why that $currentSegment is in your code, but maybe check out Segment variables for what you need there?

If this is off base, then I still don't get what you're trying to do. :)
> 0 votes

# Answer
You could do this with the Stash add-on. There's an example in the docs called Sort a list of entries by year and then by month. You could use a simpler version of that example for your needs.

I created an example that doesn't include all of your HTML markup and custom fields (photo, photo\_caption, etc.). But this should get you started.

Step by step it works like this.

First, set a list of all your entries:

```
{exp:stash:set_list name="entries" parse_tags="yes"}
    {exp:channel:entries channel="event_photos" dynamic="no" sort="asc" orderby="photo_date" search:photo_date="not IS_EMPTY"}
        {stash:title}{title}{/stash:title}
        {stash:date_sort}{photo_date format="%m/%d/%y"}{/stash:date_sort}
        {stash:date_machine}{entry_date}{/stash:date_machine}
    {/exp:channel:entries}
{/exp:stash:set_list}

```

Make a copy of the same list containing only the `date_sort` dates (mm/dd/yyyy) so we can find all unique dates:

```
{exp:stash:set_list name="dates" parse_tags="yes"}
  {exp:stash:get_list name="entries"}
      {stash:date_sort}{date_sort}{/stash:date_sort}
  {/exp:stash:get_list}
{/exp:stash:set_list}

```

Then output the list of unique dates and a list of entries that match that unique date. The `date_machine` is used to order them within each unique date.

```
{exp:stash:get_list name="dates" unique="yes" orderby="date_sort" sort="desc"}

  <h1>{date_sort}</h1>

    {exp:stash:get_list:entries
        name="entries"
        match="#^{date_sort}$#"
        against="date_sort"
        orderby="date_machine"
        sort="asc"
        prefix="entry"
    }

      {if entry:count==1}
      <ul>
      {/if}

      <li>{entry:title} ({entry:date_sort})</li>

      {if entry:count==entry:total_results}
      </ul>
      {/if}
    {/exp:stash:get_list:entries}

{/exp:stash:get_list}

```
> 0 votes

---
Tags: php, variable, loop
---


title: Links to PDF don't work in File Manager

text:
# Question
Title: Links to PDF don't work in File Manager
I have a strange issue. EE 2.6.1.

I can upload and view PDF files. However the file names in the Manager are not links to the files themselves. The manager works fine with images JPG, PNG but doesn't with PDF.

All insights are appriciated!

# Answer
I think that linking non-image files didn't start happening until 2.7.0. In the docs for the 2.7.0 update under General Changes: "All files regardless of type are now linked for viewing in the File Manager."
> 1 votes

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


title: Trying to nest Low Variables

text:
# Question
Title: Trying to nest Low Variables
I have an article page and at the bottom I'd like to show a list of related articles. I'm using Solspace's Tag add-on to generate the list. In order to generate the list I've created a Low Variables snippet called *lv\_sn\_related\_articles* where I pass in the entry id of the entry:

```
{exp:low_variables:parse var='lv_sn_related_articles' preparse:entry_id='{entry_id}'}

```

I then use this variable within the Low Variable snippet along with the Tag tags:

```
{exp:tag:related_entries channel="articles" entry_id="{entry_id}" orderby="relevance" status="open|featured" limit="3" sort="asc" rank_limit="5" rank_method="total_entries"}
  <li>{exp:low_variables:single var="lv_sn_article_block"}</li>
{/exp:tag:related_entries}

```

Within this snippet I have another Low Variables snippet called *lv\_sn\_article\_block* which is an article block style I will use in various other parts of the site:

```
<li>
  <article class="ArticleBlock">
    <div class="ArticleBlock-meta">
      {categories limit="1"}<span class="ArticleBlock-category"><a href="{path=/}">{category_name}</a></span>{/categories}
    </div>
    <div class="row">
      <div class="small-4 medium-12 columns">
        <a href="/article/{entry_date format='%Y/%m/%d'}/{url_title}">
          {article_hero_image}<img class="ArticleBlock-image" src="{exp:ce_img:pair src="{url}" width="500" height="281" crop="yes" save_type="jpg" allow_scale_larger="yes" quality="81"}{made}{/exp:ce_img:pair}">{/article_hero_image}
        </a>
      </div>
      <div class="small-8 medium-12 columns">
        <header>
          <h2 class="ArticleBlock-heading"><a href="/article/{entry_date format='%Y/%m/%d'}/{url_title}">{title}</a></h2>
          <p class="ArticleBlock-byline">
            By <a class="ArticleBlock-author" href="/author/{username}">{author}</a>, <span class="ArticleBlock-dateline">{entry_date format="%M %d, %Y"}</span>
          </p>
        </header>
        <p class="ArticleBlock-deck">{article_lead}</p>
      </div>
    </div>
  </article>
</li>

```

The problem I'm getting is that this article block does not parse. I just get the bare template tags. If I take the article block code and put it directly into the *lv\_sn\_related\_articles* the tags render normally. So something is happening with the nested *lv\_article\_block* that is causing it to not parse. How can I make this work or can it?

# Answer
> 2 votes
Ah, Parse Order.

This particular issue takes place in phase #5 of the linked PDF: parsing of module and plugin tags. This works as follows:

The first `{exp:`-tag encountered in the template is parsed. When the tag is done, the parser starts again, parsing the first `{exp:`-tag it encounters then. This goes on and on until there are no more `{exp:`-tags left.

So, in your case, the first `{exp:low_variables:parse}` tag is parsed. That results in a `{exp:tag:related_entries}` tag. So that is parsed. Which results in X entries, and subsequently, X `{exp:low_variables:single}` tags. Then, one after another, each of those are parsed. But since the variables in there should have been parsed by the Related Entries tag, but that one has already been, the vars remain unparsed.

The only way around it, is to take the content of the `lv_sn_article_block` var, and place it directly inside the Related Entries tag. This might result in duplicate code, but with your current setup, that's inevitable.

---
Tags: low-variables, solspace-tag
---


# Question
Title: Why do anchors in my links break after pagination?
I have this link in a channel entry list template:

`<a href="{site_url}/{segment_1}/{url_title}#primary">`

It works fine until page 2 and beyond. It's like ExpressionEngine's pagination is stripping off the `#primary` anchor. Anyone know what's going on here?

# Answer
> 1 votes
So jchrono-battle is correct in that anchor tags (properly known as fragment identifiers) are never sent to the server, but that doesn't seem to be the issue. OP stated the issue is the anchor is never being rendered to the page, not that the server doesn't know what the anchor is.

I would check to be sure that any templates, snippets, embeds, etc. are named properly and all needed data is being included as expected. I suspect this is a user error rather than an EE error.

# Answer
> 0 votes
I just answered something like this so I'll give you same answer:

**Anchor tags are never sent to the server, and EE can't strip them from your urls.**

However, you most likely have an addon on that template that IS doing a redirect to itself. In that situation, it can't see your anchors anyways, so it can't redirect you somewhere with a *client side* anchor after the URN because it doesn't see them. Or your local machine (browser) is stripping them. Not sure.

But I'd definitely guess you have a redirect issue, like a {segment\_1} is making EE redirect because it doesn't exists.

---
Tags: channel-entries, pagination, links
---


# Question
Title: Solspace Tag: Pagination generates %20-links, despite correct websafe-setting
when I use the pagination inside the exp:tag:entries-loop the links generated look like

```
xy.com/blog/tag/Tipps%20für%20Lehrer/P10

```

instead of

```
xy.com/blog/tag/Tipps+für+Lehrer/P10

```

It's exactly the same problem which is asked here (but not solved), except I am not using stash. Thread-starter Davor Peic tried with a spartanic clean template and had the same problem.

Therefore I do not molest you with my code but just want to ask if you could verify that this is a bug or not. Thanks.

# Answer
> 1 votes
This is also issue with EE pagination, which Tag uses: if you use the same URL, eg `http://example.com/entries/two+apples` with pagination in `{exp:channel:entries}`, the pagination URL can become `http://example.com/entries/two apples`. Spaces in URLs render as `%20` in the address bar, which is the URL entity equivalent of a space.

There is possibly a way to prevent `+` to convert to a space by making trial-and-error changes in .htaccess, but another method could be to enable PHP in your templates and put a search & replace function to convert spaces to `+` in pagination urls:

```
<?php echo str_replace(' ', '+', '{pagination_url}'); ?>

```

I posted this answer in the wrong thread earlier, but answering your follow-up question, you can use PHP, but plugins (of the search & replace type) *might* be able to do the same. Unfortunately this issue is because if the EE pagination library, and how it handles the generation of pagination code.

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


# Question
Title: Is there a limit to Pages in Pages Module?
I've been working on moving a ton of content around on a large University site. I'm suddenly encountering a problem where the Pages module gets zeroed out. Pages start breaking all over the site, and when I go to the Pages Module, there are no entries in the listing.

Is there a limit to the number of pages I can put in the pages module? Could this be a different issue?

I also notice that the pages aren't nested properly (at least how I would think they would be nested) in the pages module. Example:

```
+foo
++foo/bar
++superman

```

Or worse:

```
+superman
++foo
++foo/bar

```

When foo has nothing to do with Superman, at all. Am I not reading the pages nested output right? Is something other than URI segments driving that nesting?

EE 2.9.2 , Pages 2.2

Thanks!

# Answer
> 1 votes
I'm not sure there is a hard "## number of pages is too many" answer - but 880 is certainly pushing the Pages Module way past what it was designed for. See my writeup on the history of the pages module.

The Pages Module wasn't developed to be the basis of building the nav for an entire site and you are seeing the results of trying to do so.

---
Tags: pages
---


# Question
Title: module template tag looping thru values in module template tag
I am building a module and I am looping thru data to set a value for each key, to be used as EE template tags.

```
foreach($missing_fields as $field)
{
    $count++;

    $vars = array(
        'field_id'              =>  $field->m_field_id,
        'field_name'            =>  $field->m_field_name,
        'field_label'           =>  $field->m_field_label,
        'field_type'            =>  $field->m_field_type,
        'field_list_items'      =>  format_list_items($field->m_field_list_items),
        'count'                 =>  $count,
        'total_fields'          =>  count($missing_fields),
    );

    $out .= $this->EE->TMPL->parse_variables_row($this->EE->TMPL->tagdata, $vars);
}

return $out;

```

In the template, I want to display the field's label, which works, when it is a select field (notice conditional), I want to be able to loop thru the values.

```
{exp:module_name:form}

    <label>{field_label}</label>

    {if field_type == "select"}
    <select name="{field_name}"
        {field_list_items}
            {!-- loop thru each select value --}
            <option value="{select_item}">{select_item}</option>
        {/field_list_items}
    </select>
    {/if}

{/exp:module_name:form}

```

I created a format\_list\_items helper function that just returns a basic array of data for testing purposes.

```
return array('value 1', 'value 2');

```

I looked at the user module to see if they did anything like this in the profile edit functions & also looked at EE's myaccount.php line 364 (in edit\_profile function).

# Answer
Tag pairs need to be formatted correctly as an array of arrays like this. Just think of the tag pair as a module tag, and the arrays as the `$vars` variable in your example above.

```
$field_list_items = array(
    array('select_item' => 'value 1'),
    array('select_item' => 'value 2'),
    ...
);

```
> 1 votes

---
Tags: templates, add-on-development
---


# Question
Title: I sound like a newb, but is CKeditor supposed to be installed onto the root of EE so Wygwam can actually work?
ok so this sounds basic;

1. I've installed latest wygwam 3.3.3 and seemed to install fine.
2. ok so is CKeditor supposed to be installed onto EE on the root? Because between CKeditor's lack of answers for installation with EE and wygwam's lack of explaining how CKeditor is installed with its product, I'm lost.
3. any help is appreciated! thanks!

# Answer
You shouldn't have to do anything but install Wygwam. CKeditor is just installed under Wygwam, you can find it in

```
themes > third_party > wygwam > lib > ckeditor

```
> 1 votes

# Answer
If you've installed the addon correctly, you do not need to do *anything* with CKeditor.

Make sure you've copied these folders:

```
Wygwam3.3.3/themes/third_party
-> copy to
your-web-root/themes/third_party

Wygwam3.3.3/ee2/third_party/
-> copy to
your-web-root/system/expressionengine/third_party

```

and then make sure you install the addon through the Add-ons -\> Modules page in the back end. IF you're looking to use CKeditor separately from EE, you can find the copy that comes with Wygwam in this folder (from the installation folder):

```
Wygwam3.3.3/themes/third_party/wygwam/lib/ckeditor

```

But it might be a modified fork of CKeditor (probably is) for use with Wygwam, so if you need to use it separatly, I would recommend downloading it separately.
> 0 votes

---
Tags: wygwam, ckeditor
---


# Question
Title: Staging & Production server settings - how to manage?
I'm currently working in a development server and have certain conditions in my templates that rely on, say, entry\_id. When I migrate the site to a production server, that entry\_id is bound to change.

What's an effective approach to handling these environmental variables?

# Answer
You have a few options.

1. While in development, frequently clone your database from production to dev, which reduces the chance that they will diverge significantly.
2. Try to reduce situations where you rely on the entry ID. Find other things that you can control better, like making a decision based on some distinguishing data in the entry itself, or if you use Structure, setting the template to something special.
3. If you use master.config, create a global that defines which entry\_id to use, and set it per environment, just like database settings are set per environment.

At the agency I work for, we've used all of these techniques. It's just a question of which is appropriate for your current task.
> 4 votes

---
Tags: deployment
---


# Question
Title: Fatal error: Call to undefined method EE_Javascript
I upgraded my EE to 2.9.3 and I am running Expresso-Store 1.6.3. Now I am getting an javascript error.

Fatal error: Call to undefined method Cp::set\_variable() in /home2/oldspani/public\_html/osd/expressionengine/third\_party/store/mcp.store.php on line 65

# Answer
Unfortunately I found out. that Store 1.6 I believe ends support at 2.7.3.
> 1 votes

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


# Question
Title: solspace super search 'super_search_keywords' and 'csrf_token' tags not parsed
EE 2.7.2 MSM

I've just installed SOlspace Super Search and added the simple form example from teh docs but neither the {super\_search\_keywords} or {csrf\_token} tags are getting parsed, both are rendered literally.

```
        <form method="post" action="{path='search/results'}" role="form">
            <input type="hidden" name="csrf_token" value="{csrf_token}" />
        <input type="text" name="keywords" id="keywords" value="{super_search_keywords}" placeholder="Find a resource" />
        <button type="submit" name="commit" value="draft"></button>
        <div style="clear:both"></div>
    </form>

```

I can't see any config that I've missed, is there something else that needs to be included on the form page?

# Answer
> 1 votes
`csrf_token` has been introduced in EE 2.8+. See http://www.solspace.com/docs/super\_search/search/#csrf\_token

EE 2.7.x used `XID` before it was renamed to `csrf_token`. Therefore, you need to add an XID hash instead if you're on EE 2.7.x:

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

```

---
Tags: solspace, csrf
---


title: Individual blog for each member

text:
# Question
Title: Individual blog for each member
I need to allow members to create their own blogs. Is it possible? If yes, so how can I realize such ability?

# Answer
You'll just need to have a system that allows you to determine the author\_id of the current blog and use the `author_id=""` parameter. You can have them build profiles using Profile:Edit or ZooVisiter.

However, as Michael said above, make sure it's fine with ExpressionEngine and complies with their policies.
> 1 votes

---
Tags: members
---


title: Using Category URL Title in Segment 1

text:
# Question
Title: Using Category URL Title in Segment 1
Is it possible to use category\_url\_title in the first segment without having to create a template group for each category? I'd just like to link to categories on the fly using the first segment (site.com/news, site.com/athletics) and using just one template group. Possible?

# Answer
> 1 votes
I was able to solve this easily using Resource Router. In my master config file I added the following and it works like a charm:

```
$env_config['resource_router'] = array(
    ':category_url_title' => 'category/index',
    ':category_url_title/:pagination' => 'category/index',
);

```

# Answer
> 1 votes
Yes. I've touched on it in this answer using segment\_2, but the same is true for segment\_1 - you just have to rely on the default template group and the index template. There may be a lot of pages routing through it, so lot's of conditionals on where it should go/do (maybe embeds to different category templates, or they all look the same pulling in different data). You may get issues if you have strict URLs as it may encounter 404, I just tested it and needed to disable strict URLs in template preferences. Utilise Seg2Cat to convert urls to IDs.

Ensure you don't get a clash with an existing template group or template name.

Edit:

Had another build with Strict URLs set and had this in the .htaccess:

```
RewriteCond $1 ^(sitemap_index\.xml|sitemap\.xml|product-feed\.xml) [NC]
RewriteRule ^(.*)$ /root/$1 [L]

```

Granted this is to access a specific page (removing the template group) not a category, but if the first part of this answer doesn't work or you need strict URLs give the above a go, where you spcifically name the template to go to in the rewrite rule.

Not utilised it before, but template routes might also be worth exploring.

---
Tags: categories, url, segments, resource-router
---


title: Breaking News drop down

text:
# Question
Title: Breaking News drop down
looking for an EE plug-in/add-on to enable a breaking news drop down banner like on CNN:

Thanks, Marc

# Answer
An add-on shouldn't be strictly necessary to achieve this, EE is perfectly suited to handle "Breaking News", "Announcements", etc. natively.

We have added similar **Alert Banners** on clients sites by creating a dedicated 'Announcement' channel. We render these entries above/below the site-banner and usually limit to `1`result at a time. Sometimes we will add additional filters to the result to only show the announcement for `x hours` after the entry is published, and allow this default to be overridden by the `expiration_date` if it is set.

That, of course, assumes you want to editorialize your alerts. You could also add a specific status or category to an existing channel to indicate breaking-news. Filtering by this parameter, you show the announcement details as above by pulling details such as title and excerpt from the existing entry.

Similar results could be had by limiting to one result at a time and hiding after a given time has passed for RSS feeds, comment feeds, etc.
> 4 votes

---
Tags: add-on, drop-down
---


# Question
Title: Configure to allow EE site to be accessed from more than one domain?
Is there a way to configure EE to allow it to be accessed from more than one URL? Our site has some multilingual capabilities, and we would like to be able to offer users in some areas the ability to access the site from domains that are appropriate for the language.

We are having problems when the Site URL and Themes URL are not based off the same FQDN.

If we put the FQDN in the "Site URL" field, the site overwrites the inbound URL with the site URL on the first click within the site.

If we replace the FQDN with "/" the site works OK for browsing and preserves the inbound DN in the URL. However resources accessed via the Themes URL setting (e.g. Font Files) fail as browser fail to load them due to 'cross-origin resource sharing' preferences.

If we replace the Themes URL with "/themes" we get various page-link 'not found' errors when trying to access pages via category based links.

Is there an established solution to this issue? I cannot believe we are the first to encounter it...

Thanks a lot in advance for any / all help.

# Answer
It sounds like you need to take a look at the Multiple Site Manager add-on from EllisLab.
> 1 votes

# Answer
What are you trying to accomplish? We typically allow multiple domains to point to the same site, but then use .htaccess to redirect them to a single, canonical domain. This would prevent your issue, as well as protect you from duplicate content SEO penalties.
> 1 votes

# Answer
Isn't that hard to make a bilingual website.

On your `config.php`, set some variables on a domain basis. For example:

```
$protocol      = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 'https://' : 'http://';
$domain        = str_replace('www.', '', $_SERVER['HTTP_HOST']);
$base_url      = $protocol . $_SERVER['HTTP_HOST'];

$config['site_url'] = $base_url;
$config['cp_url'] = $base_url.'/system.php';

$config['avatar_path'] = $_SERVER['DOCUMENT_ROOT'] . '/images/avatars';
$config['avatar_url'] = $base_url.'/images/avatars/';
$config['captcha_path'] = $_SERVER['DOCUMENT_ROOT'] . '/images/captchas';
$config['captcha_url'] = $base_url.'/images/captchas/';
$config['theme_folder_path'] = $_SERVER['DOCUMENT_ROOT'] . '/themes';
$config['theme_folder_url'] = $base_url.'/themes/';
$config['path_third_themes'] = $_SERVER['DOCUMENT_ROOT'] . '/addons_themes';
$config['url_third_themes'] = $base_url.'/addons_themes/';

```

For the language settings:

```
global $assign_to_config;
if(!isset($assign_to_config['global_vars']))
$assign_to_config['global_vars'] = array();
if ( $domain == 'domain.com.br')
{
    $assign_to_config['xml_lang']   =
    $assign_to_config['language']   = 'pt';
    $config['reserved_category_word'] = 'categoria';
}
else // the default domain
{
    $assign_to_config['xml_lang']   =
    $assign_to_config['language']   = 'en';
    $config['reserved_category_word'] = 'category';
}

```

To use root relative links to all your assets is a good idea too.
> 1 votes

---
Tags: ee, config
---


# Question
Title: Channel Entries - searching relationship field?
SEE: Channel Entries - possible to search relationship field?

**Has anything changed since the above question?** I want to list all Channel entries for a given value in a relationship field. Something like this:

`search:my_relationship:url_title="foo"`

**EDIT 1:**

I didn't explain my problem properly. My Channel has a grid. The grid has a relationship field. When I loop through the grid entries, I want to apply a search filter to it.

# Answer
This is easy using Low Search and its Relationships filter. You don't necessarily need a search form, as you can use the Results tag as a drop-in replacement for the channel:entries tag. Then you can use this parameter:

```
{exp:low_search:results child:rel_field="1|2|3"}

```

...which will give you all entries that have entry ID 1, 2 or 3 assigned to them as a child.

Or:

```
{exp:low_search:results child:rel_field="foo"}

```

...which will give you all entries that has the entry with URL-title 'foo' assigned to them as a child.

The reverse is also possible:

```
{exp:low_search:results parent:rel_field="4|5|6"}
{exp:low_search:results parent:rel_field="bar"}

```
> 2 votes

---
Tags: channel-entries, relationships, grid, related-entries, reverse-related-entries
---


title: How to create a Grid field in extension

text:
# Question
Title: How to create a Grid field in extension
I’m creating an extension that on installation, programmatically creates a channel and fields for that channel.

One of the fields I’d like to create is a Grid field to store PDF documents against an entry. But reading through ExpressionEngine’s documentation on the channel fields API there’s no mention of Grid, and I can’t find anywhere that specifies the options for creating a Grid field.

What options do I need to specify? So far I have this:

```
array(
    'field_name' => 'floor_plans',
    'field_label' => 'Floor Plans',
    'field_type' => 'grid',
    'field_order' => 30,
    'field_instructions' => 'The floor plans for the property',
    'field_required' => 'n',
    'field_search' => 'n',
    'field_is_hidden' => 'n',
),

```

This creates the Grid field, but there are no inputs to enter data.

# Answer
> 1 votes
Have you had a look at the Grid Model that is in the system folder? Specifically /system/expressionengine/models/grid\_model.php

This model has methods for creating new Grid Fields (create\_field on line 140), add and update columns (save\_col\_settings on lone 235) and saving data into the grid (save\_field\_data on line 689). Is this the API you are looking for?

Surfice to say, this Model shows you the code to create grids, columns and data. With a little searching you could probably find the code that calls these model functions for examples on how to use (appologies I don't have a test enviroment to post actual code for you atm) I suspect in the /system/expressionengine/fieldtypes/ft.grid.php is a good place to start for this. Another place is the apply\_settings function on line 606 of /system/expressionengine/fieldtypes/libraries/Grid\_lib.php

In order to load and use the model, all you need to do in your model is :

```
//load the Grid Model
ee()->load->model('grid_model');

//create a new Grid field (PSEUDO)
$settings = array(
    'settings_for_grid' => true
);
$new_field = ee()->grid_model->create_field($settings, 'grid');

//create a column on the new grid
$col_id = 1;
$col_settings = array(
    'settings_for_column' => true
);
$col_ids[] = ee()->grid_model->save_col_settings($col_settings, $col_id = 1, 'grid');

```

Seems straight forward enougth, although determining your settings (for the columns look to like 645 ;) ) might be a pain it should work, after all this is how the admin CP creates the fields!

Let us know how you get on mate!

# Answer
> 0 votes
I've been sitting back waiting for an API of some kind to show up, but I haven't been able to find anything. You have created the grid field, but it doesn't have any columns. I believe you are going to have to manipulate the `exp_grid_columns` table manually.

```
$field_id = 0; //THE FIELD ID RETURNED BY THE INSERT ABOVE

$grid_column = array(
    'field_id' => $field_id,
    'content_type' => 'channel',
    'col_order' => 0,          //order of the columns
    'col_type'  => '',         //field type name (text, textarea, assets)
    'col_label' => '',         //the name of the column
    'col_name' => '',          //the short_name of the column
    'col_instructions' => '',  //instructions for the column
    'col_required' => 'n',     //is this column required
    'col_search => 'n',        //is this column searchable
    'col_width' => 0,          //zero is auto
    'col_settings' => ''       //the settings for the field type
);
$query = ee()->db->insert("grid_columns", $grid_column);

```

What I would suggest, is to create a grid fieldtype the way you would like through the channel fields editor, and then look at the grid\_columns table to get an idea of how it's set up.

---
Tags: grid, extension, channel-fields, api
---


# Question
Title: Overriding ORDERBY and SORT on channel:entries and output entries in order given by embedded entry_id list
Is it possible to ignore the `ORDERBY`/`SORT` parameters in an `exp:channel:entry` tag and display the entries as given in a list of IDs?

I have a embedded template where I pass down a list of entry IDs to render out. I would like to output the entries in the order they are passed down as entry\_ids. Is this possible?

Here's my current loop:

```
{exp:channel:entries channel="events" entry_id="{embed:ids}" sort="asc"  orderby="status" limit="5"}

```

Where `{embed:ids}` is the list of entries I would like displayed, in the order I would like. I.e. `5|1|3|7`. But there is no parameter which will not re-arrange the output order (by date, author, etc..).

Do I need to use the query module to achieve what I want here? It seems EE will try to arrange by date whenever possible.

For full clarity's sake. This is part of a ChannelForm Newsletter creator that selects events and then submits a list of entries as bar `|` separated entry\_is into a input for a given issue. This is then renderd into an email template to be used later.

# Answer
Sounds to me that the `fixed_order` parameter is exactly what you are looking for.

Related: Expression Engine Entries Loop in Reverse
> 2 votes

# Answer
You can use the `fixed_order="{embed:ids}"` parameter.

Documentation can be found here.
> 2 votes

# Answer
~~Just FYI, if you give the channel:entries tag 'entry\_id' parameter, without the order parameters, the output will be in the order specified in entry\_id parameter. Just like the fixed\_order parameter, which is the correct answer above.~~ See comments below, my bad, living in the past!
> 0 votes

---
Tags: channel-entries, entries, orderby, sort, entryid
---


# Question
Title: form validation for module mod file template tags
I am creating a dynamic form on the fly for use in EE templates. I create the tags using the mod.module\_name.php file of my module.

I am trying to run validation on the form, every field is required so I have a separate array in the loop that assigns the fields to template tags, to be returned to the template for the user to use those template tags to construct the form in their template.

I have a separate function in the mod.module\_name.php file that I have registered as an action in the actions table for it to process/post that form to that function. I tried to store the form validation in a session to check to make sure all those fields have a value in it, but it does not allow me to store that in session.

Below is my update\_form function that will display opening and closing form tag and within it will be the form fields

```
public function update_form()
{
    $action = $this->EE->functions->fetch_site_index(0, 0).QUERY_MARKER.'ACT='.$this->EE->functions->fetch_action_id($this->classname, 'process_update_form');

    $form_details = array(
        'action' => $action,
        'secure' => TRUE,
        'id'        =>  $this->EE->TMPL->fetch_param('form_id', 'profile_update_form'),
        'class'     =>  $this->EE->TMPL->fetch_param('form_class', ''),
    );

    $out = $this->EE->functions->form_declaration($form_details);

    for($i = 0; $i < count($missing_fields); $i++)
    {
        // this array will be used for setting the form validation rules
        $missing_field_validation[] = array(
            'field' => 'm_field_id_ ' . $missing_fields[$i]->m_field_id,
            'label' =>  $missing_fields[$i]->m_field_label,
            'rules' =>  'required',
        );

        $vars = array(
            'field_id'              =>  $missing_fields[$i]->m_field_id,
            'field_name'            =>  $missing_fields[$i]->m_field_name,
            'field_label'           =>  $missing_fields[$i]->m_field_label,
            'field_type'            =>  $missing_fields[$i]->m_field_type,
            'field_list_items'      =>  format_list_items($missing_fields[$i]->m_field_list_items),
            'count'                 =>  $i+1,
            'total_fields'          =>  $total_missing_fields,
        );

        $out .= $this->EE->TMPL->parse_variables_row($this->EE->TMPL->tagdata, $vars);
    }

    return $out;
}

```

Below is the form that is triggered (it is registered in the actions table), I need to set the form\_validation with the $missing\_field\_validation array without the need of using front-end validation.

```
public function process_update_form()
{
    // get form data and update it
    if ($this->EE->security->check_xid($this->EE->input->post('XID')) == FALSE)
    {
        // No data insertion if a hash isn't found or is too old
        $this->EE->functions->redirect($this->EE->functions->form_backtrack());
    }
}

```

Template tags, just in case it helps you understand what I am trying to accomplish:

```
{exp:profile_reminder:update_form}
    <p>{field_id}</p>
    <p>{field_name}</p>
    <p>{field_label}</p>
    <p>{field_type}</p>
    <p>Total: {total_fields}</p>

    {if count==total_fields}
        <input type="submit">
    {/if}
{/exp:profile_reminder:update_form}

```

# Answer
Looks like you're looking for the Forn Validation library that is inherited from CodeIgnitor.

What you seem to be trying to do is set the validation rules at thes same time as setting up the form, whereas what you should do is set up the form as you do, but remove the $missing\_field\_validation setting as we don't need the validation rules yet! Instead we set up validation in the reciving action...

In your recieving action, you can load the form validator as so :

```
ee()->load->library('form_validation');

```

Then you can iterate your $missing\_fields/vars array, adding the required rules (any any others), finally running the form\_validation to get a nice little boolean for validity. All in, something like this :

```
public function process_update_form()
{

    // get form data and update it
    if ($this->EE->security->check_xid($this->EE->input->post('XID')) == FALSE)
    {
        // No data insertion if a hash isn't found or is too old
        $this->EE->functions->redirect($this->EE->functions->form_backtrack());
    }

    //validate form, load the validator
    ee()->load->library('form_validation');

    //add the rules
    for($i = 0; $i < count($fields); $i++)
    {
        ee()->form_validation->set_rules(
            $fields[$i]->m_field_id,
            $fields[$i]->m_field_label,
            'required'
        );
    }

    //run validation
    if ( ee()form_validation->run() === true ){
        //SUCCESS, Valid action here
    } else {
        //MASSIVE FAIL, Invalid action here
    }

}

```

Last little note, you may not need to check the XID as you are doing if you use the form validator, as the validator will check this for you anyway (or rather the post router)!

For me, I'd move away from trying to pass your validation rules along with the form, instead as you construct your form from the field array in the first place, use the same field array to drive your setting of the validation rules and play the CI way!

Let us know how you get on (tick the answer box if this is of help to you!) :)
> 1 votes

---
Tags: add-on-development, forms, module, validation
---


title: Single entry not relating to url title

text:
# Question
Title: Single entry not relating to url title
I am building landing pages that will be used as direct links, not from a list on a catch all type page. I want to use one template, no categories. I am showing content from two different channels, one for the landing page and one for the "program" area. I am using an embed and {if} statements for the program channel that is nested within the other.

This all seems to be working, although to have the embedded program channel content display, I have to include the folder structure in the url\_title field for the entry (so, instead of just putting "caribbean\_culture" or "examine\_change" in the url\_title field, I'm having to put "template\_group/template/url\_title" or else the embedded channel content won't show up.) And then after it saves, its converted to template\_group\_template\_url\_title.

However, I'm not able to have the URL pull the specified entry. Instead, it just pulls the first or the last, depending on how I have the sort set up. So, using this:

```
{exp:channel:entries channel="landing" disable="member_data|pagination" sort="desc" limit="1"}

```

I get the same entry for either of these URLs, although they should actually show different entries:

http://www.sea.edu/learn\_more/sea\_semester\_voyages/caribbean\_culture http://www.sea.edu/learn\_more/sea\_semester\_voyages/examine\_change

If I change the sort to 'asc' in the channel:entries tag, then I do see the other entry, but again, at both URLs. I have the functionality of the single entry displaying on a page working on other templates in the site, but they are fed by an initial link on another page, that uses

```
href="template/{url_title}"

```

to build the page.

Is there some parameter to include in the channel:entries tag that uses the url\_title to dictate the entry that is on the page that matches the URL? Or some other solution?

I tried "require\_entry" to no avail.

# Answer
Didn't fully understand your question, so i updated this answer. First you pull the right entry from the landing pages channel, close the channel:entries loop, and open another loop for the entries in the other channel. note that you need to use **dynamic="no"** otherwise the template parser will get confused.

So your landing page will look like this:

```
<html>
{exp:channel:entries channel="landing" disable="member_data|pagination|categories" sort="desc" limit="1" url_title="{segment_3}" dynamic="no"}
-- your content --
{/exp:channel:entries}
{exp:channel:entries channel="program" disable="member_data|categories" sort="desc" dynamic="no" paginate="bottom"}
-- your content --
{/exp:channel:entries}
</html>

```

if you need content from the landing channel after the program block, you might want to use an embed/snippet for the program entries.
> 0 votes

# Answer
You could use the Pages module to do this, or even template routing if you are using the latest version of EE.

The Pages module is probably simplest for you and will allow you to assign an arbitrary url to any entry you create.
> 0 votes

# Answer
From the sounds of it you are trying to use the URL to drive your entries tag (i.e. dynamic="yes") but its not playing fair. I am afraid I can't help with that in particular as I avoid this URl stuff like the plauge!

Can I ask, have you set up a custom route setting for the section on the site?

Otherwise another solution would be to pass the segment variable straight into your channel entries tag :

```
{exp:channel:entries dynamic="no" url_title="{segment_3}" channel="landing" disable="member_data|pagination"}
     {!-- do stuff --}
{/exp:channel:entries}

```
> 0 votes

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


# Question
Title: We need some functionality to be done using solspace Favorites
We don't found below thing's. Please let me know weather this think are possible

1) Does we can add single file from grid in favorite?

2) We need collection date of particular user. can it be possible?

3) Can we delete more than one favorite from list at a time?

# Answer
1. No, you cannot favorite a Grid field column. You can only favorite *channel entries* or *members* at this time.
2. Each favorited entries/members has a timestamp for when it was favorited, but there is no timestamp for the actual collection itself. However, if you're looking for the date when an entry/member was favorited *in a collection*, that is possible to look for (using `{exp:favorites:info}` or `{exp:favorites:entries}`/`{exp:favorites:members}`, for example)
3. The `{exp:favorites:delete_all}` tag might be useful in this case: http://www.solspace.com/docs/favorites/delete\_all/
> 1 votes

# Answer
I also having the same problem so we change plan grid to relationship of that field.

But also that time having some problem need submit more then one entries submit at same time in sol space favorite.

I mean to say adding multiple entries at a time in favorite list.

Any one having any suggestion for that so please let us know.
> 0 votes

---
Tags: solspace
---