# Question
Title: Global variable as a module tag pair's parameter?
I'm trying to pass `{ip_address}` to a module, which isn't working:

```
{exp:rest url="http://domain.com/{ip_address}" verb="get" format="json"}

{/exp:rest}

```

The `{ip_address}` is getting interpreted as a string. How do I make this work?

# Answer
> 2 votes
One really simple way to get around parse order is just to use an embed.

```
{embed="embeds/_rest" ip_address="{ip_address}"}

```

Then in your embedded template (*embeds/\_rest*):

```
{exp:rest url="http://domain.com/{embed:ip_address}" verb="get" format="json"}

{/exp:rest}

```

Embeds get a bad rap performance-wise, but as long as you aren't using them excessively or inside a foreach loop like a channel:entries tag pair then in my opinion they're a handy way to get around parse order.

# Answer
> 0 votes
User defined global variables are parsed at the very end, which you can see in Low's parse order sheet which comes in handy.

However you can get the config variables in the backend with php.

```
ee()->config->item('ip_address');

```

UPDATE

Alex's solution should work as well, but in case you don't want to use the embed you could also allow php and set it to parse on input, and replace `{url_title}` with the php variable. I would just use the embed method.

```
{exp:rest
    url="http://domain.com/<?php echo ee()->config->item('ip_address'); ?>"
    verb="get"
    format="json"
}

{/exp:rest}

```

---
Tags: templates, module, parse-order, global-variables
---


title: Paginate two stash lists in one

text:
# Question
Title: Paginate two stash lists in one
Following on from here: Output x twice then y, then x twice

I have two lists. (E) is full of entries from multiple channels. (T) is a collection of tweets from another channel.

On each page there needs to be 1 tweet and 5 entries.

The output order needs to be (E) (E) (T) (E) (E) (E)

The output order has been resolved using the @Romans-8---31-39 method.

I am using ajax to load in the next set of entries/tweets and appended onto the bottom of the list.

It's nearly all working, except for the tweets. As the url for loading the next set of entries is P5, it is returning every 5th tweet. I've tried using a negative offset on the get tweet list call, but to no prevail.

Here is the code (just the core stuff here)

```
{!--set main multi-channel entry list--}
{exp:stash:set_list name="posts"  parse_tags="yes" parse_depth="2"}
    {exp:channel:entries channel="events|projects|stories|voices" dynamic="no" disable="categories|member_data" paginate="bottom" limit="5" orderby="date" sort="desc"}
      {stash:title}{title}{/stash:title}
      {!-- create the pagination links --}
            {paginate}
        {exp:stash:set_list:nested name="pagination"}
            {stash:current_page}{current_page}{/stash:current_page}
          {pagination_links}
            {next_page}{stash:next_page}{pagination_url}{/stash:next_page}{/next_page}
          {/pagination_links}
        {/exp:stash:set_list:nested}
        {/paginate}
    {/exp:channel:entries}
{/exp:stash:set_list}

{!--set tweet list--}
{exp:stash:set_list name="tweets" parse_tags="yes" parse_depth="3"}
    {exp:channel:entries channel="tweets" dynamic="no" disable="categories|member_data" limit="1" paginate="bottom" orderby="date" sort="desc"}
        {stash:tweet}{tweet}{/stash:tweet}
        {!--set a number to match every third count where the tweet should be output--}
        {stash:two_count}{exp:math formula="{count} * 3"}{/stash:two_count}
        {stash:two_count_next}{exp:math formula="{count} * 4"}{/stash:two_count_next}
    {/exp:channel:entries}
        {paginate}
      {exp:stash:set_list:nested name="pagination_t"}
        {pagination_links}
            {stash:current_page}{current_page}{/stash:current_page}
          {next_page}{stash:next_page}{pagination_url}{/stash:next_page}{/next_page}
        {/pagination_links}
      {/exp:stash:set_list:nested}
    {/paginate}
{/exp:stash:set_list}

{!--output multi-channel list and tweet list--}
<div class="ajax-wrapper">
    {exp:stash:get_list name="posts" prefix="st1"}
        {!-- PAGINATED PAGE --}
        {!-- check to see what page we are on, slightly different layout used --}
        {exp:switchee variable="{segment_1}" parse="inward"}
            {case value="#^P(\d+)$#"}
                {!--output tweet on every forth loop--}
                {if st1:count % 4 == 0}
                            {!-- get the tweet --}
                    {exp:stash:get_list:nested name="tweets" match="#{st1:count}#" limit="1" against="two_count_next" prefix="st2"}
                        {!--if no results, output main channel entry--}
                        {!-- image left / text right --}
                        {if st2:no_results}
                            {st1:title}
                        {/if}
                        {!--tweet--}
                            {st2:tweet}
                        {!--3rd main--}
                        {!-- image left / text right --}
                        {st1:title}
                    {/exp:stash:get_list:nested}
                {!--otherwise output main channel entry--}
                {if:else}
                    {st1:title}
                {/if}
            {/case}

            {!-- FIRST PAGE, slightly different layout used --}
            {case default="true"}
               {!--output tweet on every third loop--}
            {if st1:count % 3 == 0}
                {exp:stash:get_list:nested name="tweets" limit="1" match="#{st1:count}#" against="two_count" prefix="st2"}
                    {st2:tweet}
                {/exp:stash:get_list:nested}
              {!--3rd main--}
                        {st1:title}
                {!--otherwise output main channel entry--}
            {if:else}
                    {st1:title}
            {/if}
            {/case}
        {/exp:switchee}

    {/exp:stash:get_list}
    {exp:stash:get_list name="pagination"}
        {if next_page}<a href="{next_page}" class="pager-link js-pagination">Next</a>{/if}
        {exp:stash:set name="current_page"}{current_page}{/exp:stash:set}
    {/exp:stash:get_list}
</div>

```

# Answer
Solved!

On the subsequent pages I'm using a normal entries loop, and using stash and a math plugin to calculate the offset

```
{exp:stash:get_list name="pagination"}
     {exp:stash:set name="current_page"}{exp:math formula='{current_page} - 1'}{/exp:stash:set}
{/exp:stash:get_list}

```

then:

```
{exp:channel:entries channel="tweets" parse="inward" dynamic="off" disable="categories|member_data" offset="{exp:stash:current_page}" limit="1"  paginate="bottom" orderby="date" sort="desc"}
  {tweet}
{/exp:channel:entries}

```
> 1 votes

---
Tags: stash, pagination
---


# Question
Title: Wyvern - says system folder path is incorrect
I'm getting this odd message with Wyvern - it won't load the default editor, nor let me save new editor toolbar configurations. Everything else is working in EE, the system path is set correctly.

# Answer
> 1 votes
It seems that you may have renamed the **/system** directory and/or **admin.php** to something else (which is a great idea). If so, you need to change the **$system\_path** variable to be updated in all three of these locations:

```
/index.php
/admin.php (or renamed version)
/system/index.php (or renamed version)

```

Example: If you renamed **/system** to **/cantguessthis** you would need to set the variable like so in **/index.php** and **/admin.php**:

```
$system_path = './cantguessthis';

```

You would need to set it like so under **/cantguessthis/index.php** (this one actually doesn't change in this case):

```
$system_path = '';

```

If you moved /system outside of the docroot (also a good idea), for instance into your home directory at **/home/sburrell/expressionengine**, then you would need to set the full path in index.php and admin.php:

```
$system_path = '/home/sburrell/expressionengine';

```

You also need to make sure cp\_url is set correctly in your config.php file. It should be set to the full **URL** to **/admin.php** OR **/system/** OR **/system/index.php**, depending on how you prefer to login, and you need to consistently use **only one of those URLs to login**.

I recommend renaming admin.php to something unique to your site such as **hammer\_time.php**, then setting cp\_url accordingly:

```
$config['cp_url'] = "http://example.com/hammer_time.php";

```

# Answer
> 0 votes
Do you have an htaccess rule or something else setup that block ajax requests? Is your site set to offline while you develop?

That error message is from EE, not Wyvern, so like the message says something else isn't configured correctly.

# Answer
> 0 votes
I would put the third party themes and system folders into /system/expressionengine/config/config.php as config overrides like this:

```
// add-on themes path
config['path_third_themes'] = '/addons/themes/';
config['url_third_themes'] =  '/addons/themes/';

// add-on system path
$env_config['third_party_path']    = $base_path . '/addons/system/';

```

Be sure to change the above path to to be correct for your server.

---
Tags: wyvern
---


title: Addon for reports and charts

text:
# Question
Title: Addon for reports and charts
I'm looking for an addon that will enable me to track data from custom fields and output graph or chart type reports. I found NSM Reports but I was wondering if anyone knew of any other possibilities.

thanks jules

# Answer
I would recommend that you just let EE spit out the data and not draw the charts.

For instance you could create an EE template that produces dynamic JSON feed from your EE entries and then hands that data over to another script that parses the data and draws the chart.

I've had good success using Google Charts for this but there are many others to choose from, see related question: https://stackoverflow.com/questions/119969/javascript-chart-library
> 1 votes

---
Tags: plugin, reports
---


# Question
Title: Allowing users to select which categories to view
I can't seem to see a plugin for this, but it's functionality a client has asked for.

I want users to be able to customise the categories of posts that they can see. Let's say I have posts in the following categories:

* Cars
* Bikes
* Trucks
* Caravans

I want the user to select which categories they are interested in, ie. Cars and Bikes, and only show posts within those categories. So they can essentially filter the channel view.

# Answer
You can chain category ids and pass them into the `category="1|2|3"` parameter. Docs here.

Use the `exp:channel:categories` tag to output a list of the categories with checkboxes, and use jQuery to grab the checked category ids and put them into a segment.

```
{exp:channel:categories channel="YOUR_CHANNEL" style="linear"}
    <p>
        <input type="checkbox" class="category" category-id="{category_id}" /> {category_name}
    </p>
{/exp:channel:categories}
<a onclick="filter();">Filter Entries</a>

```

The javascript function, replace with your template group and template

```
<script type="text/javascript">
function filter(){
    var categories = new Array();
    $(".category:checked").each(function(){
        categories.push($(this).attr('category-id'));
    });
    categories = categories.join("|");
    window.location = "{path='TEMPLATE_GROUP/TEMPLATE'}/" + categories;
}
</script>

```

And then in your exp:channel:entries tag.

```
{exp:channel:entries channel="YOUR_CHANNEL" category="{segment_3}"}
    ...
{/exp:channel:entries}

```
> 0 votes

---
Tags: categories, filter, subscriptions
---


# Question
Title: ExpressionEngine Matrix :total_rows doesn't work when no rows
Matrix 2.5 and 2.6 on ExpressionEngine 2.7.3.

The :total\_rows property doesn't work when there are no rows. It works fine when there are rows.

Below isn't actual code, but it's showing the gist.

```
{exp:channel:entries dynamic="no" channel="regions" url_title="[url_title]"}
    {if "{social_networks:total_rows}" > 0}
        {!--  Do the things --}
    {if:else}
        {!--  Don't do the things --}
    {/if}
{/exp:channel:entries}

```

Outputting {social\_networks:total\_rows} is an empty string (which I can't even match against with a conditional) until there's a Matrix row.

Has anyone else noticed this? I don't want to have to start pulling the plugin apart.

# Answer
> 1 votes
I believe when there are zero rows the matrix variable just returns false, so you can just use it in the conditional like this.

```
{exp:channel:entries dynamic="no" channel="regions" url_title="[url_title]"}
    {if social_networks}
        {!--  Do the things --}
    {if:else}
        {!--  Don't do the things --}
    {/if}
{/exp:channel:entries}

```

# Answer
> 1 votes
{matrix:total\_rows} can't work if there are no rows in the field simply because EE doesn't parse any field tags that don't have any actual data. Matrix never even gets called and the tag gets replaced with nothing.

---
Tags: matrix, pixelandtonic
---


# Question
Title: Saving entry with grid field isn’t working
I’m creating an ExpressingEngine extension that upon activation, automatically creates a channel with fields. One of the fields the extension creates is a grid field. I create the field like this:

```
$floor_plans_field = array(
    'field_name' => 'floor_plans',
    'field_label' => 'Floor Plans',
    'field_type' => 'grid',
    'field_order' => 30,
    'field_instructions' => 'The floor plans for the property',
    'field_required' => 'n',
    'field_search' => 'n',
    'field_is_hidden' => 'n',
);

$field = array_merge($floor_plans_field, array(
    'group_id' => $group_id,
    'site_id' => 1,
));

$field_id = $this->EE->api_channel_fields->update_field($field);

$file_column = array(
    'field_id' => $field_id,
    'content_type' => 'channel',
    'col_order' => 1,
    'col_type' => 'file',
    'col_label' => 'File',
    'col_name' => 'file',
    'col_instructions' => 'A floor plan.',
    'col_required' => 'y',
    'col_search' => 'n',
    'col_settings' => json_encode(array(
        'field_content_type' => 'all',
        'show_existing' => 'y',
        'field_required' => 'y',
    )),
);

$query = $this->EE->db->insert('grid_columns', $file_column);

```

It creates the grid field for floor plans, and a single column for file (so the user can add multiple floor plans to the entry).

However, when I save the entry I get the following error:

> A Database Error Occurred Error Number: 1054
>
> Unknown column 'col\_id\_5' in 'field list'
>
> INSERT INTO \`exp\_channel\_grid\_field\_457\` (\`col\_id\_5\`, \`entry\_id\`, \`row\_order\`) VALUES ('{filedir\_1}banner1.jpg',62,0)
>
> Filename: models/grid\_model.php
>
> Line Number: 767

It seems as though the ID of the grid column isn’t getting replaced.

Why is this? What am I doing wrong? Any help here would be appreciated as documentation on the grid field is… sparse.

# Answer
Please note this is **UNTESTED** but written from the actual code files so should play fair...

```
//load up the grid model for later use
ee()->load->model('grid_model');

//first we create our field using the channel_field_api (your code)
$floor_plans_field = array(
    'field_name' => 'floor_plans',
    'field_label' => 'Floor Plans',
    'field_type' => 'grid',
    'field_order' => 30,
    'field_instructions' => 'The floor plans for the property',
    'field_required' => 'n',
    'field_search' => 'n',
    'field_is_hidden' => 'n',
);

$field = array_merge($floor_plans_field, array(
    'group_id' => $group_id,
    'site_id' => 1,
));

$field_id = $this->EE->api_channel_fields->update_field($field);

//now we have field ID we create our data table using the grid model
if ( ee()->grid_model->create_field($field_id, 'grid') == false ) {
    //handle error here
}

//next we add some columns (one in this case) again with the grid model
$file_column = array(
    'field_id' => $field_id,
    'content_type' => 'channel',
    'col_order' => 1,
    'col_type' => 'file',
    'col_label' => 'File',
    'col_name' => 'file',
    'col_instructions' => 'A floor plan.',
    'col_required' => 'y',
    'col_search' => 'n',
    'col_settings' => json_encode(array(
        'field_content_type' => 'all',
        'show_existing' => 'y',
        'field_required' => 'y',
    )),
);
$new_col_id = ee()->grid_model->save_col_settings($file_column, FALSE);

```

Give this a try, be sure to read the comments in `Grid_Model.php` as you go, and also check the return values and the database as you go through :)
> 1 votes

# Answer
Have you had a look at the Grid Model that is in the system folder? Specifically /system/expressionengine/models/grid\_model.php

This model has methods for creating new Grid Fields (create\_field on line 140), add and update columns (save\_col\_settings on lone 235) and saving data into the grid (save\_field\_data on line 689). Is this the API you are looking for?

Surfice to say, this Model shows you the code to create grids, columns and data. With a little searching you could probably find the code that calls these model functions for examples on how to use (appologies I don't have a test enviroment to post actual code for you atm) I suspect in the /system/expressionengine/fieldtypes/ft.grid.php is a good place to start for this. Another place is the apply\_settings function on line 606 of /system/expressionengine/fieldtypes/libraries/Grid\_lib.php

In order to load and use the model, all you need to do in your model is :

```
//load the Grid Model
ee()->load->model('grid_model');

//create a new Grid field (PSEUDO)
$settings = array(
    'settings_for_grid' => true
);
$new_field = ee()->grid_model->create_field($settings, 'grid');

//create a column on the new grid
$col_id = 1;
$col_settings = array(
    'settings_for_column' => true
);
$col_ids[] = ee()->grid_model->save_col_settings($col_settings, $col_id = 1, 'grid');

```

Seems straight forward enougth, although determining your settings (for the columns look to like 645 ;) ) might be a pain it should work, after all this is how the admin CP creates the fields!

Let us know how you get on mate!

---

\**Edit - Added Column creation code for comment below

```
// Add the fieldtype's columns to our data table
ee()->api_channel_fields->setup_handler($column['col_type']);
ee()->api_channel_fields->set_datatype(
    $col_id,
    json_decode($column['col_settings'], TRUE),
    array(),
    TRUE,
    FALSE,
    $this->_get_ft_api_settings($column['field_id'], $content_type)
);

```

The code above is fromthe Grid\_Model's `save_col_settings` function. After it creates the entry in the grid\_columns table, where `$col_id` is the returned column\_id (iterate youd `$col_ids[]`) it creates the "fieldtype's column" as they call it, which will hold the data value.

That'll be what your missing! Assuming you are indeed missing the columns in the data table.
> 1 votes

---
Tags: grid, extension
---


# Question
Title: Where can I change the wording of the Reset Password email FreeMember sends?
The question says it all. Here's the why:

When FreeMember sends a password reset email, the text is as follows:

> \[screen\_name\],
>
> To reset your password, please go to the following page:
>
> http://www.example.com/member/reset-password/\[hash\]
>
> Then log in with your username: \[username\]
>
> If you do not wish to reset your password, ignore this message. It will expire in 24 hours.

The problem is that I'm using an email+pwd login method, not username+pwd, so I'd like to alter the email to say "email" instead of "username".

Another issue is the fact that the email shows the member's "username" instead of "email". In most cases members registered via FreeMember's system, so their email and username will be the same. However, for members created prior to implementing FreeMember, or members registered via other methods (EE backend, etc), their username is probably *not* the same as their email, making the Reset Password email's wording misleading.

Both issues can be fixed by changing the wording and tags of the FreeMember email, so... where can that be found?

# Answer
You can edit the forgot\_password template in `EE Control Panel > Design > Message Pages > Email Notifications > Forgotten Password Instructions`. You can change the username variable and text to email.

Now you will have to add the email variable. In `system > third_party > freemember > libraries > freemember_lib.php` after line 276 add

```
$email_vars[0]['email'] = $member->email;

```
> 1 votes

---
Tags: email, freemember, forgot-password
---


# Question
Title: Set age for the Private Messages within Trash folder
If a private messages is being deleted, it stores into Trash folder. Here, I 'd like to set a time limit and after that time, PM might be permanently deleted from Trash.

I was looking for any configuration variable for it but didn't get luck. Could anyone please help me for it.

# Answer
> 2 votes
It doesn't look like you have any nice extension hooks for the PM system. What you'll likely need to do is create a custom extension that hooks a member logging in and deletes the 'deleted' messages.

**Step 1** Create an extension that hooks a member login

Here you'll need to hook `member_member_login_single`, see this documentation on how to wrap an extension : https://ellislab.com/expressionengine/user-guide/development/extensions.html

**Step 2** Check for deleted messages for the user

From Step 1 you should have the members ID (if not it should be in the global vars) so what you can do is execute a query like this to get all the messages from the DB that belong to the user and are deleted (in the trash) :

```
SELECT mc .*,md.*
FROM exp_message_copies AS mc
JOIN exp_message_data AS md
ON mc.message_id = md.message_id
WHERE mc.message_deleted = 'y'
AND mc.recipient_id = 2
AND md.message_date < (UNIX_TIMESTAMP( NOW( ) ) - ( 3600 *12 ))

```

*assuming here that the member ID logging in is `2` and we're looking for messages that are ovef 12 hours old (3600 * 12)*

In EE, we can use ActiveRecord for this :

```
$query = ee()->db->select('mc.*,md.*')
             ->from('message_copies AS mc')
             ->join('message_data AS md', 'mc.message_id = md.message_id')
             ->where('mc.message_deleted', 'y')
             ->where('mc.recipient_id', $memberId)
             ->where('md.message_date <', '(UNIX_TIMESTAMP(NOW()) - ' . $period . ')')
             ->get();

```

*here we assume $memberId is the id for the logging in member, $period is the cut off, so now - 12 hours == 43200*

**Step 3** Delete the deleted messages!

From the code above, we'll have none or more items in the $query record set. We can then iterate these and delete them from the db (`message_copies` table).

```
if ( $query->num_rows() > 0 ){
    foreach ( $query->result_array() as $row ) {
        ee()->db->where('copy_id', $row['copy_id'])
                ->delete('message_copies');
    }
}

```

Voila! The hardest part of this may be building the actual extension! Hope this answers your questions, I tested this (I didn't create the module, but I did create real PM's and tested the delete code) on EE v2.8.1

~~One last note, I notice that doing this removes the message from the senders 'send' folder as well. I can't be sure if this was ever copied to the sent folder though! I believe by looking at the code another method would be to replace the delete statement with an update, and update the `message_folder` to 0.~~ *I did some further checking and the above method won't interfere with sent messages*

After some more looking around, I notice from the PM libraries (check out the `erase` funtion on line 2022ish on /system/expressionengine/libraries/Messages.php) that when messages are deleted you'll need to clean up attachments too (line 2077) and update the message count (line 2097) :

```
$query = ee()->db->query("SELECT COUNT(*) AS count FROM exp_message_copies
                         WHERE recipient_id = '{$this->member_id}'
                         AND message_read = 'n'");

$results = ee()->db->query("UPDATE exp_members SET private_messages = '".ee()->db->escape_str($query->row('count') )."'
                            WHERE member_id = '{$this->member_id}'");

```

---
Tags: members, messages
---


# Question
Title: {structure:page_uri_for:X} and parse order
I need to send a page URL as a parameter into a plugin. So I have a global var called lv\_shop\_page (early parsing) which is an entry ID to a page which I'm passing to structure's `{structure:page_uri_for:X}` function. When I just output `{structure:page_uri_for:{lv_shop_page}}` it comes out with the proper URL but when I put this into the parameter of a plugin like so:

```
{exp:someplugin
parse="inward"
page="{structure:page_uri_for:{lv_shop_page}}/blah/blah"}

```

I get

```
{structure:page_uri_for:470}/blah/blah

```

I know this is a parse order problem, is there any way round this so I can make `{structure:page_uri_for:X}` parse earlier than my plugin? Or maybe another workaround using stash or embeds?

# Answer
The `{structure:page_uri_for:XXX}` variable is parsed late, after template parsing has occurred (using the `template_post_parse` hook). In other words, too late to be used as a tag parameter in your plugin. However, there is an undocumented Structure tag you can use instead of the `{structure:page_uri_for:XXX}` variable: `{exp:structure:page_slug}`.

```
{exp:someplugin
    parse="inward"
    page="{exp:structure:page_slug entry_id='{lv_shop_page}'}/blah/blah"
}

```

You may have to you an embed and/or Stash to get the parse order right, but this should be possible.
> 1 votes

---
Tags: structure, parse-order
---


title: Server Migration with MSM

text:
# Question
Title: Server Migration with MSM
I'm having a little trouble figuring out the best way to migrate an install of EE with MSM.

I have 2 sites set up with MSM that are currently live. I need to switch to a new host but I obviously can't set up the new host with the existing domain names since they are already hosted elsewhere.

How do I go about setting it up on the new host?

# Answer
I've run in to this issue before. At your new host, you'll have **tempdomain.hostname.com** \- this can be the primary site. For the secondary site, you may need to grab any old domain (we've used yoursiteinprogress.net) and make that the secondary domain. Update your EE config to point to these domains, and make sure everything works. Then when you're ready to flip the switch on the migration, update EE config to point to the correct domain names.
> 1 votes

---
Tags: multi-site-manager, server-migration
---


title: Comment form entries Avatar?

text:
# Question
Title: Comment form entries Avatar?
Is it possible to get the commenter's avatar through the comment:entries tag?

```
{exp:comment:entries sort="asc" limit="9" paginate="bottom" dynamic="no"}
                    <li>
                        <figure class="profile-photo"><img src="{if avatar_url}{exp:imgsizer:size src='{avatar_url}' width='120' height='120'}{sized}{/exp:imgsizer:size}{if:else}{site_url}img/assets/default_avatar.png{/if}" alt=""></figure><aside>
                            <div class="meta-info">
                                <p><a href="#">{name}</a> <time>{comment_date format="%Y %m %d"}</time></p><i class="icon-review"></i>
                            </div><!--meta-info-->
                            <article>
                                <p>{exp:stringy:striptags allowed_tags=""}{comment}{/exp:stringy:striptags}</p>
                            </article>
                        </aside>
                    </li>
                    {paginate}
                    {pagination_links}
                    <div class="pagination">
                        <p>Page {pagination_page_number} of {total_pages}:</p><!--
                        --><ul>
                            {previous_page}<li><a href="{pagination_url}" class="prev"><i class="icon-left-arrow"></i></a></li>{/previous_page}<!--
                            -->{page}<li><a href="{pagination_url}" class="page {if current_page}active{/if}">{pagination_page_number}</a></li>{/page}<!--
                            -->{next_page}<li><a href="{pagination_url}" class="next"><i class="icon-right-arrow"></i></a></li>{/next_page}
                        </ul>
                    </div><!--pagination-->
                    {/pagination_links}
                    {/paginate}
                {/exp:comment:entries}

```

Here is my current code for the latest comments, it doesn't seem to be grabbing the member's avatar?

Any ideas?

Thanks All the best -Graham.

# Answer
Take the `exp:comment:entries` tag out of the `exp:channel:entries` tag and supply either the `entry_id` or `url_title` of the entry you want. The `avatar_url` variable is being overwritten by the channel:entries variable.

```
{exp:comment:entries entry_id="XXX" sort="asc" limit="9" paginate="bottom" dynamic="no"}
   <img src="{avatar_url}" />
{/exp:comment:entries}

```
> 0 votes

---
Tags: comments
---


title: How to get a entry from each month

text:
# Question
Title: How to get a entry from each month
I would like to get the last entry of a channel from each month. is there any way to do it with channel entry module?

like: 2015, 01 : last entry is "hello 1"; 2015, 02 : last entry is "hello 2"; 2015, 03 : last entry is "hell 3";

it gives me a hard time :(

# Answer
> 0 votes
Surround the channel entries tag with the archive month links tag.

```
{exp:channel:month_links channel="YOUR_CHANNEL" limit="12"}
    {exp:channel:entries channel="YOUR_CHANNEL" limit="1" year="{year}" month="{month_num}"}
        {entry_date format="%Y  , %m"} : last entry is "{title}";
    {/exp:channel:entries}
{/exp:channel:month_links}

```

# Answer
> 0 votes
Why not just use the `month` and `year` parameters?

```
{exp:channel:entries channel="YOURCHANNELNAME" year="2015" month="01" status="not closed" limit="1" sort="asc" orderby="date" disable="categories|pagination|category_fields|member_data"}
...
{/exp:channel:entries}

```

If you're on an archive page like:

```
http:///www.your-domain-name.com/blog/archive/2015/01

```

You could do this:

```
{exp:channel:entries channel="blog" year="{segment_3}" month="{segment_4}" status="not closed" limit="1" sort="asc" orderby="date" disable="categories|pagination|category_fields|member_data"}
        ...
{/exp:channel:entries}

```

You can read more here:

year=, month=, day=

Hope that helps!

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


# Question
Title: Displaying incomplete mutlipage entries in Freeform Pro {exp:freeform:entries}
Is it possible to show incomplete multipage entries within {exp:freeform:entries}?

Right now I have this:

```
{exp:freeform:entries form_id="2" status="open|pending|closed"}
...
{/exp:freeform:entries}

```

It's only returning 'complete' entries.

The incomplete entries are being captured and are available in EE Admin.

Using FreeForm Pro 4.2.2 on EE 2.9.3

# Answer
> 0 votes
I think the Solspace docs are outdated. It is not `status` but `default_status`. Try the following:

```
{exp:freeform:entries form_id="2" default_status="open|pending|closed"}
...
{/exp:freeform:entries}

```

That should get you what you want.

---
Tags: solspace-freeform
---


# Question
Title: Pagination does not working properly with structure
I have using structure, but in my listing page pagination does not working properly. pagination links are changed but records are display at it is. means every time same records display.

I have using structure, freebie, zoo triggers and stash.

My script is given below:

```
{embed="_layouts/index"}

{exp:stash:set name="meta"}
{exp:seo_lite use_last_segment="yes"}
{/exp:stash:set}

{exp:stash:set name="content"}
<section id="content">
    <div class="inner-container">
        <span class="logo-icon"></span>
        <span class="left-line"></span>
        <span class="right-line"></span>

        <div class="row">
            <div class="col-md-8 col-sm-8">
                <section id="left-side">

                    {embed='home/breadcumb'}

                    {exp:channel:entries channel="pages" dynamic="yes" disable="categories|category_fields|member_data|pagination|trackbacks"}
                        <h1>{title}</h1>
                        {page_content}
                    {/exp:channel:entries}
                    <div class="clear"><!-- --></div>

                    <section class="all-list">
                    {exp:channel:entries channel="parliamentarian" parse="inward" dynamic="no" paginate="bottom" limit="10" disable="categories|category_fields|member_data|trackbacks"}
                        <div class="listing {switch='odd|even'} cf">
                            <div class="member-image">
                                {member_image}
                                    <img src="{image:url:small}" />
                                {/member_image}
                            </div>
                            <h2><a href="{page_uri}">{title}</a></h2>
                            <a href="{page_uri}" class="details-arrow">Read More</a>
                        </div>
                        {paginate}
                          {pagination_links}
                              <div class="paging">
                                <span class="page-name">Page({current_page}):</span>
                                  {first_page}
                                          <a href="{pagination_url}" class="first">First</a>
                                  {/first_page}

                                  {previous_page}
                                          <a href="{pagination_url}" class="prev">Prev</a>
                                  {/previous_page}
                                  {page}
                                          <a href="{pagination_url}" class="page-{pagination_page_number} {if current_page}current{/if}">{pagination_page_number}</a>
                                  {/page}
                                  {next_page}
                                          <a href="{pagination_url}" class="next">Next</a>
                                  {/next_page}

                                  {last_page}
                                          <a href="{pagination_url}" class="last">Last</a>
                                  {/last_page}
                              </div>
                          {/pagination_links}
                        {/paginate}
                    {/exp:channel:entries}
                    </section>

                </section>
            </div>

            <div class="col-md-4 col-sm-4">
                {embed='pages/right-side'}
            </div>
        </div>
    </div>
</section>
{/exp:stash:set}

```

Please help me how to solve it ?

Thanks

# Answer
> 0 votes
I'm having the same issue; did you solve your issue?

My pagination links/url are changing but the displayed entires is always the same i.e.

url: http://example.com/news/ entries: 1,2,3

url: ...news/p1 entries: 1,2,3

when I'd expect:

url: http://example.com/news/ entries: atricle-1,atricle-2,atricle-3

url: ...news/p1 entries: atricle-4,atricle-5,atricle-6

My very basic code is:

```

{exp:channel:entries
    channel="news"
    disable="categories|category_fields|member_data"
    orderby="date"
    sort="desc"
    limit="3"
    paginate="bottom"
    dynamic="no"
}
    {title}
    {paginate}
    Page {current_page} of {total_pages} pages {pagination_links}
    {/paginate}
{/exp:channel:entries}

```

If I move the code out of a 'page' defined as a lister in Structure it works as expected.

Any ideas?

Structure 3.3.14.7 ExpressionEngine 2.9.2 Build 20141004

Any help much appreciated.

# Answer
> 0 votes
Sweet - found the solution, need to disable 'enable\_sql\_caching' as per: http://structure.tenderapp.com/discussions/problems/7675-pagination-not-working

---
Tags: structure, pagination, freebie, zoo-triggers
---


title: check if a segment is a number

text:
# Question
Title: check if a segment is a number
I am trying to figure out a way to set to variable values depending on if a specific segment is a number or not. First how to I check if the segment 2 is a number or not? I want to apply this type of logic

```
if segment_2 is a number
    {exp:stash:set name="this_url_title" value=""}
    {exp:stash:set name="this_entry_id" value="{segment_2}"}
else
    {exp:stash:set name="this_url_title" value="{segment_2}"}
    {exp:stash:set name="this_entry_id" value=""}
end

```

Then use the 2 variables in a channel entries tag like so.

```
{exp:channel:entries channel="news" dynamic="off" entry_id='{exp:stash:get name="this_entry_id"}' url_title='{exp:stash:get name="this_url_title"}' parse="inward"}

```

So I can either pass an entry\_id or a url\_title in the segment to view the channel entry.

I tried hard coding the stash variables and passing them in the entries tag but I get no results. I tried hard coding them to this:

```
{exp:stash:set name="this_url_title"}{/exp:stash:set}
{exp:stash:set name="this_entry_id"}123{/exp:stash:set}

```

# Answer
> 4 votes
Using the matches operator, which was added in EE v2.9.0:

```
{if segment_2 ~ "/^\d+$/"}
    [...]
{/if}

```

---
Tags: stash, variable, global-variables
---


title: Add Unsubscribe Link To EE Emails

text:
# Question
Title: Add Unsubscribe Link To EE Emails
I am using the built-in mailing list activation template on an EE website I am working on and would like to include an unsubscribe link at the bottom of the email.

I have tried adding the tag `{unsubscribe_url}` to the bottom, but it does not seem that this tag is being parsed correctly.

Is there another way of achieving this?

Here is a snippet of my code:

```
<td height="50" align="middle">You are receiving this message because you have signed up to receive the newsletter. To unsubscribe, please click <a href="{unsubscribe_url}" style="color:#729134;">here</a></td>

```

# Answer
> 1 votes
Assuming you are using the standard MailingList module and you just can't get `{unsubscribe_url}` to work, you can create the unsubscribe URL yourself with a little PHP snippet:

```
<?php

  //fetch the action ID
  $actionID = ee()->functions->fetch_action_id('Mailinglist','unsubscribe');

  //was it a valid ACT ID? If not the mailing list is probably not installed
  $unsubUrl = "";
  if ( !empty($actionID) && isnumeric($actionID) && intval($actionID) == $actionID ) {
      //create the URL
      $unsubUrl = ee()->functions->fetch_site_index(true) . '?ACT=' . $actionID;
  } else {
      //optionally handle issues here, we have no action!
  }

  //Display the link
  if ( !empty($unsubUrl) ){ ?>

    <a href="<?php echo $unsubUrl; ?>" title="Unsubscribe">Unsubscribe</a>

  <?php }
?>

```

**Ammendum** Of course, if you're using the standard template you can't use PHP as above...

I've copied the default template as it is supplied by the module (fresh install) and I notice a couple of little things in your snippet. Here's the default template:

```
{message_text}

To remove your email from this mailing list, click here:
{if html_email}<a href=\"{unsubscribe_url}\">{unsubscribe_url}</a>{/if}
{if plain_email}{unsubscribe_url}{/if}

```

I notice that the quotes are all escaped in the default template, looking at the 3rd line (`{if html_email}...`) you'll see all the quotes are escaped `\"`.

Could you try the example with the escaped quotes please? Also as I mentioned can you confirm the unsubscribe action is set up correctly (i.e. is present in `exp_actions`)?

---
Tags: ee2, email, html-email, mailinglist
---


# Question
Title: What might cause "No direct script access allowed" during EE update
I'm in the process of updating a site from EE 2.9.0 to 2.9.3. As always, I've follow through the update process specified in the docs step by step. Upon running the update wizard the process seemed to get to 2.9.2 (ie. it was showing 2.9.2 in the wizard's progress window, but I don't know whether that means it was in the process of installing 2.9.2 or whether it meant that 2.9.2 was fully installed and it was now installing 2.9.3). But rather than completing the process it suddenly displayed a white screen saying "**No direct script access allowed**". The URL in the browser is http://mydomain/admin.php?C=wizard&M=do\_update&language=english

Re-running the wizard gives the same result, except that this time the white screen appears immediately (without showing the wizard's progress window and without mentioning 2.9.1 or 2.9.2).

I've never run into this issue before during updates; does anyone know what might be causing it?

# Answer
Looks like previous issues like this could relate to your plugins : https://ellislab.com/forums/viewthread/110352/#691061

Perhaps try removing your plugins before upgrade then re-add them?

Further we see this error message amongst many CI and EE files at the top of the class files, it's so common that debugging can cause all sorts of issues:

```
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

```

Can I suggest you look to your broken installation and see what the state of the BASEPATH definition is?
> 1 votes

---
Tags: updating
---


# Question
Title: Can I have show different member registration fields for some users?
I'm using the Members module and would like some users to enter just these fields to register: username, password, email address. But I'd like to collect that plus my custom member fields from other users who are using a different function of the site.

Is there a good way of doing this?

Right now I'm trying editing /themes/default/registration\_form.html. I removed those useless "AIM" type fields, leaving me with username, password, email, custom fields loop. So I was thinking of wrapping a conditional around the custom fields that checks a URL segment, but passing an additional segment--e.g. members/register/add\_custom\_fields--is getting a 404 error. Maybe there's another way of passing some flag to tell the page whether to show the custom fields?

Using EE 2.7.3

Any tips are appreciated.

# Answer
> 2 votes
Avoid messing with the ExpressionEngine templates. Try using FreeMember, it lets you place the registration code in your own templates and pick and choose the fields you want to retrieve from the user. Also, it helps that it's free and easy to use.

# Answer
> 1 votes
I've never used FreeMember but we're using Zoo Visitor on our site and have separate fields for different users. Zoo Visitor is not free but really well built, has great documentation and support.

# Answer
> 1 votes
I ended up using Solspace User to solve this, specifically the {exp:user:register} tag. I created one template with some fields, and another template with other fields, and it worked fine. It sounds like FreeMember was intended to do this, as well, but I couldn't get that to work.

# Answer
> 1 votes
In the case of your specific question, the problem is your `/add_custom_fields` part is technically part of the path query parameter.

What you could do is add it as part of a query string (so `members/register/?extended=true`) and then detect with

```
ee()->input->get('extended');

```

Make sure you check that the setting to allow get parameters is allowed.

Another method I would consider is rolling your own registration form as a template that you can embed, lets say `site/.regForm` for example, it just needs to post to the register\_member action that you can get from your DB table `exp_actions` or with `ee()->functions->fetch_action_id("Member","register_member");`

in here, set up your custom fields in a conditional set to an embed variable like so

```
{if {embed:show_extended} == 'yes'}
    {!-- Show custom fields here --}
{/if}

```

Next, mak a template to hold the 'standard' sign up form, lets say `site/register` and embed your registration form. Or as you're editing the member templates you could edit the actual template to embed your custom form.

Lastly, create your 'extended' registration template, at `site/full-register` and again embed your form, but this time set `show_extended` to true.

Should all work fine.

---
Tags: members, solspace-user, member-management
---


# Question
Title: pagniation_page_number-variable does not parse in Solspace Tag-Module
I am using this code inside the exp:tag:entries-loop to generate pagination:

```
{tag_paginate}
                {tag_pagination_links}
                    <div class="col-md-offset-3 text-center"><!-- col-md-offset-3 -->
                    <ul class="pagination">
                        {first_page}
                            <li><a href="{pagination_url}" class="page-first">Erste Seite</a></li>
                        {/first_page}

                        {previous_page}
                            <li><a href="{pagination_url}" class="page-previous">Vorige Seite</a></li>
                        {/previous_page}

                        {page}
                            <li {if current_page}class="active"{/if}><a href="{pagination_url}" class="page-{pagination_page_number}">{pagination_page_number}</a></li>
                        {page}

                        {next_page}
                            <li><a href="{pagination_url}" class="page-next">Nächste Seite</a></li>
                        {/next_page}
                    </ul>
                </div><!-- /col-md-offset-3 -->
                {/tag_pagination_links}
                {/tag_paginate}

```

The variable pagniation\_page\_number is not parsed, the same for the variable page - see screenshot attached:

Could you please give me a hint how this could be fixed? Thanks!

# Answer
> 1 votes
Ok - the problem was trivial. As you can see in the template-code above I just missed a slash. This one

```
{page}
   {pagination_url}{pagination_page_number}
{page}

```

just has to be replaced with

```
{page}
   {pagination_url}{pagination_page_number}
{/page}

```

It was worked out by the excellent and engaged guy from Solspace - thanks a lot!

# Answer
> 0 votes
This is also issue with EE pagination, which Tag uses: if you use the same URL, eg `http://example.com/entries/two+apples` with pagination in `{exp:channel:entries}`, the pagination URL can become `http://example.com/entries/two apples`. Spaces in URLs render as `%20` in the address bar, which is the URL entity equivalent of a space.

There is possibly a way to prevent `+` to convert to a space by making trial-and-error changes in .htaccess, but another method could be to enable PHP in your templates and put a search & replace function to convert spaces to `+` in pagination urls:

```
<?php echo str_replace(' ', '+', '{pagination_url}'); ?>

```

---
Tags: solspace, solspace-tag
---


# Question
Title: Sort a Matrix using a Playa field inside the Matrix?
I have a Matrix field with a Playa field in it. I'd like to sort the output of the Matrix using a text field from the Playa field. Is that possible?

Here's my code; I'd like to be able to sort by {former\_member\_info:people\_n\_family}:

```
{exp:channel:entries channel="org_units" status="open" dynamic="yes" disable="{mcc_disable_mem_pag}" limit="1" require_entry="yes"}
{org_units_members_mtx var_prefix="former_members"}
        {former_members:org_units_member_name_rel var_prefix="former_member_info"}
        <tr>
            <td width="25%">{former_member_info:people_n_first} {former_member_info:people_n_family}</td>
            <td width="35%">{if '{former_members:org_units_member_title}' != ""}{former_members:org_units_member_title}{if:else}{former_member_info:people_title}{/if}</td>
            <td width="20%">{former_members:org_units_member_date_start format="%F %j, %Y"}</td>
            <td width="20%">{former_members:org_units_member_date_end format="%F %j, %Y"}</td>
        </tr>
        {/former_members:org_units_member_name_rel}
{/org_units_members_mtx}{/exp:channel:entries}

```

# Answer
> 0 votes
The answer is that this isn't currently possible. I had a Twitter conversation with Brad and Andris at Pixel and Tonic. Here's the conversation: https://twitter.com/BertBartBrett/status/583301880471773184

---
Tags: matrix, playa
---


title: Uploaded images not visible

text:
# Question
Title: Uploaded images not visible
I am taking over a website from previous developers who used ExpressionEngine. When I upload a new image via ExpressionEngine, it is not visible. I have tried to upload the image through the File Manager and through its own entry. Here is what I see in Safari when I try to view the image through the CMS. I just see a question mark when I view it on the actual webpage.

What is the problem here? The size of the image is correct, and when I download the image from the File Manager, I can view it on my computer. Is there something I'm missing here?

# Answer
> 0 votes
If you can successfully upload images yet thumbnails not showing it could be

a) File permissions on the upload folder are incorrect (inc. thumbnail directory) or

b) you don't have GD library (double check docs as to required server image module) on your server

Does it show within the entry ?

# Answer
> 0 votes
Also check the "URL of Upload Directory" path in the File Upload Preferences entry for the directory. I had an extra "public" in there because I stupidly copied too much of the file path into the URL path field. I could see the thumbnails in the \_thumbs directory and everything had the correct permissions. The problem was the URL path that caused the Control Panel and the site to have an invalid URL to the thumbnail and hence all I saw was the unavailable image icon.

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


# Question
Title: Adding conditional to Store "Hurry! Only x items left!!"
I'm setting up an online apparel store and would like to set up a conditional that will check the item count in a particular sku number and output something like this "Hurry, only 9 left!!" when the count is equal or less than say 10.

I tried

```
{if store_product_stock <= 10}
<p>Hurry, only <em><span class="store_product_stock"></span></em> left!</p>
{/if}

```

But that doesn't work. Any help would be great!

# Answer
> 1 votes
According to the store docs your can use `total_stock` for that.

Example:

```
{if total_stock > 0} In Stock {if:else} Out of Stock {/if}

```

https://www.exp-resso.com/docs/product\_tag.html#total\_stock

---
Tags: expresso-store
---


# Question
Title: Expresso store - using two stripe payment gateways
We're setting up a store for a charity that accepts donations and also sells items, they have two bank accounts one for donations and one for the shop so we've setup two stripe accounts to process these separately.

We've setup the templates and everything works great, but we can't work out how to add a second stripe API key in the backend, is this possible and if so how should we go about it?

Thanks!

# Answer
> 1 votes
In Store 1x versions this was easily possibly because you named each gateway you enabled manually. When V2 was released this was changed (I assume to help reduce the support request about people mislabeling gateways).

In V2 you would need to go into Store folder and find the Stripe gateway folder/file and duplicate the structure while changing the naming of the classes everywhere in the files to match the name of your duplicated gateway.

---
Tags: expresso-store, payment-gateway, stripe
---


# Question
Title: Using years as facets in Low Search faceted search
I am creating a faceted search using Low Search with the help of this post. I would like to include a list of years as a facet, too, but I only want years listed where there is an entry. For example, if I had an entries in 2004, 2005, 2007, 2010 and 2014, I'd want those to be what displays, but not 2006, 2008, 2009, etc. I'm stumped.

**UPDATE APRIL 10:** I've made some headway! Using Low's "Ranges" examples (scroll down to "Show entries for a given month"), I created my list of years. I'd really like to be able to generate the range dynamically so that I don't have to manually change the range every year. I created a low variable that outputs the year, but when I use it as the parameter value it creates a list of numbers starting from zero.

Here's my search code with the manual range that works:

```
{exp:low_search:form form_id="search" result_page="docs/index" query="{segment_2}"}

…other facets…

<fieldset>
    <legend>Year</legend>
    {exp:low_list:each items="2014|2003" as="year" range="yes"}
        <label>
        <input type="checkbox" name="year" value="{year}"{if low_search_year == year} checked{/if} />
            {year}
        </label>
    {/exp:low_list:each}
</fieldset>
<input type="submit" class="btn btn-small" value="Filter" />
{/exp:low_search:form}

```

And here's my search code with the low variable used in the range, which outputs a list of numbers starting at 0 (the variable when not used as a parameter value outputs just fine):

```
{exp:low_search:form form_id="search" result_page="docs/index" query="{segment_2}"}

…other facets…

<fieldset>
    <legend>Year</legend>
    {exp:low_list:each items="{exp:low_variables:single var='lv_var_doc_library_published_year' preparse:var_doc_library_sort='desc'}|2003" as="year" range="yes"}
        <label>
        <input type="checkbox" name="year" value="{year}"{if low_search_year == year} checked{/if} />
            {year}
        </label>
    {/exp:low_list:each}
</fieldset>
<input type="submit" class="btn btn-small" value="Filter" />
{/exp:low_search:form}

```

Does anybody have any ideas about how I can dynamically populate the parameter value?

# Answer
How about using the Query module? Something like...

```
<select name="year">
  {exp:query sql="SELECT DISTINCT year FROM exp_channel_titles WHERE channel_id = X ORDER BY year DESC"}
    <option value="{year}">{year}</option>
  {/exp:query}
</select>

```

...where X is the channel ID you want to target.
> 0 votes

# Answer
I would honestly consider using some PHP snippet's and PHP Parsing set to input. It'd come out much cleaner! This way your php can populate the attributes for you. I assume you want 2003 to current year right?

```
<?php
    $startYear = 2003;
    $endYear = intval(date("Y",time()));
?>

{exp:low_search:form form_id="search" result_page="docs/index" query="{segment_2}"}

    …other facets…

    <fieldset>
        <legend>Year</legend>
        {exp:low_list:each items="<?php echo $startYear . '|' . $endYear; ?>" as="year" range="yes"}
            <label>
                <input type="checkbox" name="year" value="{year}"{if low_search_year == year} checked{/if} />
                {year}
            </label>
        {/exp:low_list:each}
    </fieldset>

    <input type="submit" class="btn btn-small" value="Filter" />

{/exp:low_search:form}

```
> 1 votes

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


# Question
Title: Champagne 2 get_channels() on a non-object
I'm running EE 2.7 and running champagne 2.3.4 (which is the latest). When I went to change my email template in the extensions section I got this error:

```
Fatal error: Call to a member function get_channels() on a non-object in [system_path]/expressionengine/third_party/champagne/ext.champagne.php on line 188

```

# Answer
I did some hunting and found that ee 2.6 and I assume 2.7 doesn't load the channel\_model automatically. So I added this line right above 188:

```
$this->EE->load->model('channel_model');

```

so 188 and 189 look like this:

```
'channels' => $this->EE->load->model('channel_model'),
'channels' => $this->EE->channel_model->get_channels()->result_array(),

```

and that fixed my problem.
> 1 votes

---
Tags: 2.7.0, champagne
---


# Question
Title: detect when the channel entries list in control panel has been filtered
I am playing around with a creating an accessory for EE and I am trying to figure out how to run a JavaScript function after the channel entries listing has been filtered. Any idea how I go about doing this?

# Answer
> 0 votes
There might be a better EE way of doing this but I found this little jQuery plugin that seems to work quite well, it detects changes in elements. So I use it to detect a change in the entry listing table.

https://stackoverflow.com/questions/3233991/jquery-watch-div/3234646#3234646

# Answer
> 0 votes
You could avoid writing an Accessory and just inject the JS into the Control Panel to do it for you using the CP CSS & JS add-on (download link) to inject JS on the filter event? Hook onto the form submit for #filterform - something like:

```
$("#filterform").submit(function (e) {
    e.preventDefault();
    //Do your thing.
});

```

Not sure if that will fire before the ajax or after though. Might have to watch for a change in the top row of the table.

---
Tags: channel-entries, forms, javascript, filtering
---


# Question
Title: Login Problems @ Control Panel after installing Forum software
I am using EE 2.9 on my localhost and have just installed the forum software that I purchased a few hours ago. Everything seemed to be simple enough and I am sure that I put all the right stuff in the correct folders. When this was done, I tried to get into the admin area to complete the installation but was unable to do so. I can bring up the admin login page ok, but after I input my details I get the error message shown in the attached GIF image. Can anyone help with this ?

# Answer
> 0 votes
I considered what you suggested and decided that as my little project was at it's infancy, the best course of action was to uninstall EE and re-install. A quick process that seems to have worked. Just now I am configuring my EE forum. I have the latest versions of the Help file, EE software, and Forum software. There is a lot to learn but I am finding it quite systematic and methodical. The biggest barrier to my learning curve is my uncanny ability to miss the glaringly obvious. Thank you for your advice

# Answer
> 0 votes
You have a news\_and\_stats accessory installed. It looks like its trying to display some sort of RSS feed on your Admin control panel. From the stack trace it seems this accessory is trying to cUrl a request (might be a phone home or an update check) from the function \_fetch\_news.

I would hazard a guess you don't have cUrl installed on your local server, or the URL it is cUrl'ing is unavailable from your local computer.

Check out your `phpinfo()` for cUrl status, and if presnet check out line 78 of `acc.news_and_stats.php` (probably in `/system/expressionengine/third_party/`.

It might be advisable to uninstall this accessory, finish your update then re-install if it was working on localhost before upgrade...

---
Tags: control-panel
---


title: EE Video Plugins

text:
# Question
Title: EE Video Plugins
Can anyone advise if any of the available EE plugins to embed YouTube etc into a page, will also embed into the EE forum software as a WYSIWYG so that members can use it ?

# Answer
I'm using the Channel Videos module from DevDemon with YouTube and Vimeo videos. It has a lookup feature within the module so you can search either resource from your EE install..quite good, and it's free. One issue: name your video tab anything other than {video} - that fails for some reason.
> 1 votes

---
Tags: ee2, members
---


# Question
Title: Datagrab - Importing more than one Grid row data for each row in CSV
I have this problem with importing data from CSV

Suppose I have CSV that contains a list people. Suppose these people have multiple phone numbers.

Given these assumptions, let us try this example

Suppose there is a person named John Doe who has 2 phone numbers - one for mobile, the other is for landline

In the CSV, it would be represented as

```
FirstName   LastName    PhoneNumber     PhoneNumberType
...
John        Doe         12345798        mobile
John        Doe         987654321       landline
...

```

Now here is the question. How does Datagrab know that those 2 rows are the same person with 2 different numbers?

Is there a way for Datagrab to import these 2 numbers into Grid for that 1 person?

# Answer
> 3 votes
I would imagine that a CSV is not the best way to represent this data, and that it'll prevent you from successfully importing into a Grid field.

I would take the CSV data and (using PHP or some other tool) reformat it into XML, which will much more readily represent the nested sets of fields in a Grid.

# Answer
> 0 votes
Did you get this to work out for you, if so what did you use to import several grid field-data into the entry?

Best regards Dave

---
Tags: datagrab, csv
---


title: Define PHP var using a global var

text:
# Question
Title: Define PHP var using a global var
I am trying to get a php snippet working within a template with PHP enabled(output).

$uid does contain the {member\_id} as expected but the php has not returned the correct result.

**Update** I think this is parse order issue.

What is wrong here?

```
<?php
  $uid = "{member_id}";
?>

```

# Answer
> 1 votes
This most likely is parse order, however as your trying to get a global into a php variable you can forget about tag parsing completely. Try this :

```
$uid = ee()->session->userdata('member_id');

```

Member ID is in the Session class (if logged in), test the group for if\_logged\_in or not.

FYI, for other global vars, you can do things like this :

```
//Global Variables (Site Label)
$var = ee()->config->_global_vars['site_label'];

//Global config settings (Base URL)
$var = ee()->config->config['base_url'];

//User variables (alternate method)
$var = ee()->session->userdata['group_id'];

```

---
Tags: php, ee
---


# Question
Title: Render User Submitted HTML in Freeform Notification
I have a form where I need to have a table submitted to Freeform in a text area. This is working correctly, however in the notification the table is not being rendered but is rather outputting raw html, see image.

I've set the notification template to allow html, I've also set the textarea to NOT prevent user html rendering.

Is there soemthing I'm missing?

---

UPDATE - I also set up freeform:entries and this field with the table inside it is outputting the table as entities and not html. Is there some way to get this working?

---

# Answer
> 1 votes
I found the solution to this. I had to wrap the code inside the textarea with {exp:ce\_str:ing html\_entity\_decode}. Now everything works correctly

```
<textarea name="product_requests" style="display:none;">
    {exp:cookie_fav:favourites}
        {if has_favourites}
        {exp:ce_str:ing html_entity_decode}
        <table class="quote-items table table-striped">
            <thead>
                <tr>
                    <th>Product Id</th>
                    <th>Product Name/Description</th>
                    <th>Quantity</th>
                </tr>
            </thead>

            <tbody>
                {exp:channel:entries channel="product_page" limit="200" entry_id="{favourites_entry_ids}"}
                <tr>
                    <td class="prod_id">{product_id}</td>
                    <td class="prod_name">{title}</td>

                    <td class="prod_quantity">
                        {!--
                            Get Quantity set on Page 1
                        --}
                        {exp:evopost:getpostdata}
                            {ep_quantity_entry_{entry_id}}
                        {/exp:evopost:getpostdata}
                    </td>

                </tr>
                {/exp:channel:entries}
            </tbody>
        </table>
        {/exp:ce_str:ing}

        {/if}

        {if has_favourites == FALSE}
            <p>You haven't chosen any products to request a quote yet.</p>
        {/if}
{/exp:cookie_fav:favourites}
</textarea>

```

# Answer
> 0 votes
Under Admin/Email Settings try setting default email Format to html

---
Tags: solspace-freeform
---


title: Passing JSON to plugin

text:
# Question
Title: Passing JSON to plugin
RE: Parsing JSON in EE tag

Can anyone help out here? It seems that since EE uses { and } that it interperets JSON as an EE tag.

I need to pass JSON to a plugin, how is that possible?

# Answer
> 0 votes
Since I figured out that i can pass the javascript object to the template and do my parsing there, I decided to forego messing with the JSON in the template. I still handle the JSON in my plugin but I'm taking the passed parameters and building the JSON from it.

Thanks for the help and comments.

# Answer
> 0 votes
I 'm wondering if you are preparing JSON data within the template and would like to pass within a plugin via plugin parameter.

Rather than it, just access that object or array within plugin and use PHP's function json\_encode

# Answer
> 0 votes
I had the same problem. in my case I store the JSON data in a felid, but before I save it I do php STR\_REPLACE {} to \<\>. while decoding to php array I do reverse the \<\> to {}. it works fine with me . hope you find this helpful

---
Tags: tags, json
---


title: How to get homepage to swap language?

text:
# Question
Title: How to get homepage to swap language?
For some reason having difficulty getting the homepage to translate. It just won't swap language although it adds the language prefix after the domain name "domain.co.uk/cy/ but the language switcher links still show's "en" and no content gets translated.

# Answer
> 0 votes
I had caching set on the homepage. Turning this off sorted it.

---
Tags: transcribe
---


# Question
Title: NavEE selected_class="on" becomes class="yes" - possible to solve w/o updating styling?
I assume due to some bug in the parser,

```
{exp:navee:nav nav_title="header" selected_class="on"}

```

Outputs

```
<ul>
    <li class="yes"><a href="/foo">Foo</a></li>
    <li><a href="/bar">Bar</a></li>
    <li><a href="/baz">Baz</a></li>
</ul>

```

While I am able to change the styles, it would be highly preferable to overcome this issue, as the navigation is being retrofitted.

Has anyone else hit a similar issue?

# Answer
> 0 votes
I've had a bit of a poke around in EE core, and found the likely culprit. (`system/libraries/Template.php:1690`, in `fetch_param()`)

```
// Making yes/no tag parameters consistent.  No "y/n" or "on/off".
switch($this->tagparams[$which])
{
  case 'y'  :
  case 'on' :
    return 'yes';
  break;
  case 'n'  :
  case 'off'  :
    return 'no';
  break;
  default   :
    return $this->tagparams[$which];
  break;
}

```

It would seem that the system translates all instances of y, on, n, and off into different values with no option to disable this functionality for modules using the function.

Frankly, I'm disappointed.

For now, I'd presume this impossible to fix without modifying core files.

---
Tags: templates, parsing, navee, 2.9
---


title: Search module giving incorrect links

text:
# Question
Title: Search module giving incorrect links
I'm setting up a search feature on a site and one of the channels that it's searching is downloads. Rather than link all download results to the downloads page using the {auto\_path} tag and then expect the user to find the download they want, I'd like to create a link which will actually download the file from the search results page.

The issue is that when trying to do this, subsequent results seem to have incorrect links, as if the search module is getting confused?

**Here's my code, any thoughts or alternative ways to achieve this are massively appreciated!**

Thanks in advance,

Tom

```
{exp:search:search_results}
<div class="col span_1_of_1 search_results">
    <div class="padding">
        <h3 class="no_margin_bottom">
            {if channel == 'Downloads'}
                {if download_file != ''}
                    <a href="{download_file}">{title}</a>
                {if:elseif download_link != ''}
                    <a href="{download_link}">{title}</a>
                {/if}
            {if:else}
                <a href="{auto_path}">{title}</a>
            {/if}
        </h3>
        <p class="subtitle extra_margin_bottom">{entry_date format="%j%S %F %Y"}</p>
        <span class="label">{channel}</span>
        <p>{excerpt}</p>
        {if channel == 'Downloads'}
            {if download_file != ''}
                <a href="{download_file}" download target="_blank" >Download</a>
            {if:elseif download_link != ''}
                <a href="{download_link}" download target="_blank" >Click to download</a>
            {/if}
        {if:else}
            <a href="{auto_path}">Read more</a>
        {/if}
    </div>
</div>
{/exp:search:search_results}

```

# Answer
> 0 votes
Maybe try simplifying by getting rid of the nested if:elses?

eg

`{if download_file != ''} {title}{/if}
 {if download_link != ''} {title} {/if}`

(Assuming both fields won't be populated of course.)

# Answer
> 0 votes
I've managed to solve this by removing the complex conditionals, including all links and then simply hiding the links I don't want to appear using CSS. This is a bit of a workaround I know but in this case seemed to be the best solution.

Here's a copy of my code and CSS.

**HTML:**

```
{exp:search:search_results}
    <div class="col span_1_of_1 search_results {if channel == 'Downloads'}download{/if}">
        <div class="padding">
            <h3 class="no_margin_bottom">
                <a class="auto_path" href="{auto_path}">{title}</a>
                {if download_file != ''}<a href="{download_file}" download target="_blank" >{title}</a>{/if}
                {if download_link != ''}<a href="{download_link}" download target="_blank" >{title}</a>{/if}
            </h3>
            <p class="subtitle extra_margin_bottom">{entry_date format="%j%S %F %Y"}</p>
            <span class="label">{channel}</span>
            <p>{excerpt}</p>
            <p><a class="auto_path" href="{auto_path}">Read more</a>
                {if download_file != ''}<a href="{download_file}" download target="_blank" >Click to download</a>{/if}
                {if download_link != ''}<a href="{download_link}" download target="_blank" >Click to download</a>{/if}
            </p>
        </div>
    </div>
{/exp:search:search_results}

```

**CSS:**

```
.download .auto_path {
    display: none;
}

```

---
Tags: conditionals, search
---


# Question
Title: conditional to evaluate structure (url) field and current_url
I'm trying to create a conditional to determine if the structure entry url is the same as the global `{current_url}`. I created a structure field called, `{product_category}`. For some reason I cannot get conditional below to evaluate to true. Any idea what the issue is?

When callinng in template `{product_category}` I get the following output:

> http://localsite.com/index.php/online-store/business-compliance-materials/

When calling in template `{current_url}` I get the following output:

> http://localsite.com/index.php/online-store/business-compliance-materials

Here's my conditional:

`{if product_category == current_url . '/'}
 True
{if:else}
 False
{/if}`

# Answer
If I read your question correct (the links aren't working) you're trying to check if {product\_category} is equal to {current\_url} if so you need the following.

```
{if '{product_category}' == '{current_url}'}
    True
{if:else}
     False
{/if}

```
> 1 votes

---
Tags: templates, conditionals, structure, url
---


title: Avoid spam in contact forms

text:
# Question
Title: Avoid spam in contact forms
In one site I'm getting a lot of spam via a contact form created with Freeform. Is there a good solution, besides adding a CAPTCHA?

# Answer
> 35 votes
I would recommend using either snaptcha or honeepot as they are both unobtrusive captchas that the end user never sees. They are also very very effective.

# Answer
> 14 votes
There's also Low NoSpam, which you use in conjunction with an Akismet license. I started using it on my personal site when CAPTCHAs weren't effective and it reduced spammy submissions to zero.

The other advantage to Akismet is you don't need user-unfriendly CAPTCHAs. Even honeypots can be outsmarted by bots on occasion, and they're not effective against human spammers.

The one caveat with Low NoSpam on Freeform is that you can't moderate flagged submissions from the CP. Though that hasn't really been a problem for me.

# Answer
> 8 votes
I like Sean's suggestions, but if you are avoiding CAPTCHA simply because they can be difficult to enter in for a user, check out Accessible CAPTCHA to see if it will suit your needs. You can set up a series of questions that will be picked at random instead, that a user has to answer.

I've used it on sites and have had some fun having the questions be "on brand" for the site.

# Answer
> 7 votes
In addition to CAPTCHA, you might want to take a look at VZ Bad Behavior \- it will block known spammers from the entire site. Give it a look; I've used it and had great success with it.

# Answer
> 3 votes
Not sure of any other ways of preventing forms to be submitted without a captcha, Sean's idea sounds great though and definitely worth looking into. But you can always go with RECAPTCHA if you really need to use a CAPTCHA. I hate them (as most people probably do) but here's the link:

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

It's ADA compliant, your visitors help translate books and its probably the most popular. Snaptcha would do the trick as well, but I personally think that if you need a captcha (which I hate :)) then go with RECAPTCHA :)

Oh and it's completely FREE too!!

# Answer
> 2 votes
I released a (free) anti-spam addon for Freeform which a) adds a honeypot field and b) checks the submission's IP address against a few blacklists. You might want to give it a try - I've used it to mostly eliminate spam submissions on several sites.

# Answer
> 1 votes
I've also created a plugin for Mollom. You can find it here. https://github.com/tsmith86/EE\_mollom I do need to update it though.

# Answer
> 1 votes
On Monday i installed a Snaptcha as Honeepot which had been installed for years was letting some spam through ( maybe 5/7 a week). To date no spam. It may cost $15 but if these levels stay more than worth it!

# Answer
> 0 votes
I've had good results with Freeform Anti-Spam. It places honeypot fields and can filter results for those that do get through. I've been able to remove the hated captcha field from some client forms using this. http://devot-ee.com/add-ons/freeform-anti-spam

# Answer
> 0 votes
There is also the free Honeypot for ExpressionEngine add-on which works with Solspace Freeform, Solspace User and Expresso/DevDemon FreeMember.

https://github.com/ninefour/honeypot.ext.ee\_addon

:)

# Answer
> 0 votes
Have you seen the new version of ReCaptcha? It's about as unobtrusive as you get, it's a tick box that monitors for human style movements and clicks, really nice IMHO.

I always use this : https://devot-ee.com/add-ons/recaptcha

It's kind of like a drop in replacement for the build in Captcha so it works anywhere the built in one does, including Freeform front and back end. You can use your existing captcha settings via EE CP and I beleive it has tags to easily include in many forms!

Best of all it's free! This module with the new style of ReCaptcha makes for a winning combo in my book, and not messing about at all!

---
Tags: forms, spam
---


# Question
Title: Correct way of ordering entries by a single month view
I have a calendar. Currently viewable by year.

I need to add in a drop down/list of some sort which will show

```
January 2015
February 2015
...

```

When the user selects from the list I need to show only entires from that particular month. What is the correct way of achieving this?

I have the following in mind.

I pass variables to the URL either POST or GET so the url looks like

```
domain.com/calendar/january/2016
or
domain.com/calendar?month=january&year=2016

```

Then return the variables, using start\_on & stop\_before work some magic.

Similar as to above, I could pass some variables into a session & again use the content of the variables to affect my exp loop.

How would you perform this, is my logic sound or is there a simpler way?

# Answer
> 0 votes
Strangely I can't find this in the documentation, but you can filter entries dynamically by month by simply appending the year and month to the URL.

So given a standard `channel:entries` tag like this:

```
{exp:channel:entries channel="events"}

```

... **/calendar/2015/01** will only show entries with an `entry_date` from January 2015.

On the resulting page, you can use the Date Heading tag pair to dynamically display the month:

```
{date_heading display="monthly"}
    <h1>{entry_date format="%F %Y"}</h1>
{/date_heading}

```

To generate your list of months to filter by, look a the Archive Month Links tag.

---
Tags: channel-entries, php, entries, grouping
---


# Question
Title: how to make multi value variable in addon development
I am developing an addon for EE. i could not find a way to make a variable with multi value behavior. like: i would like to write in the template: {location:lat} {location:lng} this can be (Pair Variables) but it is always about loops.

what is the proper and the write Array syntax to parse to get what i want in the template.

thank you in advance

# Answer
> 1 votes
The only add-ons which have an official method of using variable modifiers are fieldtypes, where your fieldtype class' `replace_tag` function controls `{my_field}`, `replace_lat` controls `{myfield:lat}`, etc.

If you want to use the modifier sytax in a plugin or module, you'd simply name your variables `location:lat` and `location:lng` in the array you pass to `ee()->TMPL->parse_variables()`.

The standard way of accessing nested variables like this, given a variables array that looks like:

```
array(
    array(
        'location' => array(
            'lat' => 'foo',
            'lng' => 'bar'
        )
    )
);

```

... would be:

```
{location}
    {lat}
    {lng}
{/location}

```

---
Tags: templates, add-on, add-on-development
---


# Question
Title: Using Pages module, how can I still get 404 pages?
I have a template set up that I point various Channel Entries to via a pages URL. For example, I might have a channel on my site that contains all the various pages for a department, and all those channel entries point to a single template. That template, of course, shows whatever channel entry gets pumped its way.

I'm noticing that I'm never getting a 404 when an invalid URL is typed in; the template just serves a piece of content off the stack from the channel. So if I go to /whatever/labs I'll see the content I expect there. If I go to /whatever/labsARG I'll see some random content pulled from the channel, but never the 404.

I think the problem is that the template as set up is told to fetch an article/page from the channel - so if it isn't passed on explicitly it fetches one.

```
    {exp:channel:entries channel="pathology_content" limit="1" require_entry="yes"}

```

Any thoughts? Is there a way to designate this a Pages only template - ie, only show content if it's incoming from a Pages URL, otherwise 404?

# Answer
You're already using `require_entry`, so the final step is to use the `no_results` check.

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

```
> 2 votes

# Answer
in you control panel go to Design\>Template Manager \> Global Template Preferences

find 404 page and assign a 404 template. it works for me hope thats help
> 1 votes

---
Tags: ee2, 404, pages
---


# Question
Title: Expresso Store "custom order status" message input field - as textarea?
Is there a little modification to Expresso Store 2.5 that I can make that would turn the "custom order status" message input (that appears in the Order Status controls when you click "Edit Status", and displays on email notifications when you use {custom\_order\_status} ) to a textarea field of some size?

I have a client who often writes longer messages to clients when their order is shipped, and wants to use this field as the space for writing it. It would probably be more effective for this use if she had a textarea field to work with.

If it's more appropriate for them to be using some other method to put custom messages into Store notifications, I'd welcome being steered to that. (I suppose she can also just write the messages separately, if she needs to...)

Thanks!

# Answer
> 2 votes
it's a core hack, but yes. Open **/store/views/orders/show.php** and find line 56. Change:

```
lang('store.message').': '.form_input('message','','width=10%, style=width:50%').BR.BR.

```

To:

```
lang('store.message').': '.form_textarea('message','','width=10%, style=width:50%').BR.BR.

```

---
Tags: expresso-store, custom-order-fields
---


title: parsing decoded JSON array to template

text:
# Question
Title: parsing decoded JSON array to template
I made my first plugin I don't deal allot with variable and parsing. it was a JSON data to pars to a template. the problem is when I decode the JSON to an array Then I use parse the variables to the template I can't get the variables in my plugin tag. I found a question similar to my question but it did work for me either .

Parsing JSON in EE tag

can i get help please :D

```
    public function __construct()
{
    $this->EE =& get_instance();
    $find   = array("<", ">");
    $rep = array("{", "}");
    $json = str_replace($find, $rep, $this->EE->TMPL->fetch_param('json'));
    $json = current(json_decode($json,true));
    $json['location'] = array(
        array('lat'=>$json['location']['lat'],'lng'=>$json['location']['lng'])
    );
    $json['social'] = array(
        array('twitter'=>$json['social']['twitter'],'facebook'=>$json['social']['facebook'],'LinkedIn'=>$json['social']['LinkedIn'])
    );

    $vars = (array) array($json);

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

```

# Answer
> 1 votes
If it's not coming through, I'd bet it's malformed JSON, or more likely, your array structure is incorrect.

https://ellislab.com/expressionengine/user-guide/development/usage/template.html#parsing-variables

An easy way to test this is to dump your final array to the developer logger as json, and just compare the structure to how it should be as an array. To do this, add these lines of code right before you call parse\_variables:

```
ee()->load->library('logger');
ee()->logger->developer(json_encode($vars));

```

Then check the log in your control panel. It lives under Tools -\> Logs -\> Developer Log. Almost certainly you just have a malformed array structure. Compare your structure to the Ellis Lab examples.

# Answer
> 0 votes
in my case i get some json from other website it gives an ID for the returned json value. so I only needed the first element when decoding so I used `$json = current(json_decode($json,true))` and then I add this element of array the `$vars = (array) array($json);` after that I pared the variable as well.

```
$this->return_data = $this->EE->TMPL->parse_variables($this->EE->TMPL->tagdata, $vars);

```

}

now it works find with me . thanks allot

---
Tags: plugin, parsing, json
---


title: Modify inventory report

text:
# Question
Title: Modify inventory report
My client is asking me to show a custom field in the Inventory report (see attached screenshot).

As you can see I managed to add the field to the rendered table (InventoryReport.php) but I have little clue as to how I can query and pull the custom field's data (it's a simple text field).

Anyone tried doing this before? Or could you point me in the right direction?

# Answer
> 0 votes
Awesome, thanks for extra info, we have everything in the one file so the next question is where in the DB is the data for this column coming from?

**Getting the data**

So first, as you have seen the function `row` creates an individual row from the `$stock` variable passed. This is called in the function `run` on row 77.

Now depending on if your new info is coming from the expresso tables, or other EE tables or otherwise elsewhere. We can see the query that gets the data for each row starting at line 45. For the example I'm going to pull the `entry_id` from `channel_titles`.

If it's expresso data (coming from `store_stock`, `store_products`, `store_stock_options`, `store_product_options`, `store_product_modifiers` or `channel_titles`) all you'll need to do is extend the select query part on line 50 (see example). If it's in another table you will need to add some more joins (lines 46 to 49), but if you let me know the table, column and relationship I'll edit my example.

*lines 50 to 56*

```
    ->select(array(
            'store_stock.*',
            'channel_titles.title',
            'channel_titles.entry_id AS example,
            $db->raw('price + coalesce(sum(opt_price_mod), 0) as price'),
            $db->raw('group_concat(concat(mod_name, ": ", opt_name) order by mod_order, opt_order separator ", ") as description'),
            $db->raw('price * stock_level as stock_value'),
    ))

```

See how I've added `'channel_titles.entry_id AS example,`? so this will make a value in the array called 'example'. Next is display...

**Displaying the new data**

As you've already made room in the table this is easy:

*line 103*

```
    $stock->example,

```

replacing `"CUSTOM FIELD"`. Thats it you should get your entry id's in the column!

You should be able to elaborate from here, as I said if you need some advise on how to extend the query into another table, o if you want some help linking "piece of data X" to this query let me know and I'll edit some more help in.

**Word of Warning**

You are editing a file within a 3rd party module, this means if you update the module you may potentually overwrite your changes here. Just be warned and remember this change next time you're updating :)

**\_Adding data from channel fields**

As per the comments below, the below code snippets should get you most of the way there to retrieve a field value according to the product entry. Replace this code :

```
$query = Stock::join('channel_titles', 'channel_titles.entry_id', '=', 'store_stock.entry_id')
    ->join('store_products', 'store_products.entry_id', '=', 'store_stock.entry_id')
    ->leftJoin('store_stock_options', 'store_stock_options.stock_id', '=', 'store_stock.id')
    ->leftJoin('store_product_options', 'store_product_options.product_opt_id', '=', 'store_stock_options.product_opt_id')
    ->leftJoin('store_product_modifiers', 'store_product_modifiers.product_mod_id', '=', 'store_product_options.product_mod_id')
    ->select(array(
        'store_stock.*',
        'channel_titles.title',
        $db->raw('price + coalesce(sum(opt_price_mod), 0) as price'),
        $db->raw('group_concat(concat(mod_name, ": ", opt_name) order by mod_order, opt_order separator ", ") as description'),
        $db->raw('price * stock_level as stock_value'),
    ))
    ->where('channel_titles.site_id', config_item('site_id'))
    ->groupBy('store_stock.id');

```

With this :

```
$query = Stock::join('channel_titles', 'channel_titles.entry_id', '=', 'store_stock.entry_id')
    ->join('channel_data', 'channel_data.entry_id', '=', 'store_stock.entry_id')
    ->join('store_products', 'store_products.entry_id', '=', 'store_stock.entry_id')
    ->leftJoin('store_stock_options', 'store_stock_options.stock_id', '=', 'store_stock.id')
    ->leftJoin('store_product_options', 'store_product_options.product_opt_id', '=', 'store_stock_options.product_opt_id')
    ->leftJoin('store_product_modifiers', 'store_product_modifiers.product_mod_id', '=', 'store_product_options.product_mod_id')
    ->select(array(
        'store_stock.*',
        'channel_titles.title',
        'channel_data.field_id_30 AS entry_price_in',
        $db->raw('price + coalesce(sum(opt_price_mod), 0) as price'),
        $db->raw('group_concat(concat(mod_name, ": ", opt_name) order by mod_order, opt_order separator ", ") as description'),
        $db->raw('price * stock_level as stock_value'),
    ))
    ->where('channel_titles.site_id', config_item('site_id'))
    ->groupBy('store_stock.id');

```

This should add the value `$stock->entry_price_in` value tothe `$stock` variable. Not tested, but should get you going, don't forget to update the `row()` function ;)

PS\> Don't forget to mark this as the answer if it solves your question. :D

---
Tags: expresso-store
---


title: Handling smart quotes with supersearch

text:
# Question
Title: Handling smart quotes with supersearch
Channel data may contain ‘smart’ quotes/apostrophes, sometimes encoded. Yet site users naturally search using 'dumb' quotes. Therefore, supersearch may not find entries which ‘match’ the query!

Can anything be done about this?

# Answer
> 0 votes
Well, you are rather lacking any context or examples in your question, however I would recommend stripping characters like this, that could be confused, from the search term completely, go to primitive words. This way even if your results do have 'smart' quotes as you call them in them, the mathcing will be done on a no quotes basis.

as for extra's like `'s` and `'ll` ect, replace them with nothing "" so a search for `rat's` would be a search for `rat`, likewise a search for `"rat'` (notice the mismatched quotes) would also search for `rat`.

In the searched in fields, this will return results for `rat`, `rat's`, `"rat's"` or `ratatatata!`.

# Answer
> 0 votes
Well, looking plainly for an answer for you, we *can* do something about it, but it's not an \_easy 'turn this on'. there is some common sence cleaning already happening.

What we'll have to do is submit the form to our own php action/code in a template. 'fiddle' with the words a bit, submit them to the relivent library (in this case supersearch). This is a process I've used before:

1. Modify your search form to post to a different route/template
2. Add a template here, use `ee()->input->post()` to get your posted string
3. Add your PHP and recreate your sanitised search terms string
4. Look into Supersearch's code, it will reveal the function the form normally posts to, call this function from your php code with your sanitised string.

You could of course also do this with Javascript. With jQuery you could hook the click event of the search forms submit, clean your string with JS and return true from the hook function (allowing the submit)...

# Answer
> 0 votes
I'm assuming "dumb" synonymous to "curly", "fancy", or "typographic" quotes. Unfortunately there is little that can be done in this case: searches are done based on what is stored and present in the database. If you have data stored with a straight quote `'`, that is different, for a computer and MySQL query, to a curly/fancy/typographic/dumb quote . Super Search, and likely other search-based add-ons will see the character difference and not return the result.

Others might suggest modifying core files and code, but that is risky and can lead to even more complications (eg. not distinguishing between `'` and  is nice until you *do* want `'` to be distinguishable when it's used as something else than an apostrophe). In any case, this non-distinction isn't currently possible with Super Search. Nevertheless, I suggest submitting this as a Feature Request under the specific add-on category. It'll also give other users the option to vote up the feature request, and help us prioritize features to add in upcoming versions of this add-on. :) http://support.solspace.com/support/discussions

---
Tags: solspace, supersearch
---


# Question
Title: Get the product name {title} in the low stock email?
The default low stock email template only output the product ID number.

I've tried {title} in that template, but it does not get parsed.

Any way to do this?

# Answer
You can look up the title using entry id and channel:entries

```
<p>Low Stock Warning</p>

{exp:channel:entries channel="your_products_channel" entry_id="{entry_id}"}

<p>Low stock notification for item {title} (id number {entry_id}).</p>

{/exp:channel:entries}

<p>Stock level is currently at {inventory}</p>

<p>Please restock this item and update the stock level.</p>

```

Was trying to do this myself and just tried this and it works.

**N.B.** I think {inventory} needs to be outside {exp:channel:entries}
> 1 votes

---
Tags: cartthrob
---


# Question
Title: After 2.9.3 update tons of errors related “relationship_parser/VariableFinder.php”
After updaiting to EE 2.9.3 some my sites get many-many errors like this:

```
A PHP Error was encountered
Severity: Notice
Message: Uninitialized string offset: 19096
Filename: relationship_parser/VariableFinder.php
Line Number: 109

```

Some googling revealed that probably Grid filetype and obviously relationships are involved.

Do i need change something in templates, is some syntax changed?

Everything on web page works as it should.

# Answer
I think it's a bug. I've seen it on another project I wasn't working on and one just now that I am.

I think the problem stems from a Grid-within-a-relationship or vice-versa. I fixed the first way by splitting the tag into an embed (and passing entry\_ids into it), but on my project I had to update the core files, which I hate.

If you ever HAVE TO update core code, I always recommend commenting with a universal token "MYCOMPANYNAME\_DEV" so they can be searched for before an upgrade, along with your initials, date, and a description of what you've done (and wherever possible, keep the old code commented out).

I updated the lineToCharacterOffsets method in the VariableFinder.php file, found in /system/expressionengine/libraries/relationship\_parser

The line before:

```
if ($str[$offset] == "\n") {

```

put this:

```
if ($offset > strlen($str)) {
    $offset = strlen($str);
    break;
}

```

It's looking for a linebreak beyond the scope of the string (a string being just an array of char), so I just give it the end of the string and tell it to move on. It seems to do the trick, but hopefully this will be picked up and remedied soon.
> 0 votes

---
Tags: relationships, grid, update
---


# Question
Title: Automatically delete certain channel entries
My website has two channels: **pet\_owners** and **pets**. **pets** channel also has custom field named **owner\_id**.

My problem is: whenever an entry from **pet\_owners** is deleted, would it be possible to force certain entries from **pets** to be deleted as well?

For example: if an entry from **pet\_owner** gets deleted and its **entry\_id** was ***55*** then how to automatically delete those **pet** channel entries where the value of **owner\_id** would also be ***55***?

How to make it happen? Some plugin or module perhaps?

Thank you.

(P.S. The version of my EE is 2.5.5. Don't know if this information is important or not.)

# Answer
> 0 votes
A quick search around didn't find any current third party modules to do this. What you're asking for would require a very small extension to be written, it would take well under an hour for a developer who knows EE. You'd just need an extension hooked to the

```
delete_entries_loop($val, $channel_id)

```

extension hook and use something like this:

```
function delete_pets($val, $channel_id)
{
    // look up field id
    $field_num = ee()->db->select('field_id')
                         ->where('field_name', 'owner_id')
                         ->get()
                         ->row_array();

    $field_id = 'field_id_' . $field_num['field_id'];

    // look up your entries with that field matching this entry
    $entry_ids = ee()->db->select('entry_id')
                         ->from('channel_data')
                         ->where($field_id, $val);
                         ->get()
                         ->result_array();

    // forgot to map this baby down
    $ids = array_map(function($a) { return $a['entry_id']; }, $entry_ids);

    // kill those entries
    ee()->api_channel_entries->delete_entry($ids);
}

```

---
Tags: channel, custom-fields, delete
---


# Question
Title: Simple exp:channel:entries not working on specific template
I have a very simple exp:channel:entries tag that works on several template files but not on the specific one I want to use it on. I am new to Expressionengine, but from everything I know about it, what data you can should not depend on context. But that is how this is acting sort of. I have also tested to see if it is some error in the template file by deleting everything but this tag and it still does not work in this location. Can anyone please explain why this tag would not work in this specific template? Thanks all for the help.

```
{exp:channel:entries
channel="insights"
disable="categories|category_fields|member_data|pagination|trackbacks"
limit="2"
} {/exp:channel:entries}

```

# Answer
> 2 votes
Adding dynamic="no" fixed this issue.

---
Tags: templates, channel, tags
---