# Question
Title: Zoo Visitor forgot password form redirecting
I'm trying to create a forgot-password form on my site where Zoo Visitor is used to manage members, however, when adding the standard form code from the examples provided I cannot access the form url, I'm getting a 302 redirect back to my login page (I've no redirects set in my htaccess)

linking to {site\_url}members/forgot-password

members/forgot-password template code:

```
{exp:zoo_visitor:forgot_password error_handling="inline" reset_url="/members/reset_password" parse="inward"}
    {if password_sent}
        <h3>
            A password reset mail has been sent to the provided email.
        </h3>
    {if:else}
        <fieldset>
            <p>
                <label for="email" class="form-label">
                    Your email:
                </label>
                <input type="text" name="email" id="email" class="form-text" value="" />
            </p>
            {error:email}
        </fieldset>
        <p>
            <input type="submit" value="Retrieve password" class="button" />
        </p>
    {/if}
{/exp:zoo_visitor:forgot_password}

```

# Answer
I just took a peak at one of my production sites, and I have a password reset like that, but the `reset_url` parameter points to a different page... the actual password reset request (where an email gets sent) and the page it links to (the page where they can actually reset their password) need to be different pages (probably not **need** to, be easier to manage that way).

Here is an example:

**Password reset request page** /account/password

```
{exp:zoo_visitor:forgot_password error_handling="inline" reset_url="account/reset_password" parse="inward" class="forms"}
    {if password_sent}
        A password reset email has been sent to the provided email.
    {if:else}
        Password Reset
        <br>
        Enter your Email address to receive an email with instructions on how to reset your password.
        <label>
            <input type="text" name="email" id="email" placeholder="Email" maxlength="64" >
        </label>
        <label class="error">
            {error:email}
        </label>
        <label>
            <input type="submit" value="Get Password Reset Email" class="btn width-100" />
        </label>
        Please make sure to check your "Spam" folder if you don't receive the password reset email.
    {/if}
{/exp:zoo_visitor:forgot_password}

```

**Password reset page** /account/reset\_password

```
{exp:zoo_visitor:reset_password error_handling="inline" class="forms"}
    {if password_reset}
        Your password has been reset. You can now login with your new password.
        <a href="{site_url}/login">
            Login
        </a>
    {if:else}
        Password reset
        <label>
            <input type="password" name="password" placeholder="New Password" id="new_password" class="width-100" required/>
        </label>
        <label>
            <input type="password" name="password_confirm" placeholder="New Password Again" id="new_password_confirm" class="width-100" required/>
        </label>
        <label class="error">
            {error:password}
        </label>
        <label>
            <input type="submit" value="Reset your password" class="btn width-100" />
        </label>
    {/if}
{/exp:zoo_visitor:reset_password}

```

Also, I'm not sure about your setup, but is your native EE member url set to `/members`? That could be messing with Zoo Visitor. I don't remember enough about the plugin to say for sure.
> 0 votes

---
Tags: zoo-visitor
---


title: Champagne 2 and ee 2.10

text:
# Question
Title: Champagne 2 and ee 2.10
So the cartthrob team (aka mighty big robot) have been bought by Vector Media Group read: https://www.vectormediagroup.com/blog/view/vector-acquired-cartthrob-ct-admin/

I can only assume this is why so many of their ee addons have gone untouched for a while as they were getting out of the game. Hopefully the vector team can bring some life back to some of these great addons.

I updated from 2.7 to 2.10 (big jump). Champagne gave me some errors here are the fixes I came up with:

# Answer
> 0 votes
When loading an entry I would get this error:

> Fatal error: Call to undefined method EE\_Fieldtype::EE\_Fieldtype() in ... expressionengine/third\_party/champagne/ft.champagne.php on line 47

To fix that go to line 47 and change it from: parent::EE\_Fieldtype();

to

parent::\__construct();

Then when I tried to load the module from the modules menu I got this error:

> Fatal error: Call to undefined method Cp::set\_variable() ... expressionengine/third\_party/champagne/mcp.champagne.php on line 64

To fix this I simply commented out line 64. I don't get the error because line 64 looks valid to me it's not using Cp::set\_variable anymore as that was depreciated in EE2.6...anywho, removing the page title fixed the issue for me.

Hope this helps anyone having issues like me.

---
Tags: php-errors, champagne, ee2.9.3
---


# Question
Title: Display a single Calendar Event that spans the current date
I am using Calendar in an attempt to display an Event as a single entry. I have previous events and upcoming events. I need to display the "Current Event". In other words, if the event spans the dates 9-15-2015, 9-16-2015, and 9-17-2015 I need to display it if today is 9-16-2015. If there is NOT an event spanning the current date, I need to show the NEXT event in the calendar. I am using a single calendar for this site.

I want the user to be able to enter a 'range' or add rules as seperate days and times. For that reason, I have this in my date/time display:

```
{if event_has_rules}
    {rules}

    {/rules}
{/if}
{if event_recurs}
    {occurrences}
        <span style="color:#7e7f81;">{occurrence_start_date format="%l %m-%d-%Y"} — {occurrence_start_date format="%g:%i%a"} - {occurrence_end_date format="%g:%i%a"}</span></br>
    {/occurrences}
{/if}

```

I haven't quite figured the rules syntax without blowing up my template yet though...

My primary issue is with displaying the "current" event.

I have this right now:

```
{exp:calendar:events
    calendar_id="20"
    event_limit="1"
    date_range_start="{current_time format='%Y-%m-%d @ %h:%i %A'}"
    show_days="-14"
    dynamic="no"
}

```

I tried the -14 in an attempt to catch anything starting 14 days before the current day.

I also tried without the date\_range\_start in there at all.

# Answer
With a little guidance from Solspace support, I changed to use the cal tag instead of the event tag in order to get in the date range I needed. The docs indicate being able to use the `{event}` tag pair inside, which you are, however the loop was not gathering the data as expected without providing an embed template and passing that embed template the `{event_id}`. I will attach what I ended up with below in full in hopes it may be useful to someone else.

Main template section for the event data:

```
{exp:calendar:cal
    calendar_id="20"
    date_range_start="today"
    date_range_end="today"
    pad_short_weeks="n"
}
    {display_each_day}
        {if day_event_total > 0}
            {events}
                <!-- Blog Post -->
                <div class="row">
                    <div class="span12 module_cont module_blog module_none_padding module_blog_page">
                        <div class="blog_post_page blog_post_preview has_pf">
                            <div class="preview_top">
                                <div class="preview_title">
                                    <h1 class="blogpost_title">{event_title}</h1>
                                    <div class="row">

                                        <div class="span4 module_number_9 module_cont pb50 module_iconboxes">
                                            <div class="listing_meta shortcode_iconbox">
                                                <a href="javascript:void(0)">
                                                    <div class="iconbox_wrapper">
                                                        <span class="ico"><i class="icon-calendar"></i></span>
                                                        <a><h6 class="iconbox_title">When</h6></a>
                                                        <div class="iconbox_body">
                                                            {embed="_includes/_event" event_id="{event_id}"}
                                                        </div>
                                                    </div>
                                                </a>
                                            </div>
                                        </div><!-- .module_cont -->

                                        <div class="span4 module_number_9 module_cont pb50 module_iconboxes">
                                            <div class="listing_meta shortcode_iconbox">
                                                <a href="javascript:void(0)">
                                                    <div class="iconbox_wrapper">
                                                        <span class="ico"><i class="icon-home"></i></span>
                                                        <h6 class="iconbox_title">Where</h6>
                                                        <div class="iconbox_body">
                                                            {address style="schema"}
                                                        </div>
                                                    </div>
                                                </a>
                                            </div>
                                        </div><!-- .module_cont -->

                                        <div class="span4 module_number_9 module_cont pb50 module_iconboxes">
                                            <img src="{address:static_map width='400' height='400' zoom='15'}" alt="{address style='inline'}" />
                                        </div>

                                    </div>
                                </div><!-- .preview_title -->
                            </div>

                            <div class="blog_post_content">
                                <article class="contentarea">{event_summary}</article>
                                <p> </p>
                            </div>

                            <div class="row">
                                <div class="span12 module_number_5 module_cont pb50 module_text_area">
                                    <div class="bg_title"><h5 class="headInModule">Terms and Conditions</h5></div>
                                    <div class="module_content">
                                        <blockquote class="shortcode_blockquote left type1">
                                            <div class="blockquote_wrapper">
                                                {terms_and_conditions}
                                            </div>
                                        </blockquote>
                                    </div>
                                </div><!-- .module_cont -->
                            </div>

                            <div class="row">
                                <div class="span12 module_number_19 module_cont pb0 module_divider"><hr></div><!-- .module_cont -->
                            </div>

                            <div class="row">
                                <div class="span12 module_number_14 module_cont pb60 module_gallery photo_gallery">
                                    <div class="bg_title"><h5 class="headInModule">Gallery</h5></div>
                                    <div class="list-of-images images_in_a_row_3">
                                        {sale_images}
                                            {if image:no_images}
                                                <div class="gallery_item">
                                                    <div>There are currently no images for this sale uploaded. Please check back.</div>
                                                </div>
                                            {/if}
                                            <div class="gallery_item">
                                                <div class="gallery_item_padding">
                                                    <div class="gallery_item_wrapper">
                                                        <a href="{image:url}" class="photozoom"></a>
                                                        <img class="gallery-stand-img" src="{image:url:small}" alt="{image:title}" />
                                                        <div class="gallery_fadder"></div>
                                                        <span class="featured_items_ico"></span>
                                                    </div>
                                                </div>
                                            </div>
                                        {/sale_images}
                                        <div class="clear"></div>
                                    </div>
                                </div><!-- .module_cont -->
                            </div>

                            <div class="blogpost_footer">
                                <div class="blogpost_share">
                                    {exp:sharethis:button
                                        services="facebook|pinterest|twitter|googleplus"
                                        display="hcount"
                                        title="{title}"
                                        url="{current_url}"
                                    }
                                    <div class="clear"></div>
                                </div>
                            </div>
                        </div>
                        <!--.blog_post_page -->
                    </div>
                </div>
                <!-- /Blog Post -->
            {/events}
        {/if}
    {/display_each_day}
{/exp:calendar:cal}

```

Then in the embed template:

```
{exp:calendar:events
    event_id="{embed:event_id}"
    event_limit="1"
    dynamic="no"
}
    {occurrences}
        <span style="color:#7e7f81;">{occurrence_start_date format="%l %m-%d-%Y"} — {occurrence_start_date format="%g:%i%a"} - {occurrence_end_date format="%g:%i%a"}</span></br>
    {/occurrences}
{/exp:calendar:events}

```

This achieved the data extraction I was after for the date ranges that differed.
> 1 votes

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


# Question
Title: {events} variable pair within {exp:calendar:cal} not working the same as in {exp:calendar:events}?
I have a scenario where I need to access conditionals that work in the {exp:calendar:events} tag, eg this works:

```
{exp:calendar:events}
    {title} {if event_never_ends}(never ends){/if}
{/exp:calendar:events}

```

but I need them to work within the {exp:calendar:cal} in order to maintain the chronological order. I though the {events} variable pair was supposed to allow the same conditionals/variable pairs, but this doesn't work (nor does the {rules} variable pair. Is there a special syntax or something I need to use to get something like this to work:

```
{exp:calendar:cal}
  {events}
    {event_title} {if event_never_ends}(never ends){/if}
  {/events}
{/exp:calendar:cal}

```

Thanks in advance!

# Answer
> 0 votes
It seems `{if event_never_ends}` doesn't parse in `{exp:calendar:cal}` but does in `{exp:calendar:events}`. Although it's not sure if this is a bug or a missing feature, we'll report this to our developers.

In the meantime, a workaround could be to use an embed and pass the event\_id in `{exp:calendar:cal}` into a template using `{exp:calendar:events}`, in which you can use the `{if event_never_ends}` conditional. Keep in mind that if there are many events, this would also mean many embeds, and therefore possible decreased performance. Caching might help in those cases.

# Answer
> 0 votes
I was not able to get the data out as expected using the `{events}` tag pair inside of the `{exp:calendar:cal}` tag pair either. Unfortunately, as Solspace already mentioned, I had to use an embed template and pass in the `{event_id}` to the embed and run `{exp:calendar:events}` in the embed.

I left a full example in my answer just now on my original question here. (It seems way too much info to paste in here. I will if need be though.)

Display a single Calendar Event that spans the current date

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


# Question
Title: Possible to send message for status change
Should it be possible to send a notification in mx notify control if the status of an entry changes from x to y?

I can get it to send if an entry with status x is updated but I only want it to send when the status specifically changes from x to y.

# Answer
It's a simple addon, if you don't see that option, it's probably not built in.

Quickest solution would be to roll a quick extension and hook it to the `entry_submission_ready` hook. Then check statuses, and use the email class to shoot out an email.

https://ellislab.com/expressionengine/user-guide/development/extension\_hooks/api/channel\_entries/index.html#entry-submission-ready

https://ellislab.com/expressionengine/user-guide/development/usage/email.html

Something simple like:

```
function my_extension_entry_submission_ready($meta, $data, $autosave)
{
    // submitted updated status
    $status_new = $meta["status"];

    // get previous status
    $status_old = ee()->db->select('status')
                          ->from('channel_titles')
                          ->where('entry_id', $meta['entry_id'])
                          ->get()->row_array();

    $status_old = $status_old['status'];

    // do we meet your conditions?
    if ($status_old == "desired_old_status" &&
        $status_new == "desired_new_status")
    {
        // send email using the email class
    }
}

```

Not sure if that hook hits new submissions (which wouldn't have an entry\_id), so you'll have to play around to get it right (a few extra conditionals so you can bail if it's a new entry).
> 0 votes

---
Tags: mx-notify
---


title: Store: who can access "Settings?"

text:
# Question
Title: Store: who can access "Settings?"
As a member of `Super Admins`, I can access Store's Settings:

I created a new group based on an existing on `Super Admins` and added a registered a user under it. When I tried to access Store's Settings, I get this:

Any idea what's going on? Why can't another Member Group access Store's Settings?

# Answer
You will have to login with your super admin account and go to the settings panel. From there you will need to navigate to the security panel. You should see your member group on the right hand side and you will need to check the boxes for the permissions you want to grant to that member group. (as seen in the picture below)
> 1 votes

---
Tags: expresso-store, add-on, module, addons
---


# Question
Title: How can I highlight the keyword in a search result?
How can I highlight the keyword in a search result?

```
{exp:search:results highlight="yes" backspace="5"}
    <p>
        {excerpt}
    </p>
    <br/>
{/exp:search:search_results}

```

But highlight is not working..

# Answer
There is no highlight function with the native EE search module.

You may want to invest in Low Search which is infinitely better http://gotolow.com/addons/low-search
> 1 votes

# Answer
Some quick research shows their isn't an easy answer without noodling some complicated PHP, or writing your own extension that hooks in to the search results. By why bother when this might already be solved?

https://devot-ee.com/add-ons/search-summary

Try that addon. It hasn't been updated recently, but it got the nod from Derek Hogue, who is a very regular and strong member of this community.l
> 0 votes

# Answer
There isn't a highlight parameter on the search module.

But you can use a first party add-on available on EllisLab github account.
> 0 votes

# Answer
I don't know if javascript can be an option for you but that should be fairly easy. If you're using jQuery, maybe you can try this plugin .
> 0 votes

---
Tags: search, css
---


# Question
Title: How do I force a jpeg image to download instead of open in a browser window?
I have a gallery page that lists medium and high resolution images of plants that users can download. However, the default behavior of a jpeg image inside an href is to open in the browser window. For these specific links I would like users to be able to download the image when clicking on the link instead of having to open the image in the browser and then save it.

Here is the code I have:

```
<div class="topic-links">
 <div class="topic col-sm-4 col-md-4">
  <img src="{gallery_thumb}" alt="temp_square-tn" width="220" height="200">
  <h6>{exp:char_limit total="30" exact="no"}{title}{/exp:char_limit}</h6>
  <p>
    {if medium_res != ""}<a href="{medium_res}">Medium</a><br />{/if}
    {if high_res != ""}<a href="{high_res}">Large</a>{/if}
  </p>
  </a>
 </div><!-- /.topic -->
</div><!-- /.topic-links -->

```

What is the best way to force a download?

# Answer
This is possible and the solution is quite simple:

1. add the reference to the image in an anchor tag: Medium
2. Add the following code to the .htaccess file:

Header set Content-Disposition attachment

Example: http://southernlivingplants.com/resources/image-gallery
> 1 votes

# Answer
If using HTML5, you just need to add the download attribute
> 2 votes

# Answer
This is not possible. The browser chooses how to handle these files, and that is client side. That's why

```
Right click to download

```

Is a thing. A user would have to configure their browser or use a third party browser addon to do this. Sorry, chief.

**Edit**

If you force the mime type, it's possible. But to do it selectively will require (if possible) some serious hacks, I'm betting.

https://www.timewasters-place.com/how-to-force-file-downloading-with-htaccess/

**Edit** on my way to a party on a train, so I'm bored, lol.

You could make a custom module that you link to, like this:

Link to address: `domain.com/?ACT=123&imagepath=images/myimage.jpg`

And in your module, use this answer:

https://stackoverflow.com/questions/1851849/output-an-image-in-php

And throw an `exit()` after. I don't know, killing time on the train! Hopefully leads you in a successful direction.

**Last Edit**

http://php.net/manual/en/function.imagejpeg.php

Set your header for the octet/stream header, then try that function! I don't get paid enough :p
> 0 votes

---
Tags: php
---


# Question
Title: Exp:resso Store - Admin Shipping Fields detached from main Shipping data
We have a few different shipping options set up on the site, but in the admin area when editing the shipping for a particular order just a free text field is provided rather than a drop down of the shipping options.

**Is it possible to change this to a drop down - so that its easier to control the values entered in that field?**

Additionally - changes to shipping made in the admin don't update the shipping data available via the order tag. So any 'order dispatched' emails still show the shipping details made at checkout - rather than those updated by the admin.

**Is there a way to show the final shipping option in the emails?**

Thanks!

# Answer
> 0 votes
First thing: **Admin Area**

What you need is an accessory. You'll have to write one yourself. I can throw some pseudocode at you for the logic.

https://ellislab.com/expressionengine/user-guide/development/accessories.html

Example:

```
function set_sections()
{
    /*
    Here we do a few things

    First, I would recommend checking if we are on the admin page for
    Expresso store. I don't know the plugin, so I don't know it's module URLs or whatever.

    https://ellislab.com/expressionengine/user-guide/development/module_tutorial.html#the-control-panel-file-mcp-download-php

    You'd want something like:

    */
    if (ee()->input->get('method') != 'expresso_store')
    {
        // bail, we aren't even looking at an Expresso Store CP page
        return false;
    }

    /*
    Then, if we aren't bailed, let's insert some jQuery to modify that input
    */

    ee()->cp->add_to_foot('
        <script>
        $(document).ready(function(){

           /*
           jQuery here to replace the input you're concerned about.
           Replace it with a <select> tag with your controlled <option>s.
           */

        });
        </script>
    ');
}

```

Second thing: **Edited via-admin shipping options not showing up via `order` tag**

I have no idea. But let's start with the basics... do you have any caching in place? This data is obviously stored in a database table. After you change a shipping option via the CP, can you reload the same CP page and verify the changes? Also, can you whip a database tool and investigate the Expresso Store DB tables and look at what gets changed to the order when you edit it via the CP? Sorry for asking so many questions, I don't have this addon to play with.

---
Tags: expresso-store, shipping, admin
---


title: Trade pricing in Exp:resso Store

text:
# Question
Title: Trade pricing in Exp:resso Store
I've seen this question asked before but it is from some time ago so I wondered if there is any change.

Original question at Trade prices in exp:resso Store

I need to be able to specify alternate pricing based on member group on a per-product basis. The difference between Standard and Trade prices is not universal so each product needs to have 2 price points rather than a blanket discount.

I'm fairly certain that this still isn't "baked in" to Store but does anyone have suggestions about the best way to approach it?

I'm considering using the modifiers but that seems a rather clunky way to do it and I can't see how to apply mods via member group (although I'm new to Store and working my way through the docs).

# Answer
I have managed to do what I need using product modifiers and some conditional template logic based on the logged in member group.

The logic checks the member group and if the visitor is a "Trade" member then it includes a hidden form field containing the option data within the products tag.

Within the {exp:store:product} tag pair...

```
{!-- add a price modifier for trade pricing --}
{if member_group=='6'}
    {modifiers}
        {modifier_options}
            <input type="hidden" name="{modifier_input_name}" value="{option_id}">
        {/modifier_options}
    {/modifiers}
{/if}

```

I then display the price using:

```
{if member_group=='6'}
    {modifiers}
        {modifier_options}
            {if option_name=="Trade" || option_name=="trade"}
                <h2 class="product__price">Trade Price: £{exp:math formula="{price_inc_mod_val} * 1.2" decimals="2" round="up" trailing_zeros="yes"}</h2>
                <h3 class="product__price--ex-tax">Ex Tax: £{price_inc_mod_val}</h3>
            {/if}
        {/modifier_options}
    {/modifiers}
{if:else}
    <h2 class="product__price">Price: £{exp:math formula="{sundries-details:price_val} * 1.2" decimals="2" round="up" trailing_zeros="yes"}</h2>
    <h3 class="product__price--ex-tax">Ex Tax: £{price_val}</h3>
{/if}

```

*The math plugin is so I can enter prices without tax in the backend but display them with taxes on the front end.*

This appears to be working OK but I haven't fully tested it yet. My concern is that it requires the client to set a specifically named option. It's also a bit crappy on the UI front for the client entering prices. But I think I can get away with it.

If I can find a way to preset a product option then I'd be a lot happier.
> 0 votes

# Answer
I think the best way to approach this is currently to slightly rethink your IA.

You could have a channel called 'Product' that held the product information, galleries, specifications and reviews.

You could then also have a second channel called 'Product Cost' which would include the Expresso Store field type. You could have a relationship from the 'Product Cost' back to the 'Product' and you could also have a field to select which member group this cost is for.

Then on the frontend when loading the product page you can chose the right 'Product Cost' to show based on the member group.
> 0 votes

# Answer
As mentioned in the linked post this is not built in. You have a few options you could create an extension if you are comfortable with PHP. This would be hands down the best approach and most easy to maintain for your clients down the road as they would simply be able to enter the prices per member group as they would normally enter prices in Store.

Another option as others have mentioned would be to have 2 channels with a product description and another channel with product prices per member group.

Yet another option is using modifier names and conditionals in your template.

The last option would be to enable User Defined Prices in the particular channel. Then you could build out Matrix/Grid fields for each of your modifiers with both normal and trade prices(if they modifiers need both pricing. Then in your template you would need to use the input custom modifiers to allow users to select the modifiers. Then you would need to write some javascript to calculate the totals based upon the modifiers and the member group and pass that to a hidden price field. I am doing something very similar on a project with great success.
> 0 votes

---
Tags: expresso-store
---


title: Where is the CMS login page template?

text:
# Question
Title: Where is the CMS login page template?
I need to add some logic for a plugin in the CMS login page but I can't find the correct template to modify.

How can I find the template used by /admin.php?

What have I tried so far:

I can see that when it fails to login it goes to `admin.php?/cp/login` this I assume this should be template path name?

Anyhow, I tried going to `Design > Themes > Member Profile Templates > Default` and select `Login Form` I deleted all content from there but still when I go to `/admin.php` i see the form. I've also done the same with the `Agile Records` but still no luck in making any changes in the template. I've cleared cache after each modification to rule out caching problems.

My other guess that is because we are using an in-house custom theme the system is using that and not the system default one. but when I go to the custom theme folder, there is no login custom page. I can however see that we are using custom CSS but no custom login html form, thus the system cant be using a custom one.

# Answer
> 1 votes
Well, the view file you're looking for is

```
your_web_root/system/expressionengine/views/account/login.php

```

But it's **never** recommended that you edit a core file. See if you can check your custom theme and override it somehow:

https://ellislab.com/expressionengine/user-guide/development/cp\_styles/

If that doesn't work, you could possible use an extension hook to modify view output, or craft an accessory to add JavaScript/jQuery to the login page. I'm not sure if accessories are triggered on the login controller.

---
Tags: templates, login, themes
---


title: EE and Structure nested entries

text:
# Question
Title: EE and Structure nested entries
I'm using Expression Engine 2.7.2 and Structure 3.3.17 and am having a problem creating a nested URL structure.

I have one Channel "Landing Pages" whose entries point to the template /region/index and calls the page content like so:

```
{exp:channel:entries disable="member_data|pagination" url_title="{last_segment}" limit="1" channel="landing_page" cache="yes" refresh="1500"}

    {if no_results}
        {redirect="404"}
    {/if}

    OUTPUT CONTENT....

{/exp:channel:entries}

```

I have created two test entries:

Wellington Landing Page (URL title and 'Structure URL title' both "wellington") - this page is able to be viewed as expected at /region/wellington/

Wellington Kitchens Landing Page (URL title and Structure URL title both "kitchen"). This page has "Wellington Landing Page" specified as its Structure Parent Entry. We need to be able to view this below its parent page in the URL structure, that is at /region/wellington/kitchen/ however this returns 404. It is possible to view it at /region/anyrandomtext/kitchen/ or /region/kitchen/

I have tried replacing the `{exp:channel:entries}` tag with `{exp:structure:entries}` and the problem persists.

Is this something that should work? Any suggestions would be much appreciated.

# Answer
I normally use something else for this kind of cases. Maybe a bit more cunbersome, but works great. You'll need Switchee for this

```
{exp:switchee variable="{segment_1}" parse="inward"}
    {case value="#^P(\\d+)$#|''"}
        segment_1 is empty, get the main page
    {/case}
    {case default="Yes"}
        segment_1 is not empty, so let's first see if there is any more segments
        {switchee variable="{triggers:segment_2}" parse="inward"}
            {case value="#^P(\\d+)$#|''"}
            No, the second segment is empty. display the region info
            {/case}
            {case default="Yes"}
                Segment_2 is not empty, check if there are other segments first
                {switchee variable="{triggers:segment_3}" parse="inward"}
                    {case value="#^P(\\d+)$#|''"}
                    Segment_3 is empty, display the wellington info
                        {exp:channel:entries disable="member_data|pagination" url_title="{segment_2}" limit="1" channel="landing_page" cache="yes" refresh="1500"}
                        {/exp:channel:entries}
                    {/case}
                    {case default="Yes"}
                        Segment_3 is not empty, display the city info (Kitchen)
                        {exp:channel:entries disable="member_data|pagination" url_title="{segment_3}" limit="1" channel="landing_page" cache="yes" refresh="1500"}
                        {/exp:channel:entries}
                    {/case}
                {/switchee}
            {/case}
        {/switchee}
    {/case}
{/exp:switchee}

```
> 0 votes

---
Tags: structure, entries, segments
---


# Question
Title: CI Exception handler and Magento Autoload
I have a system that kind of "merges" ExpressionEngine and Magento. They are coupled in a number of ways and one of them is that we call Mage functionality from EE plugins.

This has just started happening and I can't determine when or where it is occuring.

Can anymoe help out here?

```
[18-Sep-2015 13:36:30] PHP Fatal error:  Uncaught exception 'Exception' with message 'Warning: include(CI/Exceptions.php): failed to open stream: No such file or directory  in /srv/www/htdocs/store/lib/Varien/Autoload.php on line 93' in /srv/www/htdocs/store/app/code/core/Mage/Core/functions.php:245
Stack trace:
#0 /srv/www/htdocs/store/lib/Varien/Autoload.php(93): mageCoreErrorHandler(2, 'include(CI/Exce...', '/srv/www/htdocs...', 93, Array)
#1 /srv/www/htdocs/store/lib/Varien/Autoload.php(93): Varien_Autoload::autoload()
#2 [internal function]: Varien_Autoload->autoload('CI_Exceptions')
#3 [internal function]: spl_autoload_call('CI_Exceptions')
#4 /srv/www/htdocs/na_cms/codeigniter/system/core/Common.php(135): class_exists('CI_Exceptions')
#5 /srv/www/htdocs/na_cms/codeigniter/system/database/DB_driver.php(1172): load_class('Exceptions', 'core')
#6 /srv/www/htdocs/na_cms/codeigniter/system/database/DB_driver.php(330): CI_DB_driver->display_error(Array)
#7 /srv/www/htdocs/na_cms/expressionengine/libraries/Template.php(2806): CI_DB_driver->query('SE in /srv/www/htdocs/store/app/code/core/Mage/Core/functions.php on line 245

```

# Answer
> 0 votes
`[18-Sep-2015 13:36:30] PHP Fatal error: Uncaught exception 'Exception' with message 'Warning: include(CI/Exceptions.php): failed to open stream: No such file or directory in /srv/www/htdocs/store/lib/Varien/Autoload.php on line 93' in /srv/www/htdocs/store/app/code/core/Mage/Core/functions.php:245`

Well, I would assume someone messed up your EE install (accidentally moved a folder or something). That path would look for that file in here: `/srv/www/htdocs/store/lib/Varien/CI/Exceptions.php`. Does it live there?

**Edit**

I also hate the autoload shit. Anyways, go to line 93 of that `Autoload.php` file, and try adjusting it to the full path of the `Exceptions.php` file. Probably something like `/srv/www/htdocs/system/codeigniter/CI/Exceptions.php`.

Not sure with your setup. Try SSH'ing in, and navigate to `/srv/www/htdocs/`. Then pull one of these suckers:

```
$ find . -name "Exceptions.php"

```

That'll locate that file.

This may all be bullocks since you have an interesting setup. Let me know.

---
Tags: ee2
---


# Question
Title: post PHP multiple checkbox array and send values in email
I have a form on my website that sends the captured values of the form to an email address. On my form I have input types of text, and checkbox. But every time I submit the form with checkbox values checked the email shows up blank, with not captured values. I am using a foreach loop to check the checkbox array of its values, but maybe the loop is only seeing the Array and not the individual values of the array? Also the form is no longer redirecting to the redirect page. That must mean that the http\_code is \> 200 and the info is posting with an error code, but not sure what error?

Any and all help to understand the posting process would be greatly appreciated.

**EDIT** I added the form tags to the html. The form posts to submit.html (where the php lives)

my html

```
 <form id="form" method="post" action="/submit" enctype="multipart/form-data">
   <div class="field">
        <label for="name">Name:</label>
        <input type="text" name="name" id="name" />
    </div>
    <div class="field">
        <label for="categoryType">Category type:</label>
        <input  type="checkbox" name="check_list[]" value="value1">
        <label>value1</label>
        <input  type="checkbox" name="check_list[]" value="value2">
        <label>value2</label>
        <input  type="checkbox" name="check_list[]" value="value3">
        <label>value3</label>
   </div>
</form>

```

My php: submit.html

```
<?php

 $name         = $this->EE->input->post('name');
 $checkList  = $this->EE->input->post(['check_list']);

 foreach ($checkList as $check=>$value) {
          $msg  = '<p><strong>Category</strong> '.$value.'</p>';
    }

 $msg  = '<p><strong>Name:</strong> '.$name.'</p>';
 $msg .= '<p><strong>Category</strong> '.$value.'</p>';

    $this->EE->email->wordwrap = true;
    $this->EE->email->mailtype = 'html';
    $this->EE->email->to('email@emailcom');
    $this->EE->email->subject('form');
    $this->EE->email->message(entities_to_ascii($msg));
    $this->EE->email->Send();

     if($http_code > 200) {
      print "<p><strong>Error</strong> </p>";
    } else {
      header( 'Location: redirecturl' ) ;
    }
?>

```

---

**EDIT 2**

With the suggestions from @jrothafer I have updated the submit.html file to look like this:

```
<?php

 $name         = $this->EE->input->post('name');
 $check_list  = $this->EE->input->post(['check_list']);

 $msg  = '<p><strong>Name:</strong> '.$name.'</p>';
 $msg .= '<p><strong>Category</strong> '.$value.'</p>';

    ob_start();
    var_dump($check_list);
    $result = ob_get_clean();

    $this->EE->email->wordwrap = true;
    $this->EE->email->mailtype = 'html';
    $this->EE->email->to('email@emailcom');
    $this->EE->email->subject('form');
    $this->EE->email->message(entities_to_ascii($msg . " - " . $result));
    $this->EE->email->Send();

     if($http_code > 200) {
      print "<p><strong>Error</strong> </p>";
    } else {
      header( 'Location: redirecturl' ) ;
    }
?>

```

By correctly formatting the brackets I think I have eliminated the error code and the page successfully redirects to the redirect url on submit. The email is sending and the ob\_get\_clean(); returns

```
array(2) { [0]=> string(5) "value1" [1]=> string(5) "value2" }

```

Also just noting here that the foreach loop returns only the last value of the array.

```
      foreach ($check_list as $check=>$value) {
          $msg  = '<p><strong>Category</strong> '.$value.'</p>';
    }

```

So now I tried using

```
ob_start();
var_export($check_list);
$result = ob_get_clean();

```

and the return captured value is:

```
 array ( 0 => 'value_1', 1 => 'value_2', )

```

Does this mean I need to capture each value individually? Or can you point me in the direction to find out how to return specific key value pairs?

# Answer
Please post your `<form>` tags.

First thing, **no square brackets** belong on this line:

```
$checkList  = $this->EE->input->post(['check_list']);

```

It should be

```
$checkList  = $this->EE->input->post('check_list');

```

And please do some debugging if you're confused:

```
$checkList  = $this->EE->input->post('check_list');

ob_start();
var_dump($checkList);
$result = ob_get_clean();
// email the $result variable to yourself, it is a string of that var_dump
// that will tell you what you're getting

// ...

$this->EE->email->message(entities_to_ascii($msg . " - " . $result));

// ... continue

```

And for frigs' sake, **stop** using camelCase in PHP. Sorry, I don't mean to be a jerk but it's really awful a million miles away from PSR-1 standard.

https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-1-basic-coding-standard.md
> 1 votes

# Answer
Here is a quick solution ...try this

```
    <label for="categoryType">Category type:</label>
    <input  type="checkbox" name="check_list[]" value="value1">
    <label>value1</label>
    <input  type="checkbox" name="check_list[]" value="value2">
    <label>value2</label>
    <input  type="checkbox" name="check_list[]" value="value3">
    <label>value3</label>

```

```
//PHP CODE

$check_list = implode("|",$_POST['check_list']);

//now just put $check_list in your mail body....ping back if you need any help

```
> 0 votes

---
Tags: ee2, php, forms, html
---


title: Setting entry status with Channel Form

text:
# Question
Title: Setting entry status with Channel Form
I have a Channel Form set up which is working fine and inserting entries into a Channel with the default status.

Now there is a requirement to allow the status to be changed when creating the entry via the Channel Form but for the life of me I can't get it to work.

I have tried using the Channel Form {status} tags and also tried hardcoding the select drop down but no matter what I do the default status is applied.

Here's the EE tag version

```
<select id="status" name="status">
{statuses}
    <option value="{status}"{selected}>{status}</option>
{/statuses}
</select>

```

And here's the HTML

```
<select name="status">
    <option value="Pending">Pending</option>
    <option value="Approved">Approved</option>
    <option value="Declined">Declined</option>
</select>

```

The only thing I can think of is that I'm trying to set a custom status and not the normal "open" or "closed". Even using standard "open" and "closed" (via the EE generated drop down) doesn't work.

The site is using EE 2.9.0.

Has anyone run into this problem?

# Answer
I've encountered exactly the same problem with 2.10.1. No matter what I set the status to, it always writes as 'Open'. I'm sure I've got the proper group assigned and title-casing for 'Pending'... I can only conclude it's a system bug.
> 1 votes

# Answer
Silly question, but you're sure the custom status group is assigned to that channel, right?

Have you tried {status\_menu} ?

https://ellislab.com/expressionengine/user-guide/add-ons/channel/channel\_form/#status

Although the second code you tried looks like it should work.
> 0 votes

# Answer
i've this hardcoded checkbox tag working, didn't did anything special, try this..

```
<label for="open"><input name="status" type="radio" value="open" id="open" {if "{status}" == 'open'}Checked{/if}> <strong>Public</strong> </label>
<label for="draft"><input name="status" type="radio" value="draft" id="draft" {if "{status}" == 'draft'}Checked{/if}> <strong>Private</strong> </label>

```

Cheers.
> 0 votes

# Answer
i assume from your hard coded example you've set up the Status group with those entries? status is validated against the status group...

As Marc Miller illudes to, have you linked your custom status group to the channel you are posting in (Admin -\> Channel Administration -\> Channels -\> Edit Group Assignments (on the desired channel))?

Lastly, using your hard coded example, haveyou double checked the casing on your statuses? They are case sensative! Worse still when you edit statuses in the CP Open and Closed are displayed *proper case*, however the value you need to submit in *lowercase* (notice this in lincolnpixel's example above?).

If you create a new status the value submitted should match the case you typed in on custom statuses editing screen, if its the default Open and Closed, these values must be lowercase. for the ultimate check look at your `exp_statuses` table.
> 0 votes

---
Tags: safecracker
---


# Question
Title: 100 Spam Registrations Per Day Even With Low NoSpam
We installed Low NoSpam recently and already have captcha enabled and in the Low NoSpam documentation it reads like it will delete all spam registrations, but instead they're just sitting in our database waiting to be deleted. Is this the case and we just need to manually delete them? Or should they automatically be purged. Or is something else wrong? At one point before we caught the issue we had over 800,000 registrations on the site that should only have about few hundred at this point.

Thanks for any help you can offer.

# Answer
> 1 votes
Low NoSpam is not deleted members. It is just helps to block spammer.

If you want something different - try VZ Bad Behavior

# Answer
> 0 votes
Check your settings in Low NoSpam. Have you set "check member registrations" to "yes"?

Are also the member groups selected that should be checked?

---
Tags: low-no-spam
---


title: Removing & regenerating url titles?

text:
# Question
Title: Removing & regenerating url titles?
How could I go about removing and regenerating all URL titles for a specific channel? I did so once in the past, but unfortunately I have misplaced the query that was provided to me.

# Answer
> 3 votes
As variant you can just use MX Title Control and regenerate you url\_ titles by any pattern;

by default this ext is repeated default EE logic and convert url\_title into a low case.

if you want to change this logic, */mx\_title\_control/ext.mx\_title\_control.php*, line 125:

replace

```
$url_title_name_out = $this->convert_accented_characters(strtolower($url_title_name_out));

```

with

```
$url_title_name_out = $this->convert_accented_characters($url_title_name_out);

```

p.s. maybe I will add a setting for this in next version ;)

# Answer
> 2 votes
Here's another wing at it, one that will probably be more successful. Note that if you have thousands and thousands of rows in your `exp_channel_titles` table you might have to up your PHP's `mem_limit`.

**Again**, back it up before proceeding.

First, create yourself a temporary template somewhere. Make sure only SuperAdmin can view it (it's in the Access settings for the individual template). Next, turn PHP on output for that template. Here we go!

```
<?php

// what channel id are we working?
$channel_id = '666';

// got multisite? if so add this
$site_id = '2';

// set our separator, either _ or -
$separator = '-';

// get all the titles and url_titles
$titles_array = ee()->db->select('title, url_title, entry_id')
                        ->from('channel_titles')
                        ->where('channel_id', $channel_id)
                        ->where('site_id', $site_id)
                        ->get()->result_array();

// now lets loop over our entries and actually do the replace
foreach($titles_array as $key => &$value)
{
    // start with a shave and a haircut!
    $new_value = trim($value[$key]['title']);

    // replace spaces with our separator
    $new_value = preg_replace('/[\ ]/', $separator, $new_value);

    // now drop all non a-z characters, case insensitive, and not the _ or -
    $new_value = preg_replace('/[^a-z\-\_]/i', '', $new_value);

    // now lower case that puppy
    $new_value = strtolower($new_value);

    // stick it in the url_title spot
    $titles_array[$key]['url_title'] = $new_value;
}

// now update those rows!
ee()->db->update_batch('channel_titles', $titles_array, 'entry_id');
?>

```

Killer! Now this is untested, so again, **backup** the `channel_titles` table before doing anything. If there are any PHP errors coming from this, comment or edit your question and I'll correct them.

**Edit**

To be clear, you should do everything I said, and then visit (or curl) this template **ONCE**, then verify it did what you wanted. If not, immediately restore from the backup I've screamed you should have. If you're unsure what URI to hit, in general with EE, you can hit things like this

```
http(s)://www.your-domain.com/your_template_group/your_test_template

```

# Answer
> 0 votes
**See my other answer for the better solution**

Alright, finally, some fun!

Ha, not really. This is your answer in the terms of a MySQL call. However, I will warn you that I do not know the the exact list of what punctuation EE strips from the title when it generates the `url_title`. I'll look it up and try and update it shortly, but I wanted to get this answer in.

**First**

**Back up your `channel_titles` table before continuing**, and be prepared (know how) to restore it if things go awry. I can't emphasize this enough.

Here's a MySQL call that will get you started.

```
USE your_ee_schema;
UPDATE exp_channel_titles SET url_title =
LOWER(
    REPLACE(
        REPLACE(
            REPLACE(
                REPLACE(
                    REPLACE(
                        REPLACE(TRIM(title), " ", "_"),
                    "!", ""),
                "?", ""),
            "~", ""),
        "'", ""),
    "\"" ,"")
)
WHERE channel_id = 'your channel id' AND
WHERE site_id = 'your site id';

```

Ok, so this chains MySQL `REPLACE` functions to cut out improper `url_title` characters. In this case, it starts with a `TRIM` to remove extra spaces at the end and beginning of the `title`. Then it first replaces all spaces with underscores (you may need to change this to replace it with dashes, depends on your EE setup). Then it chains out and removes these characters:

```
!?~'"

```

The most outer function is `LOWER`, which then sets the value to be all lowercase.

**Like I said**, back up your data, and this query definitely doesn't cover all of the characters EE removes when it generates url\_title. You'll have to keep chaining `REPLACE` functions together to get all of 'em; I'll dig in the core and try and get you a list, but you'll have to modify the query to add all the extra chained `REPLACE` functions :p I can't do all the work for you!

So to be clear, this query took this `title`

```
Aren't Things healing Nicely?!

```

and converted it and then inserted it to the `url_title` as this

```
arent_things_healing_nicely

```

---
Tags: url-title
---


# Question
Title: SQL query in a channel:next/prev_entry to output an image in a matrix column
I'm trying to create a Prev / Next navigation system using thumbnail images. The images for each entry are held in a four column matrix field (field\_id = 8). I just want the first image held in the first column (col\_id\_38).

I'm using R.Sanchez's `{exp:parse_file_paths}` plugin to pull the image data without resorting to more embed or stashed lists.

Since `{exp:channel:prev_entry}` has to parsed outside of the `{exp:channel:entries}` tag, my current detail page template looks like this:

```
{exp:channel:entries channel="{segment_1}" disable="member_data|pagination" url_title="{segment_2}"}
    {title}
    {body}
    {stash:embed name="snippets:page-villanav" process="start" parse_depth="2"}
{/exp:channel:entries}

```

The `stash:embed` which looks like this:

```
{exp:channel:next_entry channel="{segment_1}" entry_id='{exp:transcribe:entry_ids channel="villa"}' parse="inward"}
    <div class="gallery">
       <a href="{path={segment_1}}">
       {title} // This is showing the correct Next entry title
       {exp:query sql="SELECT * FROM exp_matrix_data WHERE field_id = '8' && entry_id = '{entry_id}'"}
            {entry_id}          // This is showing the correct "Next" entry_id
            {exp:parse_file_paths}
                {background_image}
                    {image_01}  // This is showing the current entry's image filepath. Not the "Next" entry's first image filepath.
                {/background_image}
            {/exp:parse_file_paths}
        {/exp:query}
       </a>
    </div>
{/exp:channel:next_entry}

```

The problem is that, despite the query displaying the "Next" entry\_id, `{exp:parse_file_paths}` is pulling the first image from the matrix field for the "current" entry.

Any clues?

# Answer
Solved it:

```
{exp:query sql="SELECT col_id_38 AS file FROM exp_matrix_data WHERE entry_id = '{entry_id}'"}
    {exp:parse_file_paths}
        {file}
    {/exp:parse_file_paths}
{/exp:query}

```
> 0 votes

---
Tags: matrix, image, query, sql, next-prev
---


# Question
Title: What's the best way to handle limited membership periods and/or expiry?
This doesn't seem to be part of EE core, which - honestly - surprises me. Maybe I'm missing something.

I'd like to be able to limit membership periods by setting an expiry date on specific members (not the group), when approved by the admin in the CP.

I don't believe this is an unusual requirement, how have you all handled this in your installations?

The installation in question is version 2.5.2.

Thanks very much for viewing.

# Answer
The solution I have implemented - as laid out by @CreateSean and @foamcow - is to use Zoo Visitor and EE's channel expiry field for each members' Zoo Visitor channel entry.

Zoo Visitor holds the entered expiration date for the logged in user's entry as a global variable...

> {visitor:global:expiration\_date}

which I used in the conditional to automatically display (or not display) the limited content.

The user is still a member of the site, in the appropriate group.

Once on the right track, everything I needed was here - https://devot-ee.com/add-ons/support/zoo-visitor/viewthread/2823
> 1 votes

# Answer
You might want to look at the Charge subscriptions addon - http://squarebit.co.uk/software/expressionengine/charge/ \- that will allow members to register for specific periods and have them automatically "expire" after a certain time (though it changes the members' group on expiry, not removing them). If you allow it member can renew their subscription as well.
> 0 votes

---
Tags: members, zoo-visitor, expire
---


title: Assets: Unable to Replace File on S3

text:
# Question
Title: Assets: Unable to Replace File on S3
When attempting to replace an existing file on an S3 source, the upload fails. Here's the sequence of events:

1. Upload file `sample_image.jpg` for the first time (works fine)
2. Click 'Upload' and select `sample_image.jpg` again from the local filesystem
3. Click 'Replace Existing File' button in modal window when prompted by Assets
4. The Assets loading bar appears but remains empty forever and the new file is not uploaded.

In the console, this error displays:

> Uncaught SyntaxError: Unexpected token \<

This issue does not happen when uploading to a local directory, only when uploading to an S3 directory.

* EE 2.9.2
* Assets 2.5

# Answer
We finished this up via email support. This is a known bug and will be fixed in the next release (2.5.1, I believe). P&T sent me an advanced copy and it resolved the issue.
> 0 votes

# Answer
Was this ever fixed in the most recent version? I seem to be running into the same thing using the most recent version. Using Assets with S3. File uploads work fine, but when replacing an image with the same name, it hangs up.

cc/ @brandon-kelly

Getting the following error when trying to replace:
> 0 votes

---
Tags: assets, s3
---


title: Getting total results per status

text:
# Question
Title: Getting total results per status
I would like to get the total entries per status for each category group.

I have 3 statuses.

the best thing I can come up with is:

```
{exp:channel:entries channel="any" status="Open"}  {if count == total_results}{count}{/if}{/exp:channel:entries}
{exp:channel:entries channel="any" status="closed"}  {if count == total_results}{count}{/if}{/exp:channel:entries}
{exp:channel:entries channel="any" status="test"}  {if count == total_results}{count}{/if}{/exp:channel:entries}

```

I think there has to be a smarter way.

Any help would be appreciated. Thank you

# Answer
For best performance and simplicity...

```
{exp:query sql="SELECT status as status_label, count(*) as total_results FROM exp_channel_titles GROUP BY status_label"}
    {total_results} results for {status_label}.
{/exp:query}

```

You can just output a specific status using a conditional:

```
{if status_label == "test"}
    {total_results}
{/if}

```

Or you can refine the search if you have many other statuses you don't want included:

```
SELECT status as status_label, count(*) as total_results FROM exp_channel_titles WHERE status IN ("open", "closed", "test") GROUP BY status_label

```

Note I've used "status\_label" instead of leaving it as just "status" so that it can be used within a channel entries tag pair without conflict of it's "status" tag value.

Based on this answer, albeit exp:stats doesn't work as I have it turned off and doesn't allow you to refine to status.
> 2 votes

---
Tags: status
---


# Question
Title: CartThrob cart_total to a php php variable
I Am new in working with CartThrob and EE2. How i can assign `{exp:cartthrob:cart_total}` value to a php variable.Please let me know how to do that.

Thanks in advance.

# Answer
As with what @foamcow said, this is generally a bad idea, especially if you're new to PHP or ExpressionEngine in general. I'm providing you an example, but I highly recommend against going this route. **You do so at your own risk**. Understanding the differences between `input` and `output` parsing is huge, and it sounds like you are new to these concepts. Please revise your question and expand on what you are trying to accomplish, and we can probably give you a safer answer.

For the template in question, set it's PHP parsing to `Output`.

https://ellislab.com/expressionengine/user-guide/templates/php.html

Then, in your template code, you can use this code to grab that value:

```
<?php
// grab cart_total, cast to int
$my_php_var = (int) "{exp:cartthrob:cart_total}";

// what **are** you trying to do, anyways? let's add 10
$my_php_var += 10;

echo $my_php_var
?>

```

Again, we highly recommend **not** going this route.
> 1 votes

# Answer
You would need to enable PHP parsing for the template where you are using the variable. The parsing can be done on "input" or "output" and you will need to choose a setting depending on what you are trying to do.

Be aware that enabling PHP within template code can be a security risk and there is often a "better" way to do things by means of creating a custom plugin or extension. This keeps the PHP away from your template code.
> 0 votes

---
Tags: ee2, cartthrob
---


# Question
Title: Quick and easy way to get category name from ID
We've inherited a site that has hundreds of categories in a large number of groups.

We're working on the templates and many times need to see what a category ID actually is and *where* it is. So far it's kind of cumbersome to trawl through all the groups every time looking for each one.... is there a plug for the CP that can list all the Categories outside of their groups in sequential order?

What's the best way of quickly matching these IDs to the cat name?

# Answer
Try this free extension from the mighty Low!

http://gotolow.com/addons/low-seg2cat/docs

> Working with categories? Then you need Low Seg2Cat. This extension will give you information about categories present in the URI, in the form of early parsed global variables. No more PHP in your templates just to retrieve a category ID, no more awkward category keyword identifier in your URIs, all the category info you need comes straight from your segments. Oh, and it’s free.
> 5 votes

---
Tags: categories, control-panel
---


# Question
Title: Expresso Store throws PHP error when updating product entry via Channel Form
I've got a project involving Expresso Store, where I'm attempting to simplify the process of updating store products and stock (for the owners of the website) by going outside the ExpressionEngine publish forms and setting up the product entry and stock update process in Channel Forms.

However, though the Store field looks like it's compatible with Channel Forms, on editing an entry, I get this error:

```
A PHP Error was encountered
Severity: Warning
Message: Invalid argument supplied for foreach()

Filename: Service/ProductsService.php
Line Number: 137
A PHP Error was encountered

Severity: Warning
Message: Cannot modify header information - headers already sent by (output started at /home/tcisite5/public_html/tci/codeigniter/system/core/Exceptions.php:170)

Filename: libraries/Functions.php
Line Number: 446

```

In spite of the error, other fields are updated when I submit the Channel Form. But Store fields are not updated.

I'm running ExpressionEngine v2.9.2 - Build Date: 20141004. Also, Store has been updated the new version: 2.5.0. I've also done an optimize/repair on all of my EE database tables through the EE utility.

# Answer
> 0 votes
I got the same error when submitting a form to update a product entry without actually including/updating the store field(s) (i.e. just updating the title / other custom fields).

I found that the stock\_level field is required. Adding the following to my form fixed the PHP error:

```
{exp:store:product entry_id='{segment:offer_entry_id}' disable_form='yes' disable_javascript='yes'}
    <input type="hidden" name="store_product_field[stock][0][stock_level]" value="{if track_stock}{total_stock}{/if}">
{/exp:store:product}

```

Note that I'm getting the entry\_id for the {exp:store:product} tag from a URL segment; you'll probably want to get it from somewhere else.

Also, my products don't have modifiers. This may not work for products that do.

---
Tags: expresso-store, safecracker, php-errors
---


title: Assets Image Rotation

text:
# Question
Title: Assets Image Rotation
We have a client that uses a Windows computer that auto rotates images from his camera, but when uploaded are rotated 90 degrees. We know you can rotate images in the File Manager, but it's not very user friendly and we usually try to keep clients out of there, hence Assets. Does anyone know a solution or plugin we could implement into Assets or Control Panel in general that's easier to use?

EE v2.5.5
Assets v2.1.3

# Answer
> 0 votes
Have you taken a look at CE Image? It can do on the fly rotating of images:

---
Tags: assets, control-panel, file-uploads
---


title: Wygwam / ckeditor errors on upgrade

text:
# Question
Title: Wygwam / ckeditor errors on upgrade
I upgraded Wygwam 2.7.0 to 3.3.3. I run module update and I cleared my browser's cache. I am getting the next errors:

```
Uncaught SyntaxError: Unexpected token ILLEGAL (ckeditor.js)
config.js:10 Uncaught ReferenceError: CKEDITOR is not defined (config.js)
wygwam.js:134 Uncaught SyntaxError: Unexpected token ILLEGAL (wygwam.js)

```

Also I am getting the next error 9 times:

```
Uncaught ReferenceError: Wygwam is not defined

```

The files ckeditor.js and wygwam.js are being loaded, so that should not be the problem. I read Channel Images could interfere with Wygwam, but I am not using that. Any ideas on this?

**Edit:**

I turned off all extensions and removed all modules. That didn't made a difference.

I changed the code in ckeditor.js, but the code did not update in the browser.

After that I changed the file names to ckeditor-b.js and wygwam-b.js and referred in the code to the new files. After this change the new code loads in the browser and the errors I first had, disappeared. But now I have new errors. All of the new errors refer to paths that don't exist.

**Edit 2**

I reversed the changes I made in Wygwam.

I guess I need to use a timestamp like specified in this link. I tried it by placing it in config.js, but that file does not load in the first place because ckeditor is undefined. Where would the correct placement be?

# Answer
I finally solved it by completely uninstalling the Wygwam module!

Follow the following steps to do it safely:

1. Make a dump of your database, so you can restore data if needed. You also need this, to restore Wygwam configurations.
2. Also make sure you have an example of the Wygwam configurations, so you can verify if the configurations are correct. I had an example on my development environment.
3. Change the name of field\_type of channel\_fields in your database with a sql-query, so it will be safe to delete the module:

UPDATE `exp_channel_fields` SET field\_type = 'wygwam-2' WHERE field\_type = 'wygwam';
4. Uninstall the module in add-on-\>modules
5. Remove the module from your file system. Don't forget to also delete Wygwam from the themes folder.
6. Empty the cache in tools-\>data-\>empty cache
7. Add the latest version of Wygwam to your file system
8. Go to add-on-\>modules and install Wygwam
9. Restore the name of the Wygwam fields with a sql-query:

UPDATE `exp_channel_fields` SET field\_type = 'wygwam' WHERE field\_type = 'wygwam-2';
10. Take and perform the piece of code from you sql-dump to restore the exp\_wygwam\_configs table.
11. Check the Wygwam configurations in the CMS. If needed adjust settings.

And you are all set.
> 1 votes

# Answer
Did you just upload the folders and have them over write the existing ones? If so, this doesn't always work well, especially with a large addon like WYGWAM. Try, deleting the folders on the server and uploading them fresh.
> 3 votes

---
Tags: pixelandtonic, wygwam, ckeditor
---


# Question
Title: Issue with PHP reading times in template
I have this PHP code in one template (contact.html):

```
<?php
    $on  = 830;
    $off = 1730;
    $now = intval(date("Gi"));
    echo "<!-- ".$now."-".$on."-".$off." -->";
    if($now > $on && $now < $off) {
?>
    <!-- the HTML I want to hide by time is located here -->
<?php
    }
?>

```

and this code in another template (footer.html) that is embedded in the contact template above:

```
{if "{segment_1}" == "contact"}
<?php
    $on  = 0830;
    $off = 1530;
    $now = intval(date("Gi"));
    echo "<!-- ".$now."-".$on."-".$off." -->";
    if($now > $on && $now < $off) {
?>
    <!-- the HTML I want to hide by time is located here -->
<?php
    }
?>
{/if}

```

As you see, I echo out the values in both templates. When I load the page at 7:08am, I get this comment in the code for the contact template and the html is hidden just like planned:

```
<!-- 708-830-1730 -->

```

But in the code in the footer template, I get this comment and the html shows instead of being hidden:

```
<!-- 1208-830-1730 -->

```

Why the differences???

# Answer
> 1 votes
Is this on a load balanced server solution? Have you doubled checked that both the agent and the CLI php.ini files have the same setting for time zone? Try using this command before both date grabs (set it to your local timezone):

```
date_default_timezone_set('America/Los_Angeles');

```

Do you start seeing consistent reporting? If so, it's likely an inconsistency in timezone settings somewhere. Especially since the time difference is exactly 5 hour, I would bet that's your issue.

---
Tags: templates, php
---


title: Secure Https Channel form login

text:
# Question
Title: Secure Https Channel form login
I have a section of my site where users login and can create and edit profiles. Theses profiles are edited through a channel form and are behind a login. I have moved this section of the site over to https recently and it all works ok but my issue is the member login

```
{exp:member:login_form return="staff/index"}

```

This is insecure and give the user a browser prompt stating that before login.Is there a way to secure this login

Thanks

# Answer
There are many ways to force HTTPS. If you have a valid certificate, you really should force your entire site to use the protocol, the **only** reason not to is if you need to support very very legacy devices (think old dumb phones). In your .htaccess file, **before** your index.php rewrite, add something like this:

```
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]

```

If you **really** just want to force it on one page, you can add a condition like this:

```
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} \/staff\/index [NC]
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]

```

This will only force the `staff/index` base URI to use the HTTPS protocol.
> 0 votes

---
Tags: safecracker, members, login, ssl
---


# Question
Title: expression engine extension development - make a field required
In a custom extension, can I make a settings field required to have a value without having a create a custom form using settings\_form()?

# Answer
> 1 votes
Not really, no. You could force front-end validation by crafting an Accessory and making those fields have a "required" attribute, but you're best bet is to just use the `settings_form()` functionality. It's not hard, just follow the guide!

https://ellislab.com/expressionengine/user-guide/development/extensions.html#built-in-settings-form-and-processing

As an alternative to making fields "required", you could only set settings that are radio fields or select fields, and have defaults. It's really not the same, but I'm not sure what you're requirements are.

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


title: Themes folder above root

text:
# Question
Title: Themes folder above root
Is it possible to move the themes folder above the root?

I am using MSM and want to move the folder away from the main site.

# Answer
How would that make sense? For EE to function, it needs a resolvable URI to access the contents of that file. If you don't have an accessible folder for this setting:

```
URL to your "themes" folder

```

Your site won't function. Technically, if you're on Linux, you might be able to move it above root, but have a symlink to the folder path. I can only imagine that you have FTP users who's home is the web root, and you don't want them messing with the themes folder.

```
ln -s /path/to/new/themes_location /var/www/html/themes

```
> 0 votes

---
Tags: config, themes
---


title: Can Assets rename files on upload?

text:
# Question
Title: Can Assets rename files on upload?
I have client who is uploading files with lots of naming issues; Spaces, dots, parenthesis, and other characters in the filenames.

Is it possible to strip out the special characters, automatically, upon upload?

Thank you in advance.

# Answer
> 0 votes
Your best bet would be to make an extension that hits this hook:

```
http://docs.pixelandtonic.com/assets/developers/hooks/upload_file.html

```

And renames the file after upload. I would check the File helper to see if it can rename files:

```
https://ellislab.com/codeigniter/user-guide/helpers/file_helper.html

```

If not you'll have to do it in pure PHP:

```
http://php.net/manual/en/function.rename.php

```

Be warned; after rename the file, you'll need to use the database class to update all Assets rows that have the file name of your original file, and update them with the new file name. Also probably the EE files table.

Actually, at this point, you could honestly just hack the Assets core. I highly **do not** recommend doing that, but it would work for now. just regex out anything that isn't alpah-numeric.

---
Tags: assets, pixelandtonic
---


title: Expresso Store + Two Payment Forms

text:
# Question
Title: Expresso Store + Two Payment Forms
I want to implement Authorize.net (AIM) to take credit cards on site and PayPal Express to give a customer the option to pay off site.

Preferably there would be a column to pay by credit card and column that asks if the user would like to Use PayPal Express.

Would I need 2 forms to do so? Can I have two Checkout forms on one page?

What would the basic code setup look like for this?

# Answer
You should not have issues having two separate checkout forms on the same page but personally I would only use a single form and then use some JS to show/hide fields for each particular gateway based upon with a select field or similar. This would be based off the payment method tag

I am on my phone currently so a code example is a bit hard to do properly but if I remember correctly the store example templates in checkout2 has the ability for multiple gateways so you can see the required code.
> 1 votes

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


title: Searching a grid field with Low Search

text:
# Question
Title: Searching a grid field with Low Search
The problem I'm having is that the data in my Grid field is not influencing the search results.

I have two channels, one of which has a grid field. The field and the relevant row are both marked as searchable.

I've created two Collections, one for each channel, where the weight of the grid field is set to 3.

My template code doesn't use a collections parameter, so I believe it should search both channels?

Yes, the entries were there before I marked the fields as searchable, but I've since re-saved one entry so that it would populate the exp\_channel\_data table, and re-indexed the Collection so that I could test the search, but I'm still not getting that entry in the results.

Have I missed something else?

# Answer
> 0 votes
Things to check:

* is the content actually in the `exp_channel_data` table?
* is the searchable content actually in the `exp_low_search_indexes` table?
* enable the template debugger and look up the lines that mention Low Search; does that give you any insight?
* enable the output profiler and look up the query generated by the Keywords filter. What happens if you run that query manually (in Sequel Pro or PhpMyAdmin)?

If, for the latter, the query is present, but renders no results, then it could be that there is not enough data in the database in order for the fulltext searches to work properly. I also recommend to only give a high weight to small fields, like titles or text inputs. For fields that contain larger amounts of text, like textareas or Grid fields, setting the weight to 1 should suffice.

---
Tags: grid, low-search
---


# Question
Title: How can we post Same content on each site in Expression engine
1 down vote favorite

I am using Expression engine Multiple site management system I have developed three site using this are :-

```
1)www.exampleone.com
2)www.exampletwo.com
3)www.examplthree.com

```

Now I want to post data of www.exampleone.com to another two website listed above,everything is ready i am able to post data on theses three website separately but I want to post data of first site to other two. Channels and channel fields of three sites are same.

Thanks in advance.

# Answer
> 1 votes
You mention using MSM, so are you using the `site` parameter?

Docs here

In sites 2 and 3, simply specify `site="websiteA"` in your `exp:channel:entries` tag pair to output content from the first site. This avoids duplicating the content in the database across all three sites.

Might want to consider using Canonical meta pointing to the original site to avoid SEO penaulties for duplicate content.

# Answer
> 0 votes
This would be a good perfect use case for Multi Site Manager.

It sounds like you haven't gone that route though and retrofitting MSM can be a bit of a pain as far as I remember (only done it once).

Using MSM you would need to: 1. Set up the channel in exampleone 2. In your channel:entries tags on the other sites add the site's ID to the channel parameter.

```
{exp:channel:entries channel="exampleone:news"}

```

If you wish to mix these entries in with some from the other sites you may want to also read about orderby and multi site manager.

https://ellislab.com/expressionengine/user-guide/add-ons/channel/channel\_entries.html#channel-entries-orderby

Alternatively you could perhaps publish an RSS feed of the stories from site exampleone and pull them into the other two sites.

1. Create an RSS template on exampleone that uses a standard channel entries tag pair to write out the data in an RSS format.
2. Install something like Feed Parser on the other sites and give it the URL of your RSS feed from exampleone.

---
Tags: php, codeigniter
---


# Question
Title: MX Mobile Detect reading newest Safari version as a mobile device
I have the plugin implemented on a website to detect for mobile devices and when it does it will display a slideshow instead of a video. This has been working fine, but I just noticed today that when viewing the site in Safari on the desktop that it is loading the mobile-only slideshow. I think this was working fine previously so I wonder if a recent Safari update changed things? Any ideas?

```
{if "{exp:mobile_detect:device}" != "not_mobile"}

    (slideshow markup here)

{/if}

{if "{exp:mobile_detect:device}" == "not_mobile"}

    (video markup here)

{/if}

```

# Answer
could you please try update ? I'm in the process of rethinking this plugin (update core and don't lose functions), but I think the version on GitHub should already follow your needs.
> 4 votes

# Answer
Not sure if you're using the latest one - check here. Max (the developer) is often on here as a moderator so should be able to confirm...

If you look at the pi.mobie\_detect.php file in the add-on folder, there's a list of mobile clients held in the variable `$_mobileClients`, this is what is used to report if its a mobile device or not.

It detects the device by using `$_SERVER['HTTP_USER_AGENT']` \- so try a var\_dump to output that and see what's being reported for your Safari for it to have fallen into the list of mobile devices.

Have you checked that your version of Safari is not emulating a mobile - which will mis-report the `HTTP_USER_AGENT`? Assuming you have the developer tools enabled in Safari, you'll have a `Develop` dropdown, select `User Agent` and select the appropriate option.
> 2 votes

---
Tags: mobile, mx-mobile-detect
---


# Question
Title: Caching embedded templates with variables
If you embed a template A into template B, using embed variables, and you switch on template caching on template A. Does template A get cached multiple times according to the embed variables? Or is the template cached once, thus losing the ability to deliver content dynamically according to the embed variables?

# Answer
The way ExpressionEngine works is it parses all the templates used individually first, passing and parsing any relevant variables shared through embeds - but importantly it doesn't parse the actual embed tag during this, only once they're all done. It's at this stage that the individual template is cached. It then goes back through placing in each individual (fully parsed) template into where it needs to be inserted within the parent template.

Worth having a read of this forum post \- importantly, each cached template is relevant to the URL it's on - so even if you use the same template in your footer throughout your website it won't be rendering one and then using the cached template for the others. As they use different URLs, it will create a cached version of the same template for each different URL used. So the point of caching a template is only to revisit that exact page, not share a template across multiple pages.
> 0 votes

---
Tags: embeds, cache
---


title: If statement with a variable

text:
# Question
Title: If statement with a variable
Is it ok to use an early parsed variable/snippet with the following inside?

```
logged_in AND member_group == "1" OR member_group == "2" OR member_group == "3"

```

So that i can use the following at the top of my template

```
{if {variable}} Content {/if}

```

It works.... I just want to know if its bad practise or comes with any issues etc? If it is a problem, can anyone suggest another way i can lock down my templates but have one place that I can edit the statement if anything changes. This would save me changing it on every template.

# Answer
> 1 votes
All a snippet will do is place the content assigned to it before it parses the template.

So your original template will look like this:

```
{if {variable}} Content {/if}

```

Then once the snippet is parsed it will look like this:

```
{if logged_in AND member_group == "1" OR member_group == "2" OR member_group == "3"} Content {/if}

```

Then it will parse the template properly.

It's not bad practise as that was the main purpose of snippets in EE versus variables (which aren't able to be parsed directly, only their value is used).

Negatives regarding Snippets are that it's easier for other developers to get lost - naming all your variables and snippets with a prefix helps avoid this so when you see the code used (e.g. {tag}), you know if it's a tag variable {tag}, snippet {snp\_tag} or variable {var\_tag}.

Also there is a technical debt - have a read of this acticle that explains it extremely well.

---
Tags: conditionals, advanced-conditionals
---


title: Super Admin can't edit channel content

text:
# Question
Title: Super Admin can't edit channel content
I have a user setup as a Super Admin. There is one single channel entry that she cannot edit. Her system locks up when she attempts to edit it. She can edit anything else on the site but this one entry, no.

Any ideas of what to look at to figure this one out?

# Answer
> 0 votes
If by lock up, you mean WSOD (white screen of death), the issue is usually a database write error. If you can open that channel entry, do it. Usually, it's a WYGWAM field. If you have one in their, click on the `source` button, and copy and paste the WYGWAM source to a notepad. Then, empty that field, and save the entry. Then, reopen it, click `source`, and paste the source back in and save it.

Rinse and repeat for each field in the entry.

---
Tags: channel-entries, control-panel, super-admin
---


# Question
Title: Generate/Print Shipping Labels with Expresso Store
Has anyone written a plugin to generate shipping labels for USPS/UPS/FedEx for Expresso Store?

-Or- has anyone generated templates with the native Expresso Store tags to do the same thing? (Create a list of orders, with links to "shipping label templates")

Curious to see what, if anything, others have done here.

# Answer
> 0 votes
Since the USPS/UPS/FedEx shipping gateways do not actually request an actual shipping label you would not be able to generate a shipping label for actually shipping the order. (think with the rate already billed to your UPS account and things like tracking enabled)

It is fairly easy however to use the Store order tags along with a special template and stylesheets to create packing slips, box labels and any other thing that you might want/need for your store admins to help with order processing.

I for example have built out front end admin templates for customers that allows me to export and print a batch of pull sheets, packing slips and basic shipping labels for new orders. I am also able to use the exported data to import it into their shipping management software.

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


# Question
Title: Safe to cache Expresso Store "exp:store:product" tag?
I am wanting to cache the output of the exp:store:product tag. This seems like a safe thing to do, with one possible exception. The generated form contains a hidden `_params` field, the value of which changes with every request. **Is it safe to cache this? Or is there something I'm not considering?**

# Answer
You'll notice that the hidden `_params` field does change with each request (due to how the encryption works), but it **is safe to cache**. It's basically just an encrypted version of the Product tag parameters, so as long as your Product tag parameters don't change with each request (e.g. it contains segment variables or other dynamic variables), it's safe to cache this.

The only problem you might run into is the `XID` field which is generated fresh on each request and is **not safe to cache**. However, you can get around this by either disabling secure forms, or it's possible that CE Cache and other caching plugins take into account the XID and update it after loading the cached fragment. You would need to check with the plugin author or documentation about this. At least with the XID it will be really obvious if it is broken (every form submission after the first would break, so you would notice immediately).
> 3 votes

# Answer
The hidden `_params` field is there to encrypt any parameters you include in your Products tag. For example, if you specify some required fields then the parameters just act as an extra layer of security here to stop someone potentially modifying the form to remove the requirements upon submission. It should be safe to cache these as they generally wont change once configured but if you make any changes to the tag parameters then just be sure to clear the cache first.
> 2 votes

# Answer
If the hidden \_params value changes with every request, surely it's not safe to cache. I don't know this definitively but it's what I would conclude.
> 1 votes

# Answer
If you are using the Store Product Form most likely you would need to escape the form for security reasons. Otherwise you will get a security issue with the form submission.

We will work on removing this in v3.
> 0 votes

---
Tags: expresso-store
---


# Question
Title: Multi Add To Cart, or maybe I should try something else?
I need a way to handle customizing a variety pack of items. Each item is already in the inventory, but I need to set it up to where you can pick up to 3 of the different items, but no more than 2 of one certain item. This "variety pack" will have a set price, even though the other items have different prices.

What would be the best approach? Is there a way to dynamically generate a bundle or package?

I've been looking at on the fly and setting the price, but someone could abuse that easily once they got to the cart.

# Answer
> 0 votes
(I'm with Vector Media Group; we make CartThrob.)

How comfortable are you with PHP? You could do this pretty easily with a custom extension that runs when an item is added to the cart and during checkout. This would enforce the quantity constraints and set the custom price.

Another way to approach this is that the person isn't adding those products to the cart at all, but instead is just adding your bundle/package item and then choosing the items as options, so their price wouldn't matter. Again you could use some custom logic to enforce the quantity constraints.

Let us know if you want any other help with this!

---
Tags: cartthrob
---


# Question
Title: ExpressionEngine Continuous Integration BDD
I am curious if anyone has setup BDD, ExpressionEngine and Continuous integration and could share their setup/approach? I have heard rumor of people using cucumber with EE but have not see any information about this in practice.

Thanks, Cory

# Answer
> 3 votes
I think it's safe to say that testing at this level isn't very common in the EE community (given that no one has answered this question in the past 6 months).

It would certainly be possible to set up Cucumber with EE, although I have not tried it myself on an EE site. You will need to address a few issues first, such as setting up multiple staging/test environments to run your tests on.

You could also try using something like Mink, which seems to be a similar acceptance testing framework built on PHP instead of Ruby (may be easier to set up).

In terms of running the tests (continuous integration), I would check out either Travis Pro or CircleCI if you don't feel like going through the hassle of setting up your own Jenkins server.

# Answer
> 0 votes
We use an integration with CircleCi for our EE deployments. Currently, it runs our custom build tool called Norma to compile assets (html, sass, coffeescript, and templates) and auto deploys to our alpha, beta, and production servers if a build passes. CircleCI has been working very well for our process and we also use it for our NodeJS testing.

We've written some initial end to end tests using mocha-casperjs to check things like following a workflow to sign into a page and similar things like that, but we don't have any tests for addons yet.

There are a lot of things that would make this better, but so far it's working for us!

---
Tags: development
---


title: Show which field the term was found in?

text:
# Question
Title: Show which field the term was found in?
In the search results, is there a way to show which custom field a search term was found in?

# Answer
No.

The search index is a big text field per entry, containing all searchable fields. This is what makes the keyword searches fast. However, that also means there is no info as to what specific field contained the keywords. It's totally possible that, for keywords that contain more than one word, the terms are found in multiple fields.
> 0 votes

---
Tags: low-search
---


# Question
Title: How to search fields in two related channels, but only show results from one?
I have two channels: **blog** and **recipes**. Blog posts are about recipes, so one of the fields in the blog channel is a relationship field connected to the recipes channel. Each blog entry has a related recipe entry.

I want to let visitors search for terms in the **body** field of the blog channel as well as in the **ingredients** field of the recipes channel, but only show the related entry (the recipe) in the search results.

So let's say there's a blog post about pizza, connected to a related recipe for pizza. Within the **body** field of the blog entry, the author has typed "my kids love this." Within the **ingredients** field of the recipe entry, the author has typed "mozzarella".

I want the pizza recipe entry to show in the results if the user searches for "mozzarella" and also if the user searches for "my kids love this".

Is this possible?

\[EDIT\]

It seems like the logic I need is something like, "if a result is found in the Recipes channel, then display that entry. If the result is found in the *Blog* channel, then display that entry's related Recipes channel entry."

# Answer
Filtering entries by a child entry's keywords will require a custom filter, so isn't possible out of the box.

> if a result is found in the Recipes channel, then display that entry. If the result is found in the Blog channel, then display that entry's related Recipes channel entry.

This is possible out of the box. If you create 2 collections -- one for Recipes, one for Blog -- you can search both collections and in the Results tag use conditionals to display different types of content depending on the channel.

The gotcha here is that the excerpt will belong to the collection/channel the entry was found in. And if you're displaying the related Recipe entry for a found Blog entry, it is possible that that specific Recipe entry was already displayed. So there's a chance of duplicate results. One way around that is to also display some Blog entry information there, so it looks different.
> 0 votes

---
Tags: relationships, low-search
---


title: Use config variables in templates?

text:
# Question
Title: Use config variables in templates?
Is there a place in EE to store custom config variables and access them in the templates? I need to be able to use these variables in conditionals as well as output them. Furthermore, I need to have different sets of config values depending on which domain EE is on (e.g. if site\_url = 'foo.com' ...).

Currently, I'm using globals, but it's not really ideal.

# Answer
> 3 votes
If by config variables, you mean the ones on `config.php`, it's pretty easy to do.

On your `config.php` add the following code:

```
global $assign_to_config;
if(!isset($assign_to_config['global_vars']))
$assign_to_config['global_vars'] = array();

```

Now, you can create early parsed template variables.

Let's say you set the mail protocol used by a System Config Override:

```
$config['mail_protocol'] = 'sendmail';

```

If you need to access this info on templates, you need to create a template variable:

```
$config['mail_protocol'] =
$assign_to_config['global_vars']['cv-mail_protocol'] = 'sendmail';

```

On templates, you can use `{cv-mail_protocol}`:

```
{if cv-mail_protocol == 'sendmail'}
  The emails are being send by SendMail
{/if}

```

You can use a PHP conditional too to set them:

```
if ($_SERVER['HTTP_HOST'] == 'www.domain.com')

```

These variables are parsed even before Preload Text Replacements, which gives you a lot of flexibility.

```
{if cv-language == "en"}
    {preload_replace:pr-name_label="Name"}
    {preload_replace:pr-tel_label="Phone number"}
[...]
{/if}

<label for="name">{pr-name_label}
  <input type="text" id="name" name="required[]" size="50" />
</label>
[...]

```

# Answer
> 1 votes
I tend to use index.php for this.

On about line 72 you can add Custom Config Variables as an associative array.

```
$assign_to_config['global_vars'] = array('pv_country_id' => 3);

```

You can now use this in your template as `{pv_country_id}` (I prefix with pv\_ so I can identify them when I view my templates in the future.)

The reason I use this method is that if you're a MSM user ('Multi Site Manager' for the uninitiated) you can override your variables on a per site basis.

---
Tags: templates, config
---


# Question
Title: Can the 3rd tagpart of a plugin be used freely, or does it HAVE To be the name of a method?
I'm trying to make a plugin that I need to be as simple as possible to use. If possible, I want the usage to be:

```
{exp:pluginname:anytext}

```

And the output to be:

```
anytext

```

Obviously there will be more to it than just that, but the essence is that I need the "anytext" bit to be any bit of text, not a hard-coded method.

I've seen plugins that make use of the 4th tagpart, eg. `{exp:ce_img:make:anytext ... }`, where the `anytext` bit gets used as a variable prefix. Unfortunately, when I try to do something similar, but using the 3rd tagpart instead, I get an error:

```
Error

The following tag cannot be processed:

{exp:pluginname:anytext}

Please check that the ‘pluginname’ module is installed
and that ‘anytext’ is an available method of the module

```

# Answer
Why are you trying to go about it like that? If you need to make the plugin as simple as possible, the Tag Pair syntax is far easier than trying to understand why you want a text input as a segment of the tag:

```
{exp:my_plugin}
    anytext
{/exp:my_plugin}

```

EE Plugin parsing library always looks for a method in your plugin class if you have a second tag part. So you can't do it your way, however, if you want to use four segments like CE Image:

```
$tag_parts = $this->EE->TMPL->tagparts;

```

In an example:

```
// {exp:my_plugin:anytext:stuff}

$tag_parts = ee()->TMPL->tagparts;

$tag_parts[0] = "my_plugin";
$tag_parts[1] = "anytext"; // ALWAYS evaluated as a plugin_name::anytext()
$tag_parts[2] = "stuff";

```
> 1 votes

---
Tags: add-on-development, plugin
---


# Question
Title: Is there a way to automatically use images from entries with Campaigns?
I am using EE 2.10.1 and Campaigns 2.1.0a

Is there a way to automatically pull images from the entry being posted to FB, twitter, etc.?

For example, if I am using a Channel Images field in the entry, can I specify it to pull from that field?

# Answer
> 0 votes
Yes, you can setup in the channel settings to use a field to show the image. You can really use any template code in the pre-defined areas.

---
Tags: devdemon, social, devdemon-campaigns
---


# Question
Title: Client instructions on Control Panel home?
I'm trying to find an easy way to have basic instructions displayed when the client opens the CP (I'm using NSM Publish Hints for detailed instructions on entry windows).

I was using DashEE, which was great, but since EE2.9, it hasn't been functioning properly so that I can't update anything.

How do you all provide basic on-screen instructions to the client so that when they open the Control Panel it's obvious how they should proceed?

Thanks in advance.

# Answer
You could inject JS using this add-on into the area of the Control Panel you want the the help text to appear - then you can expand it to all relevant pages you want help on - not just the CP homepage.

JS...

```
$(document).ready(function($) {
    $(".contentMenu.create").before('<div class="helpText contentMenu"><p>Help Text goes here</p></div>');
});

```

Example CSS...

```
.contentMenu.helpText {
    background-color: honeydew;
    width: auto;
    margin: 0 40px 30px;
    float: none;
    padding: 20px;
}

```

Result...

Obviously change your JS target for different pages in the Control Panel.
> 1 votes

# Answer
If these are static instructions (they generally won't be changing), you could craft an EE Accessory to just insert a new element on the CP Home Page with your instruction in them.

https://ellislab.com/expressionengine/user-guide/development/accessories.html

Here's a pseudo-ish-code example:

```
function set_sections()
{
    // Check to see if you're on the CP Home Page
    // if not, return false

    // use the ee()->cp->add_to_foot() to add jQuery to insert stuff
    // kinda like this:
    ee()->cp->add_to_foot('
        $(document).ready(function(){
            $("#mainContent").prepend("<div class=\"contentMenu helptext\" style=\"width: 93.6%;margin-bottom: 1em;\"><div class=\"heading\"><h2>Help Text</h2><ul class=\"homeBlocks item\"><li>Help! I need to tell you all the helping things!</li></ul></div></div>");
        });
    ');
}

```

And tada!

**Edit** Welp, if it's something you need to change constantly, here is one option. Store a snippet with your instructions, and dump that instead of static stuff. Call your snippet `cp_help_text` or something. Snippet content:

```
<div class="contentMenu helptext" style="width: 93.6%;margin-bottom: 1em;">
    <div class="heading">
        <h2>
            Help Text
        </h2>
        <ul class="homeBlocks item">
            <li>
                Help! I need to tell you all the helping things! Easily changed from the Design -> Template -> Snippets.
            </li>
        </ul>
    </div>
</div>

```

And back to the accessory:

```
...
$snippet = ee()->db->select()
                   ->from('snippets')
                   ->where('snippet_name', 'cp_help_text')
                   ->get()->row_array();

ee()->cp->add_to_foot('
    $(document).ready(function(){
        $("#mainContent").prepend("'.$snippet['snippet_contents'].'");
    });
');
....

```

Yup, seems convoluted! Perhaps someone can give you a better answer.
> 0 votes

---
Tags: ee2, control-panel
---