# Question
Title: "Maximum Image Width" in Upload Destination off by 1px sometimes
I have an "Images" Upload Destination where I have specified Maximum Image Width (in pixels) as 1400. But sometimes, I'd guess 50%, the image ends up at 1401. Any idea why?

What happens is a user uploads a file, I constrain the width to 1400 with that setting, then I tell them to go Edit Image / Crop Mode and crop it to 479. (I don't do this automatically because it could result in bad crops.) It's easier if they can make their box at full width then pull it down to 479 rather than carefully setting both x and y.

# Answer
This was evidently a bug in EE and will be patched in the next version (past 2.8.1). For now, the solution is:

In system/expressionengine/libraries/Filemanager.php around line 508:

```
if (($force_master_dim == 'height' && $prefs['height'] < $prefs['max_height']) OR
                ($force_master_dim == 'width' && $prefs['width'] < $prefs['max_width']) OR
                ($force_master_dim == FALSE && $prefs['width'] < $prefs['max_width']) OR
                ($force_master_dim == FALSE && $prefs['height'] < $prefs['max_height']))

```

Instead of \< it needs to be \<= a la:

```
if (($force_master_dim == 'height' && $prefs['height'] <= $prefs['max_height']) OR
                ($force_master_dim == 'width' && $prefs['width'] <= $prefs['max_width']) OR
                ($force_master_dim == FALSE && $prefs['width'] <= $prefs['max_width']) OR
                ($force_master_dim == FALSE && $prefs['height'] <= $prefs['max_height']))

```

Retrieved from https://support.ellislab.com/bugs/detail/20292.
> 1 votes

---
Tags: file-uploads, image, crop
---


# Question
Title: Is it possible to install/create goup channel on theme install automatically
I am looking to provide my client with the theme.

Is it possible to install/create group channel on theme install automatically.

For eg: In wordpress, We can create custom theme options and meta fields within posts and pages. Similarly is it possible that I can code the extra field portion in my code so that client can simply install theme and create page content rather then creating channels and fields at backend?

# Answer
> 2 votes
I'm pretty certain this isn't possible. Themes have been tried before in Expression Engine, but there's a reason they never really took hold. Quite simply, there are so many different ways to build an EE site and structure the channels, that theming is almost impossible.

Word Press doesn't have a multi-channel approach like EE, hence theming being much easier. If you simply want to provide your client with a theme and a turnkey website, I'd say EE is the wrong platform for what you need.

EE really needs to be set up based on your clients requirements then linked to your page templates. From here your client can work with the content using their own *bespoke* theme that you would setup for them.

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


# Question
Title: Admin two site with Multiple Site Manager
Is possible to publish an entry belong to domain1 in domain2 simply adding a channel field to that entry? Something like:

**Publish on**

* domain1
* domain2
* both domain1 and domain2

I short can I have only one entries' database and choose where to publish them?

Thanks

# Answer
You could add a dropdown field (call it say, display\_on) to your channel with the options *Domain 1*, *Domain 2*, *Domain 1 + 2*.

Then in your channel entries tag:

```
{exp:channel:entries channel="channel_name" search:display_on="=Domain 1" site="domain_1" dynamic="no"}

```

or

```
{exp:channel:entries channel="channel_name" search:display_on="=Domain 1|Domain 2" site="domain_1" dynamic="no"}

```

You could also achieve this using categories instead of the dropdown depending on your content.

```
{exp:channel:entries channel="channel_name" category="1" site="domain_1" dynamic="no"}

```
> 2 votes

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


title: EE control panel dashboard search field

text:
# Question
Title: EE control panel dashboard search field
the search field in EE's dashboard doesn't seem to find anything. what is this field supposed to search?

# Answer
> 1 votes
It searches for (some) settings in the control panel. So you could search for *file*, and you should get a result/link to the file manager. Similarly, searches for *category*, *channel*, *username* should all return results with links to the respective areas of the CP.

However, the search results aren't consistent. Search for *security* and you don't get any results, yet a search for *session* gives a result for the *Security and Session Preferences*.

I'd say its there for someone who has limited knowledge of EE general options and wants to access some of the preferences, but can't find them.

Not entirely useful though!

# Answer
> 1 votes
I'd recommend using Switchboard as I guess it will give you more of the functions and results you'd expect from a search in the CP.

---
Tags: control-panel, search
---


title: Where are view_counts stored?

text:
# Question
Title: Where are view_counts stored?
I have one entry that has way more views than any other. I cant find it set as a deafult entry anywhere so I dont know how it got so high. I want to manually set it back to a lower number, then see how much it increases in one day.

Where is that view\_count\_entry amount for an an entry stored? A db search for teh view count comes up empty...

Thx!

# Answer
> 1 votes
View counts are stored in the `exp_channel_titles` table - `view_count_one`, `view_count_two`, etc.

# Answer
> 2 votes
The hits for templates are stored in the exp\_templates table. The column is called "hits".

Generally speaking though I think that you might get a more accurte idea on where the hits are coming from if you use Google Analytics.

---
Tags: count
---


# Question
Title: Is there a way to validate statuses when using channel forms?
I'm trying to prevent users from changing statuses via the {exp:channel:form} tag, but there does not seem to be a built-in way to actually validate the status on form submission.

I have tried using the status parameter like so:

```
{exp:channel:form channel="my_channel" author_only="yes" status="Pending Approval"}

```

I have also tried using the validation rules parameter, like so:

```
{exp:channel:form channel="my_channel" author_only="yes" rules:status="matches[Pending Approval]"}

```

I have also tried the above while explicitly passing the status in an html input tag, like so:

```
{exp:channel:form channel="my_channel" author_only="yes" rules:status="matches[Pending Approval]"}
     <input type="hidden" name="status" value="Pending Approval">
     <input type="submit" value="submit">
{/exp:channel:form}

```

In none of these cases is the status protected, and users can always change the status with a simple browser edit. I am aware that I can prevent member groups from accessing certain statuses via the control panel, however I do actually want the member group to be able to select the status but only at a certain point in time and not before the entry has been approved by an administrator. Am I overlooking something with respect to a native EE way to validate statuses on channel form submission?

If there is no native way to protect a status when using channel:form, I am thinking there may be a 3rd-party extension that would use one of the form hooks and actually do status validation? If one does not exist, could advice be given as to which channel form hook would be most appropriate to use?

# Answer
> 2 votes
I have come across an old safecracker extension that seems like it may be able to be modified for use with channel forms to handle this, as well as also protecting any other fields from being tampered with that are not explicitly allowed by the extension:

http://devot-ee.com/add-ons/safesharpener

It may be possible to just try editing the hook name to the new channel\_form hook and see if it works. In my own usage case, I will probably end up rolling my own add-on to replace any public-facing channel forms affected by this issue, as I prefer to limit my dependencies on unsupported add-ons which may break and are likely more difficult to maintain than code I have written myself.

Field-exclusion and full validation features should really be incorporated into the core channel form module. I'm somewhat surprised that it hasn't been included, as it is likely a prime target for security problems as many site designers may be lulled into thinking their entry fields and statuses are uneditable when in fact they are quite easily manipulated. At the very least, the EE docs for channel forms needs to be updated to make sure devs understand that statuses are NOT protected in channel forms and that fields that are not included in the form can still be edited by users with a browser editing tool.

---
Tags: channel-form, status, validation
---


# Question
Title: UPDATE Content Elements and issues with unserialize()
**Update**
The issue seems to be an `unserialize()` error. I wasn't getting notified before because CE suppresses error reporting on `unserialize` in various places in `ft.content_elements.php`. I'm going to keep digging to find out whether this is an EE issue, or what.

If anyone has run into unserialize issues with EE before, it would be much appreciated!

**Original Post**

So, I have content elements rendering the content of entries in my templates. For some reason that I can't isolate, some entries are rendered without any output from the content elements tag.

To be clear, it works just fine on some entries, but renders nothing on some entries.

I've checked the database and there is indeed the appropriate data in the `exp_channel_data` table. I've also checked the MySQL and PHP logs for something helpful, but nothing useful seems to be reported.

I'm not even sure exactly where to begin as far as giving helpful code. Would my CE snippet help?

Luckily this problem is only happening in my development environment, so there is a live site with the fishy content we could look at. The other issue is that I noticed this after upgrading various different add-ons and extensions, but even after rolling back the system code (via version control) and resetting my DB to a pre-update version, the issue persists.

Here are the extensions I'm using and version numbers and all that. Any help or guidance would be greatly appreciated! For example, does EE generate any helpful logs during the template parsing process?

EE 2.8.1 Content Elements 1.6.9 Wygwam 3.3 Assets 2.3.1 Low Search 3.1.4 Low Variables 2.4.2 Stash 2.4.6 Structure 3.3.14.4 Zenbu 1.9.1 Zoo Flexible Admin 1.81

Others too...

It seems like there is some kind of error during the parsing process so EE bails on generating the data from the DB. I can see it in the table, but it's not showing up on the front end :(.

# Answer
> 1 votes
Well, this was quite frustrating but I hacked together a workaround that at least lets me move forward and will make due for this use case.

**It seems the issue stems from a database migration.** I dumped the DB from production and loaded it up locally, which is where the non-render issue presented itself. I was able to force the errant entries back into whatever EE-DB-friendly format is required with the following steps.

1. Drop this function into the `ft.content_elements.php` file (taken from here):

```
function mb_unserialize($string) {
    $string = preg_replace('!s:(\d+):"(.*?)";!se', "'s:'.strlen('$2').':\"$2\";'", $string);
    return unserialize($string);
}

```
2. Identify the entries that need to be "re-formatted".
3. Do a wildcard search/replace in `ft.content_elements.php` for `unserialize` with `$this->mb_unserialize`. (`:%s/unserialize(/\$this->mb_unserialize(/` in vim).
4. Load up the entry on the front-end to verify that the multi-byte deserializer is working. If the entry is loading, it should load in EE.
5. Load up the entry edit form in EE. Correct any formatting issues (delete escaped quotation marks, fix hyperlinks, etc.). Save the entry.
6. Undo your previous changes to `ft.content_elements.php`. The entries should load up fine now.

Yeah, definitely not an ideal process, but I am not inclined to go combing through CE's codebase to parse what exactly is going on (for shame!), but hopefully these posts will be properly formatted for future migrations as well.

---
Tags: templates, content-elements
---


title: EE 2.8.1 relationships change

text:
# Question
Title: EE 2.8.1 relationships change
I had

```
{parents channel="gallery"}
    {if parents:no_results}Galleries: 0</a>{/if}
    {if count >= 1}
        {if count == total_results}
        Galleries: <a href="{site_url}models/profile/{embed:modelid}">{parents:total_results}</a>
        {/if}
    {/if}
{/parents}

```

And if 3 galleries and 2 videos, it would say Galleries 3 Videos 2

Now it says Galleries 3 Galleries 3 Galleries 3 Videos 2 Videos 2

I'm sure EE's realtionships changed...any idea what I need to change it to?

Thanks!

# Answer
> 3 votes
You must prefix *all* of the variables inside of a `parents` tag with `parents:`,including `count` and `total_results`.

You also have an extra conditional which you don't need - and, note the change in creating the link to use the `{path}` variable.

```
{parents channel="gallery"}
    {if parents:no_results}Galleries: 0{/if}
    {if parents:count == parents:total_results}
        Galleries: <a href="{path="models/profile/{embed:modelid}"}">{parents:total_results}</a>
    {/if}
{/parents}

```

---
Tags: relationships, conditionals
---


title: How can I enable HttpOnly cookies in EE

text:
# Question
Title: How can I enable HttpOnly cookies in EE
**Update:** Thanks to Dom Stubbs, I have an extension to accomplish this now. It is up on devot-ee and also up on GitHub. Thanks Dom!

**The Original Question**

I am nearly through a security review of a new EE2 version of an existing EE1 site that I hope to launch soon. One of the final issues remaining is to make the cookies HttpOnly. I've tried doing that through this line in the apache config:

```
Header edit Set-Cookie "(?i)^((?:(?!;\s?HttpOnly).)+)$" "$1; HttpOnly"

```

Using the dev tools in my browser I can see that it does indeed append HttpOnly to the Set-Cookie headers, but the issue then becomes that I cannot log in. When I asked Ellislab they tell me that the cookies should not be being dealt with in javascript, which was what I expected the issue might be.

ExpressionEngine does not seem to use the session libraries from codeignitor, if it did I could set a config variable to turn httponly on, but it looks like the session handling code is in the expressionengine side of things.

The real question that I need answered is how can I make HttpOnly cookies work, but I guess that breaks down into some potential subquestions:

1. Am I missing an addon that would allow me to do this without a lot more heartache?Is there something wrong with my apache approach? Are you able to log in if you enable that in Apache, log out and try to log back in?
2. Is there something wrong with my apache approach? Are you able to log in if you enable that in Apache, log out and try to log back in?
3. Failing these, can anybody give me a hint as to where cookies are being set in expressionengine so I can dig in there and try to fix this?

# Answer
I've not attempted to implement HttpOnly cookies with EE, but doing so should be relatively straightforward. If you go to line 805 of Functions.php you'll see the `setcookie()` call EE uses. Directly above that is the `set_cookie_end` hook. As that receives the `$data` array of cookie params it would be trivial to create an extension with a custom `setcookie()` call. The following is untested but I think it should work:

```
function set_cookie_end($data)
{
    // Block EE's native setcookie() call
    $this->EE->extensions->end_script = TRUE;

    // Set a HttpOnly cookie
    setcookie($data['prefix'].$data['name'], $data['value'], $data['expire'],
        $data['path'], $data['domain'], $data['secure_cookie'], TRUE);
}

```

You can use Pkg.io to eliminate some of the hassle of creating the extension.
> 3 votes

# Answer
For anyone else coming across this, ExpressionEngine 2.8.0 introduced a new config variable for httponly cookies, and it's set to 'yes' by default: http://ellislab.com/expressionengine/user-guide/general/system\_configuration\_overrides.html#cookie-httponly-config
> 1 votes

---
Tags: extension, cookies, apache
---


# Question
Title: Wyvern and CKEditor - tags within custom styles not working
I've got a Wyvern field using Typekit, custom CSS and JS. I have a style called 'callout-right' that is applied to divs. It looks like this:

The problem: when I try to change text within the styled div, Wyvern applies the div style to h2, h3, etc.

Here's the HTML it generates. You can see Wyvern is applying the callout-right class to my h2 tag.

I want it to leave my text elements alone.

My JS file is:

```
CKEDITOR.addStylesSet('wyvern', [
{name:'Image on Left',element:'img',attributes:{'class': 'left'}},
{name:'Image on Right',element:'img',attributes:{'class': 'right'}},
{name:'Callout Right',element:'div',attributes:{'class': 'callout-right'}},
{name:'Callout Left',element:'div',attributes:{'class': 'callout-left'}},
]);

```

# Answer
This isn't a Wyvern thing at all, its CKeditor's behavior. Wyvern just wraps CKeditor and provides a few EE specific features. Any and all behavior inside of the editing region is all CKeditor's behavior. You'll have better luck at the CKeditor forums for something like this.
> 2 votes

---
Tags: css, wysiwyg, wyvern, ckeditor
---


# Question
Title: Undefined variable: category_name after 2.8.1 upgrade?
I've run into a problem after updating from 2.7.3 to 2.8.1. I've got a couple pages that have this error (below).

I've also noticed, every time I have an "{exp:channel:entries} {/exp:channel:entries}" tag, the error is present. So if I repeated the tags 3 times, I'de have the error repeat 3 times.

Has anyone ran into this problem after upgrading?

```
Severity: Notice
Message: Undefined variable: category_name
Filename: helpers/segment_helper.php
Line Number: 98

```

# Answer
Found the fix. https://support.ellislab.com/bugs/detail/20152

Edit system/expressionengine/helpers/segment\_helper.php around line 97 to add this conditional above ee()-\>load-\>model(‘category\_model’); so it looks like:

```
if (empty($category_name))
            {
                return '';
            }

            ee()->load->model('category_model');

```
> 8 votes

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


# Question
Title: CartThrob Discounts being applied incorrectly
I've set up a couple discounts based on quantity, for example:

Buy 2 CD's and get $4.98 off Buy 3 CD's and get $14.97 off

Both of these are triggered by the "If order over" field. However, what seems to be happening is that all the discounts are being applied even if the order minimum is not met.

Meaning... if I have 2 CD's in the cart, BOTH discounts are being applied for a total of $19.97 off.

Anyone seen this? Is this a configuration error or a bug?

# Answer
> 0 votes
This discount option is actually *Amount off for orders over 'x' $* rather than a quantity threshold.

So, get $2 discount when your order is over $20.

---
Tags: cartthrob
---


title: Can't log out of my site

text:
# Question
Title: Can't log out of my site
I can't log out of my site's front end. When I try to do so, I get the following message:

```
The following errors were encountered

   • You are not authorized to perform this action

```

If I delete my cookies, then I will be logged out.

I've tried all three setting settings for Website Session Type in the Admin section of the Control Panel, clearing the cookies between tests, but I get the same error when I try to log out.

# Answer
I am getting the same thing. {path='logout'} does not work

This finally ended up working. I use Solspace User, not sure if that is related..

```
<a href="{path='?ACT=16'}&XID={XID_HASH}">Log out</a>

```
> 1 votes

---
Tags: cookies, logout
---


# Question
Title: Create User in the backend on channel form submission
I have a channel **Retailers** with channel fields: **Title**, **Email**, **Country**, etc..

On the front end the visitors on the site can enter information in this channel (if they are retailers) via the **channel form**.

```
{exp:channel:form channel="retailers"}

```

The site is still under construction and we want all visitors that are retailers to "register" or enter some data about themself that is going to be later displayed.

Is there any way to create a **User/Member** in the backend(using some of the channel form data) after submitting this information in the channel **Retailers**?

# Answer
> 1 votes
I would recommend using an add-on like Zoo Visitor, which ties users to channel entries. There is a tag for a registration form which could include any other fields you wanted for the channel entry as well as creating a user.

# Answer
> 0 votes
You could use an extension hook to manually create a new member in the `exp_members` table. Just grab the data from the form and do all your work in your extension.

You'll have to write the SQL queries yourself using the CodeIgniter API, but I've seen it work.

---
Tags: members, channel, channel-form, registration, users
---


title: SolSpace friends secure_action

text:
# Question
Title: SolSpace friends secure_action
Is there a way to secure the Friends forms?

I use ssl for the members section and friends is used there as well. All friends forms are giving me the non-secure message when trying to submit...

I have tried several options, none of them works. Almost thinking to alter the module code to force, only use, ssl

```
{exp:friends:message_folder_form
return="{current_url}"
form_class="form-horizontal"
form_id="accounForm"
secure_action="yes"
secure_return="yes"}

<input type="hidden" name="secure_action" value="yes">
<input type="hidden" name="secure_return" value="yes">

```

# Answer
Unfortunately this feature isn't available as of this writing.

I recommend submitting this as a Feature Request under the specific add-on category. It'll also give other users the option to vote up the feature request, and help us prioritize features to add in upcoming versions of this add-on. http://support.solspace.com/support/discussions

As a workaround for now, you could hard-code an `https://` URL in the `return=""` parameter to replace the non-existent secure\_return="yes" parameter functionality, and use javascript/jQuery to change the `<form>`'s action="" attribute to contain `https://` instead of `http://`.

Alternatively for both cases, you could use the protocol-agnostic `//` instead as al alternative. Eg. use `return="//mysite.com/etc"` and use javascript/jQuery to change the action="" `<form>` attribute to `action="//mysite.com/etc"`. This would cover both http and https cases.
> 0 votes

---
Tags: solspace, solspace-friends
---


# Question
Title: Coupon Code throws error when submitting
I am using Cartthrob 2.5 and EE 2.8.1 and when I use the coupon form from the docs:

```
{exp:cartthrob:add_coupon_form return="cart/view_cart"}
<input type="text" name="coupon_code" />
<input type="submit" name="Add Coupon" />
{/exp:cartthrob:add_coupon_form}

```

EE throws an error:

> The discount code you entered is not valid for any of the items in your cart.

The fields are properly mapped in the CT CP and the coupon entry is set to open without expiration date.

Any setting in CT I might have missed?

Cheers

# Answer
> 1 votes
Oops, as it turned out you have to specify the product ID in the coupon entry. Would be great if the coupon code would apply to all products when left blank.

---
Tags: cartthrob
---


# Question
Title: Freeform hidden field and {exp:member:custom_profile_data}
We have a form on a page, one of the feilds on the form is hidden and contains the following in the "Default incoming data" option field:

```
 {exp:member:custom_profile_data}
 {exp:channel:entries dynamic="no" channel="schools"}
   {if "{member_school}" == "{school_code}"}
     {title}
   {/if}
 {/exp:channel:entries}
 {/exp:member:custom_profile_data}

```

This code produces the correct results when pasted directly into the template, but when used with the freeform field it produces nothing.

Basically I'm checking that if the member\_school field (From the member's profile) matches school\_code (from the schools channel), then output the title of the schools article.

Any idea why this isn't working? Is custom profile data not supported by freeforms?

Thanks!

Here's the composer code we're using:

```
{exp:freeform:composer form_id="{embed:form_id}" return="{segment_1}/{segment_2}/thanks"}
<div class="ff_composer">
{composer:page}
    {composer:rows}
            <div class="line">
        {composer:columns}
                <div class="unit size1of{composer:column_total}">
            {composer:fields}
                {if composer:field_label}
                        <label {if composer:field_name != ''}
                            for="freeform_{composer:field_name}"
                            {/if}>
                            {composer:field_label}
                            {if composer:field_required}
                            <span class="required">*</span>
                            {/if}
                        </label>
                {/if}
                {if composer:field_output}
                    {if composer:field_type == 'nonfield_title'}
                        <h2>{composer:field_output}</h2>
                    {if:else}
                        {if composer:field_name AND composer:field_required}
                            {freeform:field:{composer:field_name} attr:required="required" attr:class="req"}
                        {if:else}
                            <p>{composer:field_output}
                            {if freeform:description:{composer:field_name}}
                            <span class="instruction">{freeform:description:{composer:field_name}} </span>
                            {/if}
                            </p>
                        {/if}
                    {/if}
                {/if}
            {/composer:fields}
                </div>
        {/composer:columns}
            </div>
    {/composer:rows}
{/composer:page}
</div>
{/exp:freeform:composer}

```

After a bit more digging around:

Seems to output the member\_school variable fine if I enter {exp:member:custom\_profile\_data}{member\_school}{/exp:member:custom\_profile\_data} but it won't output the information from "schools" channel. If i just have {exp:channel:entries dynamic="no" channel="schools"}{title}{/exp:channel:entries} it outputs the current page's title instead of the school titles…

# Answer
The "Default Incoming Data" option in the Freeform CP for hidden fields can accept tags and such, but complex template parsing, such as parsing of member fields and conditionals, could be a little too complex for this simple text input field, or not parsed in the correct order.

You could use a **custom Composer Template** with your Composer form, where you add a conditional for hidden field. When this conditional is met, try using your code to hard-code your own hidden field.

For example, starting with this section of your Composer Template code:

```
{if composer:field_output}
    {if composer:field_type == 'nonfield_title'}
        <h2>{composer:field_output}</h2>
    {if:elseif composer:field_type == 'nonfield_captcha'}
        {if freeform:captcha}
                {freeform:captcha}<br />
                <input type="text" name="captcha" value=""
                       size="20"   maxlength="20" style="width:140px;" />
        {/if}
    {if:else}
        <p>{composer:field_output}</p>
    {/if}
{/if}

```

Let's assume your hidden field name is "my\_hidden\_field". You could add a conditional for hidden fields like this:

```
{if composer:field_output}
    {if composer:field_type == 'nonfield_title'}
        <h2>{composer:field_output}</h2>
    {if:elseif composer:field_type == 'hidden'}
        <input type="text" name="my_hidden_field" value="
        {exp:member:custom_profile_data}
        {exp:channel:entries dynamic="no" channel="schools"}
          {if "{member_school}" == "{school_code}"}
            {title}
          {/if}
        {/exp:channel:entries}
        {/exp:member:custom_profile_data}
        " />
    {if:elseif composer:field_type == 'nonfield_captcha'}
        {if freeform:captcha}
                {freeform:captcha}<br />
                <input type="text" name="captcha" value=""
                       size="20"   maxlength="20" style="width:140px;" />
        {/if}
    {if:else}
        <p>{composer:field_output}</p>
    {/if}
{/if}

```

You might also want to put your `{exp:member:custom_profile_data}...{/exp:member:custom_profile_data}` code on one line as well, or else your hidden field might also save extra spaces and linebreaks.

If trying this in the Composer Template editor in the CP doesn't work, try putting your Composer Template code in a regular EE template, inside a `{exp:freeform:composer}...{/exp:freeform:composer}` tag pair.
> 1 votes

---
Tags: solspace-freeform
---


# Question
Title: Multiple custom matrix field in channel form issue
Working with Channel form, I have encountered some problems when working with multiple Matrix fields in a single edit form.

\[EE v2.7.3 and Matrix 2.5.10\]

1. When I work with "native" channel form fields `{field:field_name}` everything works fine and I can edit all matrix fields and post data.
2. When I try to use the "custom code" below (example on MetaQ), only the last Matrix field is working. When viewing source, the problem seems to be that all matrix fields before the last one get the `{row_id}` and the number of rows of the last Matrix in the form (the one with the highest order value in the field group they both belong to).

The template :

---

```
<!DOCTYPE html >
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="fr"> <!--<![endif]-->
    <head>

    </head>
    <body>
    {exp:channel:form  channel="test" entry_id="34"}

     <label for="title">Title</label>
    <input type="text" name="title" id="title" value="{title}" size="50" maxlength="100" onkeyup="liveUrlTitle();">

    <label for="url_title">URL Title</label>
    <input type="text" name="url_title" id="url_title" value="{url_title}" maxlength="75" size="50">

    {cf_couleur}
    <div class="field"><!--THIS IS A MATRIX ROW-->
      <input type="hidden" name="cf_couleur[row_order][]" value="row_id_{row_id}" />
      <input type="text" id="cf_couleur" name="cf_couleur[row_id_{row_id}][col_id_26]" value="{couleur1}">
    </div>
  {/cf_couleur}

   {cf_forme}
 <div class="field"><!--THIS IS A MATRIX ROW-->
      <input type="hidden" name="cf_forme[row_order][]" value="row_id_{row_id}" />
      <input type="text" id="cf_forme" name="cf_forme[row_id_{row_id}][col_id_27]" value="{form1}">
    </div>
  {/cf_forme}
    {/exp:channel:form}

   </body>
</html>

```

---

The matrix generated in the browser :

---

```
<div class="field">
  <!--THIS IS A MATRIX ROW-->
  <input type="hidden" name="cf_couleur[row_order][]" value="row_id_184" />
  <input type="text" id="cf_couleur" name="cf_couleur[row_id_184][col_id_26]" value="{couleur1}">
</div>

<div class="field">
  <!--THIS IS A MATRIX ROW-->
  <input type="hidden" name="cf_couleur[row_order][]" value="row_id_185" />
  <input type="text" id="cf_couleur" name="cf_couleur[row_id_185][col_id_26]" value="{couleur1}">
</div>

<div class="field">
  <!--THIS IS A MATRIX ROW-->
  <input type="hidden" name="cf_forme[row_order][]" value="row_id_184" />
  <input type="text" id="cf_forme" name="cf_forme[row_id_184][col_id_27]" value="cube">
</div>

<div class="field">
  <!--THIS IS A MATRIX ROW-->
  <input type="hidden" name="cf_forme[row_order][]" value="row_id_185" />
  <input type="text" id="cf_forme" name="cf_forme[row_id_185][col_id_27]" value="carrer">
</div>

```

---

The code above is a very simple form that I have done to try to narrow down the problem. On channel ad two matrix fields with just 1 text field in each of them.

I have compared my custom code and the code generated by the native channel form field and cannot see any difference in the field names.

I have then simply put every matrix field in their own embeds, passing the ID of the entry I am editing to the `{exp:channel:entries}` loop around each of them. That works fine, even with my custom code.

I would very much like to understand what is happening here, as I would rather have everything in the form and not make use of embeds.

# Answer
So, a bright (Latvian) mind was kind enough to look into this. It seems the problem lies with ExpressionEngine code on this one.

Embeds or Stash will work just fine but you can also patch EE as follow:

**File:** system/expressionengine/modules/channel/libraries/channel\_form/Channel\_form\_lib.php

**Method:** replace\_tag

Find this:

```
ee()->api_channel_fields->apply('_init', array(array(
    'row' => $this->entry,
    'content_id' => $this->entry('entry_id')
)));

```

Replace with:

```
$field_id = $this->get_field_id($field_name);
ee()->api_channel_fields->apply('_init', array(array(
    'row' => $this->entry,
    'content_id' => $this->entry('entry_id'),
    'field_id' => $field_id
)));

```

That fixes the problem. Tested in EE 2.8.1 with Matrix 2.5.10

Will post bug report.
> 3 votes

# Answer
I believe the matrix row\_id should be unique, so the problem might be where you have 2 matrix fields outputting the same row\_id values (184 and 185 for both fields). Try looking in the db in exp\_matrix\_data for entry\_id 34 and see what the row\_id values are.

I would try using the var\_prefix parameter for your matrix fields and see if that corrects the output, like:

```
var_prefix="mx1" and var_prefix="mx2"

```

Then you would have

```
{cf_couleur var_prefix="mx1"}
  <div class="field"><!--THIS IS A MATRIX ROW-->
    <input type="hidden" name="cf_couleur[row_order][]" value="row_id_{mx1:row_id}" />
    <input type="text" id="cf_couleur" name="cf_couleur[row_id_{mx1:row_id}][col_id_26]" value="{mx1:couleur1}">
  </div>
{/cf_couleur}

{cf_forme var_prefix="mx2"}
  <div class="field"><!--THIS IS A MATRIX ROW-->
    <input type="hidden" name="cf_forme[row_order][]" value="row_id_{mx2:row_id}" />
    <input type="text" id="cf_forme" name="cf_forme[row_id_{mx2:row_id}][col_id_27]" value="{mx2:form1}">
  </div>
{/cf_forme}

```
> 0 votes

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


# Question
Title: Update Quantity In Cart Using Dropdown List
I need to display my cart when the cart button is clicked, allowing the user to update the quantity of the items in his cart using a dropdown list. I can get the amount of items he chose to add to his cart using the {item\_qty} tag, but how do I display this in a dropdownlist (with the maximum number as the total in stock)?

i.e. if the re are 4 items in stock, the dropdownlist should display options 1 - 4.

My code so far:

```
<select name="items[{key}][item_qty]">
    <option value="{item_qty}">{item_qty}</option>
</select>

```

This displays a dropdownlist with one value (1), but need to display the total in stock.

# Answer
> 1 votes
I think it's going to be a bit trickier than that because when you move to the checkout you use the `Checkout` tags instead of the `Product` tag. The difference is that in the `Product` tag `item_qty` represents the number of items the user wants to buy. In the `Checkout` tag `item_qty` represents how many items the user has in their cart. There's not really a ready-made way to do that so you'd need to run a separate query on the product inventory and then use that to populate the drop-down list.

---
Tags: expresso-store, shopping-cart
---


# Question
Title: how to get parent URLs belonging to it's child categories?
i wants to get parent url of child categories like this Example: PRODUCTS & SERVICES \> ENTERTAINMENT \> SURPRISE PROMO.

PRODUCTS & SERVICES is my parent category, and ENTERTAINMENT is PRODUCTS & SERVICES's child category, and SURPRISE PROMO is ENTERTAINMENT's child category. so i need to get full url like this "www.example.com/products-services/entertainment/surprise-promo"

```
{exp:channel:categories category_group="1"}
    <a href="{category_url_title}">{category_name}</a>
{/exp:channel:categories}

```

Please help how to get full URL,

thanks in advance

# Answer
> 2 votes
**GW Code Categories** is pretty much my goto addon for anything to do with manipulating category output. It has useful parameters & variables for this type of stuff: `{complete_path}` & `{output_path}` which would work in your case. There is also an example of category based breadcrumbs:

```
{exp:channel:entries channel="add-ons" limit="1"}
    <a href="{site_url}">Home</a> »
    {exp:gwcode_categories entry_id="{entry_id}" style="linear"}
        {if group_start}<a href="{path="add-ons"}">{cat_group_name}</a> »{/if}
        <a href="{path="add-ons/{cat_url_title}"}">{cat_name}</a> »
    {/exp:gwcode_categories}
    {title}
{/exp:channel:entries}

```

You could also swap `{path="add-ons/{cat_url_title}"}` for `{complete_path}` as it will successively build the URL's in each anchor.

---
Tags: categories
---


# Question
Title: Sorting entries alphabetically in the control panel by default.
I was wondering if there was a quick way to sort entries in the control panel automatically by their titles without modifying core files. Did I miss anything in the documentation and settings?

# Answer
Not by any EE settings, however you could do this by injecting some javascript to click the `Title` column on page load. Install the CP CSS & JS add-on and add the snippet below:

```
// Check to see if element exists first, then click
if ($('th[data-table_column="title"]').length > 0) {
    $('th[data-table_column="title"]').click();
}

```
> 1 votes

---
Tags: control-panel, alphabetically, sorting
---


# Question
Title: Assets in a Matrix can't select files from a subfolder
*EDIT: Nevermind - case of outdated indexes. Could really use a warning when this happens though...*

EE 2.8.1, Assets 2.3.1, Matrix 2.5.10

I've got a Matrix field with an Assets column, which is restricted to a specific Upload Destination. Said destination has subfolders. When I select a file from the Upload Destination folder itself, things work as expected. However, when I select a file from one of the subfolders, nothing appears to register.

# Answer
> 2 votes
Ok, for some reason, the Assets index was outdated for that folder, showing a weird mixture of old and current folders and files. I'm still not sure I'm ok with the ease at which both EE and Assets' indexes get out of sync without warning, but a re-indexing resolved the issue. Sorry for the false alarm.

---
Tags: matrix, assets
---


# Question
Title: Member Registration Notification Options
I am using Profile:Edit for new member registration, but because I need to skip the email conformation step, is there a way to notify the new member of their registration, just to let them know they are now registered?

# Answer
> 1 votes
There are a number of add-ons available that will allow a notification email to be sent upon creation of an entry, which is what Profile:Edit does.

Check out Postmaster

---
Tags: profile-edit, notification
---


title: How to make expiration date required?

text:
# Question
Title: How to make expiration date required?
I need to set expiration date as required for entries on a channel. So is there any way to set expiration date as required for an entry? Thanks

# Answer
I found this add-on by typing "expressionengine, expiration date required" into Google: http://devot-ee.com/add-ons/required-expiry-date
> 3 votes

# Answer
i cant add comments yet, so i add an answer.

maybe cp-css-js from pixel and tonic, can help you out. by adding some javascript validation on the expiration date field

example:

```
$("#expiration_date").prop("required","required");

```
> 1 votes

---
Tags: date
---


# Question
Title: Rich Text Editor image tool not showing up
I'm trying to figure out why the Tool 'Image' function under the RTE module isn't showing up on our front end dashboard. I can easily remove/add other Tools such as 'Underline' or 'Link' and the changes do take place. However, 'Image' will not. I do have it enabled. Am I missing something? Hopefully the images help show you where I am. I appreciate any insight. Thank you.

# Answer
**Found Answer:** Check out the rte.image.php file, line 32. `'cp_only' => 'n'`

It was originally set to 'y'. Now to get it functioning!

Hopefully this helps others.
> 1 votes

---
Tags: rte
---


# Question
Title: Multi-Evironment config bootstrap above webroot on a single server
I'm working on a project that only has one server to work with. That means the production and development server are the same and development is a sub domain (dev.example.com). In the past when I've run into this it hasn't been an issue to use the Focus Labs multi environment bootstrap setup. I just put both system folders above webroot:

* Pulblic\_html
    + www.example.com
        - system
    + dev.example.com
        - system

However on this project we want to put the system folder above webroot:

* system
* Public\_html
    + www.example.com

That presents a problem when putting dev on the same server. They would both point to the same folder above webroot. Is there a way to have the bootstrap file look for a different system folder above webroot?

* system
* system\_dev
* public\_html
    + www.example.com
    + dev.example.com

I trie hacking around the config file, but didn't have any luck. Anyone do this? It seems like a pretty common scenario people would encounter.

# Answer
Another option, though not ideal, would be to put a conditional in the index.php and admin.php files:

```
switch ($_SERVER['HTTP_HOST']) {
    case "www.example.com" :
        $system_path = "../system";
    break;

    case "dev.example.com" :
        $system_path = "../system_dev";
    break;

    default :
        $system_path = "../system";
    break;
}

```
> 1 votes

# Answer
Ultimately it comes down to your hosting company and how much control they have over mapping the domain's web root.

I'd ask your host if you can re-map the production domain to point to /public\_html/public. Same with your development domain, have it mapped to dev\_html/public. So your setup will look like this:

* dev\_html
    + system
    + public
* public\_html
    + system
    + public

Or, another option would be:

* public\_html
    + www.example.com
        - public
        - system
    + dev.example.com
        - public
        - system

That way you can keep your above-root assets separate and tidy.
> 3 votes

---
Tags: focus-lab-master-config, staging-server
---


# Question
Title: Adjustments tag isn't displaying in {exp:store:checkout}
I'm trying to create a listing in my checkout tag of all the adjustments ( taxes, discount ).

However, when I use the {adjustments} tag, they don't print anything. The tags just show up with my markup. Am I missing something?

Below is a simplified version of my cart.

```
{exp:store:checkout next="cart/checkout"}
  {adjusments}
    <tr>
      <td>{adjustment:name}</td>
      <td>{adjustment:amount}</td>
    </tr>
  {/adjustments}
{/exp:store:checkout}

```

# Answer
Ha! There was just a typo in the documentation. No wonder!

https://exp-resso.com/docs/checkout\_tag.html#adjustments\_loop
> 1 votes

---
Tags: expresso-store
---


# Question
Title: How many size options are allowed per item?
Excuse my ignorance but I know very little about Expression Engine and CartThrob. Of course if I knew it all, I would need to ask this question would I?

So, I'm in ExpressionEngine and I click on CartThrob -\>Products -\>Store - Products, I click on one of the items listed under the Title column. It brings up a form where we can enter "Size Options" In there we can enter the following informaiton.

Option Short Name {option\_value} Option Label {option\_name} Price {price} Inventory {inventory} Weight {weight}

My question is how many of these size options can I enter? I have been told that the limit is 150 but find that difficult believe, but I haven't been able to find documentation to support or refute that claim.

# Answer
We've set up quite a large site (1500+ products) which uses about 12 different product options - each of which will have between 2 and 8 choices. I think we've used a max of 3 options on any one product. I don't know of a limit, but if it was 150, this should be more than enough for even the largest of stores.

You can always reduce the options you need by naming them a little more generically. So simply *size* or *colour* rather than being too specific would help keep the count down.

If you are even getting close to 150 options, then something has probably gone awry in the site's planning. Either than or you should probably be looking at an enterprise platform :-)
> 1 votes

---
Tags: cartthrob
---


# Question
Title: Freeform Composer spam prevention recommendations?
I'm using Composer to create my form and the Channel Entry Fieldtype (http://www.solspace.com/docs/freeform/channel\_entry\_fieldtype) to output it. Works great and is so simple. But a spambot just made it through the Captcha field I used (the default EE one), so I'm wondering what spam prevention you guys can recommend?

I've also used HonEEpot (http://devot-ee.com/add-ons/hon-ee-pot-captcha) with success, but using the channel entry fieldtype, I'm not sure how to insert that into my form.

# Answer
The best solution ended up being Snaptcha: http://devot-ee.com/add-ons/snaptcha.

I was originally thinking I'd add a custom field to Composer the same way you add EE's default captcha, but with snaptcha it automatically adds itself inside your form tag and (I assume) just works. Really convenient: just enable and all of your forms get it.
> 1 votes

---
Tags: solspace-freeform, solspace, spam, captcha
---


# Question
Title: Text Input Field Being Wrapped in <p> tags only for first entry
I'm running 2.7.2 and I have a text input field called article summary that is set to format none.

However on the front end the input is getting wrapped in p tags but weirdly enough it's only happening on the first entry.

My code is:

```
<p class="summary">{article_subtitle}</p>

```

And on the front end comes out as:

```
<p class="summary"></p><p>Article Subtitle content</p>

```

I've tried the suggestion on this post but with no luck: Unformatted Field Data Wrapped in \<p\> Tags on Output

Any thoughts?

# Answer
This was a bug with the add on Publisher Lite. The developer provided me with a new build to fix it.
> 0 votes

---
Tags: channel-entries, text-formatting
---


# Question
Title: Playa Search Filter Goes to Blank Screen
I am running playa 4.4.5 and expression engine 2.8.1. In my entries, when I try to search and filter entries in playa, no results will display with the ajax instead it is going to index.php?/cp/content\_publish/entry\_form?channel\_id=7&entry\_id=8539&&filter=YToxOntzOjEwOiJjaGFubmVsX2lkIjtzOjE6IjciO30= . Which is all blank. Can anyone help me here? Thanks

# Answer
> 1 votes
It turned out it was being sent to my index.php page instead of my news.php page. I put this in the config file and it worked `$config['playa_site_index'] = "/news.php";`

---
Tags: playa, search, filter
---


# Question
Title: want more control over URLs. Get rid of template group name for example
I am wanting to get rid of template group names in the URL and basicly get more control over the URL structure.

Maybe template routes will now allow me to do what I want but not sure I understand how that works.

Example:

# myhotel.com/template\_group/template/entry

myhotel.com/room\_types/room/double\_king

where Double King is the entry title

I want: myhotel.com/room/double\_king or even myhotel.com/double\_king

Can I do that with template routes?

THANKS!

greg

# Answer
> 2 votes
I'm not sure if template routes would work as I've not had chance to use them yet, but you could achieve it without Structure by using some basic routing in your template (which may be effectively the same as the new template routing functionality).

Basically, you could change your template group to *room*. Then you could run a conditional on {segment\_2} in the index template.

```
{if segment_2}
    {embed="rooms/_room_types"}
{if:else}
    {embed="rooms/_default"}
{/if}

```

This approach would work, but isn't ideal because of the way embeds and conditionals are parsed in EE - you'd be adding overhead to the server because it would read through both conditions, parsing both your embedded templates before deciding which one it doesn't want.

You could improve the performance by using IfElse which parses the conditionals differently, and avoid using the embedded templates, instead including your channel entries tags within the index template.

# Answer
> 2 votes
Yes, Template Routes should be able to accommodate. Given a route rule to your `room_types/room` template of:

```
/room/{room:alpha_dash}

```

then `http://example.com/room/double_king` would go to that template, and populate the `{segment:room}` variable with "double\_king".

If you want to go to single segments:

```
/{room:alpha_dash}

```

Though the trick here is if you have other valid first segments that need to go elsewhere. You would set your routes in the order of most specific to least specific, so that if you wanted `http://example.com/book-it` to go to another template, you'd want to create a route rule of `/book-it` in a higher position.

# Answer
> 1 votes
You might want to look at Structure - http://buildwithstructure.com/

It bypasses the template/group template URL structure and allows you to create any URL you like. Also makes managing a big page tree with many levels very easy, and help generate navigation and breadcrumbs too.

---
Tags: templates
---


title: Solspace Calendar & dynamic parameters

text:
# Question
Title: Solspace Calendar & dynamic parameters
Does {exp:calendar:events} accept dynamic parameters?

I am trying to pass this in:

```
calendar_id="{tunnel_calendar}{entry_id}{/tunnel_calendar}"

```

where {tunnel\_calendar} is a PLAYA field but this isn't being parsed.

Any ideas?

# Answer
**Turn on Template Debugging in EE**. This will allow you to see if tags are parsed correctly and in the right order.

In the Template Debugger, if you see the following, eg:

```
calendar_id="123"

```

...that means that your Playa code parses before `{exp:calendar:events}`, and all is good.

If you see the following, as-is:

```
calendar_id="{tunnel_calendar}{entry_id}{/tunnel_calendar}"

```

...that means that your Playa code **isn't** parsed before `{exp:calendar:events}`, in which case you'll need to rethink your EE parse order strategy (for example, passing the Playa entry\_ids in an embed containing your `{exp:calendar:events}` code. Really depends on the context).

**Highly recommended read**: http://ellislab.com/expressionengine/user-guide/templates/template\_engine.html
> 0 votes

---
Tags: playa, solspace-calendar
---


# Question
Title: Solspace Calendar : Only retrieve calendars that have events
I have a drop down that lists all the Calendars. However I would like to only show Calendars that have an event assigned to them.

I need something like the show\_empty tag for EE Category Archive: http://ellislab.com/expressionengine/user-guide/add-ons/channel/category\_archive.html#show-empty

# Answer
You can use `{exp:calendar:calendars}` to list calendars, and pass the `{calendar_id}` to `{exp:calendar:events}` or `{exp:calendar:cal}` to see if there are any event entries for that calendar.

Given that there can be variables clashes with common variables such as {total\_results}, {count}, etc, you will likely need to embed the `{exp:calendar:events}` or `{exp:calendar:cal}` code.

Here's an example. In your template use:

```
<select name="something">
{exp:calendar:calendars}
  {embed="calendars/embed" calendar_id="{calendar_id}"}
{/exp:calendar:calendars}
</select>

```

Then, in `/calendars/embed`, use:

```
{exp:calendar:events calendar_id="{embed:calendar_id}" date_range_start="12 months ago" date_range_end="+12 months"}
    {if no_results}
    {/if}

    {if count == 1}
        [{calendar_id}] {calendar_title}<br />
    {/if}

{/exp:calendar:events}

```

Using a timeframe, with `date_range_start=""` and `date_range_end=""`, large enough to cover your events is important, or else you only get a subset of the total events present for a calendar.
> 0 votes

---
Tags: solspace-calendar
---


# Question
Title: Solspace Calendar : Not able to retrieve previous events
I am trying to list 3 previous events but I'm not getting any results. Does anyone have any ideas?

```
{exp:calendar:events
                            event_limit="3"
                            status="open"
                            date_range_end="today"
                            show_weeks="10"
                            orderby="event_start_date"
                            sort="desc"
                            calendar_id="not 400|402"
                        }
                        <div class="col-xs-4 events-item">
                            <a href="{event_url_title}" class="image-block">
                                {event_images limit="1"}
                                <img src="{image:url:small}" alt="{event_title}">
                                {/event_images}
                            </a>
                            <div class="date">{event_start_date format="%M %j, %Y"} - {event_end_date format="%M %j, %Y"}</div>
                            <h3>{event_title}</h3>
                            <div class="description">
                                {event_snippet}
                            </div>
                            <a href="/events/{event_url_title}" class="blue">Read more</a>
                        </div><!-- /row events-item-->
                        {/exp:calendar:events}

```

# Answer
Since you're looking to display 3 previous events **based on a chronological timeline**, you need to use **`{exp:calendar:cal}`**, not `{exp:calendar:events}`. The reason has been explain many times here on EESE, the old Solspace support forums, as well as summarized on this documentation page: http://www.solspace.com/docs/calendar/getting\_started/

Something like this is a good start:

```
{exp:calendar:cal
   date_range_start="3 days ago"
   date_range_end="today"
   pad_short_weeks="n"
   limit="3"}

```

However, this will give you three events/occurrences *starting from 3 days ago*. I assume you want 3 events/occurrences *going back from today*. In that case, you might need to create a PHP array, and pick the last three items in the array. Those would be the events/occurrences closest to your date\_range\_end.
> 1 votes

---
Tags: solspace-calendar
---


# Question
Title: `email` field in exp_comment_subscription table
I disabled the sending of notifications for comments because I created a custom solution that triggers when a user makes a comment.

I am trying to get emails of the subscribers via the exp\_comment\_subscription table.

Normally, I would just connect the dots via the `member_id` but I think I need to know what the `email` field does before doing anything.

# Answer
The `email` field is used for guest comments only. For registered and logged in members who comment, that field will be `NULL`. So for a given `entry_id`, you need to gather email addresses from the `exp_members` table, as well as any values from the `email` column if your site allows guests to comment.
> 1 votes

---
Tags: comments, hook
---


# Question
Title: mightybigrobot profile:Edit forms are not valid html
I have lots of unescaped ampersands in this form. How can I fix this so I can validate my page as html5

# Answer
The simple answer would be to go through the add-on code and replace any ampersands with html entities but I'm guessing you've already tried that?

I don't think there will be a quick way to do it other than doing that.

I would say that you really don't need to worry about it. Validation is a guide, not a requirement. Especially at this level. Are you experiencing problems with the forms? If they work, don't worry about it. They will continue to do so until we're all old and grey.
> 2 votes

---
Tags: profile-edit, validation, mightybigrobot
---


# Question
Title: How do i export/import MX Google Map entries
I need to transfer aprox 700 MX googlemap entries from old db to new. I have tried ajw-export/Datagrab but it does not transfer the geodata.

# Answer
> 1 votes
You could use Google Maps for EE to do this, but you would need a .csv to do it. It comes with a geocoder/import utility that is really robust and will work for almost all data files. I know it's not for MX Google Maps, but this could save you quite a bit of time by not having to roll out a custom solution.

https://objectivehtml.com/google-maps

---
Tags: datagrab, mx-google-map
---


# Question
Title: Can I use a PLAYA field as a search parameter in channel entries tag
I would like to use a custom playa field as a search parameter in my EE channel entries tag, something like this:

```
{exp:channel:entries
                        channel="media_images"
                        search:media_v_location="Denver"
                        status="open"
                        dynamic="no"
                        disable="categories|category_fields|member_data|pagination"
                    }

```

I have the field set as searchable. I presume I should be passing in the {title} of the entry and not the {entry\_id}?

# Answer
You actually can search on playa fields if you've ticked the "Is field searchable?" for the field. I believe the title or entry id of the related field can be used in the search.

For example, both should work:

```
{!--with channel entries--}
{exp:channel:entries
    channel="your_channel"
    search:playa_field_name="an_entry_id"
}
    {title}<br>
{/exp:channel:entries}

{!--with playa--}
{exp:playa:parents
    channel="your_channel"
    search:playa_field_name="a_title_keyword"
    field="playa_field_name"
}
    {title}<br>
{/exp:playa:parents}

```
> 3 votes

# Answer
According to the docs http://ellislab.com/expressionengine/user-guide/add-ons/channel/channel\_entries.html#search-field-name only fields of the type “Text Input”, “Textarea”, and “Drop-down Lists” are searched with this parameter.
> 3 votes

# Answer
I have written an add-on that helps filter channel entries by their Playa relationships. If the solution above doesn't quite do it for you, check out PaternitEE on Devot:ee.
> 2 votes

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


# Question
Title: Exp:resso / FedEx: Shipping methods empty when order is over 4 items
I'm using the FedEx extension for shipping methods/rates. However, when the cart exceeds 4 items, the shipping method options are empty. There is no {error:shipping\_method} displayed when this occurs. Are there limits on the number of items or weight that the FedEx extension will calculate? Or do these limitations possibly exist in the FedEx API?

In the FedEx Rate API docs there is an error described as "660: Weight exceeds limit allowed" which leads me to believe that this may be caused by limitations within the API itself.

# Answer
Fedex as a whole has a weight limit for items they deliver, so I imagine the rate API reflects those limits. A quick Google search says that the limit is 150lbs.

Is your cart weight over 150?
> 1 votes

---
Tags: expresso-store
---


title: Check if template page exists

text:
# Question
Title: Check if template page exists
Is there a way to check if a template page exists?

When we embed pages we do it like this

```
{embed="foo/bar"}

```

I was thinking if it was possible to do something like this

```
{if {template_exists path="some/path"}}
  PAGE EXISTS
{if:else}
  PAGE DOES NOT EXISTS
{/if}

```

# Answer
EDIT: I created a plugin to help if you want. http://devot-ee.com/add-ons/if-template-exists

You can do so with the query module (keep in mind your database prefixes may be different than "exp\_"):

```
{query sql="SELECT
                exp_templates.template_id
                FROM `exp_templates`
                LEFT JOIN `exp_template_groups`
                   ON exp_template_groups.group_id = exp_templates.group_id
                WHERE exp_template_groups.group_name = 'foo'
                   AND exp_templates.template_name = 'bar'
                limit=1"}

    [code if template exists]

    {if no_results} [code if template does not exist]{/if}
{/query}

```
> 1 votes

# Answer
You could use this plugin:

If Template Exists

http://devot-ee.com/add-ons/if-template-exists
> 0 votes

---
Tags: templates
---


title: Show entries based on Grid field

text:
# Question
Title: Show entries based on Grid field
I'de like to show only entries that have gridfield:total\_rows \> 0

Is there a way to do this?

# Answer
> 1 votes
Having given this some more thought, this would be a much simpler approach...

```
{exp:channel:entries channel="channel_name"}
{if '{grid_field}{grid_field:count}{/grid_field}' > 0}
{title} - {grid_field}{grid_field:count}{/grid_field}<br/>
{/if}
{/exp:channel:entries}

```

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


# Question
Title: Output html conditional based on comments in blog post
I'm trying to only output the heading "Comments" when there are actually comments for a blog post.

Here's what I have:

```
{if total_comments >= 1}<h3>Comments</h3>{/if}
{exp:comment:entries sort="asc" limit="20"}
    <div class="text-block">
        <p>{comment}</p>
        <p id="author">By {name} on {current_time format="%F %d %Y"}</p>
    <hr>
    </div>
{/exp:comment:entries}

```

Any help is much appreciated!

# Answer
Before closing the Channel Entries tag, you can use the comment\_total variable. Or if that does not work with your markup, you can use count conditionals in the Comment Entries tag (not nested inside your Channel Entries tag):

```
{exp:comment:entries sort="asc" limit="20"}
    {if count == 1}<h3>Comments</h3>{/if}
    <div class="text-block">
        <p>{comment}</p>
        <p id="author">By {name} on {current_time format="%F %d %Y"}</p>
    <hr>
    </div>
{/exp:comment:entries}

```
> 6 votes

---
Tags: html
---


title: Post from Form to Channel

text:
# Question
Title: Post from Form to Channel
We're developing a form where the user submits a large form - 40 fields plus - which needs to get mailed to two different admins (one with the actual content and one with some other information) but which **ALSO** needs to post to a channel.

As of now we're looking at using Channel:Form and a Postmaster/Notification add on. But am wondering if this is actually the best way. Is there perhaps a more efficient approach using a form-submission module - one that submits the form and also posts to a channel?

Is there such a module? Any tips on how others might approach this?

# Answer
> 1 votes
I think your approach is a good one if you're form is inserting/updating a single channel at a time. I'm doing the same thing with channel form handling the form and Postmaster for the notifications (here's an example from the Postmaster docs).

---
Tags: channel-form, forms
---


# Question
Title: cartthrob 2.5: add_to_cart Tag Not Passing Title Or Price To cart_items_info
I am using EE2.8.1 with Cartthrob 2.5.

The cartthrob {exp:cartthrob:add\_to\_cart\_form} tag pair is working as intended, and passes the title and price of the specified entry\_id without a problem. However, when attempting to do the same with the single {exp:cartthrob:add\_to\_cart} tag the title and price seem to not be passed and do not show up in the cart when attempting to view with cart\_items\_info.

I tried the workaround in this question, but it appears to be a different issue as the cart\_items\_info tag is working with the add\_to\_cart\_form in my case, just not with add\_to\_cart.

For completeness sake, here is the working template code:

```
{exp:cartthrob:add_to_cart_form entry_id="90"}

<input type="submit" value="add to cart">

{/exp:cartthrob:add_to_cart_form}

```

And here is the template code that does not pass the title or price:

```
{exp:cartthrob:add_to_cart entry_id="90" quantity="1"}

```

Is this a bug? I suppose I could also try to auto-submit the form version using some javascript, but obviously a native solution would be preferable.

# Answer
> 1 votes
I found that snagging the add\_to\_cart function from CT 2.4 and replacing the CT 2.5 version seems to work just fine. Haven't found any issues with this so that's my solution for now.

---
Tags: cartthrob
---


title: Nivo slider matrix photoframe

text:
# Question
Title: Nivo slider matrix photoframe
```
 <div id="slider" class="nivoSlider">
                             {exp:channel:entries channel="properties" dynamic="no" limit="10" disable="categories|member_data|category_fields|member_data|pagination"}
                          Start matrix- {property_photos limit="1" sort="asc"}
                            Photo frame- {photo_images size="slider"}
                                <a href="{title_permalink="/properties/view"}"><1mg src="{photo:url}" alt="" title="#htmlcaption" /></a>
                            {/photo_images} {/property_photos} - close matrix

                        <div id="htmlcaption" class="nivo-html-caption">
     <strong>{property_address}</strong><span>{rooms} rooms,{bathrooms} Baths,{beds} beds, House size:{house_size} sq.ft., Price $ {price} <a href="#"> View Property</a></span>
                     </div>{/exp:channel:entries} </div></div>

```

Could anyone give me some advice on how to improve this? When validating html, it warns that's the html caption div is repeated twice. Is there anyway to slim this down ?

# Answer
I'm not sure how you've implemented that or what else is surrounding it but if you had 10 entries, you'd repeat the div 10 times - if you're getting this error repeating twice - you have 2 entries.

If that is expected behavior then I'd imagine the issue is that because you're calling `id='htmlcaption'` and ID's MUST be unique - you simply need to append the entry ID so that it's unique

```
<div id="htmlcaption-{entry_id}" class="nivo-html-caption">

```

If you require that div only once then you should use the simple conditional…

```
{if count==1}
  <div id="htmlcaption" class="nivo-html-caption">...stuff here</div>
{/if}

```

If you need that div at the very end, use this instead:

```
{if count == '{absolute_results}'}
 <div id="htmlcaption" class="nivo-html-caption">...stuff here</div>
{/if}

```
> 0 votes

---
Tags: matrix
---


# Question
Title: Channel Form - Conditionally Show Fields
Basically have a form to submit to a channel but need to show some extra fields depending on whether user clicks yes/no on a radio button. If yes then the hidden custom fields should appear.

Has anyone done this with Channel Form in EE 2.8.1 ? Any pointers?

# Answer
> 1 votes
This sounds like it can probably be done with jQuery, in which some script is loaded so that when a user clicks the radio button some hidden divs show up with the extra fields you want. Just make sure the hidden divs are nested within the channel:form tags.

I've not tested this, but this might get you going in the right direction with showing hidden divs on radio button selection with jQuery: https://stackoverflow.com/questions/5940963/jquery-show-and-hide-divs-based-on-radio-button-click

---
Tags: channel-form
---


title: Import to NavEE?

text:
# Question
Title: Import to NavEE?
I've got an existing site nav with well over 100 navigation elements in it (don't ask) as EE categories. Does anyone knows of a way to import a navigation hierarchy into NavEE, either directly from a category group, or indirectly via CSV or whatever?

# Answer
Not through any built-in method, no. But if you are familiar with writing SQL queries, I'm sure you could get the data out from the categories table, format it as needed, and re-insert it into the NavEE tables.
> 0 votes

---
Tags: categories, import, navigation, navee
---


# Question
Title: Issue with Fedex Extension in Expresso Store
I am using Expresso Store in my sitewhich is built using ExpressionEngine. I am also using Fedex Shipping and UPS Shipping extensions.

We have noticed an issue in our Fedex Shipping Extension. When some of our customers order products, then the Fedex Shipping cost is calculated and displayed wrongly.

This is a very severe issue and we are receiving a lot of customer complaints due to this.

Our From Address:

Place - select 'Massachusetts' (US) Zipcode - 02339

Shipping Address

Place -'nevada' Zip-code - 89423

Following shipping methods are displayed in our site during order process:

```
 Local Pickup - $0.00
 Use Your Own Shipping Account - $0.00
 Contact Me to Discuss Shipping Options/Cost - $0.00
 Fedex Priority Overnight - $81.68
 Fedex Standard Overnight - $207.30
 FedEx 2 Day - $146.91
 FedEx Express Saver - $109.01
 FedEx Ground - $34.91
 UPS Domestic Ground - $35.08
 UPS Domestic 3 Day Select - $98.73
 UPS Domestic Second Day Air AM - $168.78
 UPS Domestic Second Day Air - $147.19
 UPS Domestic Next Day Air Saver - $208.57
 UPS Domestic Next Day Air Early AM - $249.86
 UPS Domestic Next Day Air - $216.56

```

My issue is with the 4th option - **Fedex Priority Overnight**. It's showing wrong value and that too lesser than the **Fedex Standard Overnight** option. The actual cost for Fedex priority Overnight should have been around $200.

I have used the shipping calculator available in the Fedex website for this. Ref : https://www.fedex.com/ratefinder/standalone?method=goToPackageInfoPage

The shipping calculator was showing the cost as $233 for Fedex priority overnight, which should be the correct cost.

This clearly shows that there is something wrong with the Fedex Extension. It was wrongly displaying the value as $81, which is much lower than the actual value.

Options:

From : US zip -code : 02339

To : US zip-code : 89423

No. of packages - 1 Weight : 28lbs

Package type : Your packaging

Dimensions:

Length =\> 16 Width =\> 8 Height =\> 8 Units =\> IN

Can anybody help me in this.

# Answer
> 1 votes
Per the comments:

> The issue is fixed. If we use the test account credentials, the shipping costs will be displayed incorrectly. When I entered the production API details, the shipping costs appeared correctly.

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


title: Expresso Store tax hook help?

text:
# Question
Title: Expresso Store tax hook help?
I’m creating an AvaTax Tax Calculator extension for Expresso Store utilizing the ‘store\_order\_taxes’ hook.

After getting a response from the API, I'm modifying the value of the tax rate as follows:

```
$order->tax_name = $tax_response_object->TaxLines[0]->TaxDetails[0]->TaxName;
$order->tax_rate = $tax_response_object->TaxLines[0]->Rate;
$order->order_tax = $order->order_total * $order->tax_rate;
$order->order_total = $order->order_total + $order->order_tax;

```

Is this the correct way to modify these properties? It seems to be working but, to be honest, it seems too easy. It's the first time I've written an Expresso extension (and my first Expresso store) so I'm a bit cautious.

Any help/guidance would be much apprecaited.

# Answer
Yes I don't see any problem with that if it's just for a simple tax adjustment. We don't look to make things deliberately hard. :)

You could also look to set it up as an actual `tax adjustment` if you wanted to however. Adjustments were introduced in Store v2 to handle extra line items for anything which is *not* a product (e.g. shipping, discounts, taxes). Basically you write an Adjuster class, which is passed each order, and returns an array of adjustments. Each adjustment will either add or subtract from the order total (this happens automatically, all you need to do is return an array of appropriate adjustments).

Then in your templates we provide the `{adjustments}{/adjustments}` loop and corresponding tags to easily loop through and display any adjustments you've added/subtracted from the order.

Like I said though for a simple adjustment there's nothing wrong with how you currently have it but it's useful to know about adjustments if you need them in the future.
> 3 votes

# Answer
To use the `store_order_taxes` hook correctly, you should append a `Store\Model\Tax` object to the list of existing taxes. That way, Store will automatically make all the necessary adjustments to the order totals for you (you shouldn't need to edit the order directly).

If you change the `$order->order_tax` and `$order->order_total` variables directly, you may end up with some calculations not correctly including your tax (there are lots of different totals stored with the order). So it's best to use the built in Tax class and keep everything in sync.

An example of what this would look like in an extension:

```
public function store_order_taxes($order, $taxes)
{
    // make API query here

    // create new tax object
    $tax = new \Store\Model\Tax();
    $tax->name = 'My Custom Tax';
    $tax->rate = 0.15;
    $tax->included = false;
    $tax->apply_to_shipping = true;

    // add to list of taxes to apply to this order
    $taxes[] = $tax;

    return $taxes;
}

```
> 2 votes

---
Tags: expresso-store, extension, hook
---


# Question
Title: How to Display Channel Fields in a Table?
Given a channel with unknown fields (including grids), is there a way to display all the channel's fields in a table? I need a tabular representation of the data I have so that I can sort, filter, etc.

# Answer
Unfortunately EE doesn't really have any built-in facilities for automatically outputting the fields in channels. You'd have to build each template to output whatever fields you wanted.

A potential solution might be to use Open API which is an API module designed for feeding frontend data. That combined with some JavaScript should be able to get you where you want to go.
> 1 votes

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


# Question
Title: Exp-resso won't show states when US is only country
I only want to sell products to US residents. From the Exp-resso admin panel, I've set the United States to be the only enabled country.

However, when I set up the billing form ( I'm using store\_example/checkout2 ) I can't access any states from the state .

Seems like Exp-resso store is using JavaScript to populate the state select tag after you make a country selection. However, when there is only one country, the change isn't registering.

Setting a default country & state isn't making a difference either ( no matter how many countries are enabled ).

# Answer
Per the comments:

> Very strange. It's working fine for me now. I don't recall seeing a JS console error at the time it wasn't working.

Generally Store does update the select menu with states when you change the country, but this also happens once on page load, so I'm not sure why this wasn't working for you.

If you come across it in future, check for JS errors in your browser's error console - it often comes down to something like jQuery not being loaded, or other errors on the page causing Store's JS not to run.
> 1 votes

---
Tags: expresso-store
---


# Question
Title: Expresso Store Get a Quote instead of payment
I'm using Expresso Store v2 for a rental service. Is it possible when a client makes an order he gets a quote? I thought this was a feature but I can't find it.

Or is it possible to put an order on Pending by default? So stock levels will stay the same. I could hide the payment part for the client and it would function as a quote request.

Asking this, it comes to mind that there aren't any options for orders like refund, cancelled etc... I can create an Order state and name it Refund but this doesn't restore the stock levels, total sales etc. I could be wrong and missed something.

Tnx

\[edit\] I solved it (sort of). Still would be nice as a feature. I disabled track\_stock but left the stock numbers intact. So now stock numbers al always maximum. Payment part is hidden and now clients can request a Quote.

# Answer
> 0 votes
To track quotes, you can simply use the 'manual' payment method in Store, which will allow customers to proceed through the checkout without entering their card details etc.

This will still adjust stock levels, so as you found out, if you want to leave stock levels intact you will need to disable the "track stock" option for those products.

Store never adjusts stock levels after an order is complete (when you refund/delete the order etc). The reason for this is that life is often much more complicated (refunded items are faulty, or are still in transit back to your office etc), so we make no assumptions about your business processes. If you wish to restore stock levels for refunded items, this must be done manually.

# Answer
> 1 votes
I know of an add-on that's in development that may be helpful for you. Check out Michael Rog's Expiring Carts. Looks like he's got a private beta going on now.

---
Tags: expresso-store
---


title: Solspace Template Morsals and Calendar

text:
# Question
Title: Solspace Template Morsals and Calendar
I've been trying to diagnose a problem that I started a thread here:

Solspace calendar 500 error

I have it working somewhat using the following:

```
{exp:calendar:cal
         {if segment_3 == ''}
          {exp:template_morsels:fetch
            name="events_calendar_cm"
            segment_4="{segment_4}"
            segment_5="{segment_5}"
            }
         {/if}
         {if segment_3 != ""}
            {exp:template_morsels:fetch
            name="events_calendar"
            segment_4="{segment_4}"
            segment_5="{segment_5}"
            }

        {/if}

}

```

**Event\_Calendar Morsal**

```
 date_range_start="{segment_5}-{segment_4}-01"
 date_range_end="{segment_5}-{segment_4}-last"

```

I've also tried using different variable names like seg\_4, seg\_5, etc. No difference.

The calendar loads, however, it's only loading the first week on both cases:

http://figlancaster.com/events/cal/

http://figlancaster.com/events/cal/month/06/2014/

Plus, the segments don't seem to be parsing for 06/14.

Any thoughts?

# Answer
> 1 votes
Having `{exp:...}` tags used for parameters for another `{exp:...}` tag is a recipe for disaster. That's because `{exp:...}` tags won't parse before another `{exp:...}` tag. In your case, `{exp:template_morsels:fetch}` won't parse before `{exp:calendar:cal}`. You would know this by **turning on Template Debugging** and looking for your `{exp:calendar:cal}` code. Likely you'll see unparsed `{exp:template_morsels:fetch}` code in there.

Further, the way Template Morsels is used above won't help much with performance. TM allows caching of portions of template code in a manner which performs better than normal EE template or tag caching. However, caching two parameters won't do much to performance. What should be done, *if Template Morsels winds up being the only solution* (see the other thread about the 500 error first), is put the whole `{exp:calendar:cal}` code in a morsel.

---
Tags: solspace, solspace-calendar
---


title: Profile:Edit Logout link not working

text:
# Question
Title: Profile:Edit Logout link not working
I just updated to the latest EE, CT and P:E on sunday. Everything's working great so far but I found to have one problem: the logout link for logged in users doesn't work.

The code:

```
{if logged_in}
        {exp:profile:view}<a href="{path='account'}">Hallo {member_first_name} {member_last_name}</a>{/exp:profile:view} • <a href="{exp:profile:logout_link return="/"}">Logout</a>
{if:elseif logged_out}
[...]

```

When clicking the logout link on the frontpage the page refreshes but I am still logged in.

I have tried as superadmin and regular user both with the same behaviour.

I searched here and on the Forums but it seems like I am the only person having this problem... :/

Any ideas on this?

Thanks and Cheers,

Marc

# Answer
> 1 votes
I had a similar issue (EE 2.8.1) and solved this by modifying the logout link to:

```
<a href="{path='?ACT=109'}&XID={XID_HASH}" role="button">logout</a>

```

You'll find the correct action\_ID (ACT) for the profile:edit logout, in the exp\_actions table.

---
Tags: profile-edit, bug, mightybigrobot
---


title: Quick Links for Member Groups

text:
# Question
Title: Quick Links for Member Groups
I have a couple of Member Groups that have access to the cPanel. I'd like to provide them with an easy way to access special frontend pages (instead of them having to type the URLs). There is a "Quick Links Manager" that I see as Super Admin, but whatever I put there doesn't seem to appear in the other Member Groups; also, I don't want all Member Groups that have cPanel access to access these special pages.

Is there something in EE that I can set so that certain Member Groups will have an easy way to access these pages?

# Answer
There are two add-ons that will allow you to define Quick Links globally per member group in the Control Panel:

1) **Member Group Tabs**

> This extension allows you to create navigation tabs for entire member groups in the ExpressionEngine control panel.

OR

2) **Zoo Flexible Admin**

> Zoo Flexible Admin lets you fully customize the control panel menu per membergroup. Insert custom links, rename, re-order and remove menu items in order to create a more intuitive menu.

Zoo Flexible Admin is *really* powerful, giving you complete control of the entire CP navigation per member group.
> 2 votes

---
Tags: members, member-management, cpanel
---


# Question
Title: Display ALL latest related entries using Playa
I'm using Pixel & Tonics Playa which is working great however I am wondering if there is a way to display ALL related entries without the user having to manually select them?

*The example I have is as follows ...*

I have a "profile" channel which displays some info about the member. I want to set up the page to also display the members blog posts using Playa.

Since there are multiple members I cannot hard code this in the template. I know Playa allows you select channels to display related entries but ideally I want to pull in the latest posts for each user without them having to go in and manually select their latest post.

Code snippet:

```
{exp:channel:entries channel="people" disable="categories|category_fields|member_data|pagination"}

<h1>{title}</h1>
{about}

<ul>
    {exp:playa:children field="related_entries"}
            <li>{title}</li>
    {/exp:playa:children}
</ul>

{/exp:channel:entries}

```

When editing the entry, the Playa field looks like this

As you can see in the above image it is a manual process. I want to know if there is a way to set it up so it pulls in the latest posts automatically?

# Answer
> 2 votes
There is not a way to relate certain entries to another automatically with Playa.

Actually you don't need to relate entries to a certain member, because EE already does that for you. When a member is logged in and creates a new entry, that entry is related to that member.

Then with the author\_id paramater in the channel:entries tag you could display all posts by that member, like so

```
{exp:channel:entries channel="blog" author_id="5"}
    ...
{/exp:channel:entries}

```

You created a separate channel for storing extra data about members, I think that's where some problems arise, because then you have two places where you store you member data (in the native Member module and a custom channel). With an add-on like Zoo Visitor you can solve this because then you're able to add all kinds of custom fields (with all field types) for your members.

Let me know if this answers your question!

---
Tags: playa, pixelandtonic, related-entries
---


title: Permission for all Entries in a Channel

text:
# Question
Title: Permission for all Entries in a Channel
Is it possible to assign a group of members some permissions based on channel?

For example, assume that I have channel\_1 and channel\_2, and group\_1. Can I give group\_1 edit permission to all entries in channel\_1 but not allow them to edit entries in channel\_2? How? The documentation is not clear on that.

# Answer
Never mind. Found it. It is under Members \> Groups \> Edit Group
> 1 votes

---
Tags: channel, permissions
---


title: Shipping Labels for UPS, USPS, FedEx

text:
# Question
Title: Shipping Labels for UPS, USPS, FedEx
Is it possible to get shipping labels for orders?

I would like for people fulfilling orders using the backend to be able to print a shipping label for the order.

# Answer
> 1 votes
You don't mention whether you're using an ecommerce add on (eg. Store or Cart Throb). If you're using Cart Throb, CT Admin has a built in generic packing list that you might be able to customise around the requirements of your chosen shipping companies. I'm not so familiar with the options within Store.

For something pretty quick and simple, you could create a basic order manager outside of the EE control panel and limit access to your required admin member group(s). You could then output the details you require into a template and use a print stylesheet based around your labels. So you could output a simple table to list your order numbers and customer names, with a link to your label template.

If you needed anything more involved, or wanted to integrate with your ecommerce add-on, then I think you'd have to look at building a custom module.

---
Tags: shipping
---


# Question
Title: Allow un-logged in user access to a specific channel based on IP address
I am setting up a site that many different schools around the UK will log into.

Our client would like to have schools access areas that are normally restricted by login without having to log in by using their known IP address.

Is there a plugin out there that will effectively allow access to certain channels if an IP address matches one in a list (or from a range)? Alternatively, is there a plugin or method for automatically logging in users if their IP address matches one set somewhere in the admin?

Thanks, John.

# Answer
Nothing comes to mind for a plugin specifically, but this is more of a job for the .htaccess file to handle. If you aren't familiar with all of the rules to apply, there is a great book available - http://htaccessbook.com

There's a few ways to approach this, the following is by no means providing perfect examples but just indicating the possibilities available.

I redirect visitors using the .htaccess file. This one for example will redirect visitors from Russia (^RU$) to another URL, in this case Google's front page.

```
RewriteEngine on
RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^RU$ [NC]
RewriteRule ^(.*)$ http://google.com [R,L]

```

But you could of course redirect visitors to a page that handles information more suited to them or stating when they will be able to access the information at all.

Also, it can be used to redirect UK visitors to the correct location of the pages you wish them to solely see. So it can work both ways.

If it's required to use a known IP address, then the example line would be:

```
RewriteEngine on
RewriteCond %{REMOTE_ADDR} ^55\.55\.138\.243
RewriteRule ^(.*)$ http://google.com [R,L]

```

If it were just a single unique IP address (usually a company IP) then you could use:

```
RewriteCond %{REMOTE_HOST} 123\.456\.789
RewriteCond %{REQUEST_URI} /requested-page\.html
RewriteRule .* /just-for-you.html [R=301,L]

```

There's an alternative to this which is the mod\_rewrite rule.

```
<IfModule mod_rewrite.c>
      RewriteCond %{REMOTE_ADDR} ^111\.222\. [OR]
      RewriteCond %{REMOTE_ADDR} ^123\.456\.789\.0$
      RewriteRule .* http://example.com/right_location_for_UK_visitors [L,R=302]
￼￼￼￼</IfModule>

```

The first condition is matching a range of IP's whilst the second is targeting a single IP address.
> 2 votes

---
Tags: members, channel, authentication
---


# Question
Title: Trying to set up dev / staging environment for EE on Nexcess hosting
So, as a precursor - I'm new to using Git and the FocusLab Master Config and having a few issues getting set up. I'm using a Nexcess shared EEP-100 account.

If I follow everyone's advice on developing with Git, my ideal setup should have a staging or development branch / site alongside the live site so I can push and test changes first before merging and pushing to production and understand that all environments must have the same structure in order to work correctly and herein is my problem…

If I create a secondary domain on the Nexcess account it gets its own folder with web root (html) etc contained and everything works as advertised but this requires a full domain not a subdomain.

When I create a sub-domain the target folder is added to the web root of the primary domain so my set up is not going to be consistent with the local and production environments and i'd be installing everything at web root - in which instance all the base paths etc will be wrong.

How does everyone deal with this when setting up Git / EE?

# Answer
> 1 votes
Strictly speaking, this isn't an issue with either EE or Git, but just a quirk in the Siteworx hosting control panel that Nexcess uses. You can get around it by, instead of adding a subdomain to one of the domains you already configured in the panel, you add it as a new "secondary domain". To do this, go to Hosting Features -\> Domains -\> Secondary. Enter the full (sub)domain you want to use for the staging site in the first input box: e.g. "sub.domain.com". Siteworx doesn't check or care that you previously used "domain.com", it just goes ahead and creates a new webroot on the server, where you can deploy your development site.

---
Tags: focus-lab-master-config, git, hosting
---


# Question
Title: Get Original URL in assets_rename_file / assets_move_file Hooks
The documentation for Assets' assets\_rename\_file() and assets\_move\_file() hooks indicates that the first argument is "an object extending Assets\_base\_file class for the file that is about to be \[renamed or moved\]." But when I call url() on that object, I get the URL of the already renamed/moved file instead of the URL of the original file.

The documentation for Assets' assets\_replace\_file() and assets\_delete\_file() hooks uses the same wording for its first argument. But when I call url() on those objects, I get the URL of the file being replaced/deleted (which is what I expect based on the documentation).

What should the first argument of assets\_rename\_file() and assets\_move\_file() hooks represent?

What I'm trying to do is get the original URL and the URL of the renamed/moved file in the hook, but it doesn't seem possible to get the original URL. So how do I determine which file is being renamed/moved?

We're using ExpressionEngine 2.5.3 with Assets 2.2.1.

# Answer
> 0 votes
Assets 2.2.1 has an issue of calling the hook at the wrong time - you should update to at least 2.2.2 and then the hook will actually be triggered before the rename/move operation with the correct $file variable.

---
Tags: assets
---


# Question
Title: Discussion Forum can't find a few includes
I have undertaken the arduous task of skinning the discussion forum.

I have almost completed it, but can't figure out where a few things are stored.

1. In the localization settings page, where are the forms stored? `{form:localization}, {form:time_format}, {form:language}`
2. In the preview message, and view message pages, I can't find the parsed message include. `{include:parsed_message}`
3. On the view thread pages, the code `{if avatar}{/if}` works, but `{if no_avatar}{/if}` doesn't. I want to include an alternative default image if the user has no avatar stored. Is there a way to do this?

If anyone can point me in the right direction on any of the points about, that would be fantastic.

Have a great Sunday!

# Answer
> 0 votes
Try to find it here: \- "ROOT\_FOLDER"\themes\forum\_themes\default\forum\_global

# Answer
> 0 votes
For item 3 on your list try:

```
{if avatar}
    ...stuff...
{if:else}
    ...other stuff...
{/if}

```

---
Tags: forum, discussion
---


title: Freeform 4 and ExpressionEngine Core

text:
# Question
Title: Freeform 4 and ExpressionEngine Core
Does Freeform 4x (the free version) work with ExpressionEngine Core 2.8.1 ? I uploaded the Freeform folder into the third\_party folder on my server and refreshed the modules page. I wasnt able to see Freeform under it. Am I missing something?

# Answer
> 1 votes
Minutes after posting this I remembered blindly copied the files. My bad. I remember seeing a video that says the developers of add-ons specify the folder structure where the files need to be copied.

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


title: Multilingual Sites and Url Mapping

text:
# Question
Title: Multilingual Sites and Url Mapping
Wondering what solutions people might have for mapping urls in multilingual sites. Our structure is basically:

*en/template/english\_article*

Where each channel has the custom fields for each language set in this way:

*field1\_en, field1\_es, field1\_de - field2\_en, field2\_es*

All fine but the nav is primarily by a language drop down. So someone on the page: *en/template/english\_article* would select, say, Spanish from the menu and be taken to the equivalent Spanish page in the ES template group: *es/template/english\_article*

This would show the Spanish content fine but the 'english article' part of the url should map to a Spanish equivalent...but this seem not so easy to do with the structure of nav by drop down - basically because the url\_title will always be the same.

Has anyone run into this issue? Any workarounds or plugins to resolve it? Cheers!

# Answer
> 1 votes
There's a comment on EE Insider that may be useful to you. It has been contributed by ignitesystemsltd. Thanks for that!

> Our client wanted a multi language URL\_TITLE which would at first seem to be impossible out of the box with the built in URI handling. BUT we overcame this by a simple mechanism:
>
> On the page template that renders the singular item (the details page for a property listing in our case), the client want different URLS for the same item, we created a new field with naming convention {language}\_url\_title and then the url title could be set for each language.
>
> On details page we switched on PHP parsing and used:
>
> $outvar = ""; $langvar = "{language}";
>
> if ($langvar == "en") { $outvar = $outvar . 'search:en\_url\_title="{last\_segment}" '; }
>
> if ($langvar == "de") { $outvar = $outvar . 'search:de\_url\_title="{last\_segment}" '; }
>
> if ($langvar == "swe") { $outvar = $outvar . 'search:swe\_url\_title="{last\_segment}" '; }
>
> This php builds up the search for the URL title.
>
> Then the entries tag looks something like this:
>
> {exp:channel:entries channel="property" \[php echo $outvar\] limit="1"}
>
> I had to use square brackets in line above but you should put proper notation of opening and closing php tag, this window didnt allow it.
>
> The {last\_segment} tag dynamically returns the url title from the current URL. You must simple ensure that you render the correct language url from wherever you want to link from. We are doing this from a search result and rendering the correct link with:
>
> {{language}\_url\_title}
>
> Hope this makes sense.

# Answer
> 0 votes
You really want to consider the Transcribe add-on by EEHarbor. It offers URL translation routing and much more. It will 100% solve the problem you have now. Plus, you don't need separate channel fields for each language.

If you have any questions about implementing Transcribe, don't hesitate to ask here on StackExchange.

For your reference: I built this hotel website with Transcribe and you can see the different URLs for the Dutch version

# Answer
> 0 votes
As well as the conventional multi-language add-ons such as Transcribe you could achieve this using Structure, the Pages module or perhaps even the new template routing in EE 2.8.

I have done something like this with structure where each language's "home" page was given a url based on their country code. For instance /en or /de.

The entries/pages for the different translations were then placed under these pages. This means each entry/page can have it's own language specific URL.

Obviously this means you have to create different entries for each language but that may not be a bad thing and really depends on the nature of your site and how you want it to be managed.

It might also be possible to use the first url segment (the language code) and feed that into your field tags to make things a bit easier for you.

---
Tags: multi-language, multilingual
---