# Question
Title: Using Mo' Variables in Module Tag Parameters
I'm using Mo' Variables for the early-parsed request variables. Here is the best-case scenario:

```
{exp:calendar:cal
    date_range_start="{if get:start}{get:start}{if:else}today{/if}"
    date_range_end="{if get:end}{get:end}{if:else}6 months{/if}"
}

```

This obviously doesn't work do to advanced conditionals being parsed late (sigh). So here is the workaround I thought might work:

```
{exp:calendar:cal
   date_range_start="{if get:start != ''}{get:start}{/if}{if get:start == ''}today{/if}"
   date_range_end="{if get:end != ''}{get:end}{/if}{if get:end == ''}6 months{/if}"
}

```

This doesn't work either. After doing a bit of debugging, it appears that the conditionals are not being parsed. My guess is that this is because there is no query string variable called "start" when the user first visits the page so the template parser doesn't find the conditional until later in the parse order.

I can make this work with PHP, but I'd love to have a pure EE solution:

```
{exp:calendar:cal
   date_range_start="<?= !empty($_GET['start']) ? $_GET['start'] : 'today' ?>"
   date_range_end="<?= !empty($_GET['end']) ? $_GET['end'] : '6 months' ?>"
}

```

So my question is this: **is there an elegant solution to---without using PHP in my template---get the value of a request variable and if it doesn't exist use some default value?** There must be some trick I'm not seeing to make this work. I don't think using Switchee or IfElse will be elegant here. It will work, but it would look really janky and make the calendar module tag hard to read. I'll concede defeat and drop down to PHP before doing that.

# Answer
> 2 votes
One option is to set your Mo' Variables and pass them to an embedded template where you loop through your calendar.

So you could do:

```
{embed='embeds/_calendar'
    start="{if get:start != ''}{get:start}{/if}{if get:start == ''}today{/if}"
    end="{if get:end != ''}{get:end}{/if}{if get:end == ''}6 months{/if}"
}

```

And then in your embedded template:

```
{exp:calendar:cal
    date_range_start="{embed:start}"
    date_range_end="{embed:end}"
}
    {!-- calendar stuff here --}
{/exp:calendar:cal

```

---
Tags: templates, conditionals, parse-order
---


# Question
Title: A Template that uses multiple channels with different field groups
I'm currently working on a template that uses multiple channels (ie. `channel="channel1|channel2"` to show content. Each channel has a different field group–so I'm conditionally nesting each groups fields within `if` statements:

```
{exp:channel:entries
   channel="channel1|channel2"
   disable="category_fields|member_data|pagination|trackbacks"
   dynamic="no"
   limit="1"
   require_entry="yes"
   url_title="{last_segment}"
}
{if channel_id == 1}
   ...
{/if}

{if channel_id == 2}
   ...
{/if}
{/exp:channel:entries}

```

I was wondering if there are any drawbacks to this?

# Answer
Unless the formatting is very different between the two, you don't need to use the `{if}{/if}` statement. If the formatting is basically the same, I believe you can stack them like `{news_content}{book_content}` the fields not related to the entry won't display.

But I use the {if}{/if} approach when the format needs to be handled differently. There's a performance hit (more queries), but it shouldn't be too much.
> 5 votes

# Answer
If you are worried about the performance hit I would recommend using IfElse by Mark Croxton. It's basically conditionals on steroids because it only parses content if the conditional is met, unlike the baked in conditionals which parse everything and then only display it if the conditional is met.
> 3 votes

# Answer
Judging from you have limit set to 1 and using the last\_segment url title I am assuming this is just a detail page for one item and not a full listings page.

You could use the channel\_id as above and use switchee or ifelse if the field groups are all completely different and have different case blocks for each channel.

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

    {case value="12"}

```

Or if the majority of the fields are shared and only a small amount of unique fields per different channel field group and you still want to use separate field groups you can use stash to prefix the field based on channel (to use a standard formatting but to swap to unique fields). Mark Croxton submitted this example here:

```
    {stash:embed file_name="product_loop" name="product_loop_{segment_2}" replace="yes" process="end"}
    {exp:stash:set_list name="products" parse_tags="yes" parse_depth="2"}
    {exp:channel:entries channel="{segment_1}"}
    {exp:stash:set name="channel"}{channel_short_name}{/exp:stash:set}
    {!-- set ALL your product fields here--}
    {exp:stash:set name="channel1_price"}{channel1_price}{/exp:stash:set}
    {exp:stash:set name="channel2_price"}{channel2_price}{/exp:stash:set}

    {stash:this_product_price}{exp:stash:get name="{channel_short_name}_price"}    {/stash:this_product_price}
    {/exp:channel:entries}
    {/exp:stash:set_list}

```

In that situation through since most of the fields were similar it made more since (thanks to Mark's comments) to just use one fields group and hide the ones that do not pertain to that channel in the admin to alleviate extra conditionals like above.

I am not sure how your URL structure is before the last segment but for cat listings pages I have a separate template group (so the cat short name is always the first segment for listings pages) that shares one standard view. Then one standard detail page (not related to cat, just product/product-name) that will then use the Switchee similar to above to display the custom fields based on channel.
> 3 votes

# Answer
The performance hit is minimal and nothing to worry about IMO. Using the conditionals as you have them coded is the way to do what you're trying to do in the template.
> 2 votes

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


# Question
Title: What is ExpressionEngine's release cycle?
What is ExpressionEngine's latest position regarding their release cycle. Is there a public policy we can follow and hold them to?

# Answer
> 2 votes
The last we were told was 12 weeks but at this point you can't hold EL to much at all regarding internal operations.

---
Tags: untagged
---


# Question
Title: Can I use an email address as a discount code in Expresso Store?
I'm considering purchasing Store by Exp:resso in order to use the discount feature for client project.

I'm wondering if the discount value can have the characters normally used in an email address. Can a discount code be equal to test@email.com or is it randomly generated by software?

# Answer
Promo codes in Store by Exp:resso are set manually by you. I've tested that you can indeed use an email address as a code. Screenshot below.

http://cl.ly/image/0q070i1f2o0y
> 1 votes

# Answer
You shouldn't have a problem entering an email address as a promo code but you might need to increase the database column length. Currently it is set to 20 characters which might not be long enough to be reliable for email address (mine for example would exceed the character limit). You can see the documentation for creating PromoCodes here.
> 0 votes

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


# Question
Title: Output member email address without javascript encoding
I'm trying to get a member's email address to autopopulate a form field but if I use {email} then the output is the Javascript encoded "safe" email address. Obviously I dont want this, I just want the email address itself.

How can I turn off the encoding - ideally in just this instance?

This site is running EE 2.4 and I can't update it for the moment. Seems odd that the member email is being encoded. It's not coming from a channel entry so I can't simply turn off the encoding option in channel prefs and I'm not using the {encode} tag.

# Answer
> 3 votes
Depending on the context you might want to try the `{logged_in_email}` variable as that's less likely to be impacted by any other modules you're using.

*Reposted as an answer rather than a comment as it seems to have worked.*

---
Tags: templates, members, javascript
---


title: How to add per-order handling charge?

text:
# Question
Title: How to add per-order handling charge?
I'd like to add $4.00 to each order as handling, or just an adder to the shipping charge. And, actually, we have some free local delivery products so it really needs to be added to the shipping charge when there is one. Any way to do this?

# Answer
> 4 votes
I would first setup a new shipping method with the Default Shipping Gateway and give it a name of Free Shipping or similar and then setup a rule/s for your local area so that way someone outside of what you consider local isn't able to select it as an option. This will allow your users to select between local free delivery and then your UPS gateway.

Now to add the price to the UPS plugin you will want to open up the shipping plugin system/expressionengine/third\_party/store/libraries/store\_shipping/store\_shipping\_ups.php (I am not at my computer with the files so I can't give you exact line numbers) scroll down towards the bottom you should see something along the lines of

`return (float)$xml->ShipmentRate->TotalCharges->MonetaryValue;`

you will want to change that to

`return (float)$xml->ShipmentRate->TotalCharges->MonetaryValue +4;`

That should then add $4 to the calculated price of your shipping.

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


# Question
Title: Where to put static text like "about us" or contact info?
I´m thinking where to store static stuff like "About us", "Adress info", "Driving directions". Entities, that contain of \- Text \- Headlines \- Image \- Links \- but don´t change often and live just in one place.

I see three options 1) Put the stuff straight into the template. 2) Set up a variable, e.g. {impressum}. 3) Set up a special channel, called statics with a fieldgroup called statics, that has just one richtext field and make "About us", "Driving directions",... entries.

My question: Which of the 3 ist best in terms of \- maintenance \- performance

I would opt for 2). Set up a variable, put the HTML together in my HTML editor, paste it into the variable and then use the varibale in the template. I would use static/index as TG/T and use segments to decide what variable should be used. That would seperate code from content and save me from the overhead of having a dedicated channel. The reason why I mentioned version 3) is, that this would allow me to have all content in one place. Having entries, variables and sometimes snippets makes the content scattered all over the place.

# Answer
> 8 votes
I think one of the best options today is to use either Low Variables or Republic Variables:

There is plenty of information on the two add-on sites so, I won't go into crazy detail. I personally use Low Vars and it's pretty much amazing for this type of stuff and so much more!

Also, if you don't want stuff scattered around the CP you could checkout Zoo Flexible Admin like @janvl mentioned and if you are using Structure you could install Encaf Where is the LV? which will create a link in the Structure Tree:

# Answer
> 0 votes
**we usually create different channels for all these areas, but with the same field group.**

So your "default" field group contains: title, body, images & links. And you assign this field-group for all your "static" channels.

so, a static about page looks like this:

```
{exp:channel:entries channel="about" limit="1"}
  <h1>{title}</h1>
  <p>{body}</p>
{/exp:channel:entries}

```

and a "driving directions" page looks very similar:

```
{exp:channel:entries channel="driving" limit="1"}
  <h1>{title}</h1>
  <p>{body}</p>
{/exp:channel:entries}

```

The benefits are:

* easy to maintain and set up, no add-ons or anything needed.
* your client can easily access & edit all the info.
* reusable code.

**To make it even easier for our clients, we use zoo flexible admin:**
We set up a top level menu button for each of our pages, and directly link to the 1 entry in our channel by using the "custom link" functionality provided by zoo flexible admin.

# Answer
> 0 votes
For a small number of text bits, I use Snippets, with a direct link in the CP for client. I just login as the client-user and make a quick link via the "+ Add" button which you can find in the main navigation. This button takes me to the Main Menu Manger so I can setup the title of the nav item any way I like. For example:

Insure that the users' member group has access to Snippets. Not as efficient if you have a bunch of users - then Zoo Flexible Admin or something like this will be a better solution.

---
Tags: ee2, long-content, static
---


# Question
Title: Forgot password/other member functions busted
I've taken over a site that has a lot of customization.

URLs like: /member/forgot\_password yield a blank page. If I visit them when logged in as a superadmin, I get this debugging info:

```
(0.000004 / 11.29MB) - Begin Template Processing -
(0.000398 / 11.36MB) URI: member/forgot_password
(0.000408 / 11.36MB) Path.php Template: /
(0.000415 / 11.36MB) Retrieving Template
(0.000420 / 11.36MB) Parsing Template URI
(0.002118 / 11.68MB) Template group and template not found, showing 404 page
(0.002130 / 11.68MB) Retrieving Template from Database: /
(0.003083 / 11.69MB) Template Not Found
(0.003096 / 11.69MB) Template Type: 404

```

Detective work to figure out just what would hide this basic member function. Member login does work, sort of.

# Answer
Client had set the profile trigger to '---jkhadhaksdhvasdv'.time()

Which randomizes it. Great for avoiding member spam, awful for making member profile functions work!

Thanks all.
> 0 votes

# Answer
Make sure the member profile trigger word is set in the control panel member preferences. That word `example.com/member/profile/` is used to 'trigger' the member module

http://ellislab.com/expressionengine/user-guide/cp/members/membership\_preferences.html

**edit**: that being said: i generally use the Free\_member add-on, which allows templating these member forms and removes the default oldschool 3 second "you are now logged in" 3 second redirect delay screen.
> 1 votes

---
Tags: members, login, forgot-password
---


# Question
Title: How to target a specific field in the Control Panel with CSS or JS to increase its height (P&T Multiselect)?
I have a Pixel & Tonic multi-select field with 50-60 rows in it. The users obviously need to be able to easily select more than one item. By default, the P&T field shows about 4 items at a time, which is making this enormously difficult to use - I'm half tempted to switch to categories. I don't see anywhere where I can set the height of the multi-select field when setting up the custom field.

Looking at the source, I should be able to target it with CSS/JS (#sub\_hold\_field\_128 select) and set its height:

```
<div id="sub_hold_field_128" >
   <fieldset class="holder">
      <input type="hidden" name="field_id_128" value="n" />
      <select name="field_id_128[]"  multiple="multiple">
          <option value="al">Alabama</option>
          <option value="ak" selected="selected">Alaska</option>
          <option value="az" selected="selected">Arizona</option>
          <option value="ar">Arkansas</option>
          ... etc ...
      </select>
  </fieldset>

```

What is the easiest way to set this? Do I need to tie into a hook like cp\_css\_end?

# Answer
> 5 votes
After a few minutes I was able to figure out an easy way to do this. I found a similar question here on EESE about adding custom JS to a new entry. I was able to put the CSS I needed right in instructions of the field. I had to keep everything on one line, because the field instructions look like they're being parsed with XHTML, so it was adding paragraph tags around each line. I ended up adding:

```
<style type="text/css" media="screen">#sub_hold_field_128 select {height:500px;}</style>

```

That ends up being wrapped in paragraph tags, leaving a less than desirable extra space between the title and the field, but this works, and is an easy solution.

# Answer
> 4 votes
As a small edition to this (and it's a great solution by the way!), when I need to do something like this ... rather then putting the CSS (or JS!) directly into the instructions field, I create a .css or .js file and then add the link to the instructions field:

```
<script src="/assets/js/ee_cp.js"></script>

```

or

```
 <link rel="stylesheet" type="text/css" href="/assets/css/ee_cp.css">

```

The obvious benefits of this is that it's then very easy to add or edit if I've made a mistake or require an addition!

A good example of where I use this is with a Pixel & Tonic 'pill' field type. For example, in one channel (lets say a News channel), I may have different fields depending on if it's a generic news item, a media release, a simple quote, etc. With some pretty basic JS, I can use the Pill field type to allow a user to select the 'Content type', and then show/hide other fields based on that selection. Boom!

I think it's lovely that Ellislab included this (possibly as a simple side effect of the instructions field, but lets not get picky!).

---
Tags: control-panel, javascript, css, multiselect, fieldtype
---


# Question
Title: Exp:resso Store and Zoo Visitor shipping informations problem
Hello I'm having problems with the checkout tags and the shipping address features of Store from Exp:resso. I'm using Zoo Visitor and I've set up Store to map order fields with Zoo Visitor member fields. When the Zoo Vistor shipping member fields are set, if I try to checkout my cart, the shipping address will be the same as billing, it won't take the shipping mapped member fields to pre-fill the form.

If I complete my checkout, the changes I made in my shipping address will be saved in the Zoo Visitor profile, but if I try to checkout another cart, it will fulfill the shipping address with the billing one again.

I know I can build up my own inputs, and I could try to grab the data from the Zoo Visitor profile, but isn't order fields mapping supposed to solve this, even for shipping infos ?

Thanks for your help !

**Checkout Template** : I'm using the one from Store, pretty much unchanged

```
{exp:store:checkout
form_class="form-horizontal"
next="site/checkout2"
error_handling="inline"
error_delimiters='<span class="help-inline">|</span>'
require="name|address1|address3|country"}

{if no_items}
    {redirect="site/checkout"}
{/if}

<fieldset id="billing_details">
    <legend>Billing Details</legend>

    <div class="control-group {if error:billing_name}error{/if}">
        <label class="control-label" for="billing_name">Name</label>
        <div class="controls">
            {field:billing_name} {error:billing_name}
        </div>
    </div>

    <div class="control-group {if error:billing_address1}error{/if}">
        <label class="control-label" for="billing_address1">Address</label>
        <div class="controls">
            {field:billing_address1} {error:billing_address1}
        </div>
    </div>

    <div class="control-group {if error:billing_address2}error{/if}">
        <div class="controls">
            {field:billing_address2} {error:billing_address2}
        </div>
    </div>

    <div class="control-group {if error:billing_address3}error{/if}">
        <label class="control-label" for="billing_address3">City</label>
        <div class="controls">
            {field:billing_address3} {error:billing_address3}
        </div>
    </div>

    <div class="control-group {if error:billing_postcode}error{/if}">
        <label class="control-label" for="billing_postcode">Postcode</label>
        <div class="controls">
            {field:billing_postcode} {error:billing_postcode}
        </div>
    </div>

    <div class="control-group {if error:billing_country}error{/if}">
        <label class="control-label" for="billing_country">Country</label>
        <div class="controls">
            {field:billing_country} {error:billing_country}
        </div>
    </div>

    <div class="control-group {if error:billing_phone}error{/if}">
        <label class="control-label" for="billing_phone">Phone</label>
        <div class="controls">
            {field:billing_phone} {error:billing_phone}
        </div>
    </div>

    <div class="control-group {if error:order_email}error{/if}">
        <label class="control-label" for="order_email">Email</label>
        <div class="controls">
            {field:order_email} {error:order_email}
        </div>
    </div>

</fieldset>

<fieldset>
    <legend>Shipping Details</legend>

    <div class="control-group">
        <div class="controls">
            <label for="shipping_same_as_billing" class="checkbox">
                {field:shipping_same_as_billing} Same as Billing Details
            </label>
        </div>
    </div>

    <div id="shipping_details_drawer">

        <div class="control-group {if error:shipping_name}error{/if}">
            <label class="control-label" for="shipping_name">Name</label>
            <div class="controls">
                <input type="text" name="shipping_name" value="{shipping_name}" />
            </div>
        </div>

        <div class="control-group {if error:shipping_address1}error{/if}">
            <label class="control-label" for="shipping_address1">Address</label>
            <div class="controls">
                {field:shipping_address1} {error:shipping_address1}
            </div>
        </div>

        <div class="control-group {if error:shipping_address2}error{/if}">
            <div class="controls">
                {field:shipping_address2} {error:shipping_address2}
            </div>
        </div>

        <div class="control-group {if error:shipping_address3}error{/if}">
            <label class="control-label" for="shipping_address3">City</label>
            <div class="controls">
                {field:shipping_address3} {error:shipping_address3}
            </div>
        </div>

        <div class="control-group {if error:shipping_postcode}error{/if}">
            <label class="control-label" for="shipping_postcode">Postcode</label>
            <div class="controls">
                {field:shipping_postcode} {error:shipping_postcode}
            </div>
        </div>

        <div class="control-group {if error:shipping_country}error{/if}">
            <label class="control-label" for="shipping_country">Country</label>
            <div class="controls">
                {field:shipping_country} {error:shipping_country}
            </div>
        </div>

        <div class="control-group {if error:shipping_phone}error{/if}">
            <label class="control-label" for="shipping_phone">Phone</label>
            <div class="controls">
                {field:shipping_phone} {error:shipping_phone}
            </div>
        </div>

    </div>

</fieldset>

<div class="form-actions">
    <a href="{path='site/checkout'}" class="btn">Back</a>
    <input type="submit" name="next" value="Review Order" class="btn btn-primary" />
</div>

{/exp:store:checkout}

<script type="text/javascript">
$(function() {
    $('#shipping_same_as_billing').change(function() {
        if (this.checked) {
            $('#shipping_details_drawer').slideUp();
        } else {
            $('#shipping_details_drawer').slideDown();
        }
    });
    if ($('#shipping_same_as_billing').is(':checked')) {
        $('#shipping_details_drawer').hide();
    }
});
</script>

```

# Answer
Can you open up Store \> Settings \> General and scroll down to "Default Shipping Address" unless you have changed it would be set to "Shipping same as Billing" change that to "None" and save. You will need to empty your cart to clear the session data but you should now see the fields being populated by your ZooVisitor field data for the shipping fields now.
> 2 votes

---
Tags: expresso-store, zoo-visitor, shipping
---


# Question
Title: Exp:resso + MSM: Site parameter not available?
I don't see any reference to the site parameter in any of the docs, is this available in the current release? We have built a multi site enviro for a retailer that allows for one control panel (front facing) so the client does not need to access the actual EE cp, in order for this to work I need to use the store tags but specify the site thanks

# Answer
Since Store tags operate on top of Channel Data if you add the `site_id` parameter to the channel entries tag Store will be displaying the proper items based upon that. So for example

```
{exp:channel:entries channel="products" site_id="2"}
 {exp:store:products entry_id="{entry_id}"
  <h2>{title}</h2>
  <h3>{price}</h3>
 {/exp:product:price}
{/exp:channel:entries}

```

Would only show products for the site 2 so you wouldnt need to add site\_id to the product tags.
> 2 votes

# Answer
I'm not sure exactly which tag you need the site parameter on.

Store is Multi-site Manager compatible and stores the site ID on the carts and orders in the database.

If you're trying to show orders from the front-end, the `{exp:store:orders}` tag automatically uses the current site id to filter the results.

If you need to override that and show orders from another site on the front-end, you'll likely need to write an add-on to do so or use the query module.
> 1 votes

---
Tags: expresso-store
---


# Question
Title: Expresso-store: Display weight in grammes instead
How do I convert the weight of a product? Currently it's in kg, would like to display it in grammes. Thank you.

# Answer
> 3 votes
Is this within the template? If so, you could use a add-on like MX Calculator to do the arithmetic.

```
{exp:mx_calc expression="{product_weight}*1000"}

```

---
Tags: expresso-store
---


# Question
Title: Unable to post or update entries after modifying custom field type?
I have added a custom field to my channel field group and selected the "P&T Dropdown" type but whenever I attempt to submit content the edit page just reloads and the database does not get updated.

If I change the value directly within the database then the correct value is selected when the edit page is loaded. But it is still not possible to change the value of the field.

I have tried the following but it is still not possible to post or edit posts to the "damaged" channel:

1. Backed up database
2. Uninstalled P&T field types and extension
3. Removed physical files from server directory
4. Removed all custom fields from custom field group
5. Removed association with statuses and categories

This means that I cannot post content to my channel despite the fact that it contains no custom fields, statuses or categories.

I then:

1. Restored my database
2. Created a new channel and associated it with the same custom field group, statuses and categories.
3. Attempted to add content to that channel

That channel works fine, so the problem is with the original channel itself :S

Any ideas?

# Answer
I have found the source of the error and I believe it to be a bug with ExpressionEngine. I will explain this to the best of my abilities, please feel free to improve the readability of my answer if necessary.

The following is important:

* Custom channel.
* Custom field group.
* Custom field layout for "Edit Content" control panel page.
* I had a custom field that was using the built-in "Radio" field type.

I then installed the P&T alternative fields and switched from "Radio" to "P&T Radio". When I went to the edit screen I amended the arrangement of fields for easier input. From this point I was not able to create new content in my channel nor edit existing content.

# How I diagnosed this:

* I looked into the "content\_publish.php" script because the name `content_publish` appeared within the URL: `admin.php?S=0&D=cp&C=content_publish&M=entry_form&channel_id=2`
* I found the method `entry_form` and stuck lots of `echo` lines in there to see what was going on. It seemed that the form was failing validation tests.
* I then removed all of the custom fields from my custom field group and performed the same action. Again the form was still failing validation (but with no useful errors, and there is a reason for this which I found shortly later).
* I examined the HTML of the edit page itself and after about an hour of pulling my hair out I realised that the form still contained all of the fields that I had deleted. So I reset my custom field layout via the expandable toolbar and all of the fields amazingly reappeared (even though they don't exist anymore!)

# The Problem:

When custom fields are removed or changed the custom layout data is not automatically updated. However, the custom layout data is being used to prepare the form and because the data is inaccurate (contains fields that have been removed, and is invalid where field types have been changed) the form never validates.

But because the fields are not defined any more it was not possible for EE to deliver meaningful validation messages. Though some sort of error message would have been useful :/

# The Solution:

I restored my database back to its "broken" state and then:

1. Navigated to the "Edit Content" page.
2. Expanded the tool bar and clicked "Reset Layout".

Resetting the layout worked this time because I hadn't removed any fields.

Now I have to reconfigure that layout AGAIN! and I suspect that it will break again in the future for the exact same reasons.
> 5 votes

---
Tags: custom-fields, bug
---


title: ExpressionEngine with Backbone?

text:
# Question
Title: ExpressionEngine with Backbone?
I'm looking for implementation information about using Backbone.js on the front end of an ExpressionEngine site. I saw this site that appears to be using EE and Backbone together but would be curious to learn more about how that would be implemented.

The Entry API add-on is the closest add-on currently built for EE that would support the REST functionality needed for Backbone. But I was wondering if this would be the recommended way to approach integrating with Backbone, what are the potential security issues, or would this be something that would have to be implemented through developing a custom plugin that will handle the interaction between backbone and the database?

What I hope to achieve is similar to the link as well. Essentially it would be a large category listings page that would be displayed and filtered based on category check boxes. Which then would simply be probably a custom SQL query based on the cat id's passed in. Then using backbone for the display of that updated query result (through REST) based on category selection in the main content area of the front end through the JavaScript. The interaction between the REST connection would be for display only and never would it be used for any actual update or create operations.

# Answer
Since you don't need CRUD operations, you could probably do this with simple ajax calls instead.

The EE templates would simply return a chunk of markup instead of a whole page.

You can still use Backbone to tie all the views together and have everything updating in multiple places, but as far as I can see you don't need to be sending JSON backwards and forwards from Backbone models/collections, and therefore don't need RESTfulness...
> 1 votes

---
Tags: ajax
---


# Question
Title: How to conditionally enclose a list of reviews with `reverse_related_entries`?
If there are review entries related to the current entry then I would like to display it as follows:

```
<aside id="reviews">
    <h3>Reviews</h3>
{reverse_related_entries channel="review"}
    <article>
        <h4>{title}</h4>
        {review_body}
    </article>
{/reverse_related_entries}
</aside>

```

If there are no reviews then I do not want to display anything.

I could just add a JavaScript which removes the empty "Reviews" section, but I would rather it wasn't outputted if possible.

# Answer
Wouldn't this work?

```
{reverse_related_entries channel="review"}
{if count == "1"}
<aside id="reviews">
<h3>Reviews</h3>
{/if}
<article>
    <h4>{title}</h4>
    {review_body}
</article>
{if count == total_results}</aside>{/if}
{/reverse_related_entries}

```
> 6 votes

# Answer
> Do you know off the top of your head if {if count % 4 == 0} works

I'd never considered the EE could use modulus. I haven't tested but a quick look at the docs and it isn't listed: http://ellislab.com/expressionengine/user-guide/templates/globals/conditionals.html#comparison-operators

I've done this many time by just enabling PHP for the template.

\*NB Not sure how can you to reply to a thread of someone else's answer.
> 0 votes

---
Tags: templates, related-entries
---


# Question
Title: Characters are being re-encoded in control panel
I am having a strange issue.

I have the latest version of EE 2.5.3 installed.

If I update any text inside of a text area in the control panel (including templates, a template for an extension like Better Meta), certain characters are automatically converted to html encoded tags. For example, `<` becomes `<`

Working from flat-file templates, this isn't an issue. This only occurs when editing in the control panel.

Any ideas? Here is a screenshot: http://f.cl.ly/items/3u2Q190k3g4506052p0d/wtf.png

# Answer
I was able to track this one down.

I came across this post - http://ellislab.com/forums/viewthread/168189/

It looks like if `$config['global_xss_filtering']` is set to `TRUE`, all characters are automatically encoded on GET or POST.

Setting it to `FALSE` has corrected the issue.
> 4 votes

---
Tags: control-panel
---


# Question
Title: ProForm forms stopped submitting, no errors
I've already emailed the plugin dev about this, but I need to get this working again as soon as possible.

I have some forms created using ProForms that have been working fine. Today I noticed none of them are submitting. When the submit button is pressed it refreshes the page, the form fields are empty, and my "success" message doesn't display. The submission doesn't appear in the control panel like it should. I don't receive any errors. I haven't changed the templates at all. Yesterday I added some new fields to one of the forms, but had not tested it yet so I don't know if this did something.

I know I don't have too many details, but if someone is familiar with this plugin and might be able to take a look that would be great. We need to fix this urgently, so if you can help out we could throw some bucks your way. Thanks!

# Answer
> 2 votes
I'd start troubleshooting by removing the new fields that you added yesterday and reverting back to the old template version if you made template changes.

Are you seeing any JS errors in your console?

Any CSS/HTML issues in validation reports that might be causing issues?

Also, check your PHP error logs on the actual server.

Were there any server changes?

Did you make any other changes to templates, addons etc yesterday?

Clear browser cache and cookies.

# Answer
> 2 votes
Thanks for the support MediaGirl and Adrian. The developer helped me out and it turns out it was something I did the other day that messed it up. I was having a different problem with one of my extremely large forms loading slowly. I turned on caching for that template. It didn't do anything (and was the wrong thing to do), and I forgot to turn it off. Once Isaac noticed this I turned it off and everything was ok. Thansk again!

---
Tags: forms
---


# Question
Title: Store {price} field without the currency?
in exp:resso store, is it possible to display the {price} field without the currency symbol in certain situations? e.g. {raw\_price}

I want to calculate alternative currencies with a currency converter. obviously currency converters only accepts integers without currency symbols...

cheers stefan

# Answer
You can add `_val` to most price related fields to get the unformatted price so

`{price_val}`

would return "20" if your item price was "$20.00"
> 3 votes

---
Tags: expresso-store
---


title: Hotfixes for a new 2.5.3 website

text:
# Question
Title: Hotfixes for a new 2.5.3 website
Before starting on a new #eecms website, are there any other hotfixes i need to know of ?!

# Answer
Most of the errors I run into have to do with Safecracker, since I usually build out my stuff in the front-end. I have a rolling fork for it.

There is another item I forgot to write down, but it's in the Safecracker API classes that extends the channel entries API.
> 5 votes

# Answer
Yes EE has gone for months without a bug fix release. No this doesn't make any sense. But so long as you're being a Smart Developer and backing up as you go you're not likely to encounter any major issues. Just build the site and search the bug tracker if you run into an issue. In all probability most known bugs won't affect you. If something explodes, which is really unlikely, then roll back to your latest DB, revert your Git repo and be on your way.
> 5 votes

# Answer
There's also this nasty one that prevents you using {path=...} or {encode=...} tags inside your entries. Hotfix here:

https://support.ellislab.com/bugs/detail/18239/
> 4 votes

---
Tags: control-panel, settings, update
---


# Question
Title: I'm new to e-commerce implementation and have a few general questions on what to expect
I've been developing EE sites for the past 4 years but haven't had an opportunity to build a site using ecommerce yet. I now have an opportunity to build a simple an ecommerce site and I'm confident that I can implement it with any of the ecommerce modules available, but since I haven't actually done this before I have some VERY basic questions that have more to do with set-up, cost, testing, etc.

If anyone has a second to share any info I'd really appreciate it!

* Are there any hidden costs? I know the payment gateways charge a percentage of the sale and have a yearly fee too. The SSL has a fee and setup cost too? Anything else I should be aware of? Payment gateway recommendations?
* Speaking of getting an SSL set up is that difficult? I'm think of using EngineHosting any other hosting suggestions or recommendations?
* This is a broad question ... What's the most difficult part of creating an online store? I'm just trying to discover any universal pitfalls or annoyances that might be out there.
* How do you test the store when you're building it? Do payment gateways allow this? Can I test locally or do I need to use a production server?
* Anything else I should be aware of? Words of wisdom?

Thanks!!!

# Answer
I have created a couple of ecommerce sites using Expresso Store. I looked into the other available modules and felt Store was the best for me. I haven't been disappointed - it's easy to use, and they have great customer service.

Not all modules have a yearly fee, like Paypal. I have used Paypal and also Worldpay, and both allow test transactions. I've not had the need for SSL because the gateways i've used handle the payments on their sites.

For me, the most difficult part of the store creation was the learning curve. But it's not all that difficult (especially as Store comes with simple templates to copy all the important code from), and once I did it once, the others were much easier and took less time.

Good luck!
> 6 votes

# Answer
**Are there any hidden costs? I know the payment gateways charge a percentage of the sale and have a yearly fee too. The SSL has a fee and setup cost too? Anything else I should be aware of? Payment gateway recommendations?**

Payment gateway fees are usually monthly and a % of the transaction. SSL has an annual fee as well and much be renewed and reinstalled when it expires. My advice is to pay many years in advance for the SSL so you don't have to deal with an annual renew and reinstall. There may also be fees for the actual merchant account if you need one. I like Authorize.net for payment gateway. I hear good things about Stripe. There are others too that are just fine. You might ask on Twitter at #eecms.

**Speaking of getting an SSL set up is that difficult? I'm think of using EngineHosting any other hosting suggestions or recommendations?**

Hosts usually offer an SSL option through their services via a preferred third-party but you don't always need to buy that option. Most let you buy your own SSL and they will install for a small fee. GoDaddy has a promotion for $12.99 a year SSL certificates here which I think is the best price you will find anywhere: http://www.godaddy.com/compare/gdcompare3\_ssl.aspx.

**What's the most difficult part of creating an online store? I'm just trying to discover any universal pitfalls or annoyances that might be out there.**

I find the hard part to be coding the checkout process and getting that flow working in a way that makes the most sense. I think all the EE carts install basic templates, you then rework as you see fit or just stay with what's in the template. I always rework myself a ton.

**How do you test the store when you're building it? Do payment gateways allow this? Can I test locally or do I need to use a production server?**

You put the cart into test mode and the gateway into test mode (if needed) and test away. Each payment gateway will have test credit card numbers in their docs and instructions on generating certain errors. Here are the docs for Authorize.net: http://developer.authorize.net/testingfaqs/. You will probably need a production server with the SSL installed so the test transactions are received securely. You'll have to test this. Might be able to test with a local install.

**Anything else I should be aware of? Words of wisdom?**

It's not that hard. Just takes doing the work.
> 6 votes

# Answer
One of the most often overlooked features when building an e-commerce site are order fulfillment and unique shipping options.

For example, once an order is placed, who prints the invoices, runs the CC charges, packages the order etc. If its a larger company they probably have people dedicated to this process, how do they get the information they need? Do they log into the EE CP and do fulfillment there or do they have another system to integrate with that they probably forgot to tell you about during the sales process?

Items that require unique shipping, e.g. breakable things. I built a site years ago that sold soda. Customers can buy a 12 or 24 pack and have it shipped to them, and also buy a t-shirt. Due to their packaging requirements, read fulfillment, they had to ship any order that contained a 12 or 24 pack in as separate packages, thus shipping fees need to be calculated differently.

Every time I help quote an e-commerce site I ask these questions and more than half the time I get an "oh, I never thought about that stuff" sort of response.
> 6 votes

# Answer
Ecommerce is always much more hard work than a straightforward content site. I've been producing ecommerce sites for 12 years now and although the technology has changed the basic issues have remained the same. There's a lot of wisdom already on this post so I'll do my best...

About a year ago I started using EE with CartThrob for ecommerce projects and found them to be a great combination. CartThrob makes use of standard EE channels for product data so there's less of a learning curve for me and my clients.

In my experience the things to watch out for with ecommerce are:

**security:** don't be complacent about this. Make sure that your site is secure. I've had the nasty experience of having one of my sites hacked. At best it is very embarrassing (you have to explain to your client why it's happened) and at worse you're dealing with legal problems. Of course, having your payment gateway process the transactions off-site makes this less of a problem however you should still take it seriously. Ecommerce sites are a popular target for hackers.

**payment gateway:** which ever one you choose there are two broad types of service. One where the transactions are processed on their servers and another where your server is used. My advice, use the service where they process the transaction on their server. You can usually "hide" the mechanism by embedding the payment gateway's card authorisation pages into your site using Iframes if you like. Here in the UK my preferred payment gateway is SagePay. I re-style their authorisation pages to match the site and embed them into the checkout in an Iframe.

**PCI DSS Compliance:** I'm not sure about the rest of the world but here in the UK the banks insist on my customers complying with this otherwise they charge them a monthly fee for being non-compliant. By using an off-site payment gateway the process of being compliant isn't too hard but as a general rule find out what your customer's merchant bank requires of them to trade on line.

**shipping:** this has already been mentioned. Never underestimate your customer's shipping rules. You will need to make sure that the site's shipping calculations can take account of all combinations that may be ordered as well as types of shipping, geographical area etc. etc. Spend time with your client at the beginning of the project and make sure you really understand the way they charge for shipping. I had a customer who took 9 months to devise their shipping rules because before ecommerce came along it was "Fred in the warehouse who could just look at an order and know how much it would cost". Once you understand their shipping calculations make sure that your chosen ecommerce system can cope. With CartThrob I've been able to write my own shipping plugins because the standard ones haven't catered for my clients' needs.

**product data:** where is it? In a spread sheet, an MS Word document, on sheets of paper, in a database? One way or another all that data ( descriptions, sizes, prices etc) has got to be put in to your ecommerce system. Find out early on, you may need to charge for data entry.

**photography:** bad product photos will do more harm than good. Does your customer have good photos of their products? If not, get a professional photographer to take some.

**SSL:** Even when using a payment gateway I tend to advise my customers to buy an SSL. That way, their customers see that the entire checkout is secure and not just the page on which they enter their card details. I find it helps their customers have confidence in the site. If your customer can afford it, an EV certificate is best.

**testing:** we all hate this bit. Test, test and test again. Ideally get people to test the site who have never seen it before ( just like real customers). Make sure the site functions correctly, the shopping cart totals are correct for different combinations of products and that the shipping is correct ( again, for different combinations of products in the cart).

I hope this helps. Good luck!
> 6 votes

---
Tags: ecommerce, general-knowledge
---


# Question
Title: P&T Dropdown/Select Dropdown - allow users to enter item not in list?
I'm using Matrix and one of my fields needs to be a Select Dropdown, but since it apparently isn't an option in Matrix I had to install P&T Dropdown. Is there a way to let users enter their own value if they would rather not select an item from the list? I'd like to know how to do this P&T Dropdown and Select Dropdown, if possible. If not, are there any other options?

Also, I suppose not all field types are "Matrix compatible" and that's why I don't see Select Dropdown as an option for cell type. Is that right? What makes a field type Matrix compatible?

# Answer
The way I'd set this up is with an additional textarea field for the "other" content. Then you can write a conditional in the template to display that field data if it's not empty. To guide your editor, add instructions to the field column. If you want to get really detailed, you can write custom JS to hide the "other" field column until they select "other" in the dropdown.

Custom fields need to have code adjusted to be Matrix Compatible. Here are the docs for making those changes: http://pixelandtonic.com/matrix/docs/ee2-functions. It doesn't seem like EllisLab has made these changes to their default fields. Not sure why that is exactly since everyone uses Matrix on one project or another.
> 4 votes

# Answer
I wonder if this add-on could be of use:

http://devot-ee.com/add-ons/mx-select

> This add-on makes long, unwieldy select boxes much more user-friendly with Chosen plugin. It is also opens the option for the user to add new items into the list "on the fly". You can setup to save new options on field level (to be available for choosing in all entrees) or just once. Support Matrix-like fields, Low Variables, SafeCracker. And you can also populate list with custom SQL queries.
> 1 votes

---
Tags: custom-fields, matrix, fields
---


# Question
Title: Matrix, Safecracker Registration - multiple channels for member fields
I got Matrix to represent line item entries and Safecracker Registration so I can use Channels as member fields. I will be creating 2-3 member groups, for example:

* Member Group A: field 1, field 2, field 3
* Member Group B: field 1, field 2, field 3, field 4, field 5

Since fields 1-3 are the same between Member Group A and B, is there a way for me to put them together in a common Channel, then put fields 4-5 in another Channel -- and then somehow associate the various Channels to be used a member fields?

Splitting the Channels is simple enough. I'm just not sure how using Channels work with member fields, etc. I'm trying to prevent duplicating my efforts when it comes to defining these fields in the Channels.

# Answer
> 1 votes
The only way to do this is to store all your fields in the same field group and assign that field group to each member channel. Then you show/hide what you need on the edit form using **Publish Layouts**.

This will only cause issues if:

* You have a ton of fields in that field group because all fields will be loaded on the edit page and only the ones you select will be visible.
* You have required fields that aren't required across all channels using the fields. A required field will throw a validation error even if it's hidden. The editor then can never save the entry.

I asked a similar question here when we first launched the site to get the ball rolling:
Shared field group?

---
Tags: members, channel, member-details
---


# Question
Title: Automatically set expiration_date to be 24 hours after entry_date in SafeCracker form
I've got a SafeCracker form that contains (amongst other fields) an entry\_date field and an expiration\_date field:

```
<input type="text" name="entry_date" id="entry_date" value="{entry_date}" maxlength="23" size="25">
<input type="text" name="expiration_date" id="expiration_date" value="{expiration_date}" maxlength="23" size="25">

```

For this particular channel, I always want the expiration date to be exactly 24 hours after the entry date (and the user can change the entry date to be any date/time, not necessarily the current date/time). Is it possible make this happen automatically, without requiring the user to manually add/edit the expiration date?

# Answer
The Auto Expire addon should do the trick:
http://devot-ee.com/add-ons/auto-expire

---

Auto Expire adds the ability to any weblog to automatically expire new entries. It adds a predefined amount of time to the entry date. If an expiration date has already been set, that date will be used as the expiration date.
> 7 votes

---
Tags: safecracker, date
---


# Question
Title: Embeds in stash don't work when using process="end"
A stripped down example:

```
{exp:stash:get_list name="sidebar" process="end"}
    {embed="templates/sidebar-events" limit="3"}
{/exp:stash:get_list}

```

The embed tag doesn't get parsed at all, it just prints the literal embed string. I've tried both native embeds and stash embeds, and neither of them work. Anyone know of a workaround? Maybe using priority somehow? Or parse\_stage (which I don't get)?

Normally I don't use embeds but in this case I have nested channel:entries tags.

# Answer
> 5 votes
Stash won't parse EE embeds at all (this is by design) so you'll need to use a Stash embed instead. When you use process="end" the tag is replaced with a marker and 'post-processed' after the EE parser has completed parsing, and then replaced into the final template output. Therefore, it is up to the post-processed tag to do any parsing that might be required of the tags that it encloses.

With that in mind, you have two options here for the stash embed: make the stash embed behave like a standard EE tag and ask get\_list to parse it as a tag, or include the stash embed at the start of template processing before the EE parser replaces the wrapping get\_list tag with a marker:

```
{exp:stash:get_list name="sidebar" process="end" parse_tags="yes"}
    {stash:embed name="sidebar-events" stash:limit="3" process="inline"}
{/exp:stash:get_list}

{exp:stash:get_list name="sidebar" process="end" parse_tags="yes"}
    {stash:embed name="sidebar-events" stash:limit="3" process="start"}
{/exp:stash:get_list}

```

---
Tags: stash, embeds
---


title: SafeCracker Not Working?

text:
# Question
Title: SafeCracker Not Working?
I'm trying out SafeCracker for the first time. What I've done:

* SafeCracker module is installed
* Channel {test\_profiles} is created with 1 field: {full\_name}

The following code outputs nothing between the tag pair:

```
<h1>Hello World</h1>

<form>
    {exp:safecracker channel="test_profiles" datepicker="no" include_jquery="no" return="registration/form" safecracker_head="no"}
        <input name="title" type="text">
        <input name="full_name" type="text">
        <input type="submit" value="Submit">
    {/exp:safecracker}
</form>

```

Any ideas what might be wrong?

**EDIT 1:** I went to Addons -\> Modules -\> SafeCracker. I saw a list of my Channels there, including `test_profiles`. I checked the "Allow guests to post entries?" checkbox and selected one of the members from the "Set the member\_id to use for guests." drop down menu. Afterwards, I viewed the template output again. Now I see a \<script\> and \<style\> inside the \<form\> tags. I still don't see my text field, though.

# Answer
Does the member group have permission to post to the channel?

CP Home \> Members \> Member Groups \> Edit Member Group \> Channel Assignment

---

This **part of the docs** should help you allowing guests to post:

It certainly helps me to create a "Logged Out Members" member\_group and a single user in that group to take ownership of those entries. (In my case their member\_id is '2' as shown in tag example)

My tag looks a little like this:

```
{exp:safecracker channel="registrations"
                 return="foo/bar/ENTRY_ID"
                 logged_out_member_id="2"
                 ...
                 ...

```

My CP Home \> Extensions \> SafeCracker entry looks like this
> 2 votes

---
Tags: templates, channel-entries, safecracker
---


title: Matrix Fields Not Parsing

text:
# Question
Title: Matrix Fields Not Parsing
I have recently upgraded EE to 2.5.3, and Pixel and Tonic’s Matrix to 2.5.1 and now my Matrix fields have stopped parsing. The raw tags with curly braces are being output.

I’ve been pulling my hair out trying to figure out what is wrong.

I have tried contacting Pixel And Tonic on all the support channels I know of, and while it hasn't been that long, I *really* need to get this fixed pronto. Anyone know what might be causing this and how I can fix it?

# Answer
As it turns out, the issue was a conflict with Matrix and the Multiple Relationship extension where Multiple Relationship extension was being run after Matrix and was overwriting data produced by Matrix. Apparently some change in EE 2.5.3 caused this conflict because it didn’t exist before.

I actually switched to Playa anyway since I couldn’t quite do what I wanted with Multiple Relationships so I’m going to just de-install that add-on. But if you need to run them together with EE 2.5.3, the fix is to run the following query:

```
UPDATE exp_extensions SET priority = 9 WHERE class = 'Mrelshp_ext' AND method = 'channel_entries_tagdata'

```

I hope this helps anyone else pulling their hair out over this one.
> 4 votes

# Answer
I've responded to your support email. Happy to help here or there - let me know.

It would help to see your template, as well as to ensure that you visited the Matrix fieldtype settings in Add-ons -\> Fieldtypes -\> Matrix.

Thank you!

-Lisa Wess
Pixel & Tonic
> 3 votes

# Answer
Super basic, but did you remember to update all themes folders/etc? I have done this with sad results. Also I believe @onebrightlight had posted a Matrix/EE 2.5.3 prob recently - did you see if this is related?
> 2 votes

# Answer
Please take a look at the source code for what is output for those un-parsed curly-braced tags, TJ. If you find that your source code shows that they're being output as HTML entities, i.e., `{` and `|`, it *may* be a bug in EE 2.5.3.

(I had a similar hair-pulling experience when trying to use Matrix's image replacement trick after upgrading to 2.5.3, where images uploaded to matrix were referenced as {image\_1} {image\_2} inside the body of a custom field. If this is an issue straight from matrix to template, this may not be helpful for you, tho.)

In the ellislab.com forum, here's a description + link to the bug (the forum post is viewable by all no matter if you're logged into ellislab.com or not.); to view the full fix, you will need to first log in to Ellislab.com before clicking that link in order to see the post re: temporary bug fix (scroll down).
> 2 votes

---
Tags: matrix
---


# Question
Title: Can Exp:resso Store sell bundles of products?
I've installed a shop for a client, but told him that we most probably have to switch to cartthrob because of the high requirements the final shop will have. at the moment they are just selling the merchandizing stuff and they really really love the tool! and I love it too! so before switching, I might as well ask you if exp:resso store can handle the final requirements:

it's a record label store:
so products of a typical release can contain:

1. merchandizing stuff like t-shirts (w/ modifyers, colors, sizes), posters, books, dvds etc.
2. the physical product like cd, lp, mp3 stick
3. the virtual product, like mp3’s, wav, aiff files.
4. tickets to shows
5. bundles of 1-5… like, buy an album, get a ticket for free… or any other combination.

so putting this all together will be rather complex I think.

eg: if someone buys the physical LP (yes, vinyl), they should automatically get the download version for free.
you should be able to purchase one digital song or the whole album. but the bundled album price vs. all songs should be a little cheaper.
there should be different prices for mp3’s, aiff, flacs and wavs…

now my question is: has this already been done with store? do you have code samples of a working shop? do you think such a thing is feasable with store?

cheers
stefan

# Answer
> 4 votes
Since products are stored as channel entries, it's really easy to create bundles of product using Playa, or even standard EE relationships.

Remember you can have multiple product channels. For example, with Tracks and Albums, you could create a channel for `Tracks` (which has a Store product fieldtype associated with it for individual track sales), and another channel for `Albums` (which also has a product fieldtype, and is related to the individual tracks.

In your case you could also create a product channels for `Tickets`, `Merchandise`, and if you want to create some bundles containing everything, one more called `Bundles` or something similar, which can be related to any other product channel. How you display this on the front end is entirely up to you.

The only downside to this is that it is not possible to keep track of stock levels for bundled products. If you are selling digital products this isn't an issue, and for physical products it really depends on your client's requirements.

---
Tags: expresso-store
---


# Question
Title: Can I toggle sales tax exemptions in Exp:resso Store templates?
I'm working on a store that serves both consumers and wholesale retailers. The consumers pay sales tax, but the wholesalers don't. In my template, I can check for a Member Variable to see whether the customer should be tax-exempt. Then, can I somehow \[via POST\]:

* toggle {tax\_exempt} on a per-item basis?
* override the Tax Rate on a per-order basis?

# Answer
You would need to do this using an extension.

For example, you could use the store\_process\_product\_tax hook to check the member variables, and change the tax rate being applied to all products.

Likewise, you could use that hook or other cart hooks to override the tax\_exempt status on a per-item basis once items are in the cart.
> 2 votes

---
Tags: expresso-store
---


# Question
Title: Auto-post to Facebook when a channel entry is published
We would like to set something up so that when we publish a new article (channel entry) to our site it also creates a post on our Facebook page. What solutions are people using for this? I found the Social Update add-on on devot:ee, are you using this, a different add-on, or some other method?

# Answer
I'm personally using RSS Graffiti on Facebook to parse in my RSS feed and post it as Facebook entries. Has worked brilliantly and was dead simple to set up.

-Lisa
> 7 votes

# Answer
I know that Social Login Pro allows you to do this among many other features the only thing I think that might be a problem for you that it would want to post the article to the Authors Facebook page instead of a page for the entire site as it requires the user links their Facebook account to their EE member account.
> 3 votes

# Answer
I'm using http://twitterfeed.com/.

Easy setup, stable service. Free. Twitterfeed uses an RSS feed to post to FaceBook, Twitter and LinkedIn.
> 1 votes

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


# Question
Title: How to check the EE version number via PHP?
I'm writing an add-on and need to check the current EE version from PHP. What is the best way to get the current ExpressionEngine version?

# Answer
> 4 votes
One option would be to use the `APP_VER` constant. You can see it here with a few other version constants as well:

http://ellislab.com/expressionengine/user-guide/development/constants.html#version-constants

This will give you the version number with decimals unlike Adrian's solution so, pick which route you'd like. For example:

```
if (APP_VER == '2.5.3')
{
   do something;
}

```

# Answer
> 1 votes
You can use `$this->EE->config->item('app_version')` which returns a string like `253`.

I'm not sure whether this is the most reliable way to determine the version number though, or whether it's possible to get the version number including decimals.

---
Tags: ee2, php
---


title: Limit Channel Entry to 1?

text:
# Question
Title: Limit Channel Entry to 1?
Is there a way to limit channel entries to a specific number? For example, what if I had a "Company Details" channel (company name, address, telephone number, etc.). Generally, a site would only need one of those. If I use Channels, the user can add multiple Company Details, which is not right.

So, it there a way to limit Channel entries? Or should I be using something else?

# Answer
> 8 votes
There are two add-ons that are very useful for single-entry channels:

Either of these will remove the given channel from the Content \> Publish menu, making it less likely for the end-user to be confused and publish additional entries in a channel that isn't made for that.

# Answer
> 5 votes
As mentioned already, Single Entry is brilliant to do this sort of thing. A great example would be your 'home' page entry. You might have a channel called 'home' with a single 'home' entry. The Single Entry add-on is great for that.

For Company Details (which is the example given) that are used in the site, I would tend to go NOT having them in a single entry, but as either Global Variables (built-in to EE), or even better, use Low Variables. Whilst this is a commercial add-on, it is WELL worth the money, and I find it gives better performance then using an entry (particularly when used across multiple pages/templates).

# Answer
> 2 votes
Even in instances in which logically the client might only need one of something, I sometimes still wind up having a desire to avoid limiting the channel to a single entry for one simple reason - if I do that, all the power of EE's publish and expiry date is lost.

When I know for sure that I don't need to provide some of those entry-specific functions, global variables or better yet, low variables, are ideal. But for something like a homepage's welcome message, as another example of which you may figure there's only the need for one - consider that the client may wish to take advantage of the publish and expiry dates to have a new version of that entry self-publish on a given date/time, while expiring the previous entry. A retailer, for example, may have seasonal versions of their homepage welcome.

I know your example referred to contact details - which would certainly be even less likely to change, and when you need the full range of available fieldtypes, channel entries are helpful. The reason I chimed in here is to remind you that there are some circumstances in which there may be some advantage, evaluated on a case by case basis, in avoiding limiting the entry to a single item. So an add-on like single entry is excellent for those times when you need the power of channel entries but you can saw with certainty that some of the publishing features that come with a channel entry (like publish and expiry) are not needed.

# Answer
> 2 votes
I use Zoo Flexible Admin as part of my EE builds and so I simply don't include a link in the menu to publish for the given channel - just allow them to edit. Whilst this doesn't restrict the user from adding another entry they would have to know the exact URL to do so.

I use this strategy on the home pages of sites. Our home pages normally feature several matrix fields to control sliders, tabbed panels and the like. Probably a little too much to store in Low Variables - also for a consistent user experience it still feels the same as editing a page for the client.

I normally have a top level menu options of 'home page' and then 'pages', 'entries' (listings like news), 'fragments' (link to Low Variables) etc.

Works for me and the client.

However, for company details and the like I would store these under what I call 'fragments' - basically Low Variables - why use any other method?

# Answer
> 1 votes
I find that creating front-end edit links (visible to logged-in site editors only) prevents site editors from adding a duplicate entry.

# Answer
> 0 votes
If you set `limit="1"` in the channel:entries tag EE will call your most recent entry in the channel.

If you want to call a specific channel entry you set `entry_id="ID_NUMBER_HERE"` in the channel:entries tag.

**Links to channel:entries parameters in EE docs:**

# Answer
> 0 votes
Another addon to look at, that has a bit more functionality is Zoo Flexible Admin. You can fully customize the control panel (hiding channels from publish so no new entries can be created) and user experience.

---

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

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


# Question
Title: SafeCracker - display radio and checkbox? set class in <form>? wrap hidden fields in <fieldset>?
* My Channel has radios and checkboxes. How to I loop through the options so that I can display each item as a radio/checkbox option in the mark up? The example I found doesn't make much sense to me:

> ```
> {if radio}
>      {options}
>           <label class="checkbox">{option_value}
>           <input type="radio" id="{field_name}" name="{field_name}" value="{option_value}"{checked}>
>           </label>
>      {/options}
> {/if}
>
> ```

* SafeCracker outputs a bunch of hidden fields in a `div.hiddenFields`. It should be in a `<fieldset>` if it's going to pass validation. Is there a way to make them appear in a fieldset?
* I'd like to set a class in the `<form>` tag produced by SafeCracker. Is there a way to do that?
* How do I display the field value for text, textarea, radio, checkbox, etc? I'd like to display them when the form loads if the values previously exist. And when user submits a form with bad values, I'd like to display the submitted values when the error page is displayed.

**EDIT 1:** My first question is solved, I think:

```
{options:gender}
    <label for="{option_value}">
        <input type="radio" name="gender" value="{option_value}" id="{option_value}">
        {option_value}
    </label>
{/options:gender}

```

# Answer
Q1: what's not clear about the example?

Q2: Form elements can be children of divs, that's fine. They just can't be directly children of the \<form\> element (although I have a feeling that HTML5 might be a bit more relaxed about that).

Q3: The SafeCracker form has a class parameter.

Q4: Examples for custom fields are here.
> 2 votes

# Answer
My suggestion with SafeCracker is to not rely on the {exp:safecracker} tag to output your final form. Instead use it to get your initial HTML output, paste that into your template and customize as needed. This way you can change the hidden fields to have the as you want and will have 100% control over your form fields and HTML layout. This option offers the most flexibility in my opinion.

You'll need to use this Global Variable to print out the **XID hash** in your template. This will be one of the fields in the hidden group.
> 1 votes

---
Tags: safecracker
---


# Question
Title: How can I add WYSIWYG/HTML content to Poll options?
I'm looking into DevDemon's Channel Polls and EE Harbor's Polls module... What my client really wants is the option to have WYSIWYG HTML content for each poll OPTION (i.e. not just the poll question).

I can get close by creating a Matrix/Wygwam field to list the content for each option, and then put the voting/selection form after that. But, what my client really wants is for the voting controls to be in-line with the HTML content for each option.

So, my questions are:

* Is there a clever way to get the voting controls inline with content defined in another custom field?
* Or, if not, do these polls modules allow for HTML content to be entered in the plain-text options fields?

# Answer
> 1 votes
If the option fields are textareas, you should be able to easily add **Redactor** to the fields you want to change to WYSIWYG.

Below are installation instructions from the **Redactor docs**:

You can use the **CP CSS & JS extension** to add the JS/CSS to the header.

You'll need to inspect the html of the edit form to determine the selectors for the fields you want to convert. Add those into your JS and you should be set.

If you are already using **DevDemon's Editor** addon, you can reuse his js/css file includes instead of adding these new ones to the header.

---

> To install Redactor, place the following code between the tags:
>
> ```
> <link rel="stylesheet" href="/js/redactor/redactor.css" />
> <script src="/js/redactor/redactor.js"></script>
>
> ```
>
> If your Redactor download is placed in a different folder, don't forget to change file's paths.
>
> You can call Redactor using the following code:
>
> ```
> <script type="text/javascript">
>   $(document).ready(function(){
>           $("#redactor_content").redactor();
>       }
>   );
> </script>
>
> ```
>
> This code may also be placed between the tags or at any other place on the page.
>
> Finally, you need to place a element with ID "redactor\_content" (or with the ID that you set during Redactor's call). This element will be replaced by the visual representation of the Redactor.
>
> ```
> <textarea id="redactor_content" name="content"></textarea>
>
> ```

---
Tags: add-on
---


title: Remove segment from URL

text:
# Question
Title: Remove segment from URL
I'd like to take any URL where `segment_1 == "supernav"` and remove that segment. So this:

`http://alpha.ced.berkeley.edu/supernav/gallery/`

Would become this:

`http://alpha.ced.berkeley.edu/gallery/`

How can I do this?

# Answer
I'd create a template group called **supernav**, and put this in its **index** template:

`{redirect="{segment_2}/{segment_3}"}`

(If there's no 3rd segment present, EE will ignore it.)
> 4 votes

# Answer
If you're not actually talking about doing a redirect (it's not quite clear from your question for me) then you may want to consider using Freebie for this:

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

In the freebie extension settings you can set supernav to be ignored so, any time you hit `http://alpha.ced.berkeley.edu/gallery/` you are really hitting `http://alpha.ced.berkeley.edu/supernav/gallery/`

And of course you would make sure in your hrefs that you removed `supernav/`.
> 1 votes

# Answer
Here are a couple mod\_rewrite options to try in your .htaccess file to remove the "supernav" segment of your URL:

```
RewriteEngine On
RewriteBase /
RewriteRule ^supernav/gallery/$ /gallery [L]

```

or

```
RewriteEngine On
RewriteBase /
RewriteRule ^(.*)$ supernav/$1 [L]

```

---

Worth taking a look at...
> 1 votes

---
Tags: segments, url
---


# Question
Title: Extend EE_Loader (or CI_Loader) in ExpressionEngine
I want to extend the **EE\_Loader** class in ExpressionEngine 2, without hacking at core EE (or CI) code.

I tried to follow the advice from Simon Emms' blog which would be a clean way to extend CI\_Loader, and follows the standard convention for extending a CI class.

I've tried adding a `EE_Loader.php` file within `codeigniter/system/core/`, which is where **CI\_Loader** (in file `Loader.php`) lives. My subclass\_prefix is 'EE\_' because I'm using ExpressionEngine so I'm confident with the filename being used, but it's not reading in the new file.

Has anyone been successful in extending ExpressionEngine's EE\_Loader class? Any pointers would be appreciated.

To provide some background, I have written a PHP Session handler which writes to MySQL, using Active Record to form my queries. It will be used in a web cluster so I need to share sessions. I have considered using a NFS file, memcached, redis and MySQL solutions. MySQL is already in use, will perform well and provides a centralised store.

After reading the session data from the DB, I make another call to write to the DB, but I get a "deprecated" warning:

```
A PHP Error was encountered
Severity: 8192

Message: mysql_escape_string(): This function is deprecated; use mysql_real_escape_string() instead.

Filename: mysql/mysql_driver.php
Line Number: 319

```

I also get the same message when I use the mysqli driver.

It's happening because `$this->conn_id` becomes false between 2 queries. I don't know why.

# Answer
> 2 votes
For future reference, I created a new set of DB drivers (`eemysqli`) which are a renamed (filenames and class names) but otherwise exact copy of `codeigniter/system/database/drivers/mysqli/*`. I then applied the following edit to `eemysqli_driver.php`:

```
--- drivers/mysqli/mysqli_driver.php    2012-11-26 15:19:21.000000000 +0000
+++ drivers/eemysqli/tcmysqli_driver.php        2012-12-11 19:45:45.375905181 +0000
@@ -28,7 +37,7 @@
  * @author             ExpressionEngine Dev Team
  * @link               http://codeigniter.com/user_guide/database/
  */
-class CI_DB_mysqli_driver extends CI_DB {
+class CI_DB_eemysqli_driver extends CI_DB {

        var $dbdriver = 'mysqli';

@@ -278,6 +287,8 @@
     /**
      * Escape String
      *
+     * I (AD) have amended this function to fix a known bug which is fixed in CI3.
+     *
      * @access      public
      * @param       string
      * @param       bool    whether or not the string will be used in a LIKE condition
@@ -295,18 +306,7 @@
                        return $str;
                }

-               if (function_exists('mysqli_real_escape_string') AND is_object($this->conn_id))
-               {
-                       $str = mysqli_real_escape_string($this->conn_id, $str);
-               }
-               elseif (function_exists('mysql_escape_string'))
-               {
-                       $str = mysql_escape_string($str);
-               }
-               else
-               {
-                       $str = addslashes($str);
-               }
+        $str = is_resource($this->conn_id) ? mysql_real_escape_string($str, $this->conn_id) : addslashes($str);

                // escape LIKE condition wildcards
                if ($like === TRUE)

```

It's a bit of a nonsense, but I can rest easy knowing I haven't hacked core EE/CI files.

# Answer
> 0 votes
About a year ago i made a proof of concept to integrate DataMapper ORM into ExpressionEngine.
DataMapper is a database abstraction library for CodeIgniter, that does exactly that, replace the load\_class function.

It turned out that the version of CodeIgniter that ships with ExpressionEngine, does not do the check `if function_exist()` before loading most or any of the core functions. It took only a very small modification to the core to be able to override the load\_class function. It boils down to wrapping the load\_class function in a if not function\_exists conditional.

```
# 1. file: /system/codeigniter/system/core/Common.php
if ( ! function_exists('load_class'))
{
    function &load_class($class, $directory = 'libraries', $prefix = 'CI_')
    {
    ...
    }
}

```

This allows us to load our own bootstrap first from the main index.php file, just before the core system bootstrap would have been loaded.

```
# 2. file: /index.php at the, just before loading the bootstrap file
require_once APPPATH.'third_party/datamapper/bootstrap.php';

```

**NOTES**

1. the code can be found on https://github.com/GDmac/EE\_DataMapper/
2. The naming can be a bit confusing.
**A)**. The CodeIgniter ActiveRecord class actually is a QueryBuilder, and in CodeIgniter 3 it correctly has been renamed to QueryBuilder.
**B)**. Datamapper ORM ( http://datamapper.wanwizard.eu ) actually
follows the ActiveRecord design pattern.
**C)**. DataMapping is another design pattern, which abstracts the database away from the rest of the code
3. general tip: Avoid hacking core with lots of your own code intermingled in the core. Instead just add/insert an extra hook in the core and put our actual code into an extension.
This goes even for third-party add-ons.
See: http://madebyhippo.com/blog/view/expressionengine\_hook\_dont\_hack

---
Tags: codeigniter
---


# Question
Title: SafeCracker and embedding templates - channel data lost?
I have a SafeCracker form. In order to maximize code reused, I have broken the form into embeddable fieldsets, with each fieldset containing embedded fields. (Basically, I can just embed fields as I need them throughout the various forms I need.)

When I display the form, however, I don't think it has access to the Channel data. For example, here's my template for my `gender` field:

```
<div class="control-group">
    <div class="controls">
        {options:gender}
            <label class="radio" for="{option_value}">
                <input type="radio" name="gender" value="{option_value}" id="{option_value}">
                {option_value}
            </label>
        {/options:gender}
    </div>
</div>

```

The output is exactly the above. The `{options*}` stuff did not get parsed. Is embedding not allowed?

# Answer
Are you considering ExpressionEngine's parse Order?
This is a quick quick summary:
http://loweblog.com/downloads/ee-parse-order.pdf

\[...\]
3. Parse simple conditionals: segment, embed, global variables
\[...\]
5. Parse module and plugin tags

Try Pre Embed (free plugin)
http://devot-ee.com/add-ons/pre-embed
> 1 votes

---
Tags: templates, safecracker, embeds
---


# Question
Title: SafeCracker Registration - unknown error
I'm using SafeCracker Registration. Right now, I have a form with 4 fields:

* title
* email
* password
* password\_confirm

When the form displays, I click submit without entering any data in the form. I get this on the next page:

```
The following errors were encountered

You have just been sent an email containing membership activation instructions.

```

No email is received. No member is registered. My opening tag is this:

```
{exp:safecracker channel="profiles" class="form-horizontal" datepicker="no" error_handling="inline" include_jquery="no" register_member="yes" return="registration/form" safecracker_head="no"}

```

NOTE: "profiles" is a valid Channel. It contains a number of fields, but I haven't started trying to populate them.

# Answer
This is a bug. Safecracker Registration v1.2 is finished and waiting for a release. I just haven't had time to document the changes, and update the documentation, but it makes a lot of usability improvements like the one you mentioned.

Email support\[at\]objectivehtml.com and I will be happy to get your setup with the latest version.
> 2 votes

---
Tags: members, safecracker, safecracker-registration
---


# Question
Title: An automatic find and replace module + plugin?
Is there an add-on which provides a template tag for automatically finding preset phrases and replacing them with alternatives that have been defined using a module interface?

My client would like this so that they can add standard hyperlinks throughout their content without having to do it manually. It would be a bonus if it provided an API which could be used when channel entries are created so that new mappings could be generated automatically.

For example the book title gets automatically substituted with `<a href="XYZ">Fishing for Idiots</a>` in the following content:

```
{auto_replace}
{body}
{/auto_replace}

// Where {body} evaluates to:
The book Fishing for Idiots features blah blah blah...

```

# Answer
Links to content by title can be automatically introduced using the Crosslinking add-on. This add-on also avoids adding the same link multiple times to avoid "black SEO".

Cross linking can be disabled for specific parts of content by encapsulating it within `{no_crosslink}{/no_crosslink}` tags.
> 0 votes

# Answer
The **Shortcode** addon was just released today and it's exactly what you are wanting.

> Shortcode aims to allow for more dynamic use of content by authors and editors, allowing for injection of reusable bits of content or even whole pieces of functionality into any field in EE. Shortcode provides two types of codes for use in any content in EE: user-defined Macros specific to each author and each site, as well as a simple API for third-party plugins and modules to expose their tags through the shortcode Rich Text Editor dialog (or manual entry in any type of field) - complete with automatically rendered options forms.
>
> **Two Types of Codes**
>
> Macros - User defined, author and site specific bits of reusable content - basically just like Snippets but can they can be embedded directly in any field type by your content Editors!
>
> Shortcodes - Plugin/Module defined tags that can be injected into the middle of content, such as a ProForm form or other piece of functionality. This works similarly to the WordPress Shortcode API.
>
> **Features**
>
> Macros defined by each user for their own use - each author could have the same macros defined with the same names, with different values that are dynamically replaced based on the assigned author of an Entry.
>
> Macros defined by Super Admins for the entire site and usable in all content for each site (MSM compatible with separate sets of Macros for each site).
>
> Macros and Shortcodes can be inserted manually in any fieldtype, or automatically through the included Rich Text Editor tool.
>
> Simple Shortcode API that allows for any Plugin or Module to provide custom Shortcodes complete with automatically generated configuration dialogs
>
> Existing plugins and modules can be converted to shortcodes with very little code. Assistance in the forum is available for anyone who wants to add support to their own add-ons.
>
> Assistance writing glue code for existing plugins or modules is also available - just post a request for support for the plugin in the forum.
> 2 votes

# Answer
I don't think anything exactly like that currently exists. The closest you're going to get is Low Replace, but that will only replace strings where you pass the values to it in the template.
> 0 votes

---
Tags: add-on, templates, tags
---


# Question
Title: Purchasing ExpressionEngine and add-on licenses for a client?
Is it acceptable for me to purchase ExpressionEngine and the required add-on licenses on behalf of my clients?

For some of my clients the process of getting them to purchase the right add-ons would certainly be a tedious process.

# Answer
> 10 votes
I purchase EE and addon licenses for my clients unless they prefer to make the purchases for some reason. I keep them all in my company EllisLab and Devot-ee accounts until a client requests a transfer.

I keep them in company account for ease of use because I normally maintain the site after it's launched.

---

**Devot-ee** makes the addon license transfer process extremely easy. In the right column of the landing My Account page there is a "Transfer a license to another member" link. Click that link and you are presented with an easy interface for making the transfer.

---

**EllisLab** also allows for the transfer of ExpressionEngine licenses. First, have your customer register an account, then email sales (sales@ellislab.com) with the transfer request. Make sure to include the license number that should be transferred and your client’s ExpressionEngine.com username. Transfer can take a couple days and you'll get an email when it's complete.

# Answer
> 7 votes
That's exactly what I do. Generally the clients I have services don't even know what an add-on is, and they genuinely don't care. They just want their website to work. There are obvious drawbacks to this, like when a client leaves, or finds a new developer. Then the new developer can't download the updates since the client doesn't have the license.

Devotee allows people to transfer ownership of licenses, so I know a lot of people buy them initially and transfer once the project is finished. But this required everyone to use Devotee vs. developer sites directly.

In my mind, there is no perfect solution. Either the client is burdened with additional time and effort to purchase the license. Or the next developer to come along has to deal with the problem. Personally, I will be the problem on the dev over the client everyday of the week.

---
Tags: license, licensing
---


# Question
Title: Should error notifications work in Forum module in EE 1.6.9?
We have a legacy site running EE 1.6.9, and the Forum module 2.1.0. (Upgrading is not an option due to changes needed in dozens of templates.)

We have just noticed that when running the forum through EE templates, we are no longer getting the Post Submission validation error messages. We do get them when running just through the forum templates.

We've also tried changing the theme from our custom one, to all of the other default themes, and see the same issue.

Does anyone else remember having this issue, or know of a fix? I can't even seem to find the EE 1.x bug tracker any longer.

# Answer
This **EE forum post** may detail the solutions.

Are you saving templates as files?

Is there was a template in the site template folder called ‘forums’ or whatever you are using for your forum template name?

If there is, you should get your errors back if you remove or rename that template. It's hijacking the errors apparently.
> 1 votes

---
Tags: forum
---


# Question
Title: ExpressionEngine add javascript to CP head
I have been struggling with this for a while now and am stuck I am writing an extension for ExpressionEngine 2 (not a module) and need to add a script tag to the header of the page.

I have tried:

```
$script = "<script type='text/javascript'>alert('added');</script>";
$this->EE->cp->add_to_head($script);

```

but im guessing this only works when its a module, i have also tried (which i am pretty sure should work):

```
$this->EE->cp->load_package_js('file');

```

but i get the following error:

```
Call to a member function plugin() on a non-object in expressionengine/libraries/Cp.php on line 766

```

I have also tried using the hook `cp_js_end` which loads the file but its loaded after everything else thus it does not work as intended.

Any Ideas?

**EDIT**

After playign around with this it looks as if you can only use `$this->EE->cp->load_package_js('file');` for modules and not extensions.

I will close this issue

# Answer
Loading assets within an add-on can be tricky if you don't know how to do it properly. For instance, your code is likely failing because it's relying the CP (control panel) to serve the assets. So, if the CP class is not instantiated, your code will fail.

I suggest you take a look at Theme Loader, my open source library I use for all my add-ons. It works very well, and it will automatically make your script with RequireJS too (an added bonus of using the Theme Loader abstraction). The best part about Theme Loader, is it makes it also compatible with the Master Config boostrap, and supports changing the default place to store the add-ons. For instance, if you move your stuff above webroot, Theme Loader automatically takes care of it.

https://github.com/objectivehtml/Theme-Loader

Make sure you do the following:

1. Make sure your add-on has a directory inside of "themes/third\_party". Without this, your assets will fail to be served properly.
2. Make sure your add-on asset directly structure is correct, which should be at a minimum:
    * themes/third\_party/your\_addon
    * themes/third\_party/your\_addon/css
    * themes/third\_party/your\_addon/javascript

(Obviously if you don't need JS, don't include that directory. But this is the default structure Theme Loaders expects, so follow it and you will be good.)

Example Code

```
$this->EE->load->library('theme_loader');
$this->EE->theme_loader->module_name = 'your_module'; // Note, your addon doesn't have to be a real "module".

$this->EE->theme_loader->css('styles');
$this->EE->theme_loader->js('app');
$this->EE->theme_loader->output('alert("do something");');

```
> 7 votes

# Answer
Turns out that you cant load javascript in an extension as you would a module. The above worked fine in a module but errors are produced.

After speaking with a colleague it may be possible to do this with an Accessory hack.
> 2 votes

---
Tags: control-panel, javascript, extension
---


# Question
Title: How to separate view from `display_field` of a custom field type?
I am implementing a custom field type which has quite a complex `display_field` function. I would like to separate the view logic and at the moment I have done the following:

```
function display_field($data) {
    ob_start();
    include('view/designer.php');
    $html = ob_get_contents();
    ob_end_clean();
    return $html;
}

```

The above works, but given that ExpressionEngine is built on CodeIgnitor which has a solid MVC architecture, what is the proper way to display a view?

# Answer
> 6 votes
Yeah, that's the wrong way to go about it. You want to use the load class and use the view() method. You can even pass variables to the view that can be used programmatically.

```
public function display_field($data)
{
    $vars = array(
        'data'     => $data,
        'some_var' => 'some value',
        'some_array' => array(
            '1',
            '2',
            '3'
        ),
        'some_func' => some_func()
    );

    return $this->EE->load->view('designer', $vars, TRUE);
}

```

Reference http://ellislab.com/codeigniter/user-guide/libraries/loader.html

---
Tags: custom-fields, add-on-development, codeigniter, fieldtype
---


# Question
Title: How to redirect specifically dependent on Group ID selected
I'm new to this forum so hoping you can assist me with something that I've completely hit a dead end with.

I basically need to specify a confirmation page dependent on Group ID selected within a registration form (using the user module).

Below is a link to the thread I have already posted with the module developer but what they have recommended hasnt worked.

http://www.solspace.com/forums/viewthread/14730/#57817

I would've thought something like this would be relatively simple.

Any help would be gratefully appreciated.

Thanks Scott

# Answer
If you wanted to try the option Nicolas outlined in his reply then you could change the value of the hidden input field using some jQuery easy enough.

Take a look at this working example:

http://jsfiddle.net/Tyzsr/1/

It's still rough but should get you going down the right road I hope.
> 2 votes

---
Tags: add-on, forms, solspace-user
---


# Question
Title: Is it possible to build the URL Title of an entry from a different field than Title?
In EE the "URL Title" field is automatically built based on what you enter in the "Title" field. Is it possible — with an extension or otherwise — to build the URL Title from a different, or better yet multiple fields?

For instance, I have three fields on my publishing page: First Name, Middle Name / Initial, and Last name. I'd like the URL Title to be `firstname-middleinitial-lastname`.

is this possible?

# Answer
> 6 votes
There's plenty of addons already out there:

# Answer
> 4 votes
You can most definitely do this. Just use the channel entries API hooks. You can use a conditional to test to make sure your logic performs only for new records vs. edit. It would actually be relatively easy to do. The most time consuming part would be adding a settings pane so you could use a UI to building the URL titles on a per channel basis (for example). Alternatively, use config files to avoid writing all the UI logic. I would likely opt for the config route if I wasn't going to sell such add-on commercially.

Basically once the hook triggers, perform any conditionals required. If the conditionals pass run a simply database query to update the fields using the settings array generated from a UI or config file.

http://ellislab.com/expressionengine/user-guide/development/extension\_hooks/api/channel\_entries/index.html

---
Tags: url, dynamic, title, url-title
---