# Question
Title: Problem with Safecracker fields not rendering
I am having an issue with a long safecracker form.

The form requires several fields that collect the same information for multiple people.

For example, there are fields like first name, last name, age, etc and those are duplicated for up to 4 people.

I have created separate channel fields for each and appended an underscore and a number to the field's short name (i.e. first\_name, first\_name\_2, first\_name\_3, etc).

The problem I am running into is that the fields seem to be conflicting with each other even though they are named something totally different.

It causes all of the fields that appear first in the form (i.e. first\_name) to not render and the page just displays the EE field tags.

It seems to only effect select drop down, radio button and checkbox fields.

I am not using the custom\_fields loop, but am using options:my\_field\_name for each field.

Any thoughts on why this might be happening?

Thanks for any help.

Here is the code. I have cut it down quite a but, but sorry for the length. The section that starts with the header Driver 2 shows the duplicate fields. I have stripped out the Driver 3 & Driver 4 sections to shorten the code length, but when those are added in, it compounds the issue.

Everything in the Primary Driver Info section works fine, until the Additional Driver sections are added in.

```
{exp:safecracker channel="auto_requests" author_only="yes" url_title="{segment_3}" include_jquery="no" safecracker_head="no" preserve_checkboxes="yes" return="customer/request-thanks" class="request-form" id="request-form" }

Primary Driver Info

                                First Name
                                <input type="text" id="auto_first_name" name="auto_first_name" value="{auto_first_name}">

                                Last Name
                                <input type="text" id="auto_last_name" name="auto_last_name" value="{auto_last_name}">

                                        Middle Initial
                                        <input type="text" id="auto_middle_initial" name="auto_middle_initial" value="{auto_middle_initial}">

                                        Age
                                        <select id="auto_age" name="auto_age">
                                            <option value="">Select One</option>
                                            {options:auto_age}
                                            <option value="{option_value}"{selected}>{option_name}</option>
                                            {/options:auto_age}
                                        </select>

                                        Gender
                                        {options:auto_gender}

                                            <input type="radio" id="auto_gender_{option_name}" name="auto_gender" value="{option_value}"{checked}>
                                            {option_name}

                                        {/options:auto_gender}

                                        Marital Status
                                        <select id="auto_marital_status" name="auto_marital_status">
                                            <option value="">Select One</option>
                                            {options:auto_marital_status}
                                            <option value="{option_value}"{selected}>{option_name}</option>
                                            {/options:auto_marital_status}
                                        </select>

                                        Driver's License Number
                                        {field:auto_dl}

                                        Driver's License State
                                        <select id="auto_dl_state" name="auto_dl_state">
                                            <option value="">Select One</option>
                                            {options:auto_dl_state}
                                            <option value="{option_value}"{selected}>{option_name}</option>
                                            {/options:auto_dl_state}
                                        </select>

                                Is your license currently valid?
                                {options:auto_valid_license}

                                    <input type="radio" id="auto_valid_license_{option_name}" name="auto_valid_license" value="{option_value}"{checked}>
                                    {option_name}

                                {/options:auto_valid_license}

                                Social Security Number
                                {field:auto_ss}

                                Street Address
                                <input type="text" id="auto_address" name="auto_address" value="{auto_address}">

                                City
                                <input type="text" id="auto_city" name="auto_city" value="{auto_city}">

                                        State
                                        <select id="auto_state" name="auto_state">
                                            <option value="">Select One</option>
                                            {options:auto_state}
                                            <option value="{option_value}"{selected}>{option_name}</option>
                                            {/options:auto_state}
                                        </select>

                                        Zip
                                        <input type="text" id="auto_zip" name="auto_zip" value="{auto_zip}">

                                Phone
                                <input type="text" id="auto_phone" name="auto_phone" value="{auto_phone}">

                                Do you have any dependents (children, dependent spouse, etc.)?
                                <select id="auto_dependents" name="auto_dependents">
                                    <option value="">Select One</option>
                                    {options:auto_dependents}
                                    <option value="{option_value}"{selected}>{option_name}</option>
                                    {/options:auto_dependents}
                                </select>

                                Do you lease or own your residence?
                                <select id="auto_residence" name="auto_residence">
                                    <option value="">Select One</option>
                                    {options:auto_residence}
                                    <option value="{option_value}"{selected}>{option_name}</option>
                                    {/options:auto_residence}
                                </select>

                                What’s the highest level of education you’ve reached?
                                <select id="auto_education" name="auto_education">
                                    <option value="">Select One</option>
                                    {options:auto_education}
                                    <option value="{option_value}"{selected}>{option_name}</option>
                                    {/options:auto_education}
                                </select>

                                What is your career status?
                                <select id="auto_career_status" name="auto_career_status">
                                    <option value="">Select One</option>
                                    {options:auto_career_status}
                                    <option value="{option_value}"{selected}>{option_name}</option>
                                    {/options:auto_career_status}
                                </select>

                                What is your approximate total household Income?
                                <select id="auto_income" name="auto_income">
                                    <option value="">Select One</option>
                                    {options:auto_income}
                                    <option value="{option_value}"{selected}>{option_name}</option>
                                    {/options:auto_income}
                                </select>

                                Do you have any outstanding judgements, past due amounts, or have you ever filed for Bankruptcy?
                                {options:auto_outstanding}

                                    <input type="radio" id="auto_outstanding_{option_name}" name="auto_outstanding" value="{option_value}"{checked}>
                                    {option_name}

                                {/options:auto_outstanding}

                                How old were you when you received your drivers license?
                                <select id="auto_license_age" name="auto_license_age">
                                    <option value="">Select One</option>
                                    {options:auto_license_age}
                                    <option value="{option_value}"{selected}>{option_name}</option>
                                    {/options:auto_license_age}
                                </select>

                                Do you have any minor violations in the past 3 years? (i.e. speeding tickets, etc.?
                                {options:auto_minor_violations}

                                    <input type="radio" id="auto_minor_violations_{option_name}" name="auto_minor_violations" value="{option_value}"{checked}>
                                    {option_name}

                                {/options:auto_minor_violations}

                                Do you have any at fault accidents in the last 5 years?
                                {options:auto_accidents}

                                    <input type="radio" id="auto_accidents_{option_name}" name="auto_accidents" value="{option_value}"{checked}>
                                    {option_name}

                                {/options:auto_accidents}

                                Do you have any major violations in the last 3 years (for example, DWI, etc.)?
                                {options:auto_major_violations}

                                    <input type="radio" id="auto_major_violations_{option_name}" name="auto_major_violations" value="{option_value}"{checked}>
                                    {option_name}

                                {/options:auto_major_violations}

                                What deductible would you like?
                                <select id="auto_deductible" name="auto_deductible">
                                    <option value="">Select One</option>
                                    {options:auto_deductible}
                                    <option value="{option_value}"{selected}>{option_name}</option>
                                    {/options:auto_deductible}
                                </select>

                                Please enter any other coverage details you would like included in your quote. For example, if you know your liability limits or other coverage details, enter them here.
                                <textarea id="auto_other_details" name="auto_other_details" rows="5">{auto_other_details}</textarea>

Additional Driver Info

Driver 2

                                First Name
                                <input type="text" id="auto_first_name_2" name="auto_first_name_2" value="{auto_first_name_2}">

                                Last Name
                                <input type="text" id="auto_last_name_2" name="auto_last_name_2" value="{auto_last_name_2}">

                                        Middle Initial
                                        <input type="text" id="auto_middle_initial_2" name="auto_middle_initial_2" value="{auto_middle_initial_2}">

                                        Age
                                        <select id="auto_age_2" name="auto_age_2">
                                            <option value="">Select One</option>
                                            {options:auto_age_2}
                                            <option value="{option_value}"{selected}>{option_name}</option>
                                            {/options:auto_age_2}
                                        </select>

                                        Gender
                                        {options:auto_gender_2}

                                            <input type="radio" id="auto_gender_2_{option_name}" name="auto_gender_2" value="{option_value}"{checked}>
                                            {option_name}

                                        {/options:auto_gender_2}

                                        Marital Status
                                        <select id="auto_marital_status_2" name="auto_marital_status_2">
                                            <option value="">Select One</option>
                                            {options:auto_marital_status_2}
                                            <option value="{option_value}"{selected}>{option_name}</option>
                                            {/options:auto_marital_status_2}
                                        </select>

                                Relationship to Primary Applicant
                                <select id="auto_relationship_to_primary_2" name="auto_relationship_to_primary_2">
                                    <option value="">Select One</option>
                                    {options:auto_relationship_to_primary_2}
                                    <option value="{option_value}"{selected}>{option_name}</option>
                                    {/options:auto_relationship_to_primary_2}
                                </select>

                                Is this driver's license currently valid?
                                {options:auto_valid_license_2}

                                    <input type="radio" id="auto_valid_license_2_{option_name}" name="auto_valid_license_2" value="{option_value}"{checked}>
                                    {option_name}

                                {/options:auto_valid_license_2}

                                What’s the highest level of education reached for this driver?
                                <select id="auto_education_2" name="auto_education_2">
                                    <option value="">Select One</option>
                                    {options:auto_education_2}
                                    <option value="{option_value}"{selected}>{option_name}</option>
                                    {/options:auto_education_2}
                                </select>

                                What is the career status of this driver?
                                <select id="auto_career_status_2" name="auto_career_status_2">
                                    <option value="">Select One</option>
                                    {options:auto_career_status_2}
                                    <option value="{option_value}"{selected}>{option_name}</option>
                                    {/options:auto_career_status_2}
                                </select>

                                How old was this driver when they received their drivers license?
                                <select id="auto_license_age_2" name="auto_license_age_2">
                                    <option value="">Select One</option>
                                    {options:auto_license_age_2}
                                    <option value="{option_value}"{selected}>{option_name}</option>
                                    {/options:auto_license_age_2}
                                </select>

                                Has this driver had any minor violations in the past 3 years? (i.e. speeding tickets, etc.?
                                {options:auto_minor_violations_2}

                                    <input type="radio" id="auto_minor_violations_2_{option_name}" name="auto_minor_violations_2" value="{option_value}"{checked}>
                                    {option_name}

                                {/options:auto_minor_violations_2}

                                Has this driver had any at fault accidents in the last 5 years?
                                {options:auto_accidents_2}

                                    <input type="radio" id="auto_accidents_2_{option_name}" name="auto_accidents_2" value="{option_value}"{checked}>
                                    {option_name}

                                {/options:auto_accidents_2}

                                Has this driver had any major violations in the last 3 years (for example, DWI, etc.)?
                                {options:auto_major_violations_2}

                                    <input type="radio" id="auto_major_violations_2_{option_name}" name="auto_major_violations_2" value="{option_value}"{checked}>
                                    {option_name}

                                {/options:auto_major_violations_2}

                                Does this driver live at the same address as the primary applicant?
                                {options:auto_same_address_2}

                                    <input type="radio" id="auto_same_address_2_{option_name}" name="auto_same_address_2" value="{option_value}"{checked}>
                                    {option_name}

                                {/options:auto_same_address_2}

                                Please enter any other coverage details you would like included in your quote. For example, if you know your liability limits or other coverage details, enter them here.
                                <textarea id="auto_other_details_2" name="auto_other_details_2" rows="5">{auto_other_details_2}</textarea>

    {/exp:safecracker}

```

# Answer
> 1 votes
A shot in the dark, but maybe try changing your field names so that they don't *start* with the same name? I'm thinking it could be a regex false positive issue when SC is parsing its tags.

So instead of first\_name, first\_name\_2, something like first\_name, second\_first\_name. You may also want to try just changing the first one so that it doesn't start like the others, so first\_name\_1.

# Answer
> 0 votes
With the help of EllisLab, we found the issue and the solution.

It turns out that because the form was so long, the preg\_match\_all function in the template class was hitting a PHP limit.

So we had to increase the PHP backtrack\_limit which fixed the issue.

Just wanted to post this incase anyone else ever runs into this issue with long Safecracker forms.

---
Tags: safecracker
---


title: Preventing a double entries loop

text:
# Question
Title: Preventing a double entries loop
This is something that I'm wondering how you solve it:

When building a site, the index template is served with segment 1 empty. If I start an entries loop in a embed, I'll need a conditional to show the specific category for the home page and automated categories for the rest like so:

```
{if segment_1==""}
    {exp:channel:entries category="1"}
        All kinds of channel entry stuff
    {/exp:channel:entries}
{if:else}
    {exp:channel:entries}
        All kinds of channel entry stuff
    {/exp:channel:entries}
{/if}

```

The only difference between the first and second loop is the category, which is called automatically in the second loop by the URL segment. Every time I make a change in the first loop, I have to be careful to do that in the second one too. I could put the 'entry stuff' in a snippet, but I like to work with files, which snippets do not allow.

So how would you approach this? Thanks!

# Answer
You can wrap parameters of your `channel:entries` tag in simple conditionals.

So instead of duplicating your channel loop (which is not very DRY), just use one loop and put the category parameter inside a conditional:

```
{exp:channel:entries
    {if segment_1 == ""}category="1"{/if}
}
    {!-- channel entries template stuff --}
{/exp:channel:entries}

```

Or if you *did* want to use a snippet for the repeated template code yet still reap the benefits of working with templates as files you can use Snippet Sync. I use it on all my installs and it works great. There is a developer license available.
> 4 votes

---
Tags: channel-entries, how-to, loop
---


title: Create layout when publishing content

text:
# Question
Title: Create layout when publishing content
I want to allow the user to create a layout when they publish a new item. They should be able to choose one or more of a set list of templates, each containing a text area and then one or more images (something like this).

Is there an add-on out there that could do this kind of thing? I've seen Content Elements but it doesn't (as far as I can see) allow custom sections to be created. I'm thinking the best way to go might be Matrix, but am open to other suggestions!

Thanks!

Darren

# Answer
Even Matrix won't neccessarily help you here as you'll still need to predefine the fieldtypes within Matrix.

What you could possibly do (and I've done this on a build previously) is give the user radio button options for specific fields and set them on/off as per their instructions and then run conditionals on the front-end to display/hide as required.

I'd be wary of giving any client too much control though, particularly over layout, has a tendency to start looking garish.
> 2 votes

# Answer
You've just described Blueprints http://devot-ee.com/add-ons/blueprints :)
> 2 votes

# Answer
This will only help if this is a channel you wish to control via the Pages module, but Better Pages does exactly that - it provides a UI for selecting a layout, and also showing/hiding fields based on this selection.
> 1 votes

# Answer
You could create all the different fields you need for each layout and then use the entry type addon to control which ones are shown to the user based on their choice. Then you could use switchee, in your template, with the value of the chosen layout as the variable to control what code is used.

```
{exp:switchee variable = "{your_entry_type_field}" parse="inward"}

    {case value="layout1"}
        Template 1 code goes here
    {/case}

    {case value="layout2"}
        Template 2 code goes here
    {/case}

    {case value="layout3"}
        Template 3 code goes here
    {/case}

{/exp:switchee}

```

This will do what you want but out of the box you won't be able to show an image of the layout. If that is crucial you are better off going down the path Derek suggests using either Better pages or Plates add-ons.
> 1 votes

# Answer
To add to Stevens answer,

You could make a radio button with, say, three design options. The fields will then be displayed in the template as chosen. {if field=="design 1"}...{/if} This gives them a bit of freedom, but not so much as to let them shovel divs around to their liking.
> 0 votes

---
Tags: add-on, templates, publish-layout
---


# Question
Title: Assets not uploading files in Chrome, works fine in Firefox
When I try to upload a file in Chrome the "Uploads files"-button is dimmed. When I click it I can select files with the browser file browser, but when Assets tries to upload it stops after a few seconds and nothing appears. I do however get an error in the console: Uncaught Error: QUOTA\_EXCEEDED\_ERR: DOM Exception 22.

Works fine in Firefox. Tried both 2.0.1 and 2.0.2. Developing in a local environment, with no .htaccess file.

# Answer
> 1 votes
If the button is dimmed, that should mean that you don’t have a folder selected on the left, so Assets isn’t sure where to upload the file.

---
Tags: add-on, assets
---


title: Add-On Development: Control Panel Files

text:
# Question
Title: Add-On Development: Control Panel Files
I am working on a site where the admin wants a set of tabular data. I created a module to display this data in the Control Panel, no problems there. My first concern was if there is a preferred method for storing module specific files (a CSV in this case). I settled on adding a directory within the module that stores the CSVs. Is there a better way? Particularly more secure?

My next issue was in forcing the download of the CSV. I would like to use the proper URL structure to hit a download\_csv method in my module, set the headers and read out the file. When I do this, the outputted CSV has a full page markup added to the bottom. Here is the code I used in download\_csv:

```
header("Content-Type: application/csv");
header("Content-Disposition: attachment; filename=$filename");
header("Pragma: no-cache");
readfile($filedir.$filename);

```

Again is there a way to use the proper URL structure and the download\_csv method without getting all the "junk" added to the file?

Thanks!

# Answer
It's a matter of preference where you store the generated CSVs, but one argument against storing them in the module is that it may make it easier to overwrite them inadvertently when updating the module. I'd use a config setting that points to the directory and leave it up to the user.

To your second point, I've had good success generating CSVs using the following helpers/libs:

Good luck!
> 3 votes

---
Tags: add-on-development
---


# Question
Title: Passing field values from one page to the next with Freeform Pro
I'm using Freeform Pro 4 and creating a multipage form. In the first page I have a field {freeform:field:sale\_price} where the user can enter a price for their house.

On the next page I then need to do some calculations on this price.

I know that there is also a Hidden Field type, so I created a 'sale\_price\_hidden' and then when the user submits the first page, the hidden value gets added like so;

```
<input type="hidden" name="sale_price_hidden" value="{freeform:field:sale_price}{freeform:data:value}{/freeform:field:sale_price}" />

```

On the second page I am then trying to retrieve that value, but I'm not sure how to get the raw data value (assuming it is possible).

Wondered if someone could help? :)

Thanks.

# Answer
> 0 votes
Freeform Pro has the {freeform:mp\_data:FIELD\_NAME} tag to assist with items like this:

http://www.solspace.com/docs/freeform/form#freeform\_mp\_data\_field\_name

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


# Question
Title: Auto generate JPG thumbnails from a PDF in ExpressionEngine?
Just wondering if it's possible to automatically create a .jpg file from a .pdf file when uploading.

I've been seeing a bunch ImageMagick suggestions, but my brain is too tired to grasp it tonight. I guess I'm wondering if there is any other solutions to get a scaled .jpg from a .pdf on upload.

# Answer
If you need the JPGs for rendering on a page the Thumber add-on from ElectricPutty should do exactly what you need:

```
{exp:thumber:create src='/uploads/documents/yourfile.pdf' page='2' extension='jpg' height='250' class='awesome' title='Click to download' link='yes'}

```
> 3 votes

---
Tags: uploads, dynamic, thumbnails
---


title: prev/next entry linking on site index

text:
# Question
Title: prev/next entry linking on site index
Recent conundrum. Building a site that will only ever show 1 entry at a time on the homepage. I want to be able to show prev/next entry links but can only do that on an entry level template (site/my-url-title).

I know I could probably use Structure but would rather not.

Here's a good example of what I'm trying to achieve http://thegreatdiscontent.com/

# Answer
Seems like http://devot-ee.com/add-ons/next-previous-links-anywhere will allow me to dump tags into my channel entries tag.
> 1 votes

# Answer
I do this over at 5secondfilms.com... we only have one entry on the homepage, but still have the left/right arrows. I'm doing it the standard pagination function inside the exp:weblog:entries tag. Since only one entry per page is being displayed, pagination should always just move one entry over. Don't think any other plugin should be necessary.
> 3 votes

---
Tags: entry, next-prev, links
---


# Question
Title: Expresso Store Price Modifier Affecting Modifier
I am developing a website that sells design and print items. My print items run on a formula that needs me to be able to have one price modifier such as "paper type" affect the final price depending on what the "dimensions" modifier is.

To be clear my price modifiers need to affect each other's price.

Is this possible with Expresso Store. If so, what are the solutions?

# Answer
There isn't any way to customize how the price modifiers work. Generally modifiers can only add or subtract the price, not multiply or use any other formula (because is leads to issues in which order the modifiers are applied, among other reasons).

Often the solution to this is to simply "flatten" your modifiers into a single select/radio menu, for example:

* Paper (10 x 10) - $1
* Paper (10 x 10) - $2
* Cardboard (10 x 10) - $5
* Cardboard (20 x 20) - $20

Another option would be to write a PHP extension using the `store_cart_item_update_end` hook, which allows you to change the price of items in the cart based on any criteria you need (for example, you can let users enter custom dimensions, then change the price of the item based on the dimensions entered).
> 1 votes

---
Tags: expresso-store
---


# Question
Title: Importing Data from MediaWiki to Wiki Module
I am currently using MediaWiki on my current site. On my new site I will be using ExpressionEngine and was wondering if there was an easy way to import data over to the Wiki Module http://ellislab.com/expressionengine/user-guide/modules/wiki/index.html

How should I pursue importing data from MediaWiki to the Wiki module in EE?

# Answer
> 2 votes
There is no easy way. It is an involved data migration that you'd have to handle custom, unfortunately.

---
Tags: import, wiki
---


# Question
Title: Can i specify the site id to the path variable in a template?
I.e., something like what embed does, `<a href="{default_site:path='group/template'}">`.

# Answer
Are you asking if you can use the path variable to automate linking to other sites in your MSM install? If so then I think the answer is no. You could always create global variables to avoid manually typing the host information if you wanted.
> 1 votes

---
Tags: templates, multi-site-manager, path
---


title: Why do I get this Email Error?

text:
# Question
Title: Why do I get this Email Error?
When I go to tools -\> communicate and try to send an email (with my smtp configuration that was previously working fine) I get the following error:

> Message: fsockopen() \[function.fsockopen\]: unable to connect to smtp.mandrillapp.com:25 (Operation not permitted)
>
> Filename: libraries/Email.php
>
> Line Number: 1670

Does anyone have an idea about why this is happening?

To me it's weird because previously emailing worked fine... It's been a while since I last sent email, but I didn't change any email related config since then...

# Answer
Try using **port 587** instead of port 25.

And check phpinfo() to see if any socket functions are disabled or you contact your host. They may have writing disabled as **per this answer**.
> 0 votes

# Answer
Looks like your network is blocking connections to that domain, possible due to the fact it is using SMTP. It's recommended you use their web API for this purposes. REST API calls are just standard HTTP, so if your host/server is blocking requests over the SMTP port, the SMTP calls with fail while the regular HTTP requests will succeed. It should be noted, I am purely speculating based on the limited information in this report. I have read many reports about this stuff, but never experienced it directly.

The easiest way to use the Mandrill API to send email for virtually anything, included all system emails in Postmaster. Email support\[at\]objectivehtml.com if you have any Postmaster specific questions.

https://objectivehtml.com/articles/read/postmaster-v1.2
> 0 votes

---
Tags: email
---


# Question
Title: Partially Displaying Checkbox Options Based on Tab
This is somewhat a follow on question to Grouping Channel Fields

Say I have a checkbox field that has 100 options. I'd like to show about 20 options only when in a certain tab, then the complete 100 when in a different tab. Basically, the 20 options are the most common choices. Having the 100 options fully displayed in another tab gives the user the option to select the not so common choices, if needed.

Any way to do this (or something like this)? It wont be good if I show 100 options -- especially since I have several checkbox fields like this.

# Answer
Fields are generally not interlinked and, to be honest, the workflow you're describing doesn't sound ideal anyway. If you're getting to the point where you have so many options to select from that the UI is getting unwieldy then, rather than splitting the data into different sets, I'd have thought the best approach would be to switch to a revised UI that lets users more easily filter through available options.

The Chosen JS plugin is excellent for this sort of thing - take a look at the Multiple Select UI. I've only ever used it on the frontend but there is a free Chosen Selects EE fieldtype which you might want to try out.
> 4 votes

---
Tags: channel-entries, control-panel, fieldtype, entries
---


title: Categories tag causing memory issues?

text:
# Question
Title: Categories tag causing memory issues?
I have many pages that use this tag but on one of them I am getting a white screen/server error. This page happens to be one that has the most entries that use the snippet. When I remove the snippet the page loads as expected.

My server has 700M of memory allocated.

```
    {categories}
        {exp:switchee variable = "{category_id}" parse="inward"}
            {case value="2"}
            <a href="{site_url}dining/category/{category_url_title}">
            <div class="category-icons" rel="tooltip" title="{category_name}">
                <i class="icon-restaurant"></i>
            </div>
            </a>
            {/case}
            {case value="38"}
            <a href="{site_url}nightlife/category/{category_url_title}">
            <div class="category-icons" rel="tooltip" title="{category_name}">
                <i class="icon-bar"></i>
            </div>
            </a>
            {/case}
            {case value="4"}
            <a href="{site_url}arts-culture/category/{category_url_title}">
            <div class="category-icons" rel="tooltip" title="{category_name}">
                <i class="icon-art"></i>
            </div>
            </a>
            {/case}
            {case value="36"}
            <a href="{site_url}nightlife/category/{category_url_title}">
            <div class="category-icons" rel="tooltip" title="{category_name}">
                <i class="icon-brewery"></i>
            </div>
            </a>
            {/case}
            {case value="1"}
            <a href="{site_url}shopping/category/{category_url_title}">
            <div class="category-icons" rel="tooltip" title="{category_name}">
                <i class="icon-retail"></i>
            </div>
            </a>
            {/case}
            {case value="7"}
            <a href="{site_url}shopping/category/{category_url_title}">
            <div class="category-icons" rel="tooltip" title="{category_name}">
                <i class="icon-service"></i>
            </div>
            </a>
            {/case}
            {case value="3"}
            <a href="{site_url}dining/category/{category_url_title}">
            <div class="category-icons" rel="tooltip" title="Coffee-Bakery">
                <i class="icon-coffee"></i>
            </div>
            </a>
            {/case}

            {case value="11"}
            <a href="{site_url}arts-culture/category/{category_url_title}">
            <div class="category-icons" rel="tooltip" title="{category_name}">
                <i class="icon-community"></i>
            </div>
            </a>
            {/case}
        {/exp:switchee}
{/categories}

```

Any ideas? Is the code just THAT inefficient?

# Answer
> 1 votes
Could you not just use something like this

```
{categories show="1|2|3|4|7|11|36|38"}
     <a href="{site_url}shopping/category/{category_url_title}">
    <div class="category-icons" rel="tooltip" title="{category_name}">
        <i class="icon-{category_name}"></i>
    </div>
     </a>
{/categories}

```

You can tell `{categories}` which categories you want to display. Then if you match image names with category names, you can use that to control, which `icon` class you call.

These parameters are available for the `{categories}` : backspace=, limit=, show=, show\_group=,

---
Tags: categories, white-screen-of-death, memory-limit
---


# Question
Title: How to create a link to my C: drive in ExpressionEngine 1.6.4
I'm trying to create a link on my webpage to a file on my C: drive, but for some reason ExpressionEngine switches my backslashes into forward slashes.

For example \< a href="file:\\C\data\text.doc" \> will be turned into \< a href="file://C/data/text.doc" \>

And therefore the link doesn't work. What to to?

# Answer
> 2 votes
Even for an intranet, you want the files to reference the internet domain, such as

```
http://office.mydomain.org

```

You can upload files from the C: drive, but Adrian mention ExpressionEngine and probably every content management system (CMS) will expect the files to be stored in the `web area` of your machine. Pointing to the generic C: drive, is pretty much like saying, these files are located on **every employee's computer** who attempt to use them. The C:drive is local machine reference.

You want to reference the server. This can be done by IP address, as well, but is best done by a domain name, even if its internal.

If your website is hosted elsewhere from the intranet, just call your ISP, and ask them to point a subdomain, to the IP address of the machine you are using for the intranet. Anything like, office., staff., internal., in front of your current domain name should work.

Then just place the files in a folder, within the web server area. So if your structure was like:

```
public_html
-- /system/
-- /images/
-- /themes/
-- /files/

```

The reference to the files will then become:

```
http://office.mydomain.org/files/{file_name}

```

or you can use the reference, just `/files/{file_name}`

If you have lots of files, I also recommend grouping them under the `files` or `downloads` folder. Just create sub-folders. This will make uploading files using the file manager or something like 'Assets' by Pixel & Tonic easier, when they don't have to try to display 1000s of files at a time.

---
Tags: server, links
---


title: Frontend: Sending Emails

text:
# Question
Title: Frontend: Sending Emails
I'm putting together a membership website wherein the members of the site can send an email to each other via an email form presented to them in the front end. The email will go to their email's inbox -- not anywhere in EE.

In the template, I have access to the sender and receiver's email addresses. I have the form ready. When the user clicks the "Send" button -- what should I do next? Is there a native EE way to do this? Or a free add-on that is reliable?

# Answer
I agree with @Andy Homan. The Tell-a-Friend option will work for you, but because of your set-up you will need to secure it well. This is a prime opportunity for spammers to use your server, for sending spam. There is some leeway, if your members are also restricted to just real life members of your organization. But that won't stop someone from being gung-ho about marketing themselves or their work to as many other people as possible. So be forewarned.

That said, we use the Tell-a-Friend form for a number of things in one of our client's set-up. They wanted to be able to send full text of letter-writing campaigns to both the writer, local politicians, and keep an internal copy. This was before add-ons like 'PostMaster' by ObjectiveHTML. And 'Tell-a-Friend has served us well.

If you have a lot of members, you'll probably want a method for the user to select which members to send to. This could possible be ajax type ahead on the member list or maybe the Chosen Select plug-in or VMG Chosen Member, but otherwise, the form should work well.

Just a note about security, because having your website blacklisted as a spammer is no fun. Make sure ONLY members can access the form. See if you can limit the number of emails per hour or only 1 or 2 per 15 minute period. Track outgoing emails with a service like Mandrill or another service. This will allow you to see if a user us targeting the full membership list. Also, if possible, figure out a way to allow for members not to receive mail, from other members.
> 2 votes

# Answer
Sounds like you could probably use the native Tell-A-Friend Form tag. http://ellislab.com/expressionengine/user-guide/modules/email/tellafriend.html
> 2 votes

---
Tags: email
---


# Question
Title: Search results based on segment / Structure top parent
Is it possible to make a search on only subpages from the top segment? Example:

1) The user is on www.example.com/products/product-title/ and do a search on this site
2) The search results displays children of their top parent, /products

The reason why I want this is because I have several sections of the site that has been build up with exactly the same channels and structure. In other words, www.example.com/products/ and www.example.com/about/ is build up the same way, just with different content, and when I'm in "about" I only want to search articles that belong to that parent.

# Answer
> 1 votes
I think you'd have to use conditionals and only search certain channels based off the segment. Basically showing a different search form per segment. Or maybe you could use the segment in the search parameter?

---
Tags: structure, low-search, supersearch
---


# Question
Title: how to get entries based on day - session timing - entries per session entry
How to get and output entries like this ( example event Agenda )

* day01
* —session time-span ( loops session timespan entries )
* ——session span entrie(s) ( one or multiple )
* ——session span entries ( one or multiple )
* ——session span entries ( one or multiple )
* —/session time-span
* —session time-span
* ——session span entries ( one or multiple )
* —/session time-span
* /day01

-day02 ........

If anyone has input on how to do something like this ( still having the template readable :) )

I would be very thankful.

edit : my template ended up looking like this .. added storing a lastday variable to get days in the loop .. ( perhaps it can be done even better - but it works like a charm thanks for the input guys )

> Blockquote {!--keep track of previous day in order to check if we have a new day--} {exp:string:set name="lastDay"}just starting{/exp:string:set}

```
**strong text**
    {exp:channel:entries channel="session_timeblocks" show_expired="yes" show_future_entries="yes" dynamic="no" limit="999" orderby="date" sort="asc"}

    {!-- store start day and time of current entry for check later on --}
    {exp:string:set name="currentDay"}{entry_date format="%d"}{/exp:string:set}

    {exp:string:output random}
    {if currentDay != lastDay}
        {if lastDay != "just starting"}
            -2-</div> {!-- close open session and day --}
        {/if}
    <div class="prog_day grid item{currentDay}" >-1-
        <div class="prog_day_title" >{entry_date format="%D %j/%n"}</div>
    {/if}
    {/exp:string:output}

    <div class="prog_time grid">
        <div class="col-1-6">
            <div class="module">
                {entry_date format="%H:%i"} - {expiration_date format="%H:%i"}
            </div>
        </div>
        <div class="prog_session col-5-6" >
            <div class="module">
                {exp:playa:children field="{cf_session_timeblock}"}

                <h5>{title}</h5>
                <ul class='foldable'>
                    <li>
                        {if cf_session_summary}
                        <div>
                            <h3>Summary</h3>
                            <p>{cf_session_summary}</p>
                        </div>
                        {/if}
                    </li>
                </ul>
                {/exp:playa:children}
            </div>
        </div>
    </div>

    {!--store current entries start day and time--}
    {exp:string:set name="lastDay" random}{entry_date format="%d"}{/exp:string:set}
    {if count == total_results}2</div>{/if}

    {/exp:channel:entries}

```

> Blockquote

# Answer
Based on your example, it seems very similar to something I have done before. There's actually several ways to do it depending on how comfortable you are with queries. To do it natively would be a bit more complex. One way I can envision you doing it is to have en "events" channel, wherein you create the profile of each event. And then you would have a second channel of time blocks. In the time blocks channel, you would create an entry for each block of time with a label, using the entry date fields as the start date/time and the expiry date as the end date/time. The reason I recommend that is that it allows you to retain the date headings tag pair functionality, which unfortunately natively only works with the built-in date fields. The result would be a channel entries loop of date blocks for which you can use the date headings to pump out a date heading for each day of your event, for example, with each block within each date then displaying the start time and end time and label for the block. Within each block, you would then need to display the list of events from your events channel that are assigned to that date block. For this, you could use either a relationship field OR even better, Pixel & Tonic's Playa add-on. Playa would allow you to have a single session description appear in more than one session block (so if the same event - like a presentation - actually gets presented more than once over the course of the event, one entry is used for each instance).

So your date blocks loop would look like this, roughly:

```
{exp:channel:entries channel="time_blocks" show_expired="yes" show_future_entries="yes" dynamic="no" limit="50" orderby="date" sort="asc"}

{date_heading display="daily"}  <h1>{entry_date format="%Y %m %d"}</h1>  {/date_heading}

{entry_date format="%H:%i} - {expiration_date format="%H:%i"}
{title}

{exp:playa:children field="block_events"}
{title}
{/exp:playa:children}

{/exp:channel:entries}

```

This assumes that you set up a Playa field in your blocks channel called "block\_events" in which you select all the sessions occuring at that time. It might actually be better to do the reverse in the strictest sense, allowing you to add sessions and assign them in the event channel to their parent time block(s) but when you are displaying the list of time blocks as the parent list with the need to break that list up by date heading, this way may be just a bit friendlier to that.

Hope this helps.
> 3 votes

# Answer
There are a number of options available. You could use Matrix to store sessions related to a time block, like Day 1 or 10am-12pm. You could use `categories` for your main and sub-groups: Day 1 as parent, Time blocks (10am-12pm) as sub-categories. Or you could use an add-on like Playa to create relationships.

Here are some examples.

**Matrix Option**

With Matrix, you'd probably want to enter each 'session' under time blocks. There's other ways to do it, but let's assume you have a record 'Day One' in ExpressionEngine. Then that record could contain a Matrix field called sessions. Each line in Matrix could contain date, start\_time, end\_time, title, and description. This works fine if you have a small number of sessions, and have to create new agendas all year long, say for Board Meetings. I wouldn't really use it for say a conference with hundreds of sessions.

**Code Sample: Matrix** This code is untested, but should provide a general idea.

```
{exp:channel:entries site="meetings" channel="agendas" limit="3" url_title="{segment_3}" orderby="title" sort="asc"}

<h2>{title}</h2>
<p>{day_description}</p>

    <h3>Agenda</h3>
    <!-- Matrix: Uses Its Own Tagged Pairs, based on field_name -->
    <ol>{agenda}

      <li>{start_time}-{end_time}: <strong><a href="#">{title}</a><span class="hide"><br />{description}</span></li>

    {/agenda}</ol>

{/exp:channel:entries}

```

**Playa Option**

Playa probably offers the most flexibility of the options. What you would do, is set-up the fields as you described in your comment above. Storing each session as individual entries. Create a new channel in EE, and use that to assign sessions to a master grouping. That grouping could be the day or the time block, which ever is most important to you.

So for example, you could have a record in 'events' your master block, that relates all session to that record. While 'sessions' would be the current channel storing entries. The names could be however you like.

**Code Sample: Playa** This code is untested, but should provide a general idea.

```
{exp:channel:entries channel="event" orderby="date" sort="desc" limit="1" track_views="one"}

{date_heading}
<h3 class="date">{entry_date format=' %l, %F %d, %Y '}</h3>
{/date_heading}

<h2>{title}</h2>
<div style="margin-top: 0; margin-bottom: 20px;">
    <p class="summary">{event_summary}</p>
</div>

<h3>Agenda</h3>
<ol class="reverse">{exp:playa:children}

    <li><p>{start_time}-{end_time}: <a href="{comment_url_title_auto_path}" title="{title}"><strong>{title} »</strong></a></p><p class="hide">{description}</p></li>

{/exp:playa:children}</ol>
{/exp:channel:entries}

```

Playa can handle nested relations, which provides increased flexibility. But if you have pre-defined time slots, you can also create a 'Playa' field for each time period, and do very direct relations. Like these five sessions happen at 10am, these five at 12:30pm, etc.

No example for the category option. But categories are a nice quick way to group items, without dropping down into PHP. I've also used Low ReOrder to create groupings of items. It's nice, because you can technically reorder the items however you like.

If you want or need, very simple, you can do something like this example, with just basic EE code, no add-ons.

**Example Code: No Add-Ons**

The no add-on option, just uses EE's date functions group based on day and time. This is an annual event, so we also limit by year, so people can go back and view previous years schedules. We went for a pretty simple list design, but you can show hide items how ever you like.

```
{exp:channel:entries channel="schedule" year="2011" orderby="date" sort="asc" limit="50" dynamic="off" show_future_entries="yes"}

   {date_heading display="daily"}<h1 class="schedule-day" align="center">{entry_date format="%D, %F %d, %Y""}</h2>{/date_heading}

   {date_heading display="hourly"}
    <h2 class="schedule-time" align="center">{entry_date format="%g:%i %A"}</h2>
   {/date_heading}

   <div class="schedule">

       <h3><a href="{domain}/schedule/article/{url_title}" title="{title}">{title} »</a></h3>
       {if event_tagline !=""}<p><b>{event_tagline}</b>{/if}
       {if event_tagline ==""}<p>{if:else}<br />{/if}{entry_date format="%h:%i %A"} at <u>{event_location}</u> (Length: {event_length})
       <br /><br />{exp:word_limit total="60"}{exp:tagstripper:tagsToStrip keep="b,i,u"}{event_description}{/exp:tagstripper:tagsToStrip}{/exp:word_limit}</p>

  </div>

{/exp:channel:entries}

```
> 3 votes

---
Tags: channel-entries
---


# Question
Title: Select list of existing content pages using Low Variables/Structure?
When entering content, is there a way to mistake-proof entering links to other url-titles on the site without entering the full URL?

I am setting up an EE website using Structure and Low Variables. Structure is managing the "page" content in a channel called "Pages," and there are several other channels for various dynamic content listings. I am using Low Variables to manage snippets of code, various settings, and bits of content such as company contact information.

As part of the home page, I have several "featured" sections with similar formatting. Each has the option for a title, image, link, and blurb of text. The client would like to be able to select from any content on the site (as well as presumably content NOT on the site). I setup a channel called "Features" with the following fields: `title` (Text Input),`feature_url` (Text Input -- default text formatting "None"), `feature_image` (File), and `feature_body` (Textarea).

The client would select which entries from the "Features" channel to display on the Home page using a select list in Low Variables.

I setup the Home page template as follows:

```
<!-- Feature Section -->
<div class="row">
    {exp:channel:entries channel="Features" dynamic="no" limit="3" disable="{lv_shortcuts_disable_default}"}
    <div class="column one-third">
        <div class="pic">
            {feature_image}{if feature_url != ""}<a href="{feature_url}">{/if}<img src="{url:feature3}" alt="" />{if feature_url != ""}</a>{/if}{/feature_image}
        </div>
        <h3>{if feature_url != ""}<a href="{feature_url}">{/if}{title}{if feature_url != ""}</a>{/if}</h3>
        <p>{feature_body}</p>
    </div>
    {/exp:channel:entries}
</div>
<!-- Feature Section::END -->

```

When entering content, I have tried typing in the `url_title` of another page on the site, but the template wraps the `url_title` in `<p></p>` tags when rendering. (Example: entering "/index.php/our-work" in the entry field yields `http://localhost:8080/mysite/<p>/index.php/our-work</p>`.) Entering a full URL which includes "`http://`" works as expected. Also, if the `url_title` of the other entry changes this entry will have a broken link.

So I guess I have two problems:

1. First, I would like an easy way for my client to select from existing content "pages" in a way that is straightforward and mistake-proofed if the `url_title` of a page changes. Ideally, this would be a select list. (If they want to enter a link to an external page, I could have a separate variable for that.)
2. Second, I need those relative links to display in the template correctly without being wrapped in paragraph tags.

Does anyone have any experience with doing something like this? Any advice to help me?

# Answer
> 0 votes
The key to fixing problem #1 (URL's not including the full path but just the url\_title) was to use Structure's `{page_url}` tag in the template markup. `{page_url}` gives the Structure URL with parent segments included (example: "about-us/donate" instead of just "donate"). Thanks to @Travis Schmeisser for his help in the Structure support forum.

As for #2 (`p` tags wrapping the url\_title), I did delete the field from the field group then recreated it. The problem is now solved.

# Answer
> 2 votes
It's odd that you are getting p tags with formatting set to none. Was this a different field type at one point? Try deleting out any data, saving the entry, then editing it again, add the url once more and finally saving of course.

Just some thoughts that might help you (or others) though, might be slightly to one side of your current situation; if that makes sense?

There is an add-on which is very nice for featured type entries called Selected items:

> Often on a website you want to control the order that entries display. For example, on a magazine-style website, the front page stories would be editorially selected rather than just the 5 most recent.

Selected Items (*docs are at the repo/download itself*)

If all you are ever doing is linking to entries in the Page channel, for example, where the data is exactly the same as what you've built in your "Featured" channel then this route would eliminate the need for having two channels that the client has to fill out. You could just pull from the Page channel in this case assuming the data is the same like I said. Any chance you have that the client has *less* work to do is a plus IMO.

The possible downside to this add-on is that it adds a new location to the CP for the client to have to manage. This can be alleviated a bit via adding a "bookmark" in any editors/admin accounts via the `Add+` link in the main nav or better yet by using something like Zoo Flexible Admin.

Another idea would be to add a link to the top of Structure labeled "Featured", for example, which is a shortcut to the selected items page. This would require an add-on of course similar to Encaf Where is the LV.

Another option which might work is via Low Reorder. In this case you might set a status or category of "Featured" and only have those entries from the Page channel show up. You could reorder though, the difference here from Selected items is that with Selected Items you can reorder AND select which items you want to show. Low Reorder you can reorder but, the selection process is done more automatically depending on how you setup your options and filters etc.

Finally, if for some reason you can't figure out why your current setup keeps adding p tags then maybe try a different field type all together for now. There is the VZ URL add-on which would work in this case:

VZ URL

Note: using VZ URL only is "bandaging" the problem. Finding out why you're getting p tags in a text input field type with formatting set to none of course would be the real fix vs this bandaid fix. I'm not sure why this is happening from where I sit, however.

# Answer
> 1 votes
1) In the past I used to use Wygwam as my textarea field type and this has a handy plugin called Wygwam Entries which can be used to link to any channel (not just those in the pages module). Both of those are commercial however. There is a free linking addon called Wygwam Structure Pages though which I believe still works but I'm not sure if it's still supported.

Actually having just taken a look at Wygwam it now seems to include Structure Page support by default so it's all there in one addon.

Another alternative commercial option but a bit cheaper is Redactee. I believe allows you to link to channel entries (it should support Structure pages too) in a similar way.

Lastly if you don't want commercial and just use the Pages module then Easy Page Links provides an easy to use interface but unfortunately it doesn't support Structure as far as I know.

That provides a few options at least.

2) I believe that's just because you've set the formatting of the field to XHTML which is probably the default. If you set this to 'None' in wont add the paragraph tags to the URL but it also wont add XHTML to anything else in the textarea. If you're using one of the above page linking addons however then you can keep the formatting to XHTML and just tell them how to link to internal pages by selection.

Hope that helps.

---

---
Tags: structure, url-title, low-variables
---


# Question
Title: First module, how to create a simple control panel form?
I have successfully built the front end of my first module. Its a simple module that does currency conversions.

I need to create a simple control panel page for my module that allows me to add a decimal number into three different fields which is saved in the database (already have the database created on install of module).

I am a complete newbie, so wondering if anyone can give me an idea of how to create a basic form that submits to the database as I have been unable to find anywhere that shows an easy to understand version.

# Answer
Please check Module Development Tutorial
> 2 votes

---
Tags: module
---


# Question
Title: Twitter-style Tagging with Hashtags ? Devs? Anyone?
First, HUGE props to the people who've worked so hard to create this forum. EE desperately needs (and deserves) a community like this.

Wondering if any of you have experience with Twitter-style hashtagging in EE? I found an old 1.x extension called Twagger that does it. But it has not been ported to EE 2.

I really want to streamline the tagging process in SafeCracker.

If I can't find a 2.x extension that will do this, I'd be interested in contracting someone to do it for me.

# Answer
> 1 votes
While being not really tagging solution, Crosslinking might be of some help to you.

(As mentioned above, you need to be more specific to get good answers to your questions)

# Answer
> 1 votes
I'm not certain if I fully understand what you want. Are you looking for a 'tagging' solution, where people can enter tags from the front end (regardless of hash, but provides a filter for posts) or are you looking for something that converts #keywords to links, if someone used one anywhere in a post?

If you want tags to be filters, look at Solspace's Tag or DevDemon's Tagger. Either will provide a good system for dealing with tags.

If you want a system that replaces #keywords, with links. Then you'll want to use a Find and Replace plugin against the body or main text field. Something like 'Low Replace' should work. You'd still want either Tag or Tagger to do the processing.

So you would do something like:

```
<!-- Note: Find words with a hashtag (#) and encase with a url to the tag processing page -->
{exp:low_replace find="#\w+" replace="<a href=\"/tags/tag/#\w+\">#\w+</a>" regex="yes"}
  {post_body}
{/exp:low_replace}

```

My regex use is **atrocious**. So don't expect that to work as is. I work with another programmer, who just smirks, when he sees my regex, which I kindly place a note on, and he fixes. So maybe a kind soul here will do that as well.

But the find and replace will swap out any #keyword within the body and make it a link. The link would then point to a page being handled by Tag or Tagger or even search. In fact, if the items should be found from any body field, you may wish to use the search function.

I find the tag functions of Tag and Tagger work best in a single, pre-defined field or using their built in tagging method. No hashtags needed. The user just adds keywords/tags at the end of a post.

Yuri's CrossLinking might allow you to get rid of the regex find and replace. So you may want to look at that as well.

---
Tags: add-on-development, tags
---


title: Playa Position Count

text:
# Question
Title: Playa Position Count
I'm trying to display the count/position of the entries i've selected in the Playa field, but can't seem to figure it out. For example in my Playa field I have...

**Test Post
Another Test Post
Yet Another Test Post**

But do each one of these posts have a count / position number in Playa? e.g.

**1 - Test Post
2 - Another Test Post
3 - Yet Another Test Post**

But If I was to reorder them to:

**Another Test Post
Test Post
Yet Another Test Post**

The count should still count up...

**1 - Another Test Post
2 - Test Post
3 - Yet Another Test Post**

All I can seem to output is the count of the entry which always displays "1" or the entry\_id.

My code is:

```
{exp:channel:entries channel="course" url_title="{segment_2}" dynamic="no"}
     {cf_course_content} {!-- Playa Field --}
          {count}
     {/cf_course_content}
{/exp:channel:entries}

```

# Answer
In theory `{count}` should work. If it’s always being output as ‘1’ that means that `{exp:channel:entries}` (or another module tag pair you’re not telling us about?) must be parsing the tag before Playa had a chance to claim it.

Try adding your own custom var\_prefix to your Playa tag pair, and apply that var\_prefix to the `{count}` variable tag, as well as any other tags that are meant to be parsed by Playa:

```
{cf_course_content var_prefix="cc"}
    {cc:count}. {cc:title}
{/cf_course_content}

```
> 5 votes

# Answer
Maybe try with Pvl\_Increment. It counts on every call.
> 0 votes

---
Tags: playa
---


# Question
Title: How do I setup Automatic 301 Redirects on url_title change
EE gives clients great control over the url\_title of the entry. This is great for publishing new entries, and necessary for editing entries in case of mistakes or any other "good" reason to change the url\_title.

Being an SEO conscience developer who runs an EE site, when I change a url\_title for an entry that has been published and indexed by Google, I set up a 301 Redirect using .htaccess, so previous users and search engines know where the new page lives.

Clients will not do this, of course. Without me telling them, they will simply change the url\_title as they see fit. I believe this is something they should be able to do without contacting someone who knows about 301 Redirects. This is something that is handled automatically by WordPress (based on a limited understanding and experience with WordPress).

**Are there** any plugins or techniques out there that will accomplish this task you are aware of?

# Answer
The **Detour Pro** addon should do what you need.

> Detour Pro handles simple redirects like this/old/page to this/new/page

---

The **PathFinder** addon seems like it will add redirects automatically.

> Configure ExpressionEngine to automatically perform an HTTP 301 redirect when the URL slug (url\_title) for an entry is changed.
>
> ***Want to allow content editors to change URL slugs for SEO purposes or to match changes in entry titles, without losing existing search engine ranking as a result of changing the URL, and without needing a developer to setup a redirect?*** This add-on can help.
>
> Requires initial setup by someone competent with PHP.
> 2 votes

---
Tags: htaccess, url-title, redirects, automation
---


# Question
Title: Playa and Low Variables for Featured section of Home page
I am trying to use Low Variables, Playa, and a "Features" channel to allow me to select which (3-4) features will be displayed on the Home page. The intent is that either a News, Project, or (Structure) Page may be selected (but never more than one of those) or some unrelated content (body, url, file) may be entered. This is to allow maximum flexibility. Within the "Features" channel there are these fields:

## "Features" Channel

* title
* feature\_body (textarea -- required)
* feature\_related\_news (Playa -- select up to 1 entry from "News" channel)
* feature\_related\_project (Playa -- select up to 1 entry from "Projects" channel)
* feature\_related\_page (Playa -- select up to 1 entry from "Pages" channel)
* feature\_URL (text input -- optional, only entered if no related item)
* feature\_image (file)

## Low Variables

* Variable: lv\_settings\_home\_features\_items (Playa -- select up to 4 entries from "Features" channel, drag and drop to reorder)

I can tell that the variable is being populated (example output: `[93] [rainfall-news] Rainfall News [94] [check-out-our-work] Check Out Our Work [95] [donate] Donate`).

## Home Template

Each of the different types of related items (news, project, page, or other) requires slightly different formatting and field names.

I would like to do something like this:

```
<div class="row">
     {exp:playa:children var="lv_settings_home_feature_items" limit="3"}
 <div class="column one-third">
 {if feature_related_news}
      {related_entries id="feature_related_news"}
      <a href="{page_url}"><img src="{news_image:feature3}" alt="" /></a>
      <h3><a href="{page_url}">{/related_entries}{title}</a></h3>
 {if:elseif feature_related_project}
      {related_entries id="feature_related_project"}
      <a href="{page_url}"><img src="{project_image:feature3}" alt="" /></a>
      <h3><a href="{page_url}">{/related_entries}{title}</a></h3>
 {if:elseif feature_related_page}
      {related_entries id="feature_related_page"}
      <a href="{page_url}"><img src="{page_image:feature3}" alt="" /></a>
      <h3><a href="{page_url}">{/related_entries}{title}</a></h3>
 {if:else}
       {feature_image}
           {if feature_url != ""}<a href="{feature_url}">{/if}<img src="{url:feature3}" alt="" />{if feature_url != ""}</a>{/if}
       {/feature_image}
      <h3>{if feature_url != ""}<a href="{feature_url}">{/if}{title}{if feature_url != ""}</a>{/if}</h3>
 {/if}
      <p>{feature_body}</p>
 </div>
 {/exp:playa:children}
</div>

```

The code above has `related_entries` instead of the applicable Playa code. I started out with relationship fields in the Features channel but then changed them to Playa fields. The code worked when I used a `exp:channel:entries channel="Features"` to wrap the entire thing (and just outputted the 3 most recent Features), but once I put the Low Variable in and outer Playa tags on it doesn't work.

The Playa documentation says that to use nested relationships you need to use embeds. How would I structure those to achieve my goal? Or is there some other way? How do I pull the different chunks out of the LV?

# Answer
If you want to output the entries that you selected in the LV-Playa field, use the Parse (or its alias: Pair) tag. You can then use any of the parameters can use with a playa:children tag. So, for example:

```
{exp:low_variables:pair var="lv_settings_home_feature_items" limit="3"}
    ...more code here...
{/exp:low_variables:pair}

```

To get to the other related fields, don't use the native relationship syntax like you're ding, but use Playa tags or the var-pair syntax:

```
{feature_related_news}
    ...code here...
{/feature_related_news}

```
> 4 votes

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


title: Freeform timing out on return page

text:
# Question
Title: Freeform timing out on return page
I have EE v2.5.3 and Freeform Pro 4.0.10 among other things.

When submitting forms with admin notify turned on I get a server timeout error. The form data still submits to the db and I still get a notification email but the server hangs and eventually times out instead of loading the return page.

If I turn on admin notify it works properly, but obviously no notification, which I very much need.

# Answer
This sounds like it's an issue on your server since it was working and now is not.

I'd first test to see if you are having timeouts when sending from the **Communicate page** in EE. If you can't send from the Communicate page, enable **Email Debugging** to see what's going on.

Also check your PHP error logs to see what you see. An error related to the timeout may exist there.

If necessary, contact your host to see if they have changed anything on the server related to PHPMail/SMTP (I'm not clear from your comment which one you are using exactly)... Send them the info you find in the debugging and logs.
> 0 votes

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


# Question
Title: Moved EE1.7.1 site to new server and can't log into CP
I want to upgrade my EE1.7.1 installation to EE2. My existing site has been in existence since the early days of pmachine and so has a lot of legacy plugins, etc including the image gallery, a discussion forum, etc. So, before just blindly upgrading, I want to do a "practice run". I copied my data base and files to a new server hosted by EngineHosting following the instructions for migrating to a new server.

While I can access the index page of the new site okay, I cannot log into the CP in order to change all the settings I need to change to complete the migration. (I plan to use Deeploy which is installed in the migrated site.)

When I enter my login and password (using the correct credentials), I am just taken back to the CP login page. (If I use incorrect credentials, I get an error message that my username or password is incorrect.)

I've seen similar posts that blame cookies for this, but I don't think that is the problem. I've cleared my browser cache and cookies, tried several browsers, etc.

I've had this question posted over at the EE site for a while and someone kindly directed me here, thinking someone might be able to help coach me through resolving this issue.

Rick

# Answer
> 5 votes
Try adding the following at the end of your configs in the config.php file:

```
$conf['secure_forms'] = "n";
$conf['cookie_domain'] = "";
$conf['cookie_path'] = "";
$conf['cookie_prefix'] = "";
$conf['admin_session_type'] = "cs";
$conf['require_ip_for_login'] = "n";
$conf['require_ip_for_posting'] = "n";

```

MOST LIKELY THE ISSUE IS THIS LINE:

```
$conf['cookie_path'] = "";

```

---
Tags: control-panel, login, server-migration
---


# Question
Title: Entries with multiple categories, limit categories to just one parent and it's selected children?
Not sure if this can be done natively or if an add-on is out there.

I'm trying to figure out a way to limit entries with multiple parent categories to just one parent and it's children. The reason, I have nested product URL's:

```
http://domain.com/products/parent_cat/child_cat/entry
http://domain.com/products/parent_cat/child_cat/grand_child/entry

```

Currently this works well for products with a single parent category.

Right now entries with multiple parent categories build "bad" URL's in the search results with this template code:

```
<a href="/products/{categories}{category_url_title}/{/categories}{url_title}">{title}</a>

```

Which works, if the entry has only one parent category assigned to it. If it has multiple, I get a nested URL with parent and child categories mixed together:

```
http://domain.com/products/parent_cat/other_parent/child_parent_cat/child_other_parent_cat/entry

```

Any ideas on how I could limit the parent & child categories to just one parent tree? Thanks for the help!

# Answer
> 2 votes
I got this working correctly by using the Primary Category extension as Yuri recommended! I thought I would post my solution to help others in the future.

I created a conditional to check if the primary category is set and then built the URL based off the condition.

So if it returns true, the `{primary_category_url_title}` is placed outside the `{categories}` variable pair since it's going to be skipped inside the pair. Then I have another condition to skip all categories that don't have the same `parent_id` as the primary category set.

```
{if primary_category_id}
    <li><strong>{product_ci_model}</strong>: <a href="/products/{primary_category_url_title}/{categories}{if parent_id == primary_category_id}{category_url_title}/{/if}{/categories}{url_title}">{title}</a> - <em>Product<em></li>
{if:else}
    <li><strong>{product_ci_model}</strong>: <a href="/products/{categories}{category_url_title}/{/categories}{url_title}">{title}</a> - <em>Product<em></li>
{/if}

```

# Answer
> 1 votes
It looks like Primary Category might help you

# Answer
> 0 votes
You can us the limit function with `{categories}` pair tag. This would still allow multiple categories, parent and children, but only display one for url purposes. like

```
<a href="/products/{categories limit="1"}{category_url_title}/{/categories}{url_title}">{title}</a>

```

Otherwise, take a look at GWCode's GW Categories. It allows an insane amount of category control.

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


# Question
Title: Quick way to get user's signature in PHP
I'm just wondering if there is a quick way to get a user's signature using something like the session class? For example to grab the active user's email from the session class you can simply call $this-\>EE-\>session-\>userdata('email');

I am referring to the native signature value also, and not a custom member field.

I would prefer to avoid running a secondary database query to get the information as time is definitely an issue in our case.

Cheers, Conor

# Answer
> 5 votes
Try this to see if it works for you. I just tested, and it works just fine for me.

```
$this->EE->session->userdata('signature')

```

To see all the values in the session values stored as userdata, just do the following:

```
var_dump($this->EE->session->userdata);
exit();

```

---
Tags: custom-fields, database, query, sessions
---


# Question
Title: Javascript modals so slow when I parse EE content into them
I have a small simple site that is one index page with four popup modals. Everything works fine on the iphone until I try to parse EE content into them. This is the first bit of EE content I am pulling into the site:

{exp:channel:entries channel="about" disable="categories|member\_data|pagination"}

{about}

{/exp:channel:entries}
Once i do this it slows down so much that the site is unusable on the iphone...

Whats going on? I am just pulling in text? Is it something to do with the way its loading? The modals are controlled by javascript.

When I load the content outside of the modals it loads quickly and is ok. The modals load okay on their on desktop only on iphone) - how can I fix this? I have enable caching, but its not doing anything....

This is not good! Please help!

# Answer
These aren't the issues obviously but I'd change two things in your code.

1. Add "category\_fields" to your disable="" parameter:

`disable="categories|member_data|pagination|category_fields"`
2. If there is only one entry for "About", then call the entry with the `entry_id=""` parameter.

---

Next, I'd look at trying another overlay plugin to see if it's an issue with the one you are using.
> 1 votes

# Answer
Dependant on the mechanism that fires ur modal, include the modal contents inside a hidden div on the page and refer to its #id, gets the rendering done on page load and makes the modal appear snappier.
> 0 votes

---
Tags: javascript
---


title: Content based on url segment

text:
# Question
Title: Content based on url segment
I'm just learning EE and I have the following example url, http://mydomain.com/work/preview/clientname

where I want clientname to match a channel field I have setup ("client\_name") and to pull in channel content only if it matches that channel field.

For example, http://mydomain.com/work/preview/google, would display channel content if the specified channel field "client\_name" for a particular entry is "google".

I know how to use the following to pull in content from the channel "videos":

```
{exp:channel:entries channel="videos"}
    {title}
{/exp:channel:entries}

```

...but how do I accomplish this for different url segments?

# Answer
> 3 votes
This code will do the trick:

```
{exp:channel:entries channel="videos" search:client_name="{segment_3}" limit="1" require_entry="yes"}
    {if no_results} {redirect="404"} {/if}
{/exp:channel:entries}

```

---
Tags: channel-entries
---


# Question
Title: Redirect/prevent webmaster tools crawl errors using htacces?
Through Google webmaster tools i noticed many crawl errors. However none of the url's exists anymore but are still linked somewhere in other pages. If i surf to such url i get "Invalid GET Data" An example of such url is: http://www.mysite.com/normal?destination=catalogus%3Fpage%3D60 http://www.mystie.com/normal?destination=catalogus%3Fpage%3D26%26cat%3Dhom%25E2%258A%2582%253D1%26pag%3D1%26afb%3D1

Is there a way i can redirect such url's automaticly via htaccess or should i remove this manually which they are a lot...

# Answer
> 1 votes
Here's a fix from the **Bug Report** which should eliminate the error:

---

Open system/expressionengine/core/EE\_Input.php

Find this code on line 110:

```
if (preg_match("#(;|\?|exec\s*\(|system\s*\(|passthru\s*\(|cmd\s*\(|[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})#i", $val))

```

And REPLACE it with this:

```
if (preg_match("#(;|exec\s*\(|system\s*\(|passthru\s*\(|cmd\s*\()#i", $val))

```

---

A couple options for redirecting:

1. After you've made the change above, you should be able to create a template group called "normal" and add whatever you want into that template. Can you a specific message or can be redirect code to the 404 error page with `{redirect="404"}`
2. You can handle this in your .htaccess file by redirecting any URL with "normal" to the index page or any page with something like the following:

...

```
RewriteEngine On
RewriteCond %{REQUEST_URI} normal
RewriteRule .* index.php

```

Disclaimer: The above rewrite code is untested. **mod\_rewrite docs** are here if you need to fine-tune the code.

---
Tags: htaccess
---


title: Low Search - Multiple Select Problem

text:
# Question
Title: Low Search - Multiple Select Problem
I have this form

```
{exp:low_search:form collection="foo" query="{segment_2}" secure="no" search_mode="any" loose_ends="yes" result_page="test/"}

<label for="foo_gender">Gender:</label>
<select class="span12" name="search:foo_gender[]" id="foo_gender" multiple="multiple">
    <option></option>
    {exp:channel:entries channel="genders" orderby="entry_id" sort="asc"}
        <option value="={gender}">{gender}</option>
    {/exp:channel:entries}
</select>

<button type="submit" class="btn btn-primary">Search</button>

{/exp:low_search:form}

```

In the database I have 3 entries

```
 Entry 1, foo_gender = Male
 Entry 2, foo_gender = Female
 Entry 3, foo_gender = Transgender

```

I tried selecting entry 1 and 2 and submit.

I got only 1 entry from the result, entry 1.

That search form was supposed to be returning 2 entries, entry 1 and 2

Why is this the case?

P.S

The output of {low\_search\_search:foo\_gender\[\]} was "=Male|=Female"

# Answer
Currently, Low Search only supports non-exact matching for the search:field parameters *with multiple values only*. Single value fields will work with the exact syntax. You could work around it in this case by making it a single value:

```
<select class="span12" name="search:foo_gender" id="foo_gender">
    <option value="">All</option>
    {exp:channel:entries channel="genders" orderby="entry_id" sort="asc"}
        <option value="={gender}">{gender}</option>
    {/exp:channel:entries}
</select>

```

**Update**

As of Low Search v2.2.0, this is now possible, with the `exact=""` parameter. Simplfied:

```
{exp:low_search:form exact="search:foo_gender"}

    <label for="foo_gender">Gender:</label>
    <select name="search:foo_gender[]" id="foo_gender" multiple="multiple">
        {exp:channel:entries channel="genders"}
            <option value="{gender}">{gender}</option>
        {/exp:channel:entries}
    </select>

{/exp:low_search:form}

```
> 2 votes

---
Tags: low-search
---


title: Consuming HTTP Posts

text:
# Question
Title: Consuming HTTP Posts
I have a requirement to integrate an Expression Engine website with a third party recruitment system. I need to be able to make HTTP Posts to a remote server that will return XML. I also need to be able to filter the resulting XML using XPATH before transforming into HTML using XLST. I have no requirement to import the information received from the XML files.

What is the best option going forward? Should I be looking to create a custom module for the project or simply allow PHP within given templates.

I know there are a couple of modules that might be a good place to start I.e. Entry API but I'm looking for some advice from seasoned EE developers on the best way forward.

Thanks, Carl

# Answer
> 1 votes
You should definitely create a module, or use an existing one. PHP in templates is **always** a bad idea.

There are plenty of plugins which let you make web service API calls, such as Rest.

If you want to go the route of creating your own one, how you should start depends entirely on when you want these API calls to be made. If API calls should happen when entries are created/updated, or on some other event, then you probably want to look at making an "Extension". This lets you run custom PHP code based on hooks in ExpressionEngine.

If you want to call the API from your templates, you probably want to create a "Plugin". This lets you create new tags to use in your templates. If you are using the API in your templates , then I assume you are displaying it to the users. In that case, you probably also want to look at caching the responses (either cache the raw response in your PHP code, or cache the resulting template using something like CE Cache or the built in EE template caching options).

---
Tags: xml, http
---


# Question
Title: Contact form vs phpmail/sendmail vs mail()
Symptom: Contact Form does not send mail, but reports success.

maybe someone has an idea how to proceed. I have a standard contact form that DOES return a thank you (success) message but no email is being send.

I tried both sendmail and PHPmail in the email settings - and when I try to send an email from the tools \> communicate form I get errors on both ("Unable to send email using PHP Sendmail/PHP mail")

But if I enable PHP in the template and write a simple piece of PHP:

```
<?php
$to = "name@example.com";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "name@example.com";
$headers = "From: $from";
mail($to,$subject,$message,$headers);
echo "Mail Sent.";
?>

```

This works. So PHP mail() works. ....

What the heck could be possibly wrong? What do I miss here?

# Answer
Have you considered using Freeform? http://devot-ee.com/add-ons/freeform It is not advised to run PHP inside of your templates for various reasons. You are much better off using an addon to accomplish this.
> 6 votes

# Answer
I would recommend using FreeForm. The free version will do exactly what you need as well as saving the contact submissions to the database allowing your client to view them within the CP.
> 1 votes

# Answer
I can't say exactly how they do this but the problem was due to a unusual configuration from the Hoster to comply with German anti-spam legislation. The Solution was to use SMTP. I couldn't get any specifics from the Hoster to explain the symptoms.
> 0 votes

---
Tags: email
---


title: Strange Pre_Load Behavior

text:
# Question
Title: Strange Pre_Load Behavior
I want to restrict channel entries based on a pre\_load variable, so I am doing this:

```
{preload_replace:entry_id_list="{exp:myplugin:get_entries}"}

{exp:channel:entries channel="mychannel" entry_id="{entry_id_list}" limit="10"}

```

But this doesn't display any entries..however, the variable {entry\_id\_list} does have a value (1|2) that matches he entry id.

Now, if I modify the line:

```
{preload_replace:entry_id_list="1|2"}

```

it starts displaying those entries. So, is there a format difference in what the plugin function returns back to the template where function is called?

# Answer
> 2 votes
Parse order I would think.

Preload replace is assigned and parsed in the step before plugin tags.

1. Parse snippets / global variables, segment variables and embed variables * Parse date string constants Parse {template\_edit\_date} and {current\_time} If present, get cached template, then go to #7
2. Parse PHP on Input
3. Parse simple conditionals: segment, embed, global variables
4. Assign and parse preload\_replace variables
5. Parse module and plugin tags
6. Parse PHP on Output Write cache ﬁle
7. Parse advanced conditionals
8. Process embedded templates Redirect
9. Parse User Deﬁned global variables and others
10. Done

(As provided by @low)

---
Tags: ee2
---


title: Creating my first module

text:
# Question
Title: Creating my first module
I have finally managed to get some kind of control panel area created, but cant figure out how to transfer my array over to the view page.

My aim is to create an array from the database, then display the value of that field in the view page.

mcp index function `public function index()
 {`

`$this->EE->cp->set_variable('cp_page_title', $this->EE->lang->line('currency_module_name'));

```
    $this->EE->load->helper('form');
    $this->EE->load->library('table');
    $this->EE->load->library('form_validation');

    $query = $this->EE->db->query("SELECT * FROM exp_currency");

    $data = array (
        "usd" => $query->row('usd'),
        "eur" => $query->row('eur'),
        "gbp" => $query->row('gbp')
    );

    return $this->EE->load->view('add_currencies', $data, TRUE);

}

````

View file

````
<?=form_open()?>

    <?php

        $this->table->set_heading(
            lang('USD'),
            lang('EUR'),
            lang('GBP')
        );

        $this->table->add_row(
            form_input('usd', set_value('usd', $data['usd']), 'id="usd"'),
            form_input('eur', set_value('eur', $data['eur']), 'id="eur"'),
            form_input('gbp', set_value('gbp', $data['gbp']), 'id="gbp"')
        );

        echo $this->table->generate();

        $this->table->clear();

    ?>

    <input type="submit" class="submit" value="<?=lang('update_currencies')?>" />

<?=form_close()?>

````

If anyone can point me in the right direction, that would be great :)

# Answer
> 6 votes
When you pass an array of data on to a view file, the keys become the variable names in that view file. So...

```
$data = array(
    'foo' => 'bar',
    'lorem' => 'ipsum'
);

return $this->EE->load->view('my_file', $data, TRUE);

```

...will mean that in the `my_file` view file you can then use the variables `$foo` and `$lorem`.

In your case, that would mean you can use `$usd`, `$eur` and `$gbp`. That might not be too useful, so I'd pass on those in their own array:

```
$data = array(
    'currencies' => array(
        "usd" => $query->row('usd'),
        "eur" => $query->row('eur'),
        "gbp" => $query->row('gbp')
    )
);

```

...and in your view file:

```
foreach ($currencies AS $key => $val)
{
    form_input($key, set_value($key, $val), 'id="'.$key.'"');
}

```

and so on.

---
Tags: module
---


# Question
Title: Different $base_url for CP versus public site?
I have a unique situation where I'm reverse-proxying an EE site into another domain via Akamai. The origin hostname of the EE site is smallbusiness.pb.com and Akamai rewrites sends traffic coming in via www.pb.com/smb to that URL.

In order to make Structure navigation listings have the correct endpoint URL, I had to modify my Focus Lab LLC configuration by adding the following to my config.prod.php file:

```
$base_url = $protocol . 'www.pb.com' . '/smb';

```

Everything has been fine since I have been manually deploying from staging to production by synching the database and rsyncing files.

Now that I'm rolling out BetterWorkflow, however, I'm running into 403 Forbidden on Assets image thumbnail requests. Those requests are to the www.pb.com/smb URL instead of smallbusiness.pb.com.

Here's a sample of the error:

```
Request URL:http://www.pb.com/smb/?ACT=59&file_id=2&size=67x67&hash=1352925992
Request Method:GET
Status Code:403 Forbidden

```

### Request Headers

```
Accept:*/*
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8
Cache-Control:no-cache
Connection:keep-alive
Cookie:[redacted]
Host:www.pb.com
Pragma:no-cache
Referer:http://smallbusiness.pb.com/smb/admin.php?S=0&D=cp&C=content_publish&M=entry_form&channel_id=3&entry_id=10&parent_id=0
User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.56 Safari/537.17
Query String Parametersview sourceview URL encoded
ACT:59
file_id:2
size:67x67
hash:1352925992

```

### Response Headers

```
Access-Control-Allow-Origin:*
Cache-Control:max-age=0
Connection:keep-alive
Content-Length:0
Content-Type:text/html
Date:Wed, 23 Jan 2013 21:34:55 GMT
Expires:Wed, 23 Jan 2013 21:34:58 GMT
Server:Apache
Set-Cookie:exp_last_activity=1358976898; expires=Thu, 23-Jan-2014 21:34:58 GMT; path=/
Vary:Accept-Encoding

```

What I'm looking for is a way in my configuration file to have one base\_url when browsing the control panel via smallbusiness.pb.com and another base\_url when the public site is browsed via www.pb.com.

Any ideas?

# Answer
Without actually testing this maybe you could use a Request Contant along with a conditional like so in your FocusLab config file:

```
if (REQ == 'CP')
{
    $base_url = $protocol . 'smallbusiness.pb.com';
}
else
{
    $base_url = $protocol . 'www.pb.com' . '/smb';
}

```

You could edit this how you see fit of course though, it's a basic example/start.

Again, please test and let us know :)
> 1 votes

# Answer
The information Nate posted was quite helpful. Based on that and some reading on the link he posted, I was able to come up with the following, which I added to config.master.php:

```
    switch ($_SERVER['HTTP_HOST']) {
        case 'smb-staging.pb.com' :
            $base_url = $protocol . $_SERVER['HTTP_HOST'] . '/smb';
        break;

        case 'smbdev.pb.com' :
            $base_url = $protocol . $_SERVER['HTTP_HOST'] . '/smb';
        break;

        default :
            if (REQ == 'CP' || REQ == 'ACT' || AJAX_REQUEST)
            {
                $base_url = $protocol . 'smallbusiness.pb.com' . '/smb';
            } else {
                $base_url = $protocol . 'www.pb.com' . '/smb';
            }
        break;
    }

```
> 0 votes

---
Tags: assets
---


# Question
Title: EE worldwide date and times for office opening hours
We have a website, that displays a list of regional offices with their opening and closing times. Part of the design requires that each office is styled to show if its is open or closed.

Our initial thoughts on how to handle this is as follows:

Get the current time `{current_time format="%G%i"}` so we have **2033**

We then have custom fields for each entry, these are `{office_open_time}` and then `{office_close_time}` these times are set **using GMT** (the servers time) so lets take USA as an example 0900 in US time would be 1700 GMT, so the US times we set are:

`{office_open_time}` = 1700

`{office_close_time}` = 0100

Our template then checks the times:

```
{if "{current_time format="%G%i"}" <= "{office_close_time}" AND "{current_time format="%G%i"}" >= "{office_open_time}"}
we are open!
{if:else}
we are closed.
{/if}

```

On the whole this works with a few exceptions and issues.

Again lets say our time here in GMT is 2033. The US opening time set in GMT is 1700 so thats correct, but the closing time is 0100 - so the current time is never less than the closing time..!

Then there's also the issue of the weekend but I think we can do that by returning the date as a day and checking if it equals "saturday" OR "sunday" - however I'm not sure how we decide 'when' that's valid... ie it's saturday in the uk before it's saturday in the us!

Any help or suggestions greatly appreciated

# Answer
via this dude on Facebook:

> How about changing your american hours before you test them time (americantime) - (time difference) \< opening\_time sort of thing?
> 0 votes

# Answer
A plugin isn't a bad route to take, I would also take a peek at Moment.js (http://momentjs.com/). They have a lot of "time functionality" built that you could probably harness.
> 1 votes

# Answer
I would probably use a custom plugin. Feed the datetimes (and timezone?) into the plugin with parameters (or as tags), and do the checking, math and calculations with PHP inside the plugin. That also leaves you the option for editors to more easily and comfortably enter office hours in their own timezone.
> 0 votes

---
Tags: date, time
---


# Question
Title: How do I redirect users to group-specific pages on login?
I have a log-in page that needs to direct users to content based on their member group. Currently it is very simple with just two pages.

I have tried it using the single option and it directs correctly.

Example:

> {exp:member:login\_form return="member-area/" }

However, if I introduce a conditional into the mix, it does not redirect correctly:

```
{exp:member:login_form {if member_group == "5"} return="member-area/" {/if} {if member_group == "1" || member_group == "6" || member_group == "7" || member_group == "8"} return="internal-staff-center/" {/if} }

```

I suspect I have overlooked something. I would appreciate any assistance in getting this correctly.

Thanks.

Forrest

# Answer
> 4 votes
What if you do:

```
{exp:member:login_form return="member-redirect/" }

```

And then in the `member-redirect` template you have your conditionals:

```
{if member_group == "5"} {redirect="member-area/"} {/if} {if member_group == "1" || member_group == "6" || member_group == "7" || member_group == "8"} {redirect="internal-staff-center/"} {/if}

```

You don't actually have access to your member\_group variable when you set up the login form. You haven't logged the user in yet.

---
Tags: conditionals
---


# Question
Title: Freeform Pro and Whitelisting with Office 365
We have a client in which we've set up Freeform Pro and have several forms. We've got the forms working properly, but all emails are getting directed to their Spam folder.

The client is using Outlook, as part of the Office 365 package, and have whitelisted the email address that is sending the emails.

Is there any way to change the email address that Freeform is using to send these emails, or be able to mark the emails generated by Freeform not spam?

EE Version: 2.5.3 Freeform: 4.0.7

Thanks in advance!

# Answer
It's possible the addon is using the email address set on the **Email Configuration page** in the CP as the from address. If it matches the from address you are seeing, change it and retest.

Whitelisting the email address is what should stop Outlook from marking as spam. If the emails continue to be marked as spam, I'd say it's not being whitelisted correctly.
> 0 votes

# Answer
You have full control over the "from" address in Freeform's notification settings.

What you might want to do is set a "reply-to" address as well. Set the "From" address to a known, whitelisted address that your mail server will accept, and then use the submitter's email as the "reply-to" address. This lets the received directly reply to the form sender, while allowing the message to be properly received by your server.
> 1 votes

---
Tags: add-on, solspace-freeform, spam
---


# Question
Title: EE1 - Include entry category ID in an embed
I usually use Low Variables or Stash for this, but thought I would toss this one out there anyway to see if I have just been over complicating my templates.

I have a template that pulls in an entry. The entry will have a category assigned to it. This entry also has another section using the same category group. I need to embed a template that displays a list of all the titles in that section with that category. My problem is trying to nest that category id in the embed without using a plug-in.

So in my template, I have something like:

```
{exp:weblog:entries weblog="whatever" limit="1" status="not closed"}

{/exp:weblog:entries}

```

I need to embed a template inside that. I have tried the following:

```
{embed="total/product_list" cat="{category_id}"}

```

and

```
{embed="total/product_list" cat="{categories}{category_id}{/categories}"}

```

and

```
{categories}
    {embed="total/product_list" cat="{category_id}"}
{/categories}

```

I know parsing order has me in a conundrum. like I said, I just thought I would see what solutions were out there. I'm always open to an education. ;)

# Answer
> `{embed="total/product_list" cat="{categories}{category_id}{/categories}"}`

That's the one. Embeds run dead last in parse order, so there should be no issue there. Just make sure that you then use `category="{embed:cat}"` in your embedded template.
> 1 votes

---
Tags: categories, ee1, embeds
---