# Question
Title: Images in Wygwam with the CE Image Bulk Tag NOT Responsive
I have tried to use CE Images Bulk Tag with Wygwam per Ryan Masuga instructions ( http://bit.ly/1NEzxUF ). It works for resizing the images, putting in floats and padding around the image when needed. One problem when I pull the browser to the next viewport the image does not resize, its not responsive. I am using bootstrap, so I have added the class .img-responsive. I also added the class #news img {max-width: 100%; height: auto; display:block;}, thinking that might help. Still no image responsive behavior.

example: http://osd.seeingishosting.com/news/news-view/testing-images

```
<div class="col-md-8" id="news">

{exp:channel:entries channel="News"}
     <h2>{title}</h2>

    {exp:ce_img:bulk width="700" crop="no" allow_scale_larger="no" quality="80"
    output='<img src="{made}" alt="{attr:alt}" class="img-responsive osd-border" style="max-width:{width}px;{attr:style}" />'}

    {main_body_copy}

    {/exp:ce_img:bulk}

{/exp:channel:entries}

```

# Answer
there are two problems at least with your code.

First, it appears that the 'class' statement is not being added to the image in the article - here is what is currently produced in the article:

```
<img src="/images/made/images/uploads/IMG_7381-test_700_1050_80.JPG" alt="" class="" style="max-width:700px;">

```

The `alt` and `class` tags are not being populated.

The second is that even if you add the img-responsive tag back in a browser inspector the use of `max-width:700px;`seems to be fixing the width at 700px - so simply remove this and let bootstrap's default 100% width do its stuff. With these changes this image definition seems to scale OK with changing viewport sizes...

```
<img src="/images/made/images/uploads/IMG_7381-test_700_1050_80.JPG" alt="" class="img-responsive odd-border">

```

I think you got a bit confused by the 'bulk' tag syntax. You don't need to recreate the tag - it simply 'edits' whatever img tag you have in your `{main_body_copy}`. So to add the two additional fields you want passed through to the final image, you should put them within an 'attributes' tag - something like:

```
{exp:ce_img:bulk width="700" crop="no" allow_scale_larger="no" quality="80" attributes="alt='{attire:alt}' class='img-responsive osd-border' style='{attire:style}'"}

```

Hope this helps.
> 1 votes

---
Tags: ce-image, responsive-images
---


title: Using limits on exp:channel:entries

text:
# Question
Title: Using limits on exp:channel:entries
I'm trying to set a limit to the results displayed from relationship fields:

```
{exp:channel:entries channel="childChannel"}
  {siblings field="relationship_field"}
    {siblings:title} - {siblings:field1} - {siblings:field2}
  {/siblings}
{/exp:channel:entries}

```

I'd really like to use the `entry_id_to="{var}"` and the `entry_id_from="var"` so I could split the results into two nice columns. Somthing like this

```
<div class="two_column_class">
<div>
    <ul class="one">
        <li>First line of text</li>
        <li>Second line of text</li>
        <li>Third line with some text</li>
        <li>Fourth line of text</li>
        <li>Fifth line with some</li>
    </ul>
</div>
<div>
    <ul class="two">
        <li>First line of text</li>
        <li>Second line of text</li>
        <li>Third line with some text</li>
        <li>Fourth line of text</li>
        <li>Fifth line with some</li>
    </ul>
</div>

```

I'd put the first "portion" in the first DIV, and the second, the second DIV.

But in the list of options / parameters in the manual, I don't see the `entry_id_to` or the `entry_id_from` as relationship field parameters.

Am I going about trying to solve this the wrong way?

Thanks everyone...

# Answer
I've found the simplest way is to use stash like this:

```
{exp:channel:entries channel="childChannel"}
    {exp:stash:set_list name="related" parse_tags="yes"}<!-- Set the list -->
        {siblings field="relationship_field"}
            {stash:title}{siblings:title}{/stash:title}
            {stash:field1}{siblings:field1}{/stash:field1}
            {stash:field2}{siblings:field2}{/stash:field2}
        {/siblings}
    {/exp:stash:set_list}
{/exp:channel:entries}

{exp:stash:get_list name="related" limit="1/2"} <!-- Get list & limit to half -->
{if count == 1}
    <div>
    <ul class="one">
{/if}
    <li>{title} | {field1} | {field2}</li>
{if count == total_results}
    </ul>
    </div>
{/if}
{/exp:stash:get_list}

{exp:stash:get_list name="related" offset="1/2"} <!-- Get list & Offset by 1/2 -->
{if count == 1}
    <div>
    <ul class="two">
{/if}
    <li>{title} | {field1} | {field2}</li>
{if count == total_results}
    </ul>
    </div>
{/if}
{/exp:stash:get_list}

```
> 1 votes

---
Tags: channel-entries, relationships, ee3, parameters
---


# Question
Title: Assign class to First Nolan row of every matrix row
I tried and was unsuccessful in writing a conditional for assigning a class to first Nolan row of every matrix row.

Any pointers on the conditional?

# Answer
Seems Nolan has a count tag:

`{nolan_row_count} - Same as {count} to avoid variable clashes`

So use

```
{If nolan_row_count ==1}
... do stuff
{/if}

```
> 0 votes

---
Tags: ee2, matrix, nolan
---


# Question
Title: New to EE 3.3.0 Ver - Cannot Assign Status Group To Channel
I am new to Expression Engine 3.3.0. I have a "News" Channel group and "News" field status group that I want to assign so I can separate my news articles from the ones that show at the top of my site from the three that show underneath. See here for details.. http://www.mannachurch.org/ExpressionEngine/

The new UX is great....but, um....I can't assign this for some reason. I only have the option to assign my Status Groups "Homepage Featured" and "Homepage Secondary." My "Homepage Featured" and " Homepage Secondary" should be in my "News" Channel fields group, What am I doing wrong? This is test site, with no sensitive material there, so if you need access lemme know.

# Answer
Nevermind, I got it. This interface is confusing. I had to click on the "eye" in order to get into the Status field group.
> 0 votes

---
Tags: status, groups
---


title: CartThrob cart_total doesn't display

text:
# Question
Title: CartThrob cart_total doesn't display
I'm having an issue trying to display cart\_total on a CartThrob cart overview template.

I have several items in the cart.

Both of the following display $0.00 for a total:

```
{exp:cartthrob:cart_items_info}
  {cart_total}
{/exp:cartthrob:cart_items_info}

{exp:cartthrob:cart_total}

```

Yet cart subtotal works just fine:

```
{exp:cartthrob:cart_subtotal}

```

Other tags for displaying shipping totals, taxes, etc are also working.

Scratching my head a bit, or maybe I'm just missing something obvious.

Thank you in advance for any suggestions or solutions.

# Answer
This was a bizarre issue that I eventually figured was due to a recent EE / CartThrob upgrade issue. It was several weeks ago, so I don't have the exact details but this is the basics of it.

When I opened phpMyAdmin, and had a look at the cartthrob\_settings table, I saw that the product\_channels entry was referencing the wrong channel ids. It was referencing other channels that held regular site content.

I then went to the CartThrob Modules settings \> Products tab and deleted the two product channels in there and pushed submit. But that didn't actually update the product\_channels entry in the cartthrob\_settings table. I would go to the product channels tab and try and add the product channels, but the updated settings weren't being properly set. Tried different combinations of this for about 20 minutes.

At this point, I figured I had a botched recent upgrade. I could have tried just editing directly in phpMyAdmin but I figured that there were probably other things that were out of place.

So I took the store down and uninstalled cartthrob, and went into phpMyAdmin and dropped all the cartthrob tables.

I took screenshots of all the settings I had, reinstalled, applied the settings and everything has been running smoothly ever since. A couple of hours of work, I hope this helps anyone else to figure things out and maybe find a faster route for repairing the issue.
> 1 votes

# Answer
I had the same problem and discovered the issue was that I had my unit price field in the products channel set to "text\_input" rather than "carthrob\_price\_simple". Once I changed this, and had to re-enter all the unit prices for all the products, it worked fine.
> 0 votes

---
Tags: cartthrob, shopping-cart
---


# Question
Title: How to access query string params in a template?
I need to access the query string params in a template. How can I access these variables?

http://example.com/search.php?size=large&color=red&page=1

# Answer
> 4 votes
You can use PHP or plugin GET\_POST\_Var

```
color {exp:get_post_var type='get' var='color'}
page {exp:get_post_var type='get' var='page'}
size {exp:get_post_var type='get' var='size'}

```

# Answer
> 3 votes
Two other options:

You can use the excellent Mo' Variables plugin to grab GET and POST information along with a number of other variables.

If you're already using Stash on the site you can also use {exp:stash:get} with the dynamic="yes" parameter to look for POST and GET info.

# Answer
> 2 votes
There's even a native global variable: {current\_query\_string}. EE \> 2.7.0

---
Tags: url
---


# Question
Title: 500 Internal Server Error - Only for Control Panel
There was a 500 error out of no where.

The front end works fine, however, I am not able to login.

Removed the .htaccess file and checked, still no avail.

Help please!

EE 2.11.1 PHP 5.6.13

# Answer
> 1 votes
From BoldMinded Support:

**Apr 10, 2016**

> It seems there was a change in EE 2.11 that caused this. CSM was using a method of extending/hijacking a core class to get this to work, which has been fine for the last 6+ years, but no longer works. If you really need to use CSM you’ll need to downgrade to 2.10. Otherwise I suggest just uninstalling it.
>
> I’ll work with EllisLab so I can restore the functionality to CSM, however, I wouldn’t expect anything to happen in the next week or two.
>
> Sorry for the troubles, but I’ll post updates here when I get them.

**Apr 17, 2016**

> You can now download version 2.6 (it is packaged with the EE3 version 3.0.2). If you’re using EE 2.11, which is causing the problem, you will need to make a core hack. See the README file. This change will be in EE 2.12 so you only need to make this hack once.

Link to ticket: https://boldminded.com/support/ticket/1283

Hope that helps!

# Answer
> 0 votes
Try disabling extensions. In your config file add:

```
$config['allow_extensions'] = 'n';

```

# Answer
> 0 votes
You can also individually turn your extension on/off via your installation's DB.

To address the actual issue: I'm experiencing this same issue today and I've narrowed it down to Custom System Messages.

I'll report back when I find a solution.

---
Tags: ee2
---


# Question
Title: In the control panel, is there a way to make an entry field required if another entry field is selected?
EE v2.11.1
Entry Type v1.1.4

I'm using Entry Types to show/hide fields based on a selection. What I would like to do is show the fields and make some of them required if the admin user selects Yes on Entry Type pill button. Currently, if I set fields to required and the Entry Type pill button has not been set to "Yes", the entry will not publish, because the hidden fields are required.

Ideally, I would like to use the CP CSS & JS add-on to add required classes to certain fields based on the value of the Entry Type pill button. Is this even possible? If not, has anyone run into this before? If so, could you please share how solved it?

# Answer
> 1 votes
You can use jQuery to provide additional validation for the Channel Entry form using the CP CSS & JS add-on. You'll want to add some JavaScript to your entry form that hooks `required` attributes to the specific fields you want to modify on the fly.

Note: This will not provide **backend validation**, just frontend. So technically, if you conditionally add the `required` attribute to an input, the enterer could use their browser's developer tools to simply remove that attribute and the form would submit.

Here is an example of adding the attribute with jQuery to a form input:

```
$("#conditionally_required_input").prop('required',true);

```

And there a several ways of triggering that by adding an event listener to the trigger element:

```
$("#triggers_conditionally_required_input").click(function() {
    if ($(this).val() == "Yes") {
        // use jQuery to add the required prop to some element
    } else {
        // similar, but here you want to remove required prop (set false)
    }
});

```

There isn't any practical way to add back-end validation on the fly (complicated add-on mess), and it would create unusable behaviour were the enterer would open an entry and have an unexpected field be required because the last enterer made certain choices.

---
Tags: control-panel, entry-type
---


title: Why learn Javascript?

text:
# Question
Title: Why learn Javascript?
I am new to web development. I have familiarity with CSS/HTML/Wordpress and Expression Engine Content Management system. I want to be a well rounded professional web developer desperately, and trust me, it's been a struggle to do all I do and still have time for self-development with other languages. I take care of several Wordpress Sites at my job and am currently learning Expression Engine 3.0 for a new, much large Expression Engine site. I love the Javascript language, but I am concerned if learning it right now would be good given my current type of work. I was told that learning Javascript would be helpful for customizing things in Expression Engine as well.

That said, here is my question....is learning JS beneficial for Wordpress Dev or/and Expression Engine development? Please forgive me if this is a stupid question. Eventually I would like to design my own EE add-ons and Wordpress themes/plugins with the ability to customize them as needed for my client, maybe even make web games? Is learning JS a good skill for my current career direction? I'm also trying to learn BootStrap as well to my language learning TODO list.

# Answer
Greg is right - javascript is primarily a front-end resource: you use it to program activity within the user's browser.

While you can construct EE Sites that don't use any javascript at all - if you want to include any kind of locally dynamic behaviour (UX / UI) you'll need some kind of javascript running somewhere. So it is hard to imagine that you could build a modern EE site without some knowledge of javascript.

But there is also another factor - many of the 'new generation' of web development tools make use of javascript as an automation language - so if you run anything that uses "Node.js" (e.g. gulp, grunt, bower etc.) these all require some familiarity with javascript to configure their operation. So it might be worth learning a bit of javascript for that too...

HTH
> 1 votes

---
Tags: javascript, ee3, development
---


title: MSM and Grid Fields

text:
# Question
Title: MSM and Grid Fields
Primary site has approximately 100 grid fields. Duplicating the first site with MSM, that makes 200 exp\_channel\_grid\_field\_\[id\] tables. With setting up 4 sites total, that means we will be dealing with over 400 grid tables. This is far from ideal, and will there be any impact in performance having this many tables?

# Answer
No, you should be fine. It will be a pain in the ass to manually manipulate the schema (using a GUI tool like MySQL Workbench) since you will be looking at a list of hundreds of tables, but there is no theoretical limit if your table engine is MyISAM. InnoDB has a theoretical limit of 4 billion tables.

So you're fine. The only possible overhead would be if you were querying the `information_schema` table, which stores meta data about the schema, it's tables, and it's table's columns. So it's only overhead if you have billions of tables and need to look up the meta on lots of tables (so querying a table with billions of rows).

When you (EE) queries a table, it's called out by name, and I'm pretty sure MySQL seeks the table data directly and doesn't need to do a tech-debt heavy look-up. I could be wrong, but MySQL schemas (in relation to table count) scale vertically with very little issues in my experience.

I might not be exactly right (probably some engine overhead I'm not keyed in to), but EE expanding vertically in the schema versus expanding horizontally inside of a table (think about the `exp_channel_data` table, that adds columns for every new custon field) is much smarter.

That said; be aware about the theoretical limit on table columns when you add new fields. Every new custom field you add creates a column in the `exp_channel_data` table, and there is a much closer limit. It's something like 4096 columns in theory, but less depending on column type. I'll link some resources.

https://dev.mysql.com/doc/refman/5.5/en/database-count-limit.html

https://dba.stackexchange.com/questions/3972/too-many-columns-in-mysql

https://www.percona.com/blog/2013/04/08/understanding-the-maximum-number-of-columns-in-a-mysql-table/
> 1 votes

---
Tags: multi-site-manager, grid, multiple-sites
---


# Question
Title: Duplicate main site into a MSM site, what native EE channel field values are duplicated?
I'm wondering if these native EE fieldtypes are supported with content duplication when creating a new MSM site. In my experience there are some 3rd party add-ons that don't support MSM site duplication.

* Grid
* Relationships
* Textarea (Rich Text)

# Answer
> 0 votes
After some testing, Grid and Relationship native EE fields are not duplicated. Not sure why this is the case.

---
Tags: ee2
---


title: Want to update website content

text:
# Question
Title: Want to update website content
I bought a licence for expression engine 7 years ago. I now want to update my content on website and I cannot find expression engine to log in and make changes. My website is www.keeinteriors.com can you help me?

I tried to log in and get forgotten password but none was sent to either email.

# Answer
Normally you'd go to www.yoursite.com/admin.php however this has been moved/renamed on your site. I'd FTP into the site and look at similar files in the root directory. You may find it's been renamed for security reasons.
> 0 votes

---
Tags: update
---


# Question
Title: Forbidden: You do not have permission to access this document - When attempting to save a Template
EE Version 2.10.1, PHP 5.3.27 Neither have been updated since installed. And as much as I would LOVE to upgrade to EE v3.x, I cannot due to some of the Add-Ons not having been upgraded.

This appears to have something to do with ExpressionEngine’s query functionality. I uninstalled the Query Module and reinstalled it, but the same issue.

Just started to receive this error about 2 hours ago. I have looked all over ExpressionEngine but cannot figure out what the issue is EXCEPT that when I use the following in PHP within the Template, it causes the above error:

$uploadTo = $this-\>EE-\>db-\>query( “SELECT server\_path as url FROM ” . $prefix . “upload\_prefs WHERE 1 = 1 and name = ‘ABC’ “);

Hmmm, it appears to be the same issue if I use the following:

{exp:query sql=”select Count(\*) TheCnt from EE-\>db-\>dbprefix; ?\>FrEd fred Where 1=1 and fred.ID = EE-\>session-\>userdata(‘member\_id’); ?\> and fred.CanDt is NULL” } {/exp:query}

# Answer
> 1 votes
The issue was that the Hosting Provider had enabled mod\_security in the middle of the day (right when I had taken a slight break) without notifying me of this ahead of time.

They disabled mod\_security late last night and all is working correctly now.

BTW, the error\_log file on the hosting site had all sorts of errors notifying that the issue was mod\_security.

---
Tags: templates, query
---


# Question
Title: Low Variables "Grid" Search Parameter... why am I failing?
I have a Low Variables Grid setup and I'm trying to just return the rows that match a value in a column, if it exists.

In the Low Variable setup, I have the column checked to be "Grid Column Searchable". And the grid column is a plain text field.

Is there any reason why my setup is returning all the rows, instead of just the one with "wa"?

```
{!-- Low Variables "Grid" Field. --}
{exp:low_variables:pair var="lv_states" search:gd_state="wa"}
  {lv_states:gd_state}
{/exp:low_variables:pair}

```

Alternatively, I tried to see if the low variables "Table" fieldtype or P&T Field Pack "List" would cover it but that isn't giving a result either.

Is searching those two field types possible?

```
{!-- Low Variables "List" Field. --}
{exp:low_variables:pair var="lv_states" search:item="wa"}
{item}
{/exp:low_variables:pair}

```

Thank you for any assistance,

# Answer
Issue is related to a bug that existed with an older version of EE.

Details:

Grid Search Parameter Does Not Work With Low Variables

Thank you Low for your assistance.
> 0 votes

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


# Question
Title: Expression engine 2.1 to 2.11.1 Upgrade never completes
I am trying to do an upgrade from 2.1 to 2.11.1. I have followed the instructions here https://docs.expressionengine.com/v2/installation/update.html. My issue when i go through the wizard I get to the portion where it is supposed to start the update and it never finishes or errors out. It just refreshes every 2 seconds but never gets past that. I let it sit for a couple of hours and never got past that screen.

I then went in to try and get the login page but I get this error.

> Error
>
> Unable to load requested field type file: ft.rel.php.
>
> Confirm the fieldtype file is located in the expressionengine/third\_party/ directory

I noticed a change with the filetype folder where each file type is now in its own folder and also rel went to relationship. I made sure I copied /system/expressionengine/fieldtypes/relationship/ft.relationship.php and saved it to /system/expressionengine/fieldtypes/ft.rel.php and /system/expressionengine/third\_party/ft.rel.php. This did not make the error go away.

Any advice on what to try next would be appreciated.

Thanks

### UPDATE

I have gotten past this point now. I went in and manually changed a couple of things in the database. First I changed rel to relationship in exp\_fieldtypes table. Second I changed all references to rel to relationship in exp\_channel\_fields.

I am now able to see the login page but I am not able to login. I get the following error.

> The following errors were encountered
>
> This form has expired. Please refresh and try again.

I have read some places it could be because of cookies or cache but fixing those did not help at all. I found the error occurs because of an expired csrf token. In my case no csrf token.

So again I am stuck as the issue is the upgrade wizard does not do what it is supposed to do.

Wondering if anyone else has had a similar issue with the upgrade wizard from any version of 2 past 2.6 which is where I believe csrf tokens were implemented. Any tips would be appreciated.

# Answer
> 1 votes
Looks like the issue was because the config file was setup to grab a different config file for each environment. Even though I set it up the same way it causes the upgrade wizard to stall. Once I copied my dev config file to the base config file the upgrade proceeded as planned. Then I switched back the base config file to use env specific conf files it worked.

---
Tags: upgrade, ee2-upgrades
---


title: Accessing EE data via iOS swift

text:
# Question
Title: Accessing EE data via iOS swift
Good afternoon,

I have a bit of a noob question here. I'm learning swift, and I'd like to write an application to access (read only at first) data from my EE3 site. All the good data I'm hoping to access is locked behind logins for members.

I've read a number of terms, but I was hoping someone might be able to point me in the right direction on what I should study up on first?

REST? JSON? AJAX? XID\_CODE?

I understand I'll probably using a swift NSURLSession call along with some authentication.

Really appreciate anyone's thoughts here.

Cheers!

# Answer
> 2 votes
EE doesn't have a native API interface to communicate with, but I've been having quite a good time with Webservice API plugin from Reinos, and with it you can turn a EE install into a REST/XMLRPC/SOAP server. They've also done the hard work of connecting with many third-party add-ons. Check out the docs here.

---
Tags: ajax, ee3, json, authentication, rest
---


# Question
Title: Selling event tickets with an initial deposit using either Store or CartThrob?
I've previously read it's possible to setup EE for selling tickets for an event using the inventory as the number of tickets for sale, so each product can be used as the event.

However, is it possible to somehow setup the process of buying a ticket so that the customer pays a deposit to confirm their place, then pay the remaining fee at a later date nearer the time of the event?

Thanks in advance.

# Answer
> 0 votes
(I'm with Vector; we own CartThrob)

You'd need to customize CartThrob a bit to do this, likely with a custom payment gateway. Depending on how far from the event you're selling the tickets, you may also need to make use of your gateway's token/vault function. (If it's close, you could use the "authorize and capture" later function). Either way, you'd need customization though -- because you want two charges, the deposit and the balance.

Let us know if you can't figure this out and we'd be happy to find a way to help!

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


# Question
Title: ExpressionEngine code being used with JQuery
I have been working with ExpressionEngine for awhile, but I am fairly new to Jquery.

I have a photo slideshow that works well if I hard code all the data in the template, but when I try to use ExpressionEngine variables to pull the data from the channel field it breaks the JQuery because there is extra code.

**ExpressionEngine Code**

```
    {photos}
{if "{gallery_site}" == "Facebook"}
    {
    name:'{gallery_nav_title}',
    url:'{gallery_site_url}',
    selected:{default_gallery}
    },
    {/if}
    {/photos}

```

**Results**

```
{
name:'Spring Jubilee 2016',
url:'https://www.facebook.com/media/set/?set=a.10153370870941895.1073741883.26942986894&type=3',
selected:true
},

```

This works perfectly.

**Jquery Single Entry Code**

```
$("#photomax").photomax({

  facebook_album_photos:[

{
name:'{gallery_nav_title}',
url:'{gallery_site_url}',
selected:{default_gallery}
},
  ],
});

```

This code works perfectly

**Jquery IF Statement Code Added**

```
$("#photomax").photomax({

facebook_album_photos:[

    {if "{gallery_site}" == "Facebook"}
    {
    name:'{gallery_nav_title}',
    url:'{gallery_site_url}',
    selected:{default_gallery}
    },
    {/if}

```

**Results**

```
$("#photomax").photomax({

facebook_album_photos:[

    {if "{gallery_site}" == "Facebook"}
{
name:'Spring Jubilee 2016',
url:'https://www.facebook.com/media/set/?set=a.10153370870941895.1073741883.26942986894&type=3',
selected:true
},
    {/if}

```

When I place the IF statement into the code it breaks the code.

I need the If statement because I have a Matrix setup up to add Multiple galleries. The Galleries can come from Facebook or Instagram and I have different code depending on where it is coming.

**Here is code showing multiple galleries working WITHOUT the IF Statement and ExpressionEngine code.**

```
$("#photomax").photomax({

  instagram_user_tagged_photos:[
    {
      name:"Instagram User Tag",
      url:"https://instagram.com/muradosmann",
      hashtag:"#followme",
      selected:false
    },
  ],

  facebook_album_photos:[
    {
      name:"Facebook Album Photos",
      url:"https://www.facebook.com/media/set/?set=a.10153495891665541.1073741843.76810820540&type=3",
      selected:true
    },
  ],

});

```

# Answer
> 1 votes
There's a few posts around on the subject but you could start with adding a config override either via the CP or if you're using an Override you should only need:

```
$config['protect_javascript'] = 'n';

```

Like this post

---
Tags: jquery
---


title: help understanding stash context=""

text:
# Question
Title: help understanding stash context=""
I'm not able to make sense of how to use context="" in stash.

I've not yet had to use it but I'm not sure if there are things I may have been able to handle more efficiently.

could somebody give an example please?

Thanks

# Answer
> 1 votes
Think of `context` as a prefix to the `name` parameter (that is in fact exactly how it works in the background). This enables you to use dynamic variables (or 'variable variables') that have the same `name` but might be used in different contexts. You don't have to use `context` \- you could achieve the same thing with a dynamic name parameter e.g.: `name="faqs-related-to-{entry_id}"`

Personally, every site I build has a dedicated and permanent development/staging environment in addition to the live/production environment (and local environments per developer). So for me, `context` is an ideal way of scoping my Stash variables to the environment so that, for example, cached Stash lists are unique per environment. Without using `context` I'd have private draft status entries appearing on the live site due to the caching.

Here's an example of a cached list of 'news' entries where the staging environment's list can be different to the production environment's list thanks to `context`. Notice too that on the inside of the `channel:entries` loop I have another Stash list for the categories, which, instead of using `context`, achieves the same thing with the `name` parameter. (I prefer this as I always reserve the `context` parameter for environment scoping):

```
{exp:stash:set_list
    name="news-items"
    parse="yes"
    parse_depth="2"
    context="{global:env}"
    save="yes"
    replace="{global:stash_cache_replace}"
    scope="site"
    bundle="news"
}
    {exp:channel:entries
        channel="news"
        disable="member_data|pagination"
        dynamic="no"
        status="{global:entry_statuses}"
    }
        {stash:item-id}{entry_id}{/stash:item-id}
        {stash:item-title}{title}{/stash:item-title}
        {stash:item-date}{entry_date}{/stash:item-date}
        {stash:item-url}{if page_url}{page_url}{if:else}{url_title_path=news}{/if}{/stash:item-url}
        {stash:item-thumb}{news_img}{/stash:item-thumb}

        {exp:stash:set_list:2 name="cats-of-{entry_id}" context="{global:env}"}
            {categories}
                {stash:cat}{category_name}{/stash:cat}
                {stash:cat-url}{path=news}{/stash:cat-url}
            {/categories}
        {/exp:stash:set_list:2}

    {/exp:channel:entries}
{/exp:stash:set_list}

```

(`{global:env}` is set in my config bootstrap and equates to "live" or "dev" depending on the environment, while `{global:entry_statuses}` equates to "open" or "open|draft" depending on the environment).

---
Tags: stash
---


# Question
Title: EE 3.x - Import from EE 2.x to EE 3.x all Snippets
I started with a fresh **EE 3.3.0** installation on my localhost. However, I would like to bring over ALL the Snippets that I am using on my Production website to my brand new localhost EE 3.3.0 site. I exported all the Snippets from the one site, imported them into the EE 3.3.0 site but I do not see them anyplace within EE.

I thought I had seen a note that Snippets had been replaced, but Snippets are referenced in the 3.3.0 Manual and it doesn't appear to have been deprecated.

1. Are Snippets still being used ?
    * Where do I find them in EE 3.3.0 ?
2. If they are no longer being used, what has replaced them ?
    * How do I bring over the existing Snippets into this new object (Table Name) ?

Thanks!!!!

# Answer
It is now called "Template Partials", uses the Snippets table (xxx\_snippets -- where xxx is replaced by your site's prefix". You can export from the old xxx\_snippets table and then insert this into your new xxx\_snippets table.

However, if you have already created Template Partials then you have a couple of choices: a) Delete all existing Template Partials, perform the mas insert of the snippets and add all new Template Partials b) Edit the snippets SQL such that all the IDs are incremented OR set to NULL. \- I personally believe the NULL idea would be best.
> 0 votes

---
Tags: snippets
---


title: Added content not showing up

text:
# Question
Title: Added content not showing up
I'm very new to ExpressionEngine and am currently dealing with updating an existing site. I've been having problems getting new content to show up where its supposed to. I've added content that is the same structure and assigned to the same channel as the current content, but it doesn't show up on the page. I'm really confused since I thought this was supposed to be pretty straightforward. The channel I'm trying to add to is called brand-merchandise here is the design view of the page I'm having problems with: (brands/listing-template)

```
{exp:channel:entries channel="{segment_1}" category="{last_segment_category_id}" dynamic="no" orderby="date" sort="dsc"}
<div class="isotope-item post span8">
    <div class="row">
        <div class="span4">
        {exp:channel_images:images entry_id="{entry_id}" limit="1"}
            <div class="thumbnail post-media">
                <div id="{image:entry_id}" class="carousel slide fadeLeft">
                    <!-- Carousel items -->
                    <div class="carousel-inner">
                        {product_images}
                           <div class="{if {image:count} == 1}active item{if:else}item{/if}">
                               <img src="{image:url:medium}" alt="{image:title}" />
                           </div>
                        {/product_images}
                    </div>
                    <!-- Carousel nav -->
                    {product_images}
                       {if {image:total} > 1}
                          <a class="carousel-control left" href="#{image:entry_id}" data-slide="prev"><i class="icon-angle-left"></i></a>
                          <a class="carousel-control right" href="#{image:entry_id}" data-slide="next"><i class="icon-angle-right"></i></a>
                       {if:else}
                          {if segment_1 != "retail-products"}
                             <div class="thumbnail-hover">
                                <a href="{page_url}"></a>
                             </div>
                          {/if}
                       {/if}
                    {/product_images}
                </div>
            </div>
        {/exp:channel_images:images}
     </div>

     <div class="span4">
         <div class="post-content">
             <div class="post-title">
                 <h2>{title}</h2><br>
             </div>

             <div class="post-excerpt">
                {product_description}<br><br>
             </div>

             {if segment_1 != "retail-products"}
                <div class="stylish-button">
                    <a href="{page_url}">view work</a>
                </div>
             {/if}
         </div>
     </div>
 </div>
</div>
{/exp:channel:entries}

```

# Answer
To the exp:channel:entries tag, you need to add status="not closed" or any other custom statuses you might have defined.
> 0 votes

---
Tags: ee2
---


# Question
Title: Video Training Site built with Expression Engine
I'm looking to build a billing video training site with Expression Engine so I'm wondering if anyone in this community has built one and what add-ons you recommend.

Thank you!

# Answer
> 0 votes
For your addons inventory, you might consider

* Stash
* Channel Videos
* Channel Images
* Matrix
* Low Search
* Low Variables
* Visitor
* CartThrob2

to build the site you mentioned.

---
Tags: ee2, ee, video
---


# Question
Title: Codeigniter style validation callback function not working
I've created an EE custom addon that processes a simple enquiry form. All works well but I'm trying to add a callback function to my validation rules and it appears to be completely ignored.

Here's my call to the validation rule:

```
ee()->form_validation->set_rules('url', 'URL', 'callback_honeypot'); // Honeypot field

```

and my callback function (which is in the same file) is:

```
public function honeypot($input)
{
    if (!empty($input))
    {
        ee()->form_validation->set_message('honeypot', '<p>Not all is as it should be...</p>');
        return FALSE;
    } else {
        return TRUE;
    }
}

```

Will the standard CI form validation callback method not work with EE?

**Update / workaround:**

Although I haven't got the callback method to work, a simple workaround for (in my case) a honeypot field is to hide the field on the frontend form and use something like this:

```
ee()->form_validation->set_rules('nickname', 'Nickname', 'max_length[1]');

```

So if the 'nickname' field has more than one character entered into it, the validation fails.

Alternatively, you could do this:

`$honeypot_field = ee()->input->post('nickname', TRUE);`

and only process the form if the following conditions are met:

`if (ee()->form_validation->run() == TRUE && (empty($honeypot_field)))`

But it doesn't answer the question of why the proper CI callback functionality doesn't work in EE.

# Answer
The first thing I would do is check that your conditional is running as expected.

```
if (!empty($input))
{
echo "I have Input"
exit();
}else{
echo "I have no Input"
exit();
}

```

Also, not all CodeIgniter functions are available in EE's branch, though this one seems to be there.
> 0 votes

---
Tags: add-on-development, validation
---


title: remove a range of channel entries

text:
# Question
Title: remove a range of channel entries
I have the following entries. I would like to only display only a range from entry 5 and on. how do i remove 1-4 from the entries and keep the rest?

**Entries**

* 2016-02-08 Entry 1
* 2016-03-01 Entry 2
* 2016-03-29 Entry 3
* 2016-05-02 Entry 4
* 2016-05-15 Entry 5
* 2016-05-30 Entry 6
* 2016-09-12 Entry 7
* 2016-10-24 Entry 8
* 2016-11-01 Entry 9
* 2016-12-06 Entry 10

**Code**

```
            {exp:channel:entries channel="events" orderby="event_start_date" sort="asc"}
                 {event_start_date format='%Y-%m-%d'} {title}

            {/exp:channel:entries}

```

# Answer
> 0 votes
If you want to always skip a set number of entries you can use `offset=x` as described in the docs: https://docs.expressionengine.com/latest/channel/channel\_entries.html#offset

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


# Question
Title: Conditional statement error inside relationship field
I have a relationship problem and I figured Stack Exchange can help ;)

I'm using the standard relationship field in EE 2.8.1 but the conditional statement just keeps throwing an error;

```
{cf_campaign_accommodation}
{cf_campaign_accommodation:placetostay_addressline1}
{if "{cf_campaign_accommodation:placetostay_addressline2}" != ""}{cf_campaign_accommodation:placetostay_addressline2}, {/if}
{/cf_campaign_accommodation}

```

{cf\_campaign\_accommodation} is the relationship field. When I load the template, Google Chrome throws a "This site can't be reached. ERR\_CONTENT\_DECODING\_FAILED" error.

I have also tried the following but neither of these work;

```
{if '{cf_campaign_accommodation:placetostay_addressline2}' != ''}{cf_campaign_accommodation:placetostay_addressline2}, {/if}

{if cf_campaign_accommodation:placetostay_addressline2 != ""}{cf_campaign_accommodation:placetostay_addressline2}, {/if}

```

Wondered if anyone else has seen a similar issue or knows of a solution?

Thank you.

# Answer
An error reported by Google Chrome won't be linked to a problem with this field - you'd get an error from EE (what kind depends on what the error is).

If you are not seeing an EE error perhaps this code is working OK and the error is somewhere else.

A good simple check is simply to temporarily remove the `{if}` clause and output the content of the field always - just so you can make sure that the field is generating the content you expect.

If it is, then you can review the `{if}` logic again confident that you know what content is etc. If when you find that the field is always blank then you need to track down where the missing information is...

Another option would be to change the logic - you could use something like this:

```
{cf_campaign_accommodation}
  {cf_campaign_accommodation:placetostay_addressline1}
  {if ! cf_campaign_accommodation:placetostay_addressline2:no_results}
    {cf_campaign_accommodation:placetostay_addressline2},
  {/if}
{/cf_campaign_accommodation}

```

I've not tested this and wonder about the use of the `!` operator - but if that doesn't work you could do something using `{if:else}` such as:

```
{cf_campaign_accommodation}
  {cf_campaign_accommodation:placetostay_addressline1}
  {if cf_campaign_accommodation:placetostay_addressline2:no_results}
    {!- Do nothing -}
  {if:else}
    {cf_campaign_accommodation:placetostay_addressline2},
  {/if}
{/cf_campaign_accommodation}

```

HTH
> 0 votes

---
Tags: relationships, conditionals
---


# Question
Title: Is there any way to add 'save cart for later' functionality to CartThrob?
I would like to offer customers (who may have complex orders, with cart contents gathered over several weeks) the opportunity to save their cart for later, in order to complete their order on a subsequent visit, or visits. Is there any way to achieve this functionality with CartThrob?

I understand that the wishlist addon allows customers to assemble a list of products which can later be added to a cart, but the likely scenario is that customers have already started adding products to their order, and then realise that they will need to complete it later.

EDIT: it seems that CartThrob actually stores cart data in the DB and sets a cookie to associate user with cart. So perhaps it would just be necessary to modify Cartthrob\_session.php to extend the length of the session cookie?

Can anyone confirm?

# Answer
> 0 votes
This is achievable by enabling the `save_order` gateway in settings. The customer effectively performs a "checkout" like they normally would, but by using the save\_order gateway, no payment is taken and the order is set to a status you choose in the settings area. You can then use something like the CT Order Loader to load the order back in to the cart at a later date.

I found that I needed to make a few tweaks to the Order Loader plugin, as it's not very secure in its current form: https://github.com/CartThrob/plugin-load-order (there are no checks that the order being loaded was created by the currently logged-in user). It also doesn't clear the cart before loading in a new order. Easy enough to add those things though.

---
Tags: cartthrob, shopping-cart
---


# Question
Title: conditional statment to display all entries that are from today and forward
Have

* events channel
* have 10 entries
* have a date field called event\_start\_date

Desire \- display only up coming events in asc order

List

* 2016-12-06
* 2016-11-01
* 2016-10-24
* 2016-05-30
* 2016-09-12
* 2016-05-15
* 2016-05-02
* 2016-03-29
* 2016-03-01
* 2016-02-08

Code:

```
{exp:channel:entries channel="events" orderby="event_start_date" sort="asc"}
  {if {event_start_date format='%Y-%m-%d'} >= {current_time format='%Y-%m-%d'}}
    {event_start_date format='%Y-%m-%d'}<br>
  {/if}
{/exp:channel:entries}

```

Results:

```
2016-02-08
2016-03-01
2016-03-29
2016-05-02
2016-05-15
2016-05-30
2016-09-12
2016-10-24
2016-11-01
2016-12-06

```

Desired

```
2016-05-15
2016-05-30
2016-09-12
2016-10-24
2016-11-01
2016-12-06

```

What am i doing wrong?

Final working code:

```
{exp:channel:entries channel="events" orderby="event_start_date" sort="asc" search:event_start_date=">={current_time}"}
    {event_start_date format='%Y-%m-%d'}<br>
{/exp:channel:entries}

```

# Answer
Try using the search parameter - https://docs.expressionengine.com/v2/add-ons/channel/channel\_entries.html#search-field-name

```
search:event_start_date=">={current_time}"

```

How are you storing your date field? unix, mysql??
> 0 votes

# Answer
It would be much simpler if you were to use the EE default `{entry_date}` that way you could use `start_on=` with `show_future_entries="yes"`:

```
{exp:channel:entries channel="events" start_on="{current_time}" orderby="date" show_future_entries="yes"}
...
{/exp:channel:entries}

```

As per the documentation

Your current use of a custom field will return, lets say 30 entries and then you'll subsequently have to query, each of those 30 entries, one at a time, if this fields value is greater then the current date - all of which is an expensive DB/EE operation.

**PS.** Your conditional, is trying to compare a string that includes operators it should be just numbers. Try removing the `format=` part from your tag.
> 0 votes

---
Tags: conditionals, date
---


title: NSM Better Meta & Using EE Layouts

text:
# Question
Title: NSM Better Meta & Using EE Layouts
What is the propper way to use NSM better meta and layouts?

At the moment, my layout has the NSM tag in the head, I've wrapped some channel entry tags around it. Not sure if this is the correct way to use it?

```
{exp:channel:entries require_entry="yes" limit="1" dynamic="yes"}
{exp:nsm_better_meta:template entry_id="{entry_id}"}
{/exp:channel:entries}

```

I also have another problem, how do I deal with the homepage? I can't seem to pull any nsm data through.

The homepage entry\_id is 1, with a status of hidden.

When I was using embeds I used...

```
{embed="/includes/head" title_prefix="Site" hide_site_title="y" entry_id="1"}

```

But with layouts I can't use those parameters.

# Answer
Set a layout variable for the `entry_id`, then instruct NSM Better Meta to use that if it exists.

In your entry template:

```
{layout:set name="entry_id" value="{entry_id}"}

```

(This would have to be within a `channel:entries` loop obviously.)

Then in your layout template:

```
{exp:nsm_better_meta:template{if layout:entry_id} entry_id="{layout:entry_id}"{/if}}

```
> 0 votes

---
Tags: template-layouts, metadata, layouts
---


title: Events sorted by month?

text:
# Question
Title: Events sorted by month?
I have just upgrade to Calendar 2.0.5 and I used to have a template that generated a list of events sorted by month using the {display\_each\_month} loop within {exp:calendar:cal} tag. Now that the cal tag no longer exists I can't figure out how to do this...

```
<ul>
{exp:calendar:cal sort="asc" dynamic="no" calendar_name="events" date_range_start="today" show_months="3" pad_short_weeks="n"}
{display_each_month}  <br/>
<p><strong>{date format="%F"}</strong></p>
{if month_event_total == "0"}<li>There are no events scheduled for {date format="%F"}.</li>{/if}
{events}
<li><strong>{event_start_date format="%d"}</strong> - {event_title}</li>
{/events}
{/display_each_month}

{/exp:calendar:cal}

```

# Answer
I'm assuming it's the Month headings you want included in the list? Unfortunately this is currently not possible with Calendar 2. The closest you could get would be this code, but it would not give you any month headings:

```
<ul>
{exp:calendar:events
    channel="events"
    date_range_start="today"
    date_range_end="3 months"
    limit="50"
}
    <li>
        <a href="{path='calendar/events'}/{calendar:url_title}/">{calendar:title}</a>
        ({calendar:event_start_date format="%F %j, %Y"})
    </li>
    {if calendar:no_results}
        <li>No results found.</li>
    {/if}
{/exp:calendar:events}
</ul>

```
> 0 votes

---
Tags: solspace-calendar
---


title: trigger postmaster in an "api" request

text:
# Question
Title: trigger postmaster in an "api" request
Hi trying to make an API call that triggers a postmaster update parcel

looked at this post

I'm called my plugin from at jquery ajax call , all working fine can update the entry with the db class

```
$updateQuery = ee()->db->
            update('exp_channel_data',
                array(
                    'field_id_85' => "tester"
                ),
                array(
                    'field_id_73' => $user['userdata'][0]['field_id_73']
                )
        );

```

But I would like to trigger postmaster (entry updated)

```
$this->EE->api_channel_entries->save_entry($data, (int)$user['userdata'][0]['channel_id'], (int)$user['userdata'][0]['entry_id']);

```

Like descibed in the post link above - but getting an error - do I need to login or is there another way to trigger a postmaster parcel ?

any help would be appreciated :)

# Answer
> 0 votes
Aha found out I have to be loggedin : ( using start , end session )

```
$this->startTempSession();

ee()->load->library('api');
ee()->api->instantiate('channel_entries');
ee()->api->instantiate('channel_fields');

ee()->api_channel_fields->setup_entry_settings($channel_id, $edit_array);
$saveResult = ee()->api_channel_entries->save_entry($edit_array, $channel_id , $entry_id , FALSE);

```

ee()-\>session-\>destroy();

Start and session destroy :

```
public function startTempSession()
{
    $ee = ee();
    if (!class_exists('Channel_from_session')) {
        require_once PATH_MOD . 'channel/libraries/channel_form/Channel_form_session.php';
    }

    $tmpSession = $ee->session;
    $tmpSession->userdata['can_edit_other_entries'] = 'y';

    $ee->session = new Channel_form_session(array(
        'session_object'       => $tmpSession,
        'logged_out_member_id' => 1,
        'logged_out_group_id'  => 1
        ));
}

```

Please comment if there is a better way of doing this : just got here through trial n error ...

---
Tags: plugin, postmaster
---


title: Having trouble with EE3 and NavEE

text:
# Question
Title: Having trouble with EE3 and NavEE
I am using EE 3.2.1 and NavEE 3.1.0

I am having trouble with the `{is_selected}` parameter and the home page displaying in breadcrumbs.

I have the following for my nav:

```
<!-- Navigation
================================================== -->
<nav id="navigation" class="style-1">
    <div class="left-corner">
        <div class="right-corner">
            <ul class="menu" id="responsive">
                {exp:navee:custom
                    nav_title='primary'
                    wrap_type='none'
                }
                    <li><a href="{link}" {if '{is_selected}' == TRUE}id="current"{/if}><i class="halflings white {custom}"> {text}
{/exp:navee:custom}
            </ul>
        </div>
    </div>
</nav>

```

I have also tried:

```
{if is_selected}id="current"{/if}

```

What am I doing wrong here?

Also the home page/link is not displaying in `{custom_crumbs}` and `{last_anchor}` is not working in the following:

```
<nav id="breadcrumbs">
    <ul>
        <li>You are here:</li>
        {exp:navee:custom_crumbs
            wrap_type="none"
            no_last_anchor="true"
        }
            <li><a href="{link}">{text}</a></li>
        {/exp:navee:custom_crumbs}
    </ul>
</nav>

```

# Answer
This was due to an issue with NavEE. (See email)

> Hey Brian,
>
> Didn't need to FTP in or anything - just needed to look at your setup. I've been able to recreate the bug and it was a combination of the Prefix with Site URL + the selected state regex stuff. I simplified the way I add those prefixes, but forgot to take that into account when cleaning the URI for comparison.
>
> Can you give this version a try and let me know if it works for you? Don't forget you need to add back in the {if is\_selected} stuff and/or just use the {class} variable.
>
> MW

Like always, Michael was great to get to the issue quickly and respond with a provided solution. All is well in the world again now.
> 0 votes

# Answer
Try this

```
<!-- Navigation
================================================== -->
<nav id="navigation" class="style-1">
    <div class="left-corner">
        <div class="right-corner">
            <ul class="menu" id="responsive">
                {exp:navee:custom
                    nav_title="primary"
                    wrap_type="none"
                    selected_class="current"
                }
                    <li><a href="{link}" {if class}id="{class}"{/if}><i class="halflings white {custom}"> {text}
                {/exp:navee:custom}
            </ul>
        </div>
    </div>
</nav>

```
> 0 votes

---
Tags: ee3, navigation, navee
---


# Question
Title: channel entries bulk entry input or import
We are moving from another system to EE. We have over a few dozen to 100s of line items.

Is there a way to add/upload content to expression engine like a database dump or some addon that allows like multiple entries in one interface so you can add all the data in one page?

hope i'm making sense :) lack of sleep...

# Answer
> 0 votes
http://brandnewbox.co.uk/products/details/datagrab is normally the go to addon for importing data.

You'll need your data in CSV, Json, or XML format.

I'd suggest doing some trial runs on a test installation so you can get everything working, then apply to your dev site.

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


# Question
Title: display category and child id’s separately for masonary filtering
I am using masonry filters to filter entries on a template using category ID’s to differentiate

Filter buttons:

```
    <div class="masonry-filters">
<ul data-option-key="filter">
<li><a class="selected" href="#" data-option-value="*">All</a></li>
   {exp:query sql="
        SELECT *
        FROM exp_categories
        WHERE group_id IN (4)
        ORDER BY cat_name ASC"}
          <li><a href="#" data-option-value=".mansonry-filter-{cat_id} ">{cat_name}</a></li>
        {/exp:query}
</div>

```

Then each entry has the category id in the class for filtering:

```
<article class="masonry-item col-sm-6 col-md-4 mansonry-filter-{categories}{category_id}{/categories} hentry">

```

The problem I have is an entry has a parent AND child category they will not be included in the filter because the ID’s are combined.

ie: USA cat id = 11 New York child id is 65 So this entry’s class will be 1165. I need to separate them so I have just the parent 11 ideally also have 65 as a separate class but not sure how that will work with my filtering.

This would be my goal:

```
class="masonry-item col-sm-6 col-md-4 mansonry-filter-11  mansonry-filter-65 hentry"

```

EDIT: I think this is my solution

```
<article class="masonry-item col-sm-6 col-md-4 {exp:gwcode_categories entry_id="{entry_id}" style="linear"} mansonry-filter-{cat_id} {/exp:gwcode_categories} hentry">

```

# Answer
I might be missing something but aren't you able to accomplish that like this?

```
<article class="masonry-item col-sm-6 col-md-4 {categories}mansonry-filter-{category_id} {/categories} hentry">

```

This would output what you desire. I know nothing about masonry filters.
> 0 votes

---
Tags: categories, gwcode-categories
---


title: 'IF' Conditional Not Working

text:
# Question
Title: 'IF' Conditional Not Working
I want to set up a conditional that when correctly running will post a 'widget' on the sidebar based on the entry. I have eight events (concerts) and three venues. On the individual detail page, I want the correct venue to show up, which is the 'widget.'

I have tried several ways, and I am getting nowhere. I am lost.

```
{if segment_3 == "opening_night_concert1" XOR "the_greats" XOR    "a_woodwind_affair"}

{exp:channel:categories style="linear" channel="sidebar_widgets" show="6" }
    <h4>{category_name}</h4>
{/exp:channel:categories}

{exp:channel:entries channel="sidebar_widgets"  dynamic="no" category="6"}
    <a href="/index.php/site/contact"><img src="{widget_photo}" class="img-responsive img-hover" alt="{title}" /></a>
    <div id="widget">{widget_copy}</div>
{/exp:channel:entries} {/if}

```

# Answer
> 1 votes
It needs to look like this:

```
{if segment_3 == "opening_night_concert1" XOR segment_3 == "the_greats" XOR    segment_3 == "a_woodwind_affair"}

```

---
Tags: conditionals, ifelse
---


# Question
Title: Category Parent & Children Loop Layout Help
I'm trying to create a specific layout that makes use of categories and category children. I'm trying to use GW Code Categories but can't seem to make the layout work as I need it to.

I basically need to loop through parent categories with title & description and then within that loop, go through all child categories and display title, description & image.

This is the code to be looped. I've put in descriptive variables to illustrate what I'm trying to do.

```
<!-- This is the main parent category loop -->
<div class="product-group">
    <div class="row">
        <div class="col-2-3 centered text-center">
            <h1 class="margin-none">{parent_cat_name}</h1>
            <p>{parent_cat_description}</p>
        </div>
    </div>

    <div class="row">
        <div class="col-2-3 centered">
                <div class="grid product-grid">
                    <!-- This is the child category loop -->
                    <div class="grid-item grid-item-2">
                        <div class="cell">
                            <a href="#"><img src="{child_cat_image}" /></a>
                            <h2>{child_cat_name}</h2>
                            <p>{child_cat_description}</p>
                        </div>
                    </div>
                    <!-- This is the end of the child category loop -->
                </div>
            </div>
        </div>
    </div>
</div>
<!-- End of the main parent category loop -->

```

So this entire block will loop for however many parent categories there are. And then the child categories will loop within the parent categories.

Is there a way to get this to work with GW Code Categories or any other plugin or native way?

Hope this makes sense.

Thanks for any help.

# Answer
> 0 votes
I decided to go a different route using just parent categories and making the child categories channel entries. Got everything working as I needed to using this method and also took the headache out of using categories in general.

---
Tags: categories, gwcode-categories, child-categories
---


# Question
Title: Clean 301 redirects using an .htaccess that also removes index.php
I've got a somewhat standard `.htaccess` for removing `index.php` from my EE1 URLs:

```
RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_URI} ^/$ [NC]
RewriteCond %{QUERY_STRING} ^(utm_source=.*)
RewriteRule ^(.*)$ /index.php?/ [L,PT]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{QUERY_STRING} (.+)
RewriteRule ^(.*)$ /index.php?/$1&%1 [L]

```

What I need to do is redirect calls to a subfolder (`/store`) to a new subdomain (`store.example.com`). So I added this line at the top:

```
Redirect 301 /store http://store.example.com/

```

Unfortunately, the end result is that I get redirected to `http://store.example.com//?/store/`

I've tried a few variations, such as moving the line to the bottom, but nothing worked properly.

How can I do a 301 redirect (using `.htaccess`) without including the extra `/?/store/` bit at the end?

# Answer
Try a RedirectMatch rule and see what you get:

```
RedirectMatch 301 ^/store/?$ http://store.example.com

```
> 1 votes

# Answer
This is what we use to redirect a directory to a subdomain

```
RewriteRule ^trade* http://trade.domain.com/    [R=301,L]

```
> 1 votes

---
Tags: htaccess, redirects, rewrite
---


title: Relate channel entries to members?

text:
# Question
Title: Relate channel entries to members?
Can you relate channel entries to members?

I need to be able to create a channel into which entries are posted and a relationship field is shown so that I can select a member that the entry pertains to.

I want to then use this relationship to show these entries to those logged in members on the front end of the site.

# Answer
> 0 votes
I knew somebody had to have done this already. https://devot-ee.com/add-ons/member-list-custom-field

---
Tags: members, relationships, related
---


# Question
Title: Unable to locate the model you have specified
I installed vwm\_secure\_files and now when I try and edit ANY channel field I am getting this error and cannot do anything

> An Error Was Encountered Unable to locate the model you have specified: vwm\_secure\_files\_m

EE. 2.5.3 VWM Secure Files .3

# Answer
> 2 votes
This is an EE bug. They changes some things in EE 2.5.3, which has effected almost all of my add-ons. Definitely contact the developer, it's a relatively easy fix. In my case I just abandoned the `$this->EE->load->model()` method entirely, along with the config too. It's entirely unreliable. It particularly fails in `__construct()` methods.

Here is how I usually fix the code.

```
 require_once PATH_THIRD . 'your_addon/models/your_model.php';
 $this->EE->your_model = new Your_model();

```

# Answer
> 0 votes
The problem is that the module is not registered when the model is called. We just need to check it is registered or not.

Open "vwm\_secure\_files\models\vwm\_secure\_files\_m.php" look for this line
`class Vwm_secure_files_m extends CI_Model {`

add the following code above it:

```
if ( ! class_exists('Vwm_secure_files_m'))    {
    require_once realpath(rtrim(dirname(__FILE__), "/") . '/../mod.vwm_secure_files.php');
}

```

Please note I was using: EE 2.5.2

---
Tags: add-on
---


# Question
Title: Strange CE Image / Stash / Low Search problem
I have a strange problem where a CE Image tag is outputting fine for one Stash list but not another but only when within a Low Search results tag, works fine in a normal channel entries tag.

**APPEND LIST**

```
{product_styles search:code="not IS_EMPTY"}
  {exp:stash:append_list
    name="product_images_{entry_id}"
  }
    {stash:product_lg}
    <img src="{exp:ce_img:single
      src='{image}'
      width='350'
      height='350'
      crop='yes'
      quality='85'
      url_only='yes'
      allow_scale_larger='yes'
      interlace='yes'}">
    {/stash:product_lg}
    {stash:product_options}
      <option
        value="{title} {code}"
        data-thumb="{exp:ce_img:single
          src='{image}'
          width='50'
          height='50'
          crop='yes'
          quality='85'
          url_only='yes'
          interlace='yes'}"
      >{code} {title}</option>
    {/stash:product_options}
  {/exp:stash:append_list}
{/product_styles}

```

**OUTPUT**

```
{exp:stash:get_list name="product_images_{entry_id}"}
{product_lg}
{/exp:stash:get_list}

{exp:cartthrob:add_to_cart_form}
  <select>
    {exp:stash:get_list name="product_images_{entry_id}"}
    {product_options}
    {/exp:stash:get_list}
  </select>
{/exp:cartthrob:add_to_cart_form}

```

So with the above, I get a series of images output fine where `{product_lg}` is, but where `{product_options}` is, it's outputting `<option value="XXXXX" data-thumb="{exp:ce_img:single src='filename.jpg'… ">XXXXX</option>`, i.e. parsing the CE image tag inside the `option`.

Which I can't work out because it's essentially the same tag just with slightly different parameters. Anyone have any ideas what's going wrong? :?

# Answer
> 1 votes
You're using the single tag form of `{exp:ce_img}`, and if you repeat an instance of a single tag in the same template EE will "cache" subsequent instances after parsing the first (replaces with a random-string marker, with the intention of replacing with the value at the end of parsing). You can either append the word `random` at the end of the ce\_img tag parameters, or cause the image to be fully parsed when the list is appended by using `parse="yes"`.

---
Tags: stash, low-search, ce-image
---


# Question
Title: Proper way to add PHP code in Expression engine Template?
I am new in Expression engine. I know that We can not write PHP code in template due to security reason. I want to know the flow like from where can write php code and how it will render in my template ?

# Answer
Which version of EE are you working with?

EE allows use of PHP in templates, but there are security factors to be aware of before you enable it, so you have to enable PHP processing on a per-template basis. PHP should not be a problem provided you have a good control of who can edit templates in your EE setup - vis:

> Enabling PHP in a template will enable anyone with editing rights for that template to become a de-facto Super Admin since they can execute any PHP they want in that template

You can find out more about how to embed PHP in EE templates from the EE documentation

EE2 - https://docs.expressionengine.com/v2/templates/php.html

EE3 - https://docs.expressionengine.com/latest/templates/php.html

HTH
> 1 votes

---
Tags: php
---


# Question
Title: CartThrob: Setting up different state/region options in checkout process
I've got a site running CartThrob v2.7. For the checkout process, I'm using `{exp:cartthrob:state_select}` and `{exp:cartthrob:country_select}` tags to help populate the checkout form's "State" and "Country" select menus. Since the site in question primarily deals with American customers, those menus default to U.S. options.

But is there an easy way to use those same tags to make the form work with non-U.S. options? Basically, I'd like the user to be able to select "Canada" from the "Country" menu, and have the "State" menu switch to displaying Canadian provinces.

I know CartThrob can handle different locales but the docs implied that that's primarily for initial config. I'm looking for something "on the fly." Right now, it looks like I'd have to manually build the "State" and "Country" menus instead of using those CartThrob tags, make sure they automatically select the appropriate options for any currently logged-in users, and then use JS to repopulate the "State" menu based on what's selected in the "Country" menu. Which is fine, but I was hoping for an easier solution.

# Answer
That page you linked to should be helpful even though it's more for showing in one list instead of using a JS helper. It has a pre-filled list of man countries and their states, so if you were writing your own EE plugin, you could `include` that files and use its arrays to build separate dropdowns from there.

You can also consider using something like this: https://devot-ee.com/add-ons/reegion-select
> 0 votes

---
Tags: cartthrob
---


title: Authors: User field type not installed?

text:
# Question
Title: Authors: User field type not installed?
I might misunderstand something here - so sorry in advance if this is a dumb question.

We have purchased User and installed it on a clean install of EE2:

* EE 2.11.1
* User 3.5.3 for EE 2.x

I am not working on a prototype for a required custom functionality using Related. This is what the documentation has to say:

*To create a Related Authors field, you must select a custom fieldtype of User with the sub field of Related Authors.*

I presume this is a channel custom field type? It seems not to be available as a *field type* when I try to add it as a custom field.

When checking Add-Ons --\> Fieldtypes, User is not on the list (neither with status *Installed* nor *Not Installed*).

I checked the module preferences and do not see a specific setting that I have missed.

What am I doing wrong? Is Related Authors only available in User 4.x?

ED

# Answer
Things were a little bit backwards for User in EE 2.x. Also, the instructions you're looking at are for User 4.x for ExpressionEngine 3. You need to reference the documentation for User 3.x when using ExpressionEngine 2.

To create the User Authors "fieldtype", you need to:

1. Go to Preferences tab in User module control panel area
2. At bottom of page, enter a name for the "tab" to add to the publish page where User Authors "field" will be
3. Submit/save page

You don't have to keep your User Authors field in that tab either. You can simply visit the Publish page and edit the layout to have the User Authors "field" on your main tab and remove the User Authors "tab" from the layout. :)
> 0 votes

---
Tags: solspace-user
---


# Question
Title: Can a customer save their cart to an invoice?
We have a client whose shipping needs are complicated enough that they currently only allow checkout for customers with their own shipping accounts. They would like to be able to open up their checkout process to allow purchases where the customer may not have their own shipping account.

I don't have any experience with CartThrob Invoice, which seems like it may make it possible for our client to create an invoice and add their own shipping cost. But would it be possible for a customer to somehow save their order as an invoice? Or maybe use the Save Order payment gateway, and then convert that saved order into an invoice so the shipping could be updated?

# Answer
Thanks for providing the information in the comment above. Unfortunately I don't think there's a built-in way to programmatically do this. However, the `exp_cartthrob_invoice_table` is pretty straightforward. You should consider an extension that fires after an order is placed (potentially via the "offline payments" or "Save Order" gateways) that takes their info and `INSERT`s a row into `exp_cartthrob_invoice_table`.

Here's the structure of that table:

```
CREATE TABLE `exp_cartthrob_invoice_table` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `inv_description` text,
  `inv_title` text,
  `inv_line_items` text,
  `inv_cost` varchar(12) DEFAULT NULL,
  `inv_total_hours` varchar(12) DEFAULT NULL,
  `inv_status` varchar(20) DEFAULT NULL,
  `inv_date` int(11) DEFAULT NULL,
  `inv_paid_date` int(11) DEFAULT NULL,
  `inv_email_address` varchar(255) DEFAULT NULL,
  `inv_member_id` int(10) DEFAULT NULL,
  `inv_order_id` int(10) DEFAULT NULL,
  `inv_reference_number` varchar(1000) DEFAULT NULL,
  `inv_first_name` varchar(255) DEFAULT NULL,
  `inv_last_name` varchar(255) DEFAULT NULL,
  `inv_company` varchar(255) DEFAULT NULL,
  `inv_address` varchar(255) DEFAULT NULL,
  `inv_address2` varchar(255) DEFAULT NULL,
  `inv_city` varchar(255) DEFAULT NULL,
  `inv_state` varchar(5) DEFAULT NULL,
  `inv_zip` varchar(10) DEFAULT NULL,
  `inv_country_code` varchar(3) DEFAULT NULL,
  `inv_phone` varchar(15) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=103 DEFAULT CHARSET=utf8;

```

And here's a sample row. The `inv_line_items` column is a `base64_encode()`d JSON object.

```
INSERT INTO `exp_cartthrob_invoice_table` (`id`, `inv_description`, `inv_title`, `inv_line_items`, `inv_cost`, `inv_total_hours`, `inv_status`, `inv_date`, `inv_paid_date`, `inv_email_address`, `inv_member_id`, `inv_order_id`, `inv_reference_number`, `inv_first_name`, `inv_last_name`, `inv_company`, `inv_address`, `inv_address2`, `inv_city`, `inv_state`, `inv_zip`, `inv_country_code`, `inv_phone`)
VALUES
    (1, 'Test Invoice', 'Test Invoice', 'YToxOntpOjA7YTo0OntzOjEwOiJpdGVtX3RpdGxlIjtzOjQ6InRlc3QiO3M6MTY6Iml0ZW1fZGVzY3JpcHRpb24iO3M6NDoidGVzdCI7czo1OiJob3VycyI7aToyO3M6OToiaXRlbV9jb3N0IjtpOjI1MDt9fQ==', '250', '2', 'pending', 1382031430, NULL, 'test@test.com', 0, NULL, '', 'John', 'Smith', '', '', '', '', '', '', '', '');

```

Feel free to contact us at support@cartthrob.com if you'd like help implementing this!
> 0 votes

---
Tags: cartthrob
---


title: Super search with Playa and Matrix

text:
# Question
Title: Super search with Playa and Matrix
I'm currently building a product website with a Super Search search, which needs to find keywords in Matrix data through a Playa field. My structure is looking like this:

**Channel Product** \- Custom field: Articles (Playa field type, links one or multiple entries to Product list channel). Field is set to searchable.

**Channel Product list** \- Custom field: Product\_table (Matrix field type). Field and columns 'article code' and 'article description' set to searchable.

Channel Product, field **'articles'** \[*Playa fieldtype*\] =\> Channel Product list, field **'product\_table'** \[*Matrix fieldtype*\]

What I have is a single (keyword) input field in my search form, which redirects to the results page. I want the search function to find entries in the channel 'Product' through the Playa field (so linked Product list entries are not shown separately).

I first set up the channel fields and search preferences, and after that I published and linked the entries.

This is my code:

```
{exp:super_search:results channel="products" highlight_keywords="em" limit="50" status="open"}
<!-- HTML Markup -->
{/exp:super_search:results}

```

I am however not getting it to work. It looks like the Matrix data is not searched for the keyword. When I pass the column via GET parameters (*/search?product\_list\_table:article\_code=XXXX*), I do get the result I want. However, my search function should only consist out of 1 field (the keyword field) and should search in other custom fields as well.

Is this even possible?

# Answer
The issue is that Playa only stores the **Title** of the selected entry in its `exp_channel_data` field, and since you're searching the `products` channel, Super Search will only look for matching keyword data in that channel's `exp_channel_data` fields. It won't "follow" Playa fields to also look at all the field content for child entries.

Unfortunately your particular setup is not well-suited to search in this way.
> 0 votes

---
Tags: matrix, playa, supersearch
---


# Question
Title: EE3 pagination loop incompatible with Bootstrap
I'm building a site using EE 3.3.1 and Bootstrap 3.3.6

I'm trying to output a list of news articles which are paginated. But the only way I can show the pagination is to repeat the channel entries query further down the page, because otherwise it causes repetitions of the markup.

This is the area where the problem starts:

```
<div class="row">

    <div class="col-md-9">
        {exp:channel:entries channel='news' orderby='date' sort='desc' limit="10" paginate="bottom"}
        <div class="col-md-6 mb-45">
            <h3 class="mb-25"><a href="{url_title_path='news-article'}">{title}</a></h3>
        </div>
        {/exp:channel:entries}

    </div><!-- /.col-md-9 -->

    <div class="col-md-3">
        <div class="row">
            <h4>Browse by category</h4>
            {exp:channel:categories show_empty="no" category_group="4"}
            <a href="{path='news/index'}"{if active} class="active"{/if}>{category_name}</a>
            {/exp:channel:categories}
        </div>
    </div><!-- /.col-md-3 -->

</div><!-- /.row -->

```

The pagination code needs to be inside

```
    {exp:channel:entries} {/exp:channel:entries}

```

But I want to display it at the bottom of the page, therefore it needs to be outside

```
    <div class="row">  </div>

```

I can't move the closing

```
           {/exp:channel:entries}

```

tag lower down, otherwise it will repeat all the markup (e.g. where Browse by Category, see .col-md-3) up to 10 times (10 being the limit on the query).

The only solution I came up with was to add this outside the original row. But this means repeating the query, which is not DRY.

```
<div class="row">
    {exp:channel:entries channel='news' orderby='date' sort='desc' limit="10" paginate="bottom"}
    {paginate}
    {pagination_links}
    <ul class="pagination">
        {first_page}
        <li><a href="{pagination_url}" aria-label="Previous"><span aria-hidden="true">«</span></a></li>
        {/first_page}
        {page}
        <li{if current_page} class="active"{/if}><a href="{pagination_url}">{pagination_page_number}</a></li>
        {/page}
        {last_page}
        <li><a href="{pagination_url}" aria-label="Previous"><span aria-hidden="true">»</span></a></li>
        {/last_page}
    </ul>
    {/pagination_links}
    {/paginate}
    {/exp:channel:entries}
</div>

```

How can I improve this?

# Answer
> 1 votes
You should be put the pagination query within the first channel:entries loop and capture the output using the Stash add-on.

There is a worked example of moving pagination to later on a page in the stash wiki

HTH

---
Tags: pagination, ee3, twitter-bootstrap
---


# Question
Title: Structure field type - how do I get additional entry data to display?
I'm using the Structure field type as pictured.

The only thing my template will output is {field\_name}, which yields:

http://domain.com/my-structure-url

But I need to access/display more info. If I could get the entry\_id or url\_title, I could run a channel entries loop, but it appears that's not available. Ideas?

# Answer
> 0 votes
If you need to get more info from the entry, I think a 'Relationship' field or Playa could be your best option.

# Answer
> 0 votes
Did you check the docs?

http://buildwithstructure.com/tags#tag\_global\_variables

I believe you want to utilize one of these Structure global variables. Something like:

```
{exp:channel:entries entry_id="{structure:page:entry_id}"}

    {title} - Stuff! - {entry_id} - Things!

{/exp:channel:entries}

```

# Answer
> 0 votes
You could use the query module. Find the ID of your Structure field (shown in the Channel Fields table) and then enter the following in your template, replacing the field\_id\_25 with your field ID. This will output the entry id of the selected entry.

```
{exp:query sql="select field_id_25 from exp_channel_data where entry_id={structure:page:entry_id}"}{field_id_25}{/exp:query}

```

---
Tags: channel-entries, structure, fieldtype
---


# Question
Title: Is there a way to be able to translate grid table headers in {exp:channel:form}?
Is there a way to be able to translate data inside grid table in {exp:channel:form}?

I want to change the table headers to be translated.

I also want to change the button to add new rows to something like a translatable word(for example, "add row").

Is this possible with Grid? Or are we stuck with what we input in the channels?

**EDIT**:

My question only applies to the publish form inside a Channel Form tag. I am not looking for a solution that works on the EE Control Panel.

# Answer
Preface: this is just an idea.

You could use Brian Litzinger's Publisher (http://devot-ee.com/add-ons/publisher) on `exp:channel:form` to allow for grid translations.

To change the headers and buttons you could possibly add the grid to the Channel Form, grab the rendered code and paste that into the template directly (rather than letting the field generate the HTML on the fly) and then use Publisher's language tags to translate headers and buttons.

So for example, I might make a Channel Form and tell it to render the grid. Looking at the code I will see that it generates...

```
<table id="testing" class="grid_field_container" cellspacing="0" cellpadding="0">
<tr>
    <td class="grid_field_container_cell">
        <table class="grid_field" cellspacing="0" cellpadding="0">
            <thead>
                <th class="grid_handle"> </th>
                <th width="0%"><b>Column 1</b></th>
                <th width="0%"><b>Column 2</b></th>
            </thead>
            <tbody class="grid_row_container">
                <tr class="grid_row blank_row">
                    <td class="grid_handle"> </td>
                    <td width="0%" data-fieldtype="text" data-column-id="1">
                        <div class="grid_cell">
                            <input type="text" name="testing[rows][new_row_0][col_id_1]" value="" dir="ltr" field_content_type="all" maxlength="256"  />
                        </div>
                    </td>
                    <td width="0%" data-fieldtype="text" data-column-id="2">
                        <div class="grid_cell">
                            <a href="#" class="grid_button_delete" tabindex="-1" title="Delete Row">Delete Row</a>
                            <input type="text" name="testing[rows][new_row_0][col_id_2]" value="" dir="ltr" field_content_type="all" maxlength="256"  />
                        </div>
                    </td>
                </tr>
                <tr class="empty_field">
                    <td colspan="3" class="empty_field first">You have not added any rows of data yet. <a href="#" class="grid_link_add">Add some data?</a></td>
                </tr>
            </tbody>
        </table>
    </td>
    <td class="grid_delete_row_gutter"> </td>
</tr>
<tr>
    <td>
        <a class="grid_button_add" href="#" title="Add Row">Add Row</a>
    </td>
</tr>

```

Well you could now change that to use Publisher "Phrases" (https://boldminded.com/add-ons/publisher/phrases)

```
<table id="testing" class="grid_field_container" cellspacing="0" cellpadding="0">
<tr>
    <td class="grid_field_container_cell">
        <table class="grid_field" cellspacing="0" cellpadding="0">
            <thead>
                <th class="grid_handle"> </th>
                <th width="0%"><b>{phrase:form_col1}</b></th>
                <th width="0%"><b>{phrase:form_col1}</b></th>
            </thead>
            <tbody class="grid_row_container">
                <tr class="grid_row blank_row">
                    <td class="grid_handle"> </td>
                    <td width="0%" data-fieldtype="text" data-column-id="1">
                        <div class="grid_cell">
                            <input type="text" name="testing[rows][new_row_0][col_id_1]" value="" dir="ltr" field_content_type="all" maxlength="256"  />
                        </div>
                    </td>
                    <td width="0%" data-fieldtype="text" data-column-id="2">
                        <div class="grid_cell">
                            <a href="#" class="grid_button_delete" tabindex="-1" title="Delete Row">{phrase:form_delete}</a>
                            <input type="text" name="testing[rows][new_row_0][col_id_2]" value="" dir="ltr" field_content_type="all" maxlength="256"  />
                        </div>
                    </td>
                </tr>
                <tr class="empty_field">
                    <td colspan="3" class="empty_field first">{phrase:form_no-rows} <a href="#" class="grid_link_add">{phrase:form_add-data}</a></td>
                </tr>
            </tbody>
        </table>
    </td>
    <td class="grid_delete_row_gutter"> </td>
</tr>
<tr>
    <td>
        <a class="grid_button_add" href="#" title="Add Row">{phrase:form_add-row}</a>
    </td>
</tr>

```

You would then just set those phrases in your Publisher's control panel and it should do the job.

Bare in mind: this is a bit of a hacky solution, and if Grid's markup changes you'll have to rinse and repeat.
> 1 votes

# Answer
Know it's a 2014 question. To help people looking into this in the future, you can use "Low Replace". Example:

```
{exp:low_replace find="You have not added any rows of data yet|Add some data" replace="No agregaste informacion|Agregar" multiple="yes"}
{field:estudios_en_curso_y_terminados}
{/exp:low_replace}

```
> 0 votes

---
Tags: grid
---


title: Low Search prefetch number of entries

text:
# Question
Title: Low Search prefetch number of entries
I'm trying to pre-fetch the number of results available per year for a specific category of articles.

The loopee module allows me to loop from current year back to 1999. I would like to show a filter available (possibly with the number of entries available) only if there are results for that specific year and that specific category.

Example:

**Sports**

2016(**5**) | 2015(**4**)

```
{exp:channel:categories channel="articles" style="linear"}
    <h1>{category_name}</h1>
    {exp:loopee forint="{current_time format="%Y"}" to="1999" by="-1" parse="inward}
        {exp:low_search:filters query="{segment_3}"}
(IF) ONLY SHOW FOLLOWING CODE IF THERE ARE ENTRIES AVAILABLE
            <span>
                <a href="{low_search:url collection="articles" category="{category_id}" search:anno="{loopee_value}"}">{loopee_value}(X) | </a>
            </span>
(/END IF)
       {/exp:low_search:filters}
    {/exp:loopee}
{/exp:channel:categories}

```

# Answer
> 1 votes
This is not something Low Search can do for you. You generate the form (or links) that contain the parameters to filters. LS uses a combination of native and its own filters, and EE lacks the API to get to *just* a results count based on those params (ie. Generating context-aware totals per parameter value)

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


title: include today's date with expired times

text:
# Question
Title: include today's date with expired times
Overview:

* current time 10:00PM
* event\_start\_date - is a date field
* trying to display all entries from today and all future entries
* i understand \>={current\_time} includes the time as well but start\_on='today' doesn't seem to include entirety of today

Issue:

* It excludes entries that are past the current time and doesn't
* how do you include all entries from the start of today.

List

* 2016-02-08
* 2016-03-01
* 2016-03-29
* 2016-05-02
* 2016-05-15
* 2016-05-17 (9:50 PM)
* 2016-05-18
* 2016-05-18
* 2016-05-30
* 2016-09-12
* 2016-10-24
* 2016-11-01
* 2016-12-06

Code:

```
{exp:channel:entries channel="events" search:event_start_date=">={current_time}"
    {event_start_date format='%Y-%m-%d'}
{/exp:channel:entries}

```

# Answer
> 0 votes
You could try adding date format information to the time entries. Something like:

```
{exp:channel:entries channel="events" search:{event_start_date format='%Y-%m-%d'}=">={current_time format='%Y-%m-%d'}"}
    {event_start_date format='%Y-%m-%d'}
{/exp:channel:entries}

```

The documentation is not clear on how these comparisons are made, but reading across from how comparisons of relative dates are handled suggests that adding format to the date should (or could) work. Worth a try I think.

HTH

---
Tags: list
---


title: display last 6 entries in a channel

text:
# Question
Title: display last 6 entries in a channel
Have

* events channel
* have 10 entries (the channel can have varying range of entries for example it has 10)
* have a date field called event\_start\_date
* ex. current date is 2016-05-30

Desire \- dynamically display last 6 entries in this sorted list \- this list can have

List

* 2016-02-08
* 2016-03-01
* 2016-03-29
* 2016-05-02
* 2016-05-15
* 2016-05-30
* 2016-09-12
* 2016-10-24
* 2016-11-01
* 2016-12-06

Desired Results:

* 2016-05-15
* 2016-05-30
* 2016-09-12
* 2016-10-24
* 2016-11-01
* 2016-12-06

Unsure how to grab the last 6 entries always in a channel. Any help would be greatly appreciated.

# Answer
> 0 votes
It's quite straight forward, just use the sort order (default is desc) and limit parameters.

```
{exp:channel:entries channel="my-channel" sort="asc" limit="6"}
    ...
{/exp:channel:entries}

```

# Answer
> 0 votes
ok had to use the query option but here's the code

```
{exp:query sql="SELECT * FROM (SELECT * FROM (SELECT * FROM exp_channel_data WHERE field_id_13 > '1' ORDER BY field_id_13 asc LIMIT 6) AS tableStore) AS tableStore ORDER BY field_id_13 DESC"}
        {field_id_13 format='%Y-%m-%d'}<br>
{/exp:query}

```

# Answer
> 0 votes
add the search parameter:

```
search:event_start_date=">=2016-05-30"

```

to the channel entries tag.

---
Tags: conditionals
---


# Question
Title: Pull through entries that are not in playa
Is it possible with the playa field to pull through entries that aren't selected.

The idea is, I want to be able to pull through the entries that are selected and give them a tick icon, and then also pull through the entries that have been left out and give them a cross icon. So that I can easily display to the user what's included in a particular entry and what is not.

# Answer
You could use the query module to select the entry IDs of all entries in that channel that are not in the playa and pass the IDs to the channel entries tag. Here's an (untested) example.

```
{exp:channel:entries dynamic="no" entry_id="{exp:query backspace='1'
    sql='SELECT entry_id FROM `exp_channel_titles`
    WHERE channel_id = 6 AND entry_id NOT IN
    (SELECT `child_entry_id` FROM `exp_playa_relationships`
    WHERE parent_entry_id=20229 AND parent_field_id = 28)'}{entry_id}|{/exp:query}"}
    {title}...
{/exp:channel:entries}

```

You will need to replace the channel\_id (currently 6) with your channel id, the parent\_field\_id (currently 28) with the field ID of the playa field and the parent\_entry\_id (currently 20229) with the ID of the entry that has the playa field on it.
> 0 votes

---
Tags: playa
---


# Question
Title: Google crawling Solspace Rating Vote Links
I have an issue on a site I maintain where we use the Solspace Rating module. We have added up/down vote links on ratings and are triggering the click with a JavaScript event, however Google (and other search engine bots) appear to be crawling the target URLs and as a result generating thousands of up/down votes during the crawl.

We have tried adding rel="nofollow" and removing the URL from the href and placing it inside a custom data attribute instead but still no joy...

Our markup:

```
{exp:rating:rating_vote_stats rating_id="{rating_id}"}
<a href="#" class="vote" rel="nofollow" data-vote-path="{path='reviews/vote'}/{rating_id}/up">Yes</a>
<a href="#" class="vote" rel="nofollow" data-vote-path="{path='reviews/vote'}/{rating_id}/down">No</a>
{/exp:rating:rating_vote_stats}

```

and our JavaScript/jQuery:

```
$(".vote") .click (function(e) {
    e.preventDefault();
    var link = $(this).data("vote-path");
    $.ajax({
        url: link
    });
});

```

Any suggestions as to how we can resolve this issue without requiring log-in to up/down vote?

# Answer
Ok, working this out in the end. I used a relatively simple .htaccess rule to prevent access to the voting URLs by common robots:

```
# Prevent Robots from voting on reviews
RewriteCond %{HTTP_USER_AGENT} (googlebot|bingbot|Baiduspider) [NC]
RewriteRule ^reviews/course/(.*)/review/vote/(.*)/(.*)$ - [R=403,L]

```

That does it! :)
> 0 votes

---
Tags: solspace, google
---


# Question
Title: Channel Entries API/Model: Get created Id or Entry by Field Name
I hope that I can explain this succinctly. Platform is EE 2.10.1 (this is a sandbox, live version will be on 2.11.1).

I am working on an extension which is using Solspace's User Module's *user\_register\_end* hook. After entering the user to the member list, we need to process company information into the *Companies* channel.

I am achieving this by loading the *channel entries* and *channel fields* API and then calling the *save\_entry* method:

```
ee()->load->library('api');
ee()->api->instantiate('channel_entries');
ee()->api->instantiate('channel_fields');

```

No problem so far. However, I need to process the information further and require the ID of the newly created company entry.

As far as I see, the *save\_entry* method is only returning a success boolean - not the ID of the successfully created channel entry. First thought was to load the *channel\_entries\_model* to get the channel entry by field name. But *get\_entry* only accepts the entry ID, which I don't have. Then I reckoned, I could use the *get\_recent\_entries* method of the *channel\_entries\_model*. However, when I run it I get the following error:

```
A PHP Error was encountered
Severity: Notice
Message: Undefined property: EE::$cp
Filename: core/Model.php
Line Number: 50
Fatal error: Call to a member function allowed_group() on a non-object in /var/www/html/system/expressionengine/models/channel_entries_model.php on line 189

```

How can I get the ID of the channel entry that has just been created through the API? I can create a custom query using Codeigniter - but would rather not.

Thanks for guidance and help.

# Answer
> 3 votes
Well, logically the last submitted `insert` query from the API is in the `channel_data` table. This tables Primary Key is `entry_id`, so you could try this CI command after you run the `save_entry` method:

```
$new_entry_id = ee()->db->insert_id();

```

Check to make sure it's returning the correct `entry_id`. I'm assuming this works within an execution cycle and uses a stored return in the database class and the `insert_id` method doesn't actually asynchronously retrieve that insert id via another SQL query. If it does retrieve it via a second query, you might run into collisions where two processes are spawned at near the same time and something like this happens:

```
process 1: save_entry
process 2: save_entry
process 1: insert_id (get's process 2's insert_id)
process 2: insert_id (get's process 2's insert_id);

```

Check the database class in CI core the database class to verify how the last inserted id is retrieved.

Ref: https://ellislab.com/codeigniter/user-guide/database/helpers.html

**Edit**

`insert_id()` uses this function: http://php.net/manual/en/function.mysql-insert-id.php

I think it should work fine for you. You can always do post data validation if you feel it's truly necessary, once you have your `entry_id`.

**Edit**

Try this after you save a new entry:

```
$new_entry_id = ee()->api_channel_entries->entry_id;

```

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


title: A Link to Edit a Specific Site

text:
# Question
Title: A Link to Edit a Specific Site
I want to build a page of links that will let me login to edit a specific MSM (Multi Site Manager) site. Instead, EE opens the site I was editing last. This has often resulted in adding templates to the wrong site and then having to move them. Or editing content on the wrong site. Making changes and not seeing them on the site. Or being very confused when trying to edit content because I can't find it.

We're using ExpressionEngine 2.7.3 with Multi Site Manager 2.1.6 - and we've renamed admin.php for security purposes.

**What I've Tried**

I looked at: Creating Custom CP Links to Other Site Channels in MSM with Zoo Flexible Admin which discusses the commented-out base64 `page` parameter. Since I'm not interested in loading a specific page, I'm not terribly worried about that functionality. But the question seems to indicate that I can build a link with `C=sites&site_id=1` to switch to site 1. This doesn't quite work for me.

So next, I examined the msm\_sites links. This revealed that the link to switch to a site is constructed as described in the question above, but with additional parameters. Here's all of them, with some bogus values:

```
S=QSBsb25nIHRpbWUgYWdvLCBpbiBhIGdhbGF4eSBmYXIsIGZhciBhd2F5
D=cp
C=sites
site_id=1
page=TGl2ZSBsb25nIGFuZCBwcm9zcGVy

```

Exploration reveals that the `S` ("session" I'm guessing) parameter is probably the value of `{cp_session_id}`. I can't include that in my link, because it will only be good during the current session. I'm guessing the `D` param is for "destination" or something. And `D=cp` looks good to me. The `C` ("controller" maybe?) and `site_id` parameters look promising, so I include those. And since I don't care about which page I end up on, I leave out the `page` parameter as well, leaving me with an HREF that looks like:

`http://ee.example.com/notadmin.php?D=cp&C=sites&site_id=1`

However, when I load this URL and log in, I end up at the control panel for the site I was editing last. Much sadness. Very growl. My best guess is that EE is discarding my request to switch sites because I don't provide the `S` parameter. I don't know how to get around this.

My partial solution is creating an accessory that color codes the control panel background to improve the chances that I'll notice I'm working in the wrong site. But I'd really like to be able to use my handy page-full-of-links method. Any suggestions?

# Answer
I can think of two possible approaches:

I assume you're administering all sites through a single shared control panel? If so, you could consider switching to using per-site control panels - all it takes is copying admin.php (or whatever you renamed it to) into each site's public root and then editing the path to the system directory and setting which site to use for each one as described in that file.

```
$assign_to_config['site_name']  = 'domain2_short_name';
$assign_to_config['cp_url'] = 'http://domain2.com/admin.php';

```

Alternatively, if you want to stick with a single shared control panel, you could probably manipulate the value of the `exp_cp_last_site_id` cookie to suit your needs. That alone should log you in to your chosen site. Depending on how you're generating your page full of links (is it an EE template?), you could make an add-on that does the heavy lifting, or depending on security settings you might be able to manipulate the cookie via JavaScript. If it were me, I'd make an add-on and have each link go to an EE ACT url to direct it through a module method which figures everything out, resetting the cookie value before redirecting to the control panel.
> 1 votes

---
Tags: ee2, multi-site-manager
---


title: Uploaded images and browser detection

text:
# Question
Title: Uploaded images and browser detection
I have main installation of EE3 (test.example.com) and subdomain (m-test.example.com) for mobile version. Also I use detectmobilebrowser.com for detecting the device. Everything work well despite images. Mobile version will have the same content, images etc. as main version.

So this URL works: `test.example.com/images/upload/folder/image.jpg` but this one unfortunately not: `m-test.example.com/images/upload/folder/image.jpg`. Templates are loading properly but without images.

I found out the problem has been created by detectmobilebrowser.com because without this the images work properly on subdomain (`m-test.example.com`). So the problem is starting when someone go to `test.example.com` by mobile and will be redirected to `m-test.example.com`. Then images not working. When you go to `m-test.example.com` by desktop, everything will be fine.

What is the reason of that and how to deal with it?

Thanks for help!

# Answer
I change the way of making mobile version of site. I'm going to stay at the same URL and use Mobile Detect script (http://mobiledetect.net/) in my templates. So I do not have to create a new subdomain and detect device by server. To be honest, this is something I was looking for.
> 1 votes

---
Tags: ee3, redirection, mobile
---