# Question
Title: Importing separate data into a single checkbox field?
Not sure what the best title for this question was, so hope it makes sense!

I am importing some data from an XML feed into EE via the add on Datagrab.

Its mostly straight forward data, so its pretty simple, but I would like to know if its possible to change the way some of it is imported.

Each entry in the XML feed has a range of "Options"

For example...

```
...
<option1>1</option1>
<option2>0</option2>
<option3>1</option3>
...

```

Whereby the value of "1" means yes and "0" means no.

I would like to import these values into a single checkbox field so it would be something like...

```
Option One [√]
Option Two [ ]
Option Three [√]

```

Does anyone know if this is possible?

It would save me quite a few custom fields if it is, and will make outputting the data/creating search forms a lot easier!

Thanks.

# Answer
> 1 votes
If you store the actual value of the import as either a 0 or a 1 then can you not place a conditional in your front-end templates to check for either of those values(?):

```
<input type="checkbox" {if field_name == "1"}checked="checked"{/if} />

```

---
Tags: import, datagrab, xml, checkbox
---


# Question
Title: Passing js file parameter in embed in ExpressionEngine
I am learning EE on the fly as I am creating our new corporate website in EE (at management's insistence) and I need to load different external js files depending on the template. I tried the approach below and the page in the browser doesn't show the variable as passing through even though the title variable comes through nicely.

Is there an error I don't see or is there a better way to do this?

I have a template named html\_head.html coded as such:

```
<!DOCTYPE html>
<!--[if IE 7]> <html lang="en" class="ie7 no-js"> <![endif]-->
<!--[if IE 8]> <html lang="en" class="ie no-js"> <![endif]-->
<!--[if !IE]><!--> <html lang="en" class="no-js"> <!--<![endif]-->

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta id="view" name="viewport" content="width=device-width, maximum-scale=1.0, minimum-scale=1.0, initial-scale=1" />
    <title>{embed:page_title}</title>

    <!-- Stylesheets -->
    <link rel="stylesheet" href="{site_url}/bootstrap/css/bootstrap.min.css" />
    <link rel="stylesheet" href="{site_url}/bootstrap/css/bootstrap-responsive.min.css" />
    <link rel="stylesheet" href="{site_url}/css/styles.min.css" />

    <!--[if lt IE 9]>
        <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->

    <script src="{site_url}/js/respond.min.js"></script>
    <script src="{site_url}/js/jquery-182.min.js"></script>
    <script src="{site_url}/js/modernizr.js"></script>
    <script src="{site_url}/bootstrap/js/bootstrap.min.js"></script>
    <script src="{site_url}/js/page_scripts/{embed:page_script}.js"></script>
</head>

<body>

```

and I am calling this from other templates as such:

```
{embed="embeds/html_head" page_title="Company Name" page_script="home"}

```

But as mentioned page\_title works but page\_script doesn't. Any help is appreciated.

Thanks in advance!

# Answer
Try these two things and see what you get.

1) Put {embed:page\_script} somewhere else in the template and see if you have the same results.

2) Create a new parameter in the embed= tag and see if get's passed through.
> 0 votes

---
Tags: templates
---


# Question
Title: Playa - use a child category to filter the channel entries of the parent?
We are still having some trouble with this. We need to display the daily deals for today from businesses that match the current category. I thought I would take one last shot at seeing if you can help. I have also broken down our objective in case I said something that confused things.

**Channel: Daily Deal**

1. Field: (Playa) Deal-Owner \[Applebees on Charles\] (selected from the list of entries in the “business-listing” channel)
2. Field: Title \[Applebees Deal\]
3. Field: Monday-deal \[example: 15% Off Senior Meals\]
4. Field: Tuesday-deal \[example: 10% Off Junior Meals\]
5. Field: Tuesday-deal \[example: 10% Off Junior Meals\]

**Channel: Business-Listing**

1. Title \[Applebees on Charles\]
2. City \[Denver\]
3. State \[CO\]
4. Status (options: Super Enhanced, Enhanced, Basic) \[Enhanced\]
5. Categories: Zone \[Central\]

The daily deal channel has a 1 to 1 playa relationship field which connects the deal to the business. The business listing has all the relevant data about the business (address, etc) The Business is classified to a “Zone” (one of 5 locations) that is used in the URL {segment\_1}.

We are attempting to view a Zone home page (segment\_1 is populated with the zone name that matches the business category name).

Phonebook.com/central

On the page, only 6 daily deals are listed. The daily deals are comprised of the deal information (corresponds with the day of the week), the business name, the business city and business state.

Example: (assuming you are viewing the page on Monday)

15% Off Senior Meals Applebees on Charles - Denver, CO

Our thinking (as shown in the code below) is: Select the daily deals that have a “Monday” deal. Of those, find the associated businesses and filter to identify only those that coincide with the zone we are viewing. Of the filtered deals/businesses, show the information about the business and the deal information – and show 6 entries on the page.

The code below is what we believe should work (assuming some of it is located in embed files, but have put it all together in hopes that it will make sense).

```
{exp:channel:entries channel="daily-deals" orderby="random" search:monday-deal="not IS_EMPTY" limit="6"}
{if monday-deal}
{exp:playa:children field="deal-owner" category="{segment_1_category_id}" status="Super Enhanced|Enhanced|Basic"}
{exp:playa:parent channel="daily-deals"}{friday-deal}{/exp:playa:parent}<br>{title} - {city},{state}
{/exp:playa:children}
{/if}
{/exp:channel:entries}

```

Unfortunately, something is not working. We have tried many variations, but something seems out of line. Either we cannot get the code to limit to 6 entries, or it returns only 3 entries (because the code picks up all deals and limits to 6, but of the 6, it includes those with no deal on Monday (or from different zones).

**\__*_*\__*_*\__*_****UPDATE****_*\__*_*\__*_*\__**

Ok - we have made some progress on this question and are using the code below.

Basically we need to filter the PARENT by the CHILD category (which in our case we would like to pull from segment\_1 using LowSeg2 addon) Is there a way to filter the parent exp:channel:entries by a child category? {segment\_1\_category\_id}

```
 {exp:channel:entries channel="daily-deals" orderby="random" search:monday-deal="not IS_EMPTY" limit="6"}
<h2>{monday-deal}<br /></h2>
{deal-owner status="Super Enhanced|Enhanced|Basic" disable="members" category="{segment_1_category_id}"}
    {if no_children} no kids {/if}
    {categories show_group="1"}category_name: {category_name}<br />{/categories}
    deal_owner: {title}
{/deal-owner}
{/exp:channel:entries}

```

# Answer
> 1 votes
```
{exp:channel:entries channel="business-listing" category="{segment_1_category_id}"}
  {exp:playa:parents channel="daily-deals" limit="6"}
    {title} ({entry_id})<br>
  {/exp:playa:parents}
{/exp:channel:entries}

```

Does this give you the right set of entries?

---
Tags: categories, playa
---


# Question
Title: Using site_id or site_name Inside Master Config Environment Files
I'm engaged in the Herculean task of configuring Focus Lab Master Config with an MSM site. I'm trying to write some conditionals based on the `site_id` variable, but I keep getting errors.

Right now I'm just running this on my local server, so inside `config/config.local.php`, at the bottom, I put:

```
if ($config['site_id'] == '1') {
    $env_config['webmaster_email'] = 'me@site-one.com';
} else {
    $env_config['webmaster_email'] = 'me@site-two.com';
}

```

But when I do this it causes the page to crash (`Error 330 (net::ERR_CONTENT_DECODING_FAILED): Unknown error.`). The problem seems to be the `site_id` variable, because if I do something like:

```
if (1 == 1) {
    $env_config['webmaster_email'] = 'me@site-one.com';
} else {
    $env_config['webmaster_email'] = 'me@site-two.com';
}

```

Then everything is fine. I tried using `$site_id` instead of `$config['site_id']`, and I tried `site_name` instead of `site_id` but it's still not responding.

Any thoughts?

# Answer
> 2 votes
Due to the order in which EE determines and sets the `site_id` config item, I would recommend that any conditions that must be on the `site_id` value be avoided and you simply have those values saved to EE's database. In this case that would mean changing the Webmaster Email value in the Control Panel.

That said, most environment conditions are in place to override what's in production. Production is "king" in most scenarios so having the `webmaster_email` value in the database without a config override is perfectly acceptable. Then in your staging, dev or local environments you can override the value with something else.

I can't think of a case where a `webmaster_email` override would be different by `site_id`. Is it possible you could take this approach?

---
Tags: multi-site-manager, focus-lab-master-config, configuration-variables
---


title: Renaming files via Assets

text:
# Question
Title: Renaming files via Assets
I'm having a really odd issue with Assets. The problem is that we don't seem to be able to rename files - right clicking gives only the delete option. We're sure this worked before, but a) we can't prove it and b) if so, I don't know before 'what'.

Have discovered that if I upload a temporary image into Assets, the right click \> rename option is available again (on the image I want to rename originally, as well as on the newly uploaded image).

If I then delete the temporary image, we're back to square one - no option to rename images, only delete.

Anyone have an idea what this might be?

Thanks, Andy.

# Answer
> 2 votes
Assets 2.0 to 2.0.5 had this intermittent bug. Updating to 2.1 should solve this issue.

(Thanks to stuartmcd69 and Andris Sevcenko for this answer)

---
Tags: pixelandtonic, assets
---


# Question
Title: Writing update queries more efficiently in EE
I've got two queries that I'm running separately in a template, one after the other, like this:

```
<?php
  $sql = "UPDATE exp_channel_titles SET status = 'Registered' WHERE channel_id = '12' AND entry_id = {entry_id} AND status != 'Hidden';";
  $this->EE->db->query($sql);
?>

<?php
  $sql = "UPDATE exp_channel_data SET field_id_119 = 'Yes' WHERE channel_id = '12' AND entry_id = {entry_id} AND field_id_119 != 'Yes';";
  $this->EE->db->query($sql);
?>

```

Can someone tell me if and how to write these more efficiently within a single PHP tag/database call please? When I tried running them one after another within a single PHP tag, they failed to work. Thanks.

# Answer
Right, you are performing two queries so you need two calls to the db (if you want to use CI). This is the only other way I could think to do reasonably do it, but it's actually more code (but not handwritten SQL).

```
$this->EE->db->where(array(
    'channel_id' => 12,
    'entry_id'   => $entry_id,
    'status !='  => 'Hidden'
));

$this->EE->db->update('channel_titles', array('status' => 'Registered'));

$this->EE->db->where(array(
    'channel_id'      => 12,
    'entry_id'        => $entry_id,
    'field_id_119 !=' => "Yes"
));

$this->EE->db->update('channel_data', array('field_id_119' => 'Yes'));

```
> 3 votes

# Answer
You can use one query instead of two using the sql JOIN:

```
$sql = "UPDATE  exp_channel_titles ct
LEFT JOIN exp_channel_data cd
ON cd.entry_id = ct.entry_id
SET ct.status = 'Registered', cd.field_id_119 = 'Yes'
WHERE ct.channel_id=12 AND cd.field_id_119 != 'Yes' AND ct.entry_id={entry_id} AND ct.status != 'Hidden'";

$this->EE->db->query($sql);

```
> 3 votes

---
Tags: database, query
---


# Question
Title: Code hints/Autocomplete - Aptana Studio/Eclipse
Working with Aptana Studio 3 (Windows & Mac). Does anyone know of a code hint bundle for EE? I know Coda has one and I like using it, but I am trying to get something that will work well for both environments, Mac/PC, for team use. Eclipse/Aptana Studio are pretty impressive, but would be great to have that for those not as familiar with commands. Would also make coding templates and add-ons quicker.

# Answer
Apparently (don't know for sure as I'm not an Aptana user) there is a command to convert Textmate bundle for use with Apatana. Commands \> Bundle Development \> Convert Textmate Bundle.

Update: It seems (based on the original poster's comment below) that this menu item is only available on the Mac version. If that option is available to you there are some good EE Textmate bundles.

This doesn't answer your question but... you could switch to Sublime Text 2, which is cross-platform, uses Textmate bundles, and has a good bundle here.
> 1 votes

---
Tags: ee2
---


# Question
Title: get_upload_preferences() is deprecated - any idea how to fix this?
I've got a custom fieldtype I need to upgrade for EE 2.5.5 - It uses the Tools model, which was deprecated in EE 2.2. Here's the code that's coughing up errors in the developer log:

> $upload\_prefs = $this-\>EE-\>tools\_model-\>get\_upload\_preferences($this-\>EE-\>session-\>userdata('group\_id')); foreach ($upload\_prefs-\>result() as $row) $upload\_dirs\[$row-\>id\] = $row-\>name;

And here's the error:

> The system has detected an add-on that is using outdated code that may stop working or cause issues with the system. What does this mean? Deprecated function get\_upload\_preferences() called in C:\Program Files\EasyPHP-12.1\www\EE\system\expressionengine\third\_party\custom\_fieldtype\ft.custom\_fieldtype.php on line 272. Deprecated since 2.2. Use File\_upload\_preferences\_model::get\_file\_upload\_preferences() instead.

I've tried replacing tools\_model-\>get\_upload\_preferences with file\_upload\_preferences\_model-\>get\_file\_upload\_preferences, but that gives us this:

> Fatal error: Call to a member function result() on a non-object in C:\Program Files\EasyPHP-12.1\www\EE\system\expressionengine\third\_party\custom\_fieldtype\ft.custom\_fieldtype.php on line 273

Any ideas how to fix this?

# Answer
> 1 votes
Again I am trying to resolve your problem :)

You should update your code like:

```
$this->EE->load->model('file_upload_preferences_model');
$upload_prefs = $this->EE->file_upload_preferences_model->get_file_upload_preferences($this->EE->session->userdata('group_id'));

/***
$upload_prefs itself an array having all the upload preferences.
***/

foreach ($upload_prefs as $row)
{
$upload_dirs[$row['id']] = $row['name'];
}

```

I hope, it would help. Plz post your further comments if it didn't work.

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


# Question
Title: Questions about the Google Maps modules and more
what are the main differences are between the Gmaps and Google Maps for ExpressionEngine modules? Anyone know? My preference is now going towards Gmaps because of the price, but I don't have a good idea of what the difference really are currently, in terms of futures etc.

In relation to the abilities of those modules:

What I want to do is have entries with a location marker field type. Those entries will then show that marker (and that marker only) in Google Maps on the front end. I'm sure that's possible, but what I'm not sure about are the other things I want to do, which are...

1) When I add a new entry with a location marker I want that location marker to be part of a "master map" also where ALL the different location markers from all the different entries are shown. Is this possible?

2) There will be different kind of location markers, for example, restaurants, hotels etc. Can I make it so that those different categories automatically use their own custom makrker type when I add them in an entry?

3) When looking at the master map, can I also filter the markers shown by showing only hotels for example (excluding the restaurants)?

I hope someone can clear those things up for me.

# Answer
> 4 votes
I am Justin from Objective HTML. Google Maps for EE is my add-on.

Gmaps can't do entry based proximity searches. Gmaps doesn't have a fieldtype, and I don't think geocode entries via the CP or Safecracker. Where as Google Maps for EE has a fieldtype, a configurable data import utility, loads of caching, all the front-end template tags you need, and very robust API which I have been used to release new add-ons like Geocoder (https://objectivehtml.com/geocoder).

Those are the biggest differences that I can think of off hand. Gmaps can do a few things out of the box Google Maps for EE can't do, but those are all JS related (which could be ported to Google Maps for EE). I focus on delivering robust features that integrate within EE, Safecracker, and Matrix, and any other module you need.

1. Yes.
2. Yes. It's best to have 1 location per entry and have all the entry data appear on the same map on the front-end.
3. Yes. You just need to use jQuery and follow my example. Don't take my example 100% literally though, which some people do and run into problems. My example is a working implementation of what you *could* do. 9/10 people want slightly different functionality and the code is different for each implementation. https://objectivehtml.com/google-maps/examples/jquery

Email support@objectivehtml.com if you have any questions.

# Answer
> 3 votes
The main difference between both modules is that Gmaps is only a Module and Google Maps for EE is a module and a fieldtype. Gmaps cannot geocode addresses in the CP, like Google Maps for EE does. Both modules gives you the ability to use front-end tags to show your maps with EE tags and use a solid cache technique.

Gmaps target on easy to use Maps, with a nice set of tags (mostly used one tag with params). With those tags you can create 'almost' all kind of maps. Beside that it comes by default with a Geocoder API (http://reinos.nl/add-ons/gmaps/docs#Geocoder\_API) and a JS API (http://reinos.nl/add-ons/gmaps/docs#Javascript\_events) and use some nice geocode technique that will geocode data from multiple services like; Google Maps, Bing Maps, Yahoo, Cloudmade, Openstreetmap, Mapquest, Yandex and Geocoder\_ca. All the address will be cached, so you don\`t have to worry about quota's and limits.

See the 50+ different examples in action (http://reinos.nl/add-ons/gmaps/examples/)

Back to your questions;

1) Yes, but you must define an address or latlng by the entry manually. You cannot select the address in the CP from the map because Gmaps has no fieldtype. (http://reinos.nl/add-ons/gmaps/examples/339)

2) Yes (Different Markers http://reinos.nl/add-ons/gmaps/examples/175 and here Complex Markers http://reinos.nl/add-ons/gmaps/examples/353)

3) Yes, (http://reinos.nl/add-ons/gmaps/examples/357).

Hope this will clear the sky.

# Answer
> 0 votes
I believe both addons will do everything you specify.

Personally I went for Google Maps for EE, based on the fact that it allows you to plot markers via a front end safecracker form. Don't think Gmaps let's you do that.

---
Tags: google-maps-for-ee
---


# Question
Title: Gathering category_id value from segment - Low Seg2cat
Not sure if I doing it wrong, my basic url goes like this

====

'site.dev/scooter' - I used {segment\_1\_category\_id} and I get the value of "8" which is correct

If my url is 'site.dev/8' and I used {segment\_1\_category\_name} and I get no results? I tried all the variables on the docs, nothing works.

The docs did not say this extension only works with category\_url\_title

====

I know I can do it with category loop with {segment\_1}, etc etc. If my url goes like this 'site.dev/scooter-unicycle' My result is 8 and 9 which is correct. This is reason why I am using Low Seg2Cat

====

This is not a duplicate, I have checked other querys.

# Answer
Low Seg2Cat only matches on the category\_url\_title. This is why your first example works and your second example inputting the category ID doesn't.

```
$this->EE->db->select('cat_url_title, '. implode(', ', array_keys($this->fields)))
                         ->from('categories')
                         ->where('site_id', $this->site_id)
                         ->where_in('cat_url_title', $segment_array);

```

I'm not sure on what you're actually trying to do though? If you have a particular problem you need to solve then someone may be able to put forward a suggestion of how to do it with Low Seg2Cat or an alternative solution.
> 1 votes

---
Tags: categories, segments, low-seg2cat
---


title: Upgrade 1.6x or ditch Expression Engine

text:
# Question
Title: Upgrade 1.6x or ditch Expression Engine
I was recommended to post my question here as it might get better answers from current developers of EE. My original post is over on EllisLab: http://ellislab.com/forums/viewthread/234789/ You can post your reply here and I will be back.

In a nutshell, I came back to EE after a long hiatus. EE looks to offer more but yet, something doesn't seem right. With a HUGE project ahead of me, should I not bother to upgrade 1.6 and go with something new like PyroCMS (based on CI by moving to Lavarel) or ProcessWire (or ????).

Basically if you had a large project that would take month and months to complete and be ever evolving, is EE a good bet?

I don't think EE will disappear overnight but I have seen CMS systems slowly fade away.

thanks! Carlos

# Answer
> 2 votes
I don't know if EE's going to fade away; I think that even now, it's difficult to find developers who can maintain the existing systems.

As to the "shag/marry/avoid" question: that all depends on way too many factors. There is no "one best CMS", there's "the CMS that's best for you." Only you can really answer that question, because only you know the project scope and outlines and your own skill level / comfort level with maintaining it / the budget of your client(s) and their needs.

# Answer
> 1 votes
You are, of course, asking a rather subjective question. One man's meat is another man's poison, etc. Having said that, it would be interesting to get a dialog going on this subject, so I will start it.

I have been using EE since the early days as well, and have built quite a few sites using both 1.x and 2.x My overall opinion of the technology and the company is that both are mediocre at best. Doesn't really suck, but neither does it shine. Having said that, I am not aware of anything that is so much better (for my needs) that I am ready to jump ship. I am currently building a site using Craft, which looks to have real promise, but it is still early days.

The platform is reasonably stable, but seems way overpriced given it's capabilities and the lack of support, unless you want to pay an additional $49 a month! There are many incredibly frustrating things that seem completely out of line for a $300 piece of software - absolutely crap WYSIWYG editor (for clients), horrid image management, hellish membership management, having to jump through hoops to create common SEO metadata, and amateurish documentation. Most of the items on the complaint list can be addressed with add-ons,but that drives up the cost considerably and you can easily end up spending $500 to $600, plus incur the burden of dealing with multiple vendors for stuff that should be part of the base application.

I won't even get into the frustration with EE's confounding template parsing issues that will have you ripping out your hair and wasting huge amounts of time.

Addressing your question - if I were in your situation I would definitely look elsewhere.

Roi

# Answer
> 1 votes
It's a subjective question but I think it's still good to have a little opinion in the forums. Naturally you'd get mostly biased answers here though. ;)

I've worked and still regularly work with many CMS' but in my honest opinion if I had a big project with a growing scope then I wouldn't even consider using another CMS. It can handle it all and allow you to architect it from day 1 to fit into your needs rather than you having to fit into the system.

EE is *very* mature and the community is thriving. Being commercial and having commercial addons is a huge advantage as it means that people's livelihoods are on the line in ensuring their addons and the system itself is always kept up to date and progressing forward. You don't get that with various other open source CMS'. Nor do you get the level of support that EE themselves offer along with that which you'll find here in the community. If you don't know the answer to something you can bet your bottom dollar someone else will and will be more than happy to offer suggestions.

I can't think of anything better to use knowing I'm working with a system that allows me to do virtually anything in the way **I** want to do it whilst having a willing community of people there to help out when I have a question or get stuck. In addition to official support for EE with a guaranteed response time and commercial addons guaranteeing a high level of quality and support you can go into each project fearless! :)

(Plus, for only $50 to upgrade what's the lose??)

---
Tags: upgrade, codeigniter
---


# Question
Title: Display entries from channel if checked on publish page
I have a page where I am allowing the client to choose which channel entries are displayed on the page, which is controlled by a field with checkboxes on the publish page.

If rides is checked, I need to display entries from the ride channel. If rides and gear is checked, I need to display entries from both.

I have never had to use checkboxes as a field before, and am unsure how to display content only if a specific checkbox is checked. The values of my checkboxes are:

Rides

Gear

Group

The name of my custom checkbox field is `choose_entries`

```
{exp:channel:entries channel="pages" limit="1" url_title="{segment_1}"}
            {if choose_entries == "Rides"}
            <h2 class="section-title">Rides<span class="green"></span></h2>
            {embed="views/.rides"}
                        <img src="content/img/bike.png" />
            {/if}
            {if choose_entries == "Gear"}
                        <h2 class="section-title">Gear<span class="orange"></span></h2>
            {embed="views/.gear"}
            {/if}
            {if choose_entries == "Groups"}
                        <h2 class="section-title">Groups<span class="blue"></span></h2>
            {embed="views/.groups"}
            {/if}
{/exp:channel:entries}

```

I'm pretty sure my conditionals are incorrect at present, I need some help getting them to work properly. Thank you!

And in case it's needed, here is an example of one of the embedded templates, but they display properly on their own.

```
{exp:channel:entries channel="rides" orderby="date" dynamic="no" sort="asc" limit="5" show_future_entries="yes"}
<article class="rides left">
<img src="{ride_img:excerpt}" alt="{title}, ${event:price}" />
<div class="content">
    <h2>{title}</h2>
    <p class="lead">${event:price}</p>
    <p>{ride_excerpt}</p>
    {if "{event:can_purchase}" == "y"}
        <p class="read-more"><a class="blue" href="{path=checkout/quantity/{event:id}}">Book now</a></p>
        {if:else}
        <p><strong>Tickets are not available</strong></p>
        {/if}
</div>
</article>
{/exp:channel:entries}

```

Note: I am using Pages and Better Pages to make use of a template across multiple pages, if that complicates matters any.

# Answer
> 3 votes
The problem in your code stems from the placement of your conditional. Because you haven't started with a channel:entries call EE has no idea what choose\_entries is. But you cant put a channel:entries call within another (nested) so you would need to do something like this.

```
{exp:channel:entries (any relevant parameters to pull the correct entry)}
  {if choose_entries == "Rides"}
    {embed="includes/.rides"}
  {/if}
  {if choose_entries == "Gear"}
    {embed="includes/.gear"}
  {/if}
  {if choose_entries == "Groups"}
    {embed="includes/.groups"}
  {/if}
{/exp:channel:entries}

```

in the embed calls if you are not familiar with them 'includes' is the template group and '.rides' is the template. I like to use a . before any template i dont want to be accessible via the web. On the embeded templates just add your chunk of specific code as above ie.

Rides
```
        {exp:channel:entries channel="rides" orderby="date" sort="asc" limit="5" show_future_entries="yes"}
                    <article class="rides left">
                        <img src="{ride_image:excerpt}" alt="{title}, ${ride_price}" />
                        <div class="content">
                                <h2>{title}</h2>
                                <p class="lead">${ride_price}</p>
                                <p>{ride_excerpt}</p>
                                <p class="read-more"><a class="blue" href="/san-diego">Learn more about this ride »</a></p>
                        </div>
                    </article>
        {/exp:channel:entries}
                    <img src="content/img/bike.png" />

```

Hope that makes sense. There is at least one other way you could do this by passing info to a single embedded template but this way is the easiest to explain.

---
Tags: channel-entries, custom-fields, checkbox
---


# Question
Title: title_permalink is showing entry number instead of url_title
Never seen this before so I'm guessing it will probably be something small I missed. I have a title\_permalink that is generating a url with the entry\_id at the end instead of the url\_title. The enewsletter\_articles tag is a Playa field...

The generated url is **site.com/enewsletter/article/255** it should be **site.com/enewseltter/article/article-url-title**

```
{exp:channel:entries channel='enewsletter_issue' disable='categories|member_data|pagination' limit="1" dynamic="no" sort="asc"}
    <h4>{title}</h4>
    {enewsletter_articles}
        <h2>{title}</h2>
        {summary}
        <a href="{permalink=enewsletter/article}">» Read More</a>
    {/enewsletter_articles}
{/exp:channel:entries}

```

# Answer
You are using {permalink=enewsletter/article} in your code.

http://ellislab.com/expressionengine/user-guide/modules/channel/channel\_entries.html#permalink

That will return an id

What you want is {title\_permalink="enewsletter/article"}
> 3 votes

---
Tags: playa, url, url-title
---


title: Order Confirmation page

text:
# Question
Title: Order Confirmation page
I have an Exp:resso store setup based off of the example templates bundled with the software. I'm using Stripe.com as my payment gateway, in test mode.

### Problem:

After submitting a payment, checkout page 3 returns to itself without proceeding to the return="shop/order/ORDER\_HASH".

This is the response that I see in my Stripe control panel.

`The site is available at: http://74.52.63.240/shop/product/alessandra` (sorry, stackexchange won't link to an IP address)

There is an SSL cert installed for https://taliahancock.com. For testing purposes, I have my hosts file set to 74.52.63.240 taliahancock.com.

Help is much appreciated. This is my first time using both Exp:resso store and Stripe.

# Answer
To submit the order, your "Place Order" button needs to have `name="submit"` attached to it. This is so that Store can distinguish it from simply an "Update Totals" button, or a "Next Step" button. Currently it's being treated as an "Update Totals" button.

For example, in your checkout template, change:

```
<button id="checkout_submit">Place Order</button>

```

to:

```
<button id="checkout_submit" name="submit">Place Order</button>

```

or alternatively:

```
<input type="submit" id="checkout_submit" name="submit" value="Place Order" />

```

Documentation here: https://exp-resso.com/docs/store/checkout\_tag.html#submitting\_orders
> 1 votes

---
Tags: expresso-store
---


title: 'Fuzzy' conditionals

text:
# Question
Title: 'Fuzzy' conditionals
feeling little dumb for this.

What I am trying to do is to make my list of checkboxes checked depending on {segment\_5}

If the value is '6', that is easy with

```
<input type="checkbox" name="categories[]" value="{category_id}" {if '{segment_5}' == '{category_id}'}checked='checked'{/if} /> {category_name}

```

I am in a situation where my url goes like this 'site.dev/search/geo/n31lj/6-7' from doing a search.
Look at {segment\_5}, the value is '6-7', multiple categories have been selected.

How can I tell the {category\_id} to pick up 6 or 7 inside the {segment\_5} with conditionals?

Look at this link, I have tried but it not possible.
http://ellislab.com/expressionengine/user-guide/templates/globals/conditionals.html#comment\_box\_9433

# Answer
== EDIT ==

```
{exp:stash:set name="numbers" parse_tags="yes"}
    {exp:low_replace find="-" replace="|"}{segment_4}{/exp:low_replace}
{/exp:stash:set}

{exp:channel:categories channel="items" category_group="3"}
    <input type="checkbox" name="categories[]" value="{category_id}" {exp:loopee foreach="{exp:stash:numbers}" parse="inward"}{if category_id == {loopee_value}}checked='checked'{/if}{/exp:loopee} /> {category_name}<br />
{/exp:channel:categories}

```

This does exactly the job I wanted to do. Converting any segment with values like `5-19-11` into individual values to be checked with a conditional in order to make a checkbox checked

Plugins required
**Stash
Low replace
Loopee**
> 1 votes

# Answer
There are a several ways really. You could use regular PHP:

```
$categories = "{segment_5}";

$category = explode("-", $categories);

echo "category 1 = $category[0]"; // 5
echo "Category 2 = $category[1]"; // 6

```

But beware of parse order when integrating with PHP tags.

Alternative you could always have some string fun. You can take advantage of the full array of PHP string functions such as explode() and split the URL segment by the dash creating an array values (5 and 6 in your case).

```
{exp:phpstringfun function="explode" par1="-" separator="|" reverse="y"}
    {segment_5}
{/exp:phpstringfun}

```

Because segment variables are parsed very early in the rendering of the template this should work fine. I'm exploding segment 5 of the URL by the dash (-) and then replacing it with a pipe (|) character. You could then use that in your query to test for either 5 OR 6 by wrapping that in a Stash variable to call later on in your condtional:

```
{exp:stash:set name="categories" parse_tags="yes"}
    {exp:phpstringfun function="explode" par1="-" separator="|" reverse="y"}{segment_5}{/exp:phpstringfun}
{/exp:stash:set}

{if segment_5 == '{exp:stash:categories}'}
    checked='checked'
{/if}

```

That will mark it as checked if `segment_5 == '5|6'`, if that's what you want. Once you have it broken up though you can handle it in many ways.
> 2 votes

---
Tags: categories, conditionals, segments, advanced-conditionals
---


title: Playa php errors after upgrade to 4.4.1

text:
# Question
Title: Playa php errors after upgrade to 4.4.1
I upgraded to the latest version of playa (unsucessfully with Upgrader then manuallly). The module and field type are showing as 4.4.1 ok but I am getting php errors on all pages that contain playa fileds:

```
Error Number: 1054

Unknown column 'rel.parent_is_draft' in 'where clause'

SELECT DISTINCT(rel.child_entry_id) AS entry_id FROM exp_playa_relationships
rel WHERE rel.parent_entry_id = 5416 AND rel.parent_is_draft = 0 AND
rel.parent_field_id = 188 ORDER BY rel.rel_order

```

# Answer
Did you follow the upgrade instructions and go to the license key setting page? (http://pixelandtonic.com/playa/docs/updating)
> 2 votes

# Answer
Upgrader may have failed, but it most likely modified a few things in the database making the manual update not right.

I'd try a few things.

1) Re-import database backup from prior to the failed Upgrader attempt.

if you don't have the backup... 2) Backup now, and uninstall Playa module (not extension), then reinstall the module.

if that didn't work... 3) Contact Playa official support at http://pixelandtonic.com/support
> 0 votes

---
Tags: playa
---


# Question
Title: Auto assign old entries to parent category
A client wants to clean up their messy categories, but when assigning the categories to parent categories, the entries don't update. So when I want to output a list of all entries in a parent category, I might get no results if the entries wasn't originally categorized with the parent category...

I realize there's an answer here: Automatically assign parent category to sub-category entries?

But that PHP-code does nothing for my entries, they're still only categorized with their original categories (which are now child-categories). Anybody got another PHP-code or an SQL-query to help me out?

# Answer
I got a similar code-snippet as the one referred to in my question from Kevin at Ellislab. I couldn't get that one to work initially eiher, but after pruning the code, taking away some ' and " it worked perfectly. Here's the code that worked for me: cdpn.io/DAHeg
> 1 votes

---
Tags: categories
---


# Question
Title: Safecracker entries not showing in front end
Pretty new to EE, I am creating a site similar to desert island discs - but for crisps for a friend and as part of my uni assignment.

I'm using EE 2.5 and Safecracker 2.1. I have created the safecracker form based on this tutorial by Ryan White http://www.venveo.com/articles/view/understanding-safecracker-for-expressionengine.

Now the form works a charm from the front end. This is the setup:user\_entries. Status group with status Pending created and assigned to the group. In members I have created an annonymous user and assigned access to the above channel to publish from front end (status still pending). This is all good.

I have a template group called entries and inside this I have the user\_entries template where the form code resides. I also have a confirmation template to redirect users upo successful submission.

Now every time I test this, an entry is created - but in the pages section, which is fine. I can go there publish the page and all is good. What I can't figure out is how do I output all the new entries (after status change to Open) on the front end to another page called say Previous entries or similar.

Here is my code for the Safecracker form:

```
{embed="includes/html_head"}
<body>

<!-- Super Container for entire site -->
{embed="includes/masthead"}
<!-- Super Container -->
<div class="super-container full-width">

    <!-- 960 Container -->
    <div class="container">

        <!-- CONTENT -->
        <div class="eleven columns content">
        <h2 class="title"><span>Submit your 8 choices!</span></h2>

<!--============SAFECRACKER STUFF GOES RIGHT HERE=============-->
                    {exp:safecracker
  channel="user_entries"
  return="entries/confirmation"
  include_jquery="no"
  logged_out_member_id="2"
  rules:your_name="required"
  rules:choice_number_1="required"
  rules:choice_number_2="required"
  rules:choice_number_3="required"
  rules:choice_number_4="required"
  rules:choice_number_5="required"
  rules:choice_number_6="required"
  rules:choice_number_7="required"
  rules:choice_number_8="required"
  rules:title="required"
}
<br class="clearfix" />
            <hr />

<h3 class="feature">
    <label><strong>First please tell us your name</strong></label>
    <input type="text" class="text" name="your_name" value="{your_name}"/>
  </h3>
 <br class="clearfix" />
            <hr />
<h3 class="feature">
    <label><strong>Give your choice a memorable name</strong></label>
    <input type="text" class="text" name="title" value="{title}"/>
  </h3>

<fieldset class="five columns alpha aside">

  <!--Choice one code-->
  <h5>
    <label><strong>Choice number 1</strong></label>
    <input type="text" class="text" name="choice_number_1"/>
  </h5>
  <p>
    <label>Choice 1 description</label>
    <input type="text" class="text" name="choice_1_description"/>
  </p>
<br />
    <label>Choice 1 image</label>
    <input type="file" class="" name="choice_1_image" />
</fieldset>

<!--====Choice twocode-->
<fieldset class="five columns omega aside">
  <h5>
    <label><strong>Choice number 2</strong></label>
    <input type="text" class="text" name="choice_number_2"/>
  </h5>
  <p>
    <label>Choice 2 description</label>
    <input type="text" class="text" name="choice_2_description"/>
  </p>
  <br />
    <label>Choice 2 image</label>
    <input type="file" class="button green" name="choice_2_image"/>

  </fieldset>

<!--===============Choice three code-->
<fieldset class="five columns alpha aside">

<h5>
    <label><strong>Choice number 3</strong></label>
    <input type="text" class="text" name="choice_number_3"/>
  </h5>
  <p>
    <label>Choice 3 description</label>
    <input type="text" class="text" name="choice_3_description"/>
  </p>
<br />
    <label>Choice 3 image</label>
    <input type="file" class="button green" name="choice_3_image"/>

</fieldset>

<!--====Choice four code-->
<fieldset class="five columns omega aside">
  <h5>
    <label><strong>Choice number 4</strong></label>
    <input type="text" class="text" name="choice_number_4"/>
  </h5>
  <p>
    <label>Choice 4 description</label>
    <input type="text" class="text" name="choice_4_description"/>
  </p>
<br />
    <label>Choice 4 image</label>
    <input type="file" class="button green" name="choice_4_image"/>
  </fieldset>

<!--===============Choice five code-->
<fieldset class="five columns alpha aside">

<h5>
    <label><strong>Choice number 5</strong></label>
    <input type="text" class="text" name="choice_number_5"/>
  </h5>
  <p>
    <label>Choice 5 description</label>
    <input type="text" class="text" name="choice_5_description"/>
  </p>
<br />
    <label>Choice 5 image</label>
    <input type="file" class="button green" name="choice_5_image"/>
</fieldset>

<!--====Choice six code-->
<fieldset class="five columns omega aside">
  <h5>
    <label><strong>Choice number 6</strong></label>
    <input type="text" class="text" name="choice_number_6"/>
  </h5>
  <p>
    <label>Choice 6 description</label>
    <input type="text" class="text" name="choice_6_description"/>
  </p>
<br />
    <label>Choice 6 image</label>
    <input type="file" class="button green" name="choice_6_image"/>
  </fieldset>

<!--===============Choice seven code-->
<fieldset class="five columns alpha aside">

<h5>
    <label><strong>Choice number 7</strong></label>
    <input type="text" class="text" name="choice_number_7"/>
  </h5>
  <p>
    <label>Choice 7 description</label>
    <input type="text" class="text" name="choice_7_description"/>
  </p>
<br />
    <label>Choice 7 image</label>
    <input type="file" class="button green" name="choice_7_image"/>
</fieldset>

<!--====Choice eight code-->
<fieldset class="five columns omega aside">
  <h5>
    <label><strong>Choice number 8</strong></label>
    <input type="text" class="text" name="choice_number_8"/>
  </h5>
  <p>
    <label>Choice 8 description</label>
    <input type="text" class="text" name="choice_8_description"/>
  </p>
<br />
    <label>Have an image for Choice 8 image?</label>
    <input type="file" class="button green" name="choice_8_image"/>
  </fieldset>
<!==============End the fieldsets here for the 8 choices-->
<br class="clearfix" />
            <hr />
  <p>
  <input type="submit" class="button yellow" value="Submit your choices now!" />
</p>
   <br class="clear" />
{/exp:safecracker}

            <br class="clearfix" />
            <hr />

        </div>
        <!-- /CONTENT -->

        <!-- SIDEBAR -->
        <div class="five columns sidebar">

            {embed="includes/sidebar"}      <!-- /SIDEBAR -->

    </div>
    <!-- /End 960 Container -->

</div>
<!-- /End Super Container -->

<!-- ============================================== -->

{footer}
<!-- End Document
================================================== -->
</body>
</html>

```

I shall be eternally grateful to any body who can help me with this issue. Please remember I'm new to EE so go gentle.

Many thanks

Ilir

```
{exp:channel:entries channel="user_entries" limit="8" status="pending|open"}
  <h4 class="title">
    <span>
      This is the choice {title} made by {your_name} on {entry_date format="%F %d, %Y"}
    </span>
  </h4>
  <ol>
    <li class={first|second|third|fourth|fifth|sixth|seventh|last}>
      <h5>{choice_number_1}</h5>
      <p class="align-left">{choice_1_description}</p>
      <img class="align-left" src="{choice_1_image}"/>
    </li>
  </ol>
{/exp:channel:entries}

```

# Answer
> 1 votes
Try adding `dynamic="no"`and see if that changes things.

`{exp:channel:entries channel="user_entries" limit="8" status="pending|open" dynamic="no"}Entry Title: {title}
Entry ID: {entry_id}
Choice 1 Description: {choice_1_description}

{/exp:channel:entries}`

---
Tags: safecracker, entries
---


# Question
Title: Is there a way to filter Playa relationship in {exp:gmap:results}?
One of the "filters" so to speak on my gmap search is a playa field. Is there a way to filter my results by that relationship? I tried running the `{exp:playa:parents}` loop inside the `{results}` but naturally, it is a double loop. If on the search form, I only want parents of entry\_id 1, how would I go about that? The data is in the post var, but I need to get the playa parents loop combined with the results loop - else I'll tear in to PHP.

# Answer
> 1 votes
While it wasn't as clean of a solution as I wanted, I ended up using categories rather than a Playa relationship. Does the trick, but now I have a category group acting as a channel.

---
Tags: add-on, playa, google-maps-for-ee
---


# Question
Title: Safecracker: get constants in javascript
I'm working on a fieldtype with a lot of javascript and I use the following to get EE constants in the js:

```
$this->EE->javascript->set_global(array('THIRD_PARTY_THEME_URL' => URL_THIRD_THEMES));

```

This works well in the Control Panel, but not in Safecracker, which seems to reset all the EE js object.

Any idea how I can pass those kind of constants?

# Answer
> 1 votes
Not sure how to answer your specific questions, but I would use my Theme\_loader class. It makes life really easy when it comes to loading JS and CSS assets within your module, and it works in Safecracker too. I typically like to extract all these type of components into stand-alone libraries to make code maintenance easier.

Once upon a time, EE didn't have those variables available so when they were released that caused a lot of code to be incompatible (or in need of upgrade). If devs would use an abstraction like this, they would have just only had to update 1 library for all their add-ons.

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

---
Tags: safecracker, add-on-development, javascript, fieldtype
---


title: Conditional Tags Based on EE Tag Value?

text:
# Question
Title: Conditional Tags Based on EE Tag Value?
I am coding a plugin for our company's stock price. I am determining growth as such:

```
public function __construct(){
   $this->EE =& get_instance();
   $fp = fopen ("http://finance.yahoo.com/d/quotes.csv?s=EDR&f=sl1c1pohgv&e=.csv","r");
   $retData = fgetcsv ($fp, 1000, ",");
   $this->return_data = round($retData[2]/$retData[3]*100,2);
}

```

where $retData\[2\] is "change" and $retData\[3\] is "previous close."

My returned data is something like -0.19% which I can output in a template using {exp:edrstock}%.

Now the question: I need to create a conditional set of if/else tags so that if the number is negative I output it in a div with a class of "negStock" or if it is even, I output it in a div with a class of "evenStock" and if it is positive, I output it in a div with a class of "posStock."

By the way, the class will determine what color the text is and whether or not it appears in the header (positive) or the footer (even or negative).

I would appreciate any guidance as I am teaching myself EE from a book and would like to learn this the right way.

Thanks in advance, Jon

# Answer
You should create a tag pair:

```
$variables = array(
  'change' => $retData[2],
  'previous_close' => $retData[3],
  'percentage' => round($retData[2]/$retData[3]*100,2),
);
$this->return_data = $this->EE->TMPL->parse_variables_row($this->EE->TMPL->tagdata, $variables);

```

And then you could do this (AND you'd have access to these other variables, should you need them):

```
{exp:edrstock}
{if percentage >= 0}
  <span class="posStock">{percentage}%</span> (+${change})
{if:else}
  <span class="negStock">{percentage}%</span> (-${change})
{/if}
{/exp:edrstock}

```
> 1 votes

---
Tags: templates, plugin
---


# Question
Title: Pagination using the Query Module or Active Record Plugin
I have a custom table exp\_jobs which I am querying. I have used {exp:query} and have also been trying out http://devot-ee.com/add-ons/activerecord ...

Having 1 issue which I think could be solved a few ways. The issue is when you page through the results page 2 I lose the value I am search for. So if I have search form and I do a post I get: http://website.com/jobs?keyword=medical&job\_state=AL

Works fine.

Going to page 2 and I the query string is gone, which I expect. I need to be able to alter the paging links however the {pagination\_links} pair doesn't work for exp:query even though the docs say:

```
The pagination in the Query module works exactly like the Channel and Comment Pagination with only one exception. Instead of using a LIMIT clause in your query, use the limit=”“ parameter to specify how many results to display per page, and ExpressionEngine will automatically modify your query to display the appropriate results.

```

Somehow I need to override the standard pagination to include the query string, any thoughts on how I can do that or plugin I may have overlooked. Tried a bunch.

I also looked at cookies and sessions but not getting consistent results. I may just need to write my own plugin here to handle this if all else fails.

Thank you!

UPDATE: April 20, 2013

I ended up using jQuery to append the URL based on an earlier recommendation from Rob

```
<script type="text/javascript">
var querystring = '{querystring}';

$('#paging a').each(function()
{
 var href = $(this).attr('href');
 href += (href.match(/\?/) ? '&' : '?') + querystring;
 $(this).attr('href', href);
});
</script>

```

# Answer
> 1 votes
Take a look at the channel\_module\_create\_pagination hook. Don't be fooled by the name, it doesn't just work with the channel module.

I've also had success using Low Replace wrapped around pagination tags to manipulate pagination URLs. This might not be easy, though.

---
Tags: pagination, query, querystring
---


title: EE "Assets" not recognizing FLV file

text:
# Question
Title: EE "Assets" not recognizing FLV file
I've installed P&T "Assets", set up an upload directory "/videos", added 4 files to it, and had Assets "index" that folder: http://d.pr/i/kG39

Assets ignores the .flv file but finds, or I presume "indexes" the other 3: http://d.pr/i/UCSw

I'm able to add meta data as expected.

How can I make Assets recognize the .flv file? What about other kinds of files?

Cheers,

-Brandon

# Answer
If you look in system/expressionengine/config/mimes.php, is 'flv' in that list? If not, try adding:

```
'flv'  =>  'video/x-flv',

```
> 5 votes

---
Tags: ee2, assets, pixelandtonic
---


# Question
Title: Categories work on dev server but not live server
We've just moved a site from the dev server to the live server and everything seems to be fine. However, the categories filtering on the blog doesn't seem to be working.

The URLs generated are:

```
/blog/category/recipes

```

The sidebar code for the categories is:

```
<h3>Categories</h3>
<ul>
  {exp:channel:categories channel="blog" style="linear"}
  <li><a href="{path='blog/index'}">{category_name}</a></li>
  {/exp:channel:categories}
</ul>

```

The stripped down channel entries tag for "blog/index" is:

```
{exp:channel:entries channel="blog" orderby="entry_date" sort="desc" limit="5"}
{if no_results}No results{/if}
<section class="blog-overview">
    <h2>{title}</h2>
    <div class="extract-text">
      {blog_main_content:excerpt}
    </div>
  <p class="publish-date">Published on {entry_date format="%l %j %F %Y"}</p>
</section>
{/exp:channel:entries}

```

What could I have missed during the site move? Where should I start looking to troubleshoot this?

Thanks for any advice

EE2.5.5

**EDIT:** Archives seems to be filtering though:

```
/blog/archives/2013/04

{exp:channel:month_links channel="blog" limit="12"}
    <li><a href="{path='blog/archives'}">{month} {year}</a></li>
{/exp:channel:month_links}

```

# Answer
The issue was caused by a misconfiguration of the Freebie extension.

The `Break on category URL indicator` had been set to "Yes" which meant that Freebie was overwriting EE's native functionality for processing `/channel/category/category-name`
> 1 votes

---
Tags: ee2, categories
---


# Question
Title: Cartthrob Show Conditional Text/HTML Code Based on Coupon Code?
Is it possible to show conditional HTML code or text based on the coupon code that has been entered?

This works fine if there is a coupon code:

```
{exp:cartthrob:coupon_info}
<div class="helper">"{coupon_code}" has been applied  <span class="label"><a href="{path=store/clear_coupon_codes}">remove coupon code?</a></span></div>
{/exp:cartthrob:coupon_info}

```

But say I want to add a class to an item or change some text:

No coupon code:

```
<ul>
<li>Subtotal {exp:cartthrob:cart_subtotal}</li>
<li>Shipping {exp:cartthrob:cart_shipping}</li>
<li>Discount {exp:cartthrob:cart_discount}</li>
<li>Total {exp:cartthrob:cart_total}</li>
</ul>

```

Coupon code == cash:

```
<ul>
<li>Subtotal {exp:cartthrob:cart_subtotal}</li>
<li>Discount {exp:cartthrob:cart_discount}</li>
<li class="cash">Cash {exp:cartthrob:cart_total}</li>
</ul>

```

I've tried a few things and can get them to work when there is a coupon code but not when the coupon code if empty.

# Answer
> 1 votes
Because the `{coupon_code}` can only be returned inside of the `{exp:cartthrob:coupon_info}` tags, we'll need to Stash that variable for use later on outside of the tags (unless you want to wrap everything in those tags).

So, install Stash and then try this:

```
{exp:stash:set name="coupon_used"}
    {exp:cartthrob:coupon_info}
        {coupon_code}
    {/exp:cartthrob:coupon_info}
{/exp:stash:set}

{!-- No Coupon Used (Default) --}
<ul>
    <li>Subtotal {exp:cartthrob:cart_subtotal}</li>
    <li>Shipping {exp:cartthrob:cart_shipping}</li>
    <li>Discount {exp:cartthrob:cart_discount}</li>
    <li>Total {exp:cartthrob:cart_total}</li>
</ul>

{!-- Coupon code == 'cash' --}
{if {exp:stash:coupon_used} == 'cash'}
    <ul>
        <li>Subtotal {exp:cartthrob:cart_subtotal}</li>
        <li>Discount {exp:cartthrob:cart_discount}</li>
        <li class="cash">Cash {exp:cartthrob:cart_total}</li>
    </ul>
{/if}

```

So here we're running the cartthrob tags once and stashing the value of the coupon code for use later on in the template. Then we're running a conditional check on that stashed variable to see if it returns true. If it does then we display the conditional content. All without using any PHP in templates.

Does that work for you?

---
Tags: ee2, cartthrob
---


title: GWCode Categories displays nothing

text:
# Question
Title: GWCode Categories displays nothing
I can't get a simple GWCode Categories tag to display anything.

```
{exp:gwcode_categories channel="general_areas"}
{cat_name}
{/exp:gwcode_categories}

```

But this displays the list just fine:

```
{exp:channel:categories
    channel="general_areas"
    style="nested"
}
{category_name}
{/exp:channel:categories}

```

I'm stumped.

# Answer
> 1 votes
Finally got it working. This is an MSM setup and it seems you must provide a site id to the tag.

---
Tags: gwcode-categories
---


# Question
Title: How can I increase the number of custom Order Fields in Expresso Store?
How can I increase the number of custom Order Fields in Expresso Store? There are 9 by default but I need more.

Thanks! Lee

# Answer
> 3 votes
There's no natively supported way to add new custom order fields. I know they were increased from 5 to 9 to provide more flexibility but I'm not sure anyone has got to the point of needing more than 9 yet. Is there no way some of those fields can be combined? What are you storing?

If you *did* want to add more than you would have to modify the Store module itself but obviously that wouldn't be supported and you'd have problems with future updates. If you desperately needed to do this then:

**1)** Add the required extra columns to the exp\_store\_orders table in the database

**2)** Open up Store \> Libraries \> store\_cart.php and append the new custom order fields to the array on or around line 326 like so:

```
// update order details fields
foreach (array( '..., 'order_custom7', 'order_custom8', 'order_custom9', 'order_custom10', 'order_custom11' ...) as $field_name)
{
    ...
}

```

**3)** Open up Store \> Libraries \> store\_config.php and append the new custom order fields to the array on or around line 156 like so:

```
public function get_order_fields($get_defaults = FALSE)
{
    $order_fields = array(
        ...
        'order_custom7' => array('title' => '', 'member_field' => ''),
        'order_custom8' => array('title' => '', 'member_field' => ''),
        'order_custom9' => array('title' => '', 'member_field' => ''),
        'order_custom10' => array('title' => '', 'member_field' => ''),
        'order_custom11' => array('title' => '', 'member_field' => ''),
    );
}

```

**4)** Open up Store \> models \> store\_orders\_model.php on or around line 538 and append the new custom order fields like so:

```
foreach (array( ... 'order_custom7', 'order_custom8', 'order_custom9', 'order_custom10', 'order_custom11',
        ...) as $field_name)
{
    ...
}

```

This should be everything you need to get Store to register those new fields. But like I said, it's not supported.

# Answer
> 0 votes
Ian hit the nail on the head with regard to adding this yourself. It's not much work to add the extra columns to the database, and your data will not be deleted during any future updates.

I agree this would be a nice feature to have, there just hasn't been much demand for it (especially once we increased the fixed limit from 5 to 9) so other features have taken priority.

I've added it to the feature requests page for you so we can gauge interest in it.

---
Tags: expresso-store
---


title: templates vs. themes

text:
# Question
Title: templates vs. themes
What's the difference between "templates" (default location `system/expressionengine/templates/default_site/`) and "themes" (default location `themes/`)?

I'm curious particularly for a single site setup.

I want to manage my templates as files (for my editor + git) and by default it set me up with the templates folder, but it looks like the themes folder which came with a nice `site_themes/agile_records` example is the same thing? Should I point my `Template File Directory` setting to `themes/`?

# Answer
**Templates** are the templates that you make with the ExpressionEngine tags, html etc.

**Themes** are used by the system to display the control panel, field types etc. (also, as NateTronn mentions, there are/is some example code for the example site "Agile Records" that is shipped with EE)

Generally the system directory is not publicly accessible, the themes directory is. The themes directory also holds the javascript and css files for third-party addons.
> 1 votes

# Answer
I think it's fair to say that themes should be looked at as examples and nothing more. I also think most people start off EE sites without installing a theme and also most people I know delete Agile Records from their installs from the get go.

ExpressionEngine really makes no assumption about what you want to build for the most part.

With that said, there are a few ways to handle templates. You can turn on the save templates as file feature. More about that can be found here.

You can use a product like Mountee which I won't go into detail here because they have a full site of details. Basically, however, it mounts your templates folder so you can access it via your favorite editor.

You can use something like EE Master Config to setup templates as files using Config Overrides so you don't have to turn on each template as a file. This also has config overrides for moving the default location of the template folder as well. This of course is the more advanced of the three options I listed.

There really is no reason to ever have to edit a template in the control panel these days.
> 5 votes

---
Tags: templates, themes
---


title: Wrong date being parsed

text:
# Question
Title: Wrong date being parsed
I am using ajw feedparser to output a feed from Songkick. It has been working correctly up until recently but now the date is showing as a day earlier than it should eg. 15th April instead of 16th. Any suggestions would be much appreciated! (The feedparser plugin support forum is pretty dead!)

```
{exp:ajw_feedparser
url="http://api.songkick.com/api/3.0/artists/304376/calendar.xml?apikey=2bpAQkQkQ3wYFukP"
itempath="/resultsPage/results/event"
         cache_refresh="60"
         limit="3"}
    <h5>{start@date format='%M %j %Y'}   <a href="{@uri}">
{if series@displayName}{series@displayName}, {/if}
{if venue@displayName}{venue@displayName}{/if}</a></h5>
      {/exp:ajw_feedparser}

```

# Answer
A weird thing has happened and the date has resolved itself again without any changes on my part. Makes me think it was a songkick issue that has now been resolved!
> 0 votes

---
Tags: plugin, rss
---


title: Random String Returned on Plugin

text:
# Question
Title: Random String Returned on Plugin
I have a simple plugin that runs a query and returns a single value.

```
{exp:company_id id='{segment_3}'}

```

This outputs a number such as 5081

If I do this:

```
{preload_replace:cid="{exp:company_id id='{segment_3}'}"}

{cid}

```

It works as well.

If I drop either {cid} or {exp:company\_id id='{segment\_3}'} into a query

```
    {exp:query sql="select field_id_10 as facebook, field_id_11 as twitter, field_id_13 as linkedin, field_id_15 as youtube from exp_channel_data where field_id_4 = '{exp:company_id id='{segment_3}'}'" parse="inward"}

```

Either using parse inward or not ... or using the preload or plugin the value in debugging shows : M00o93H7pQ09L8X1t49cHY01Z5j4TT91fGfr

I am a bit stumped at this point. Any pointers would be much appreciated.

Updated:

Taking Advice Below I got this to work both ways: {exp:company\_id id="123456"}{/exp:company\_id} and {exp:company\_id}{segment\_3}{/exp:company\_id}

```
var $return_data;

function company_id()
{
    $this->EE =& get_instance();
    $tagdata = $this->EE->TMPL->tagdata;
    $id = ($this->EE->TMPL->fetch_param('id')) ? $this->EE->TMPL->fetch_param('id') : $this->EE->TMPL->tagdata ;

    $id = $this->_get_id($id);
    $this->return_data = $id;
}

function _get_id($id)
{
    // Query
    $this->results = $this->EE->db->query('SELECT company_id FROM '.$this->EE->db->dbprefix('jobs').' WHERE job_id = '.$id.' LIMIT 1');

    if($this->results->num_rows() == 0) :
        if($this->errors == 'false') :
            return null;
        else :
            return null;
        endif;
    else :
        return $this->results->row('company_id');
    endif;
}

```

# Answer
> 5 votes
There are a few possible solutions available here:

## 1. Global variable approach

Amend your plugin so that it sets a global variable instead of/as well as returning the value directly. This ensures that it is parsed very early so you can use it as {cid} in tag parameters. You can set a global EE variable like this in your plugin:

```
$this->EE->config->_global_vars['cid'] = 123;

```

You'd still need to call the plugin once in a template for the variable to be set. If you'd rather keep it clean and not do that you'd simply need to make it into an extension instead, probably using the `sessions_end` or `template_fetch_template` hooks.

## 2. Tag pair approach

You could amend your plugin to work as a tag pair so that you can wrap it around any other EE tags and therefore get the parse order right.

Eg:

```
public function __construct() {
  $this->EE =& get_instance();
  $tagdata = $this->EE->TMPL->tagdata;
  $id = $this->EE->TMPL->fetch_param('id');

  $vars[0] = array('cid' => 123);

  $tagdata = $this->EE->TMPL->parse_variables($tagdata, $vars);
  return $tagdata;
}

```

You would then use the plugin as a tag pair and {cid} would be available on the inside.

## 3. Create a new plugin method

If you're comfortable making a plugin to do the job of fetching the company id, it seems odd to use the query module for this when you could just combine your methods together into a single plugin, so you'd have `{exp:your_site:company_id}` and `{exp:your_site:company_social_links}`

## 4. Use the channel:entries search parameter combined with one of the above

If you take the first or second approaches numbered above, could you not use a simple channel:entries tag with the `search` parameter instead of a query tag? Eg:

```
{exp:channel:entries search:cf_company_id="={cid}" ...}
   {cf_twitter}|{cf_facebook} etc
{/exp:channel:entries}

```

This wouldn't perform as well as the query module but is a bit cleaner and less fiddly.

## 5. Stash

Stash is an answer for everything these days, and there's probably a way you could do some template gymnastics to make it work in pretty much the same way you're attempting to with the preload\_replace. The complexity would probably outweigh the benefit however.

## Security

I should also point out that (whilst I don't know exactly what you're aiming for), you need to be quite careful from a security point of view that you don't allow users to hack your urls, since you're directly passing segment\_3 into your plugin. Without the proper precautions this could allow people to view other companies' data by changing numbers in the urls.

# Answer
> 0 votes
Use Active Record instead and it will likely work, as well as being somewhat safer.

---
Tags: custom-fields, plugin, preload-replace
---


title: Assign Matrix field entry in Playa

text:
# Question
Title: Assign Matrix field entry in Playa
I've been using Matrix for quite a long time and yesterday I bought Playa because I thought that it can do what I need.

I have a channel "Movies" and a channel "People". I made a Matrix field for the People channel with the column "Names" because some people have alias names. I made a a Matrix field for "Movies" with the columns "Name" and "Role". Name is a Playa field and I thought it's possible to make a setting that I can chose that I can select from the "People" matrix name Field.

So what I need in publish for the movies is a field where I can select a person (entry) from the people channel and then one of this persons alias.

John Doe (this is a entry) \- David (this is a alias) \- Steven (this is a alias)

# Answer
Unfortunately Playa can only create relationships between entries, not individual fields. If you have the development skills, this would be a good candidate for a custom fieldtype if it doesn't already exist. (You could use moreMatrixRelations as a starting point for your own matrix-compatible field).

Alternatively, you could store all the alias names as entries (either in the People channel or in a new channel) and then use Playa to relate the aliases to the people and a pair of Playa fields nested in Matrix columns to choose both the person and his alias in the Movies entries. This could get quite unwieldy however, and performance would probably become an issue if a Matrix grows much beyond a dozen rows.
> 1 votes

---
Tags: matrix, playa
---


# Question
Title: Limiting GWcode categories based one an additional category
I am designing an EE site for a board game cafe which sells games online and also has a games library in-store for playing. The client wants to enter the game information only once into the shop database (games will be for sale online only, available in store only, or both). Initially, when I did the online shop coding for online sales (I'm using Expresso Store), I used the categories as navigation. I did this so that the client can easily add categories. The client wants the same categories available for the in-store games library, so I copied the entire Store template group for the games library and modified the product template to remove the pricing and ‘add to cart’ functionality, but I need different sidebar category navigation in this template group as not all games available online for sale are available in store. I made a new category group called ‘games library’ and was hoping that only products with that checked (id 10) will return the other categories.

I have sidebar navigation which looks (in part) like this:

```
<h2>Genres</h2>
{exp:gwcode_categories group_id="4" show_empty="no"}
     <a href="{path=games_library/cat/{cat_url_title}}">{cat_name}</a>
{/exp:gwcode_categories}

<h2>Age Groups</h2>
{exp:gwcode_categories group_id="8" show_empty="no"}
     <a href="{path=games_library/cat/{cat_url_title}}">{cat_name}</a>
{/exp:gwcode_categories}

```

I only want items to show up in this navigation if another category (ID 10) is also checked.

I tried this, but it doesn’t work – it just shows empty bullets

```
<h2>Genres</h2>
{exp:gwcode_categories group_id="4" show_empty="no"}
{if cat_group_id == '10' AND cat_group_id == '4'}
     <a href="{path=games_library/cat/{cat_url_title}}">{cat_name}</a>
{/if}
{/exp:gwcode_categories}

```

Can anyone help?

# Answer
You could perhaps feed a list of entry ids to the gwcode plugin's entry\_id parameter via Stash like this:

```
{exp:stash:set name="the_ids" trim="yes" parse_tags="yes"}
  {exp:channel:entries category="241" limit="999" channel="products" disable="categories|pagination|custom_fields|member_data"}
    {entry_id}|
  {/exp:channel:entries}
{/exp:stash:set}

{exp:gwcode_categories parse="inward" entry_id="{exp:stash:get name='the_ids'}" show_empty="no" style="linear"}
   {if group_start}
     <h2>{cat_group_name}</h2>
     <ul>
   {/if}

    <li><a href="{path=games_library/cat/{cat_url_title}}">{cat_name}</a></li>

    {if group_end}
      </ul>
    {/if}
{/exp:gwcode_categories}

```
> 0 votes

# Answer
Try `group_id` instead of `cat_group_id`
> 0 votes

---
Tags: expresso-store, ee2, categories, gwcode-categories
---


# Question
Title: Category tag pair show group parameter not working
I've got a safecracker form which edits a channel entry. I want to display the categories that have been selected for the entry through check boxes, I've used this code:

```
{categories show_group="13"}
   <input type="checkbox" name="category[]" id="{category_name}" value="{category_id}"{checked}> {category_name}<br>
{/categories}

```

Which works fine, the checkboxes that have been previously selected are showing up as selected, but it's ignoring the 'show\_group="13"' parameter. It's showing all a categories for that channel but I just want it to show the category group 13.

I'm not sure where I'm going wrong? From the documentation it looks like I've got the right parameter, and 13 is definitely to category group id.

Is there any other way of displaying the categories selected for a certain category id for an entry?

Thanks, Julie

# Answer
> 1 votes
A work-around is to use conditionals when displaying the categories, and set hidden form fields for any categories from other groups to preserve them when they're checked.

```
{categories}
  {if '{category_group_id}'=='13'}
    <input type="checkbox" name="category[]" id="{category_name}" value="{category_id}"{checked}> {category_name}<br>
  {/if}
  {if "{category_group_id}" != '13' && '{checked}' != ""}
    <input type="hidden" name="category[]" value="{category_id}"><br>
  {/if}
{/categories}

```

ps. you can use `{categories group_id="xx"}...{/categories}` to limit to a category group, but from my tests, that doesn't seem to preserve any categories from other groups that might already have been selected.

---
Tags: safecracker, categories
---


title: Safecracker and Categories

text:
# Question
Title: Safecracker and Categories
The safecracker form related custom fields are being submitted, the problem is the select drop-down categories. After having chosen the category to associate the entry with, the respective category does not remain selected in the CP.

I'm using the User Guide Code

```
<select name="category[]" id="categories">
{categories}
<option value="{category_id}"{selected}>{category_name}</option>
{/categories}
</select>

```

# Answer
> 1 votes
I tested this and seems tot work correctly (EE 2.5.5). if you want to preserve already selected categories, you could make your select a multi-select.

```
<select name="category[]" id="categories" multiple="multiple">
...
</select>

```

---
Tags: safecracker
---


# Question
Title: Showing a grouped category drop down for safecracker?
Just wanted to know, is it possible to let the user select a category via safecracker, by means of a grouped drop down?

Something like this

Where by , in this case "England" is the parent category, and Avon, Bedfordshire etc are the child categories. Looking to use this for users to choose the category in safecracker, and search via this method in a Low search form.

# Answer
> 1 votes
Take a look at this **answer on StackOverflow** which details how to accomplish nested using jQuery.

# Answer
> 0 votes
It is possible with the native safecracker `{categories}` tag, but your milage may vary. you can check if `{category_parent}` is empty (meaning it is a top category), but there is no nice way to close the optgroup. I've found that not closing the optgroup does work, but haven't tested it in all browsers. Also, for nested categories EE outputs a couple of ` ` before the category\_name to denote the depth of the category.

**Edit**: *also make sure how u want to use (or need to use) the setting for<br>"Auto-Assign Category Parents" under Admin \> Channel Administration \> Global preferences*

```
<select name="category[]" id="categories">
{categories}
  {if '{category_parent}'==''}
    <optgroup label="{category_name}">
  {/if}
  {if '{category_parent}'!=''}
    <option value="{category_id}"{selected}>{category_name}</option>
  {/if}
{/categories}
</select>

// result optgroups :) but not closing optgroup tags

<select name="category[]" id="categories">
  <optgroup label="base1">
  <option value="1" selected="selected">cat1</option>
  <option value="2">cat2</option>
  <optgroup label="base2">
  <option value="7">cat3</option>
</select>

```

---
Tags: categories, drop-down
---


# Question
Title: Freeform used for two different email addresses
I have always used Freeform for a single form.

For a new project, I need the user to be able to choose two different organisations in a select field. Depending on the option selected the admin email notification needs to be send to one of two email addresses.

I tried using the following code which I made following some of the example documentation on the freeform site, but I am not sure if this is what its meant for.

```
   {exp:freeform:form
   form_id="1"
   required="name|email|message"
   recipients="yes"
   recipient_limit="2"
   recipient_template="admin_notification"
   recipient1="Name 1|email@domain1.com"
   recipient2="Name 2||email@domain2.com""
}
    <p>
        <select name="recipient_email" />
            {freeform:recipients}
                <option value="{freeform:recipient_value}">
                    {freeform:recipient_name}
                </option>
            {/freeform:recipients}
        </select>
    </p>
    <p>Your Name: <input type="text" name="name" /></p>
    <p>Your Email: <input type="text" name="email" /></p>
    <p>Your Message: <textarea name="message"></textarea></p>
    <input type="submit" value="Submit" name="Submit" />
{/exp:freeform:form}

```

Can anyone tell me if this is the best route, as it doesn't appear to work as I had hoped. Do I remove the email in the control panel for admin notification? or leave an email there?

Thanks

# Answer
Your parameters looks correct.

In the **select** part, it should look something like this

```
<select name="recipient_email">
    <option value="{freeform:recipient_value1}">Sales</option>
    <option value="{freeform:recipient_value2}">Technical Support</option>
    <option value="{freeform:recipient_value3}">Service</option>
</select>

OR

<select name="recipient_email">
    <option value="{freeform:recipient_value1}">{freeform:recipient_name1}</option>
    <option value="{freeform:recipient_value2}">{freeform:recipient_name2}</option>
    <option value="{freeform:recipient_value3}">{freeform:recipient_name3}</option>
</select>

```

Hope that helps. http://www.solspace.com/docs/freeform/form/#freeform\_recipient\_name1
> 3 votes

---
Tags: solspace-freeform
---


# Question
Title: How to share an entry to show up only to some users
Hei everyone,

I am trying to build a small system for an architectural bureaux like this :

# The main architect posts a House Project ( # an entry ).

* he invites 1 or more people to join the "project"

When they log in into their account, they will see only the entry "asigned" to them

# Questions:

How can the architect invite people into "his project" ?

How can that people, once they log in, to see only the posts assigned to them ?

I thougght using SOLSPACE USER module and let the architect select from his list the authors ( people ) so they can see the post they are assigned to, but it doesen't seem to work as I encounter the problem : there are more than 2 architects and they each have different people to assign to different projects, so the list of authors to select from will be the same for both of them and they well see each other's people...

Any solution for this ?

Thank you !

# Answer
> 1 votes
Solspace have a module called 'friends' that should be able to do what you are looking for: http://www.solspace.com/software/detail/friends/

# Answer
> 0 votes
Hah, I got bit by the users thing thinking it would do something similar.

My best guess would be to checkout devotee & look for some sort of coupon/special code generator to generate a code and use that to supply the end user with.

There's still the problem of assigning the code to the master entry. Maybe just setup a new field with an author set string they can use on 1 or many entries have the user be greeted with a modal or somesuch, user enters "password/key" if matches then show entry.

This fall's into non native territory, but u have a blank slate, rethink the process and arrive @ a repeatable process.

# Answer
> 0 votes
I've never used it, but this seems like it might do what you need... http://devot-ee.com/add-ons/entry-access

---
Tags: channel-entries, entry, solspace-user, users
---


title: URL Structures (Listings & Pages)

text:
# Question
Title: URL Structures (Listings & Pages)
I'm working on a site that has an 'edition', like a newspaper. The URL structure looks like this:

```
website.dev/edition/2013-05-01

```

The date is the name and url title of the listing.

The edition channel links to all the content added to the website: articles, images, video, etc which all have their own listing channels. I'm using the structure module by the way.

If I view an article from an edition the url structure is like:

```
website.dev/article/the-name-of-the-article

```

If I make the other listing channels subpages of the editions, the url structure will look like this:

```
website.dev/edition/article/the-name-of-the-article

```

Basically I want it to look like this:

```
website.dev/edition/2013-05-01/article/the-name-of-the-article

```

Any advice on how to do this (Using the structure module).

# Answer
> 1 votes
Mmm, sounds like a job for Router.

# Answer
> 1 votes
With Structure, every segment must be a page in the hierarchy. You may be able to do what you're looking for utilizing Freebie though: http://devot-ee.com/add-ons/freebie

---
Tags: structure, url
---


title: Checking if Matrix has rows or not

text:
# Question
Title: Checking if Matrix has rows or not
how can I conditionally output rows of an matrix, if there are any? Eg:

```
{if matrixfield}
    <h2>Also check</h2>
    {matrixfield}
        <a href="{url_title}">{title}</a><br />
    {/matrixfield}
{/if}

```

Thanks!

# Answer
> 10 votes
Yep, just check to see if the matrix field `total_rows` are greater than 0

```
{if my_matrix_field:total_rows > 0}
    Matrix field has rows
{/if}

```

# Answer
> 3 votes
I dont have enough rep to make a comment.

So, I am not sure what you are looking for. The code below is an example how to work with conditionals for Matrix.

```
{matrixfield}

   {if no_results}
       No rows available
   {/if}

   {if '{row_count}' == '1'}
       <a href="{url_title}">{title} - First row</a>
   {/if}

  <a href="{url_title}">{title}</a>

   {if '{row_count}' == '{total_rows}'}
        <a href="{url_title}">{title} - Last row</a>
   {/if}
{/matrixfield}

```

---
Tags: matrix
---


# Question
Title: How to add/display/manage private videos that only a specific member group can access?
I've used DevDemon Channel Videos plugin successful in the past, but this time the videos will need to be "private" so I can't host them on Youtube or Vimeo. I'm trying to brainstorm the best way to set this section up so it's easy for the client to add videos. The videos need to only be accessible to a certain member group.

I know if I want to host the videos on the site server that I need like 3 different video file types in order to display the video on different browsers (how annoying!). This doesn't sound very client friendly. Not as friendly as using a video service like Youtube that automatically converts video and works in all browsers. Any ideas?

# Answer
1. If you have a vimeo plus account, you can set the video as private and only allow the embedding on one site (yours). Pretty sure youtube has similar options (although not tested). This has worked very well for us.
2. If you want to host videos on site and use HTML5 / Flash playback I recommend mediaelements.js.

Making the videos accessible to a single member group can be done easily with conditionals like

```
{if member_group == "2"}
display video embed code
{/if}

```

If you want to go vanilla and not use add-ons, a simple text field where client has to enter the video ID on Vimeo is enough. Template can handle the embed code. WIth that setup, you can also combine youtube / vimeo pretty easily by adding another custom field (drop down / radio group / p&T pill) alowing the user to select the service they uploaded the video on.
> 4 votes

# Answer
I would just setup a video channel with DevDemon's Channel Video fieldtype so the client can post videos after uploading them to YouTube.

Then in the video template just use a conditional to show/hide videos to a certain field group:

```
{if member_group == "5"}
   show video
{if:else}
   hide video
{/if}

```
> 1 votes

---
Tags: video, channel-videos
---


title: External Links Stored in Channel

text:
# Question
Title: External Links Stored in Channel
In my navigation snippet I have some immutable external links and I just used a standard a tag with a hard-coded href attribute. No problems and it worked nicely.

So I figured there was "no trick" to external links, but ...

I am trying to display news which is actually created offsite at our financial reporting service website. I created a news channel with fields for an excerpt, a pubdate and the external url (which stores the URL as an absolute link \[http://www...com\].

When I tried to display the news in my template (code below), I am getting the text of the external URL field displaying as a hyperlink and the title of the article as static text (no link). Also, when I click on the exposed link, the URL that tries to load is "http://dev-edrweb.edrtrust.com/%3Ca%20href=".

It's pretty obvious I don't understand templating and external links. Any help is appreciated.

Here's the code from the template:

```
<ul class="news-feed">
  {exp:channel:entries channel="news" limit="5" disable="pagination"}
      <li>
          <h4>
              <a href="{full_article_url}" target="_blank">{title}</a>
          </h4>
          <span class="news-date">
              {publish_date format="%j %M %y"} |
          </span>
          <span class="news-summary">
              {excerpt}
          </span>
      </li>
  {/exp:channel:entries}
</ul>

```

# Answer
> 4 votes
It sounds like maybe ExpressionEngine is parsing the hyperlink for you. So you are in effect trying to add an anchor element into your href attribute of an exsiting anchor element. Either output {full\_article\_url} without surrounding it in an tag or turn off this setting for the channel.

http://ellislab.com/expressionengine/user-guide/cp/admin/channels/channel\_edit\_preferences.html#automatically-turn-urls-and-email-addresses-into-links

---
Tags: templates
---


# Question
Title: Playa Reverse Relationship - not working
I've looked at this question which confirms that as far as I can tell that I am doing things correctly.

I have two channels: Divisions and Zoo Visitor (members). In the zoo visitor channel I have a field "division" where the member selects the division or divisions that they belong to. Then in the divisions template I want to list the members in that division. The code I am using is below.

```
  {exp:channel:entries channel="divisions" limit="1" disable="categories|pagination"}
    <h3>{title}</h3>

    <img src="http://placehold.it/600x240&text=[img 600*240]" />

    {divisions-content}

<hr />
    {exp:playa:parents channel="zoo_visitor"}
    playa field
      {title}
    {/exp:playa:parents}
<hr />

  {/exp:channel:entries}

```

However this code is not outputting anything, not even playa field inside the playa tag pair. I've also tried adding this parameter to the playa field pair: `disable="categories|category_fields|pagination"` but nothing changes. I've triple checked that I'm on a page where the reverse relationship should be working.

Please advise.

# Answer
Sean, you may need to add a status parameter to your playa tag like so: {exp:playa:parents channel="zoo\_visitor" status="not closed"}.

Zoo Visitor uses a custom status per member group and the playa tag will only pull in those with an Open status by default.
> 4 votes

---
Tags: templates, playa, relationships
---


title: How to load javascript using module

text:
# Question
Title: How to load javascript using module
I am very new to Expression Engine .

I have created a module , i want to know how do i load/run it in the current template .

I want to add some custom javascript to the front end website , and i know that i have to use

$this-\>EE-\>cp-\>add\_to\_head('myscript'); or any other function

But i don't know where should i call this function . I tried to call it in the mod.my\_module.php in construct function but nothing happened.

Is there something i am missing ?

# Answer
Take a look at the answer I gave here, and specifically this bit:

> If you want to output the JS file URL in your templates, create a method in your mod file that outputs `URL_THIRD_THEMES.'your_addon/js/file.js'` or something like that. Then use `{exp:your_addon:your_method}` to output the URL in the template.

Using `$this->EE->cp->add_to_head()` only applies to Control Panel pages.
> 1 votes

# Answer
You could also take a look a at my Theme Loader class, which does some extra things and makes code a little easier to manage for older versions of EE and various configurations.

https://github.com/objectivehtml/Theme-Loader
> 0 votes

---
Tags: module
---


# Question
Title: Creating a new member account (without the accompanying profile channel entry) with Profile:Edit
Using Profile:Edit, is there a way to create a new member account, without creating the profile channel entry at the same time? I've got a situation where I have profile channel entries already created, but just need to create the member accounts separately on the front end.

Using the {exp:profile:register} tag creates both the member account and the profile channel entry (so I then end up with a duplicate profile channel entry as it already existed previously).

Just wondering if there's a non-documented parameter I can use to make it create just the member account, or if there's any ideas for an alternative method (SQL, Database class, etc), thanks.

# Answer
You may be able to use something like Stand-Alone Member Registration to create the new profiles from the front-end but I'm not sure how in sync you need those to be with your existing Profile:Edit channel entries? That will create the member entries at least.
> 1 votes

# Answer
I think you'll need to just use a Safecracker form to create a regular old member account, and then on the backend use the Profile:Edit utility under the P:E Settings to associate that new member account with the existing P:E entry.

If you need this all to happen from the front-end, I'd dig into the P:E utility to see how it works and maybe reuse that code.
> 3 votes

---
Tags: members, profile-edit
---


# Question
Title: Search custom Playa fields with Super Search using template parameters
Using Super Search 2.0.7, I want to be able to search on a custom Playa field using the `results` template tag.

```
{exp:super_search:results
    channel       = "entries"
    keywords      = "something"
    cf_city       = "Boston"
    dynamic       = "off"
}
    {super_search_total_results}
{/exp:super_search:results}

```

I can get this to work perfectly fine using GET params:

```
/search&keywords=something&cf_city=Boston&channel=entries

```

Am I missing something to get this functionality working with template tag params?

# Answer
> 2 votes
You need to make sure the field is set to "searchable" in the field settings page but you should be able to get the two working together.

> Super Search has limited support for Pixel & Tonic's Playa add-on. You can perform regular searches (excluding exact, ranges, etc) on entry titles within Playa fields, as long as the field(s) are set to searchable in the custom fields' settings. This means that you are be able to perform direct searches on Playa fields, as well as keyword searches that include Playa field searching.

---
Tags: playa, supersearch
---


title: {field:register_member}

text:
# Question
Title: {field:register_member}
I wonder where the {field:register\_member} can be translated? I've looked through the Store lang file, but it does not seam to be translatable?

I have store 1.6.3 and EE 2.5.5.

cheers stefan

# Answer
I'm not sure if it needs to be translated. All it does is output a hidden field to a page:

```
<input type="hidden" name="register_member" value="1" />

```

So the user wont actually see it anyway.
> 1 votes

---
Tags: expresso-store
---


# Question
Title: Display embedded templates inside a conditional statement if checked on publish page
In short: I need to display embedded templates based on whether they are selected by checkbox on the publish page, but my code doesn't work if more than 1 is checked.

I tried using the code below to check for whether a checkbox was checked and display the template if it was. This works, unless more than one is checked off, then none display because the statement no longer validates as true.

I have one full-page template shared by 2 pages. I have one page that requires Rides, and the other requires all 3 templates.

The name of my checkbox field is choose\_entries, and the options are "Rides" "Gear" "Groups".

```
{exp:channel:entries channel="pages" limit="1" url_title="{segment_1}"}
    {if choose_entries == "Rides"}
            <h2 class="section-title">Rides<span class="green"></span></h2>
            {embed="views/.rides"}
            <img src="content/img/bike.png" />
    {/if}
    {if choose_entries == "Gear"}
            <h2 class="section-title">Gear<span class="orange"></span></h2>
            {embed="views/.gear"}
    {/if}
    {if choose_entries == "Groups"}
            <h2 class="section-title">Groups<span class="blue"></span></h2>
            {embed="views/.groups"}
    {/if}
{/exp:channel:entries}

```

I know there is probably a way to do it with php (but I don't write php), I would like to avoid that if possible. I was unable to find the correct php syntax to get an "if contains" type statement to work.

# Answer
> 0 votes
Don't even attempt to do something like this with the native checkboxes, they're really substandard. Use pixel and tonic's field pack instead and you'll have no problems:

http://devot-ee.com/add-ons/pt-field-pack

---
Tags: conditionals, embeds, checkbox
---


# Question
Title: Using a module tag as parameter adds +1 query per loop
I'm finding that if I use a module tag like stash or playa as a parameter in a plugin tag, that an extra query for the module name is run for each loop. Here's the query that's run:

```
SELECT `module_version`, `module_name`
FROM (`exp_modules`)

```

From what I can tell, it's EE looking up the module so that it can parse it's tags. Here's some example template code that's generating the extra queries. This example uses a channel entries loop and a playa tag as a parameter but using another module tag like stash with just a string of ids `1|2|3|4` will do the same thing. The `sp_within` plugin is a custom plugin I've written however I've tried this with other plugins and the same thing occurs.

```
{exp:channel:entries channel="professions" orderby="title" dynamic="no" sort="asc" disable="custom_fields|categories|member_data|pagination"}
    {exp:sp_within haystack='{exp:playa:child_ids field="member_profession" entry_id="{zoo_visitor_id}"}' needle='{entry_id}' parse="inward"}
        <label><input name="member_profession[selections][]" value="{entry_id}" type="checkbox"{if within} checked="checked"{/if}> {title}</label>
    {/exp:sp_within}
{/exp:channel:entries}

```

**Edit** Here's a clearer example that just uses a channel entry loop and a stash variable.

```
{exp:stash:set name="selected_ids"}94|2|45|87{/exp:stash:set}

{exp:channel:entries channel="professions" dynamic="no" disable="custom_fields|categories|member_data"}
    {exp:sp_within haystack='{exp:stash:selected_ids}' needle='{entry_id}' parse="inward"}
        <label><input name="member_profession[selections][]" value="{entry_id}" type="checkbox"{if within} checked="checked"{/if}> {title}</label>
    {/exp:sp_within}
{/exp:channel:entries}

```

Can I cache the query for the module name in my sp\_within plugin? It's okay when there's only a few extra queries but it gets a bit ridiculous when there's 20 plus. Does anyone know how to remove the extra queries?

# Answer
Instead of using your plugin as a parameter, you can wrap the entire channel:entries tag inside your own plugin, and then just search-replace `{custom_value}`, a single variable, with the data you want to insert in the inner tags parameter. (parse=inward so that the outer tag-pair is parsed first)

```
{exp:custom_plugin:method parse="inward"}
  {exp:channel:entries channel="products"
    entry_id="{custom_value}" status="wide"
  }
    <h3>{title}</h3>
  {/exp:channel:entries}
{/exp:custom_plugin:method}

```

e.g.: Entry ID Returned From Plug-In Not Working in Channel Entries Tag
> 1 votes

# Answer
That's because you're telling it to loop multiple times. The outer Channel Entries tag is a loop so it will loop through all results defined by the filtering criteria. Then You're calling in your plugin and passing in the Playa Child ID's tag which also produces a full loop to provide a single parameter to your plugin. Anything with tag pairs will loop. You're also passing in dynamic variables as attribute values so all in all that will produce quite a lot of queries to even return a small number of entries.

Using Stash will help to cut this down but obviously the loop(s) would still need to run at least once to have the value available to pass on to your plugin. So in that case you'll probably need to set some nested Stash results to run the Channel Entries tag and the Playa Child IDs tag. Then Stash those results and call your plugin later on (outside of that loop). The first time it's run it may well result in the same number of queries but after that you should see a noticeable reduction.
> 0 votes

# Answer
This appears to be a limitation of using module tags as a parameter of any tag that produces a loop. I found two ways to avoid using the module tag as a parameter and therefore the additional queries for the module name.

### 1. Set the stash type parameter to snippet

This my preferred approach.

```
{exp:stash:set name="sn_selected_ids" type="snippet"}94|2|45|87{/exp:stash:set}

{exp:stash:parse process="end"}
   {exp:channel:entries channel="professions" dynamic="no" disable="custom_fields|categories|member_data"}
       {exp:sp_within haystack='{sn_selected_ids}' needle='{entry_id}'}
           <label><input name="member_profession[selections][]" value="{entry_id}" type="checkbox"{if within} checked="checked"{/if}> {title}</label>
       {/exp:sp_within}
   {/exp:channel:entries}
{/exp:stash:parse}

```

### 2. Enable PHP in your template

```
{exp:stash:set name="selected_ids"}94|2|45|87{/exp:stash:set}
{exp:channel:entries channel="professions" dynamic="no" disable="custom_fields|categories|member_data"}
    <?php
        $haystack = '{exp:stash:selected_ids}';
        $haystack = explode('|', $haystack);
        $in_array = array_search('{entry_id}', $haystack);
    ?>
    <label><input name="member_profession[selections][]" value="{entry_id}" type="checkbox"<? if ($in_array !== false) echo ' checked="checked"' ?>>{title}</label>
{/exp:channel:entries}

```
> 0 votes

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