title: A list of entries inside Playa tags

text:
# Question
Title: A list of entries inside Playa tags
In the below I need the field `{link_rhs}` to display a link to any page or entry on the website. Previously we were using StructureFrame which was perfect for displaying pages, but it doesn't display all entries. Do I need the `{link_rhs}` field to also be a Playa field? How can a Playa field work within a Playa field? Or maybe another option?

```
{exp:playa:parents channel="rhs_cta" dynamic="off" entry_id='{embed:entry_id}'}
<article class="post">
    <figure>
        <a href="{link_rhs}">
            <img src="{thumbnail_image_rhs}" alt="{title}">
        </a>
        {if ribbon_title}<span class="green">{ribbon_title}</span>{/if}
    </figure>

    <div class="text">
        <h2><a href="{link_rhs}">{title}</a></h2>
        <p>{text_rhs}</p>
    </div>
    <hr class="desktop-version">
</article>
{if no_parents}
    {embed="embeds/latest-blogs"}
{/if}
{/exp:playa:parents}

```

# Answer
Sure, `{link_rhs}` can be a Playa field, and can be displayed inside of the `playa:parents` loop. Just use the standard fieldtype tag pair.

```
{link_rhs}
<a href="{comment_url_title_auto_path}">
    <img src="{thumbnail_image_rhs}" alt="{title}">
</a>
{/link_rhs}

```

I use comment\_url\_title\_auto\_path here in case you're allowing entries from multiple channels )and hnce multiple URL structures) to be selected in the Playa field.
> 1 votes

---
Tags: playa, relationships, structure
---


# Question
Title: Grid Field Count Search in Channel Entries
Is there a way to filter `{exp:channel:entries}` based on the number of rows in a Grid field?

# Answer
Not natively, no. But you could use the Query module to populate the `entry_id` parameter:

```
{exp:channel:entries channel="foo" entry_id="
    {exp:query sql="
        SELECT entry_id, count(*) AS count
        FROM exp_channel_grid_field_XXX
        GROUP BY entry_id
        HAVING count > X"
        backspace="1"}{entry_id}|"{/exp:query}
"}

```
> 1 votes

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


title: Assets and subfolders

text:
# Question
Title: Assets and subfolders
I'm using Assets 2.0.4 and I just noticed that it doesn't include my subfolders that exist within my upload directories from when I had Assets 1. For instance, I have a press releases folder that has about 8-10 subfolders in it, but all I see in Assets 2 is the parent directory. Is this a bug?

If not, how would I get all of my subfolders indexed in Assets without having to re-upload them all?

System: EE 2.5.5 / Assets 2.0.4 / PHP 5.2.

# Answer
> 1 votes
An update fixed the issue. Thanks for the help, Lisa.

---
Tags: assets
---


title: ExpressionEngine with Percona Cluster?

text:
# Question
Title: ExpressionEngine with Percona Cluster?
I've tried using Percona Cluster as a drop-in replacement for MySQL.

However when templates are saved, each cluster node is updated with a different value for the primary key column `template_id` in the `exp_templates` table. The primary key column `group_id` in the `exp_template_groups` table is also different on each node when group updates are made or a group is created.

This (obviously) causes database inconsistencies, and templates to disappear depending on which MySQL cluster node they're served by.

Does anyone have any experience or advice on whether or not EE2 with Percona Cluster is possible?

# Answer
Ok.

I changed the storage engine of EE database from MyISAM to InnoDB. And now the database is replicating the primary key columns of the `exp_templates` and `exp_template_groups` tables correctly.

It may have something to do with Percona Clusters' limitations:

The main Percona site (Percona XtraDB Cluster Limitations) states:

> Currently replication works only with InnoDB storage engine. Any writes to tables of other types, including system (mysql.\*) tables, are not replicated.

However numerous blogs on the Percona Blog state that MyISAM replication can be enabled via the `my.cnf`. But is currently experimental only...

MySQL Performance Blog....

> **Does replication of MyISAM form any bottlenecks in XtraDB Cluster? If so, how bad?**
>
> MyISAM replication in PXC/Galera is labeled as experimental, but I think that’s a misnomer. It should be labeled “broken by design“. MyISAM replication really will never work properly with Galera due to its non-transactional nature.....

For now I'm not sure there's a solid answer on whether MyISAM replication works properly.
> 2 votes

---
Tags: ee2, database, mysql
---


# Question
Title: Username field validation on registration form
I have absolutely zero experience with Expression Engine but I've been given a task to fix a validation on a registration form. There's a username field that is supposed to validate as email address only but right now it accepts any string. I have no idea if that registration is a plugin or built in. I found it's template in /themes/forum\_themes/site/forum\_member

I suspect I need to find a model for the registration db table now and change the validation type from string to email? Or something like that? I have basically no idea where to start without getting to know EE from scratch.

Any help apprieciated. Thanks

# Answer
That's the native EE forum template.

I suggest using the jQuery Validation plugin http://jqueryvalidation.org/. You can add the code to the forum header template. I don't know the header template name offhand but it should be in the same directory.

```
<form id="registration" action="">
    <input id="email" type="email" name="email" required>
    <input type="submit" value="Submit">
</form>
<script>
    $("#registration").validate({
        rules: {
            email: {
                required: true,
                email: true
            }
        },
        messages: {
            email: {
                required: "Please enter a valid email address"
            }
        },
    });
</script>

```
> 3 votes

---
Tags: email, forum, validation, username
---


# Question
Title: How to re-assign channels to different field groups?
I have channels sharing the same field group and am thinking about re-assigning them to different groups because they will develop in different directions (= different fields needed). Is this possible and what would be the best approach? Thanks a lot for suggestions!

# Answer
If you've already got a lot of entries published in any of these channels I'd recommend *not* changing the field group for those channels. The reason being as soon as you go to edit one of your existing entries you will not see the custom fields where you data was stored and as soon as you resave the entry you will lose the data that was stored in the custom fields in the old field group.

So instead just add any new fields to the existing field group to accommodate the different directions your channels are headed in. Then use Publish Layouts on a per-channel basis to hide any irrelevant fields.

---

If you really need to change the field groups and you have a lot of entries you can migrate the existing field data to new the new fields. You'd need to create analogous custom fields in your new field group and then use SQL to copy the data over to the new fields in `exp_channel_data`.

Here is some SQL to use as a starting point:

```
UPDATE exp_channel_data
SET field_id_X = field_id_Y
WHERE channel_id = Z

```

X = the *new* field ID number
Y = the *old* field ID number
Z = the channel ID for the channel at hand

I recommend using a tool like Sequel Pro to help you inspect the data and run the queries. Make sure you backup your database first!
> 2 votes

---
Tags: field-group
---


# Question
Title: Product Method - Order Item Hash in return URL
Is there a way that you can return a hash of the order line as part of the "Add to basket" button?

For example,

`/basket/added/ORDER_ITEM_HASH`

Then, it would be great if on the page you can find the order item by this hash and show the user an informative notification rather than a simple "Added to basket" message.

> You have added the **Acme 3000** to your basket with the following options:-
>
> * Colour: Red
> * Size: Large
> * Qty: 4

# Answer
> 2 votes
I don't think there's a way to do it exactly like you're asking.

Perhaps you could add a `{exp:store:cart}` tag at the top where you want to display the message and inside the `{items}` loop, use a conditional to only show the last item added. Something like this

```
{exp:store:cart}
    {items}
         {if item:count == item:total_results}
            display item
         {/if}
    {/items}
{/exp:store:cart}

```

---
Tags: expresso-store
---


# Question
Title: When multiple channel forms present each containing a matrix, the add row button adds multiple rows
When a page contains multiple channel forms on the same page, each with a matrix field; the Add Row button adds multiple rows (1 per channel form on the page it seems.)

Is there any easy way to work around this?

# Answer
> 3 votes
After examining some pseudo-related questions I discovered that multiple instances of the matrix.js were being loaded causing multiple executions upon the Add Row click event. I added `include_assets="no"` on channel forms after the first one which prevented the problem.

---
Tags: matrix, channel-form
---


# Question
Title: Move categories from one group to another
In a category group "Shops & Services" we have three parent categories each with many sub-categories:

* Offices
* Services
* Retail

The Retail (parent category) has grown to a point where it needs to become its own category group. In the end we will have these groups:

* Offices & Services
* Retail

Is there a best method for doing this? There are quite a few entries here so manually updating each individual entry would be daunting. Would it be as simple as running a SQL query?

# Answer
**UPDATE**

Since you would probably prefer to truly just move an existing category to a new group (and not create new ones and reassign entries as outlined below), this SQL is all you would need:

```
UPDATE exp_categories
SET group_id = X
WHERE cat_id = Y OR parent_id = Y

```

X = new category group
Y = parent category that you want to move to new group

The `OR` clause will catch and move the child categories to the new group as well. Remember to make a backup first.

---

The edit page in the CP does include an option to filter entries by category and then mass-assign a new category. I've used this to do exactly what you've described.

1. Filter by your old category to get the entries
2. Select (check) all entries,
then choose "Add Categories" bulk action from the menu on the bottom right

This is practical if you don't have *too* many entries that need systematic recategorization (say a few hundred). Just set the limit on the edit page search to 150 entries so you mass-apply categories to a larger batch at each pass.

Otherwise, yes, SQL is the way to go. Just create your new category and note its ID. Then run the following query (backup your database first):

```
UPDATE exp_category_posts
SET cat_id = X
WHERE cat_id = Y

```

X = the new category ID
Y = the old category ID
> 5 votes

---
Tags: categories, mysql
---


# Question
Title: Reset Password not displaying errors inline?
Using Profile:Edit and am having a hard time getting errors to display inline:

```
{exp:profile:reset_password return="account/reset-confirmed" error_handling="inline"}
  <label>Password</label>
  <input type="password" name="password" value="">

  <label>Password Confirm</label>
  <input type="password" name="password_confirm" value="">

  <input type="submit" value="Submit" >
{/exp:profile:reset_password}

```

Am I missing something obvious or is this just not possible?

Thanks!

# Answer
> 2 votes
It seems that you're missing the variables within the tag to output the errors. See the errors portion of the docs for information about the available variables and conditionals.

---
Tags: profile-edit
---


# Question
Title: How to include text editor in third party module for CP?
I need to include a text editor in a custom module developed. Can anyone help how to include WysiHat or Rich text editor in a form in the module addon developed?

# Answer
> 1 votes
This is how I do it in ProForm and other add-ons...

Basically, you first put the needed files into the themes/third\_party directory under a new directory name that matches the name of your addon's main third\_party folder.

For instance, if your module is at this location:

```
system/expressionengine/third_party/module_name/mcp.module_name.php

```

You would place your assets here:

```
themes/third_party/module_name/

```

At that point you just need to include a reference to the JS/CSS files, which is pretty easy to do, just put these lines into your module's constructor:

```
$this->EE->cp->add_to_head('<link rel="stylesheet" href="'
    .$this->EE->config->item('theme_folder_url')
    .'third_party/module_name/editor/styles/stylesheet.css" type="text/css" media="screen" />');

$this->EE->cp->add_to_head('<script type="text/javascript" src="'
    .$this->EE->config->item('theme_folder_url')
    .'third_party/module_name/javascript/editor/javascript/prolib.js"></script>');

```

You can then either use an inline `<script>` tag in your view file to trigger the binding on the editor according to their documentation, or you can create your own external JS file and include it the same way as above in the constructor.

---
Tags: add-on, control-panel, module, editor
---


title: Solspace Importer Grid field

text:
# Question
Title: Solspace Importer Grid field
Does the Solspace Importer support the new EE Grid field? I didn't see it mentioned anywhere in the documentation, only the Matrix field. If yes - any documentation available?

# Answer
> 1 votes
As of this writing, Importer does not import into Grid fields.

I suggest commenting or adding your +1 in our feature request section found here: http://support.solspace.com/support/discussions/

In particular, this feature request thread seems spot-on: http://support.solspace.com/support/discussions/topics/33803

---
Tags: matrix, solspace, grid, solspace-importer
---


title: Calendar Month in Arabic

text:
# Question
Title: Calendar Month in Arabic
I am using the Month calendar. I would like to display the months and days in Arabic language. Can anyone help me with this?

---

Can you please guide me how to call the arabic calendar?

# Answer
> 2 votes
For maximum control over the data and markup of a calendar, you should use the `{exp:calendar:cal}` tag instead of the `{exp:calendar:month}`. The latter is a shortcut to the former. Please see the **advanced** example in the documentation: http://www.solspace.com/docs/calendar/month//#examples

You may also need to translate the language file in Calendar under `/system/expressionengine/third_party/calendar/language/english/lang.calendar.php`. Of course, instead of "english" you might want to create a separate "arabic" folder containing lang.calendar.php, to have `/system/expressionengine/third_party/calendar/language/arabic/lang.calendar.php`

---
Tags: solspace-calendar
---


title: Password protect one specific page

text:
# Question
Title: Password protect one specific page
I want to password protect one specific page on an ee site.

```
http://nameofsite/site/media

```

for some reason I can't get it to work

I have both htaccess and htpasswd in the site folder.

# Answer
Since `/site/media` this isn't really a directory you won't be able to do it with plain old htaccess. But you *can* use ExpressionEngine's Template Access Restriction to accomplish the same thing, though.

See the option on HTTP Authentication

> If this setting is enabled, users will be prompted to login with their username and password to view the template using a standard HTTP Authentication dialog box.

Just set up a user account with the desired username and password. You may want to create a member group with the correct permissions just for this one account.
> 1 votes

# Answer
You might try using Authentic, a plugin which specifically lets you set up basic authentication on arbitrary templates.
> 3 votes

---
Tags: member-management
---


title: how to show my recent post on home?

text:
# Question
Title: how to show my recent post on home?
please help me ... i'm nubiew on EE.

how to display the latest article on the front page, so I want each of my finished publishing my article and the article was immediately appear on the front page.

how to change this into a recent article:

```
<div class="container">
            <div class="row">
                <div class="span6">
                    <h3>Latest News</h3>
                    <ul class="bloglist-small">
                        <li>
                            <div class="date-box">
                                <span class="day">28</span>
                                <span class="month">SEP</span>
                            </div>
                            <div class="txt">
                                <h5><a href="#">Lorem ipsum sit amet</a></h5>
                                <span class="read">Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem</span>
                                <span class="info">Sept 23, 2013 | <a href="#">Read More</a></span>
                            </div>
                        </li>
                        <li>
                            <div class="date-box">
                                <span class="day">24</span>
                                <span class="month">SEP</span>
                            </div>
                            <div class="txt">
                                <h5><a href="#">Lorem ipsum sit amet</a></h5>
                                <span class="read">Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem</span>
                                <span class="info">Sept 23, 2013 | <a href="#">Read More</a></span>
                            </div>
                        </li>
                        <li>
                            <div class="date-box">
                                <span class="day">20</span>
                                <span class="month">SEP</span>
                            </div>
                            <div class="txt">
                                <h5><a href="#">Lorem ipsum sit amet</a></h5>
                                <span class="read">Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem</span>
                                <span class="info">Sept 23, 2013 | <a href="#">Read More</a></span>
                            </div>
                        </li>
                    </ul>
                </div>

```

this is screenshot:

and this is my web danchindia.com

# Answer
> 1 votes
Dan, i will advice you to take some time and learn the basic concept behind EE -:) There are free tutorials around, on Train-ee for example you can follow the free tutorials. *Building a Simple News Site from Start to Finish* is part of the official User Guide.

To show the 3 latest news, you can use this..

```
<ul>
{exp:channel:entries channel="news" limit="3"}
<li>
<div class="date-box">
<span class="day">{entry_date format="%d"}</span>
<span class="month">{entry_date format="%M"}<</span>
</div>

<div class="txt">
<h5><a href="{url_title_path='news'}">{title}</a></h5>
<span class="read">{YOUR_CUSTOM_FIELD}</span>
<span class="info">{entry_date format="%F %j, %Y"} | <a href="{url_title_path='news'}">Read More</a></span>
</div>
</li>
{/exp:channel:entries}
</ul>

```

# Answer
> 1 votes
Try to create a snippet called {sp\_lastest\_post} and place these lines inside it

```
<ul class="bloglist-small">
    {exp:channel:entries channel="channel_name"
                         category="cat_id"
                         limit="10"}

        {!-- Begin Loop --}
        {!-- Replace below values with channel entries tag variables --}
        <li>
            <div class="date-box">
                <span class="day">28</span>
                <span class="month">SEP</span>
            </div>
            <div class="txt">
                <h5><a href="#">Lorem ipsum sit amet</a></h5>
                <span class="read">Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem</span>
                <span class="info">Sept 23, 2013 | <a href="#">Read More</a></span>
            </div>
        </li>

        {!-- No Results Message --}
        {if no_results}<h4>Updating...</h4>{/if}

    {/exp:channel:entries}
</ul>

```

Then place the snippet to wherever you want your posts to appear.

---
Tags: ee2
---


# Question
Title: ExpressionEngine and Magento integration?
I am getting a little frustrated with EE ecommerce modules. They are great, but just don't have the flexibility or features for our larger clients. I'm really not too keen on having two systems - it's seems like a step back in time.

However, I have used all the EE ecommerce addons and am starting to think it might be the way to go. A dedicated ecommerce platform will naturally be more powerful for serious online retailers.

I've been looking recently at Magento. I'm not 100% convinced of it yet.

I've been reading all the docs I can find that relate to integrating the two. It seems pretty straightforward on the templating side, however, I'm wondering if anyone ever found a solution to help manage users? Sharing sessions etc?

I'd be interested in hearing your views/solutions to this if you have one.

Anyone found the right solution? Or built an extension that might help?

# Answer
> 2 votes
I have built a couple of sites that integrate EE into Magento with both Magento Enterprise and Magento Community. Basically I use EE for the part of the navigation the, left nav on CMS pages and the footer for the entire site. When you are wanting content fro the CMS you basically force a 404 error in Magento and you override the 404 controller in Magento and then pass the request off to EE. Once you get the generated html back from EE you give that to Magento to display.

Here is a link the give you an idea of how to do this, I used to have a really well documented blog post from someone but for the life of me I can not find the post any more.

http://www.magentocommerce.com/blog/comments/tutorial-integrating-3rd-party-cms-content-within-magento/

# Answer
> 0 votes
I have not had the need for sharing session between Magento and EE. The clients using the admins have been pretty tech savvy so having the 2 admins have not been an issue once they were shown what admin did what. Now if you have a client that is not very web savvy then not sure how that would go over but I have been lucky so far.

---
Tags: ee2, ecommerce, magento
---


# Question
Title: Assets folders showing...but no image thumbnails are loading
I'm using EE 2.7.2, PHP 5.3.27, and Assets 2.2.2 and I'm running into a weird issue that I haven't come across. I'm getting 403 forbidden errors in my javascript console and I check the files on the server and they're there and the permissions are correct.

What I'm trying to do is load the module Assets in the EE CP and it loads the subfolders on the left hand-side but it doesn't load any image thumbnails on the right. When I try and update indexes, I select a folder or two, and then I push the Update Indexes and it just greys out and doesn't do anything. I checked my file upload paths and they are correct and I've loaded files in those folders to make sure they load without an issue. My permission settings on the folders are all 777 and I made sure my cache folder and all folders enclosed were 777.

The red warnings are "POST http://mydomain.com/ 403 Forbidden" against the file "jquery.js?v=1386166017:178"

Any thoughts or help would be great?

(If you're wondering about an .htaccess issue...I use the same .htaccess file on another site...same provider...same plan...and it works...so something went weird on this install.)

# Answer
If you're getting HTTP 403, rather than the cross-domain error that most people get, then you might be hitting the incompatible session bug. Assets uses Ajax to do a lot of things and that is processed via Frontend by EE, so if your Control Panel Session and User Session types are not compatible, the Ajax requests will think you're not logged in.

You cna try going to Admin -\> Security and Privacy -\> Security and Sessions and changing settings for "Control Panel Session Type" to "Cookies and Session Id", and changing "User Session Type" to "Cookies only". This should make sure that if you're authorized in the CP, when you access anything via front-end (such as any of Ajax requests), EE is able to recognise your credentials.
> 3 votes

---
Tags: ee2, assets, jquery
---


title: Store: Orders not completing

text:
# Question
Title: Store: Orders not completing
I posted this question a while ago under a different user - I can't comment on that one, so I'm reposting. Hope that's OK!

I'm having a problem with exp-resso whereby my client is receiving payment for orders made on the site but the orders are not appearing in the 'Orders' section of the store - they are remaining as 'Incomplete'

The first port of call would be the payment gateway, as it appears not to be flagging payment. However, the problem is appearing with both PayPal Express AND the Barclaycard EPDQ gateways.

Any pointers?

EDIT Apparently users are getting redirected to the order confirmation page as expected, but there is no order confirmation ail generated, and the order remains at 'incomplete'

Using EE 2.53 and Store 1.6.4

# Answer
> 1 votes
It's almost impossible for payments to be collected with Paypal and yet the order to remain incomplete. Paypal doesn't actually collect the funds until Store marks the order as complete. So that seems unlikely - I would check with your client and find exact steps to reproduce the problem.

With some other gateways, they only notify Store of the payment success, and there is a possibility the payment may go through but Store's notification URL is not called successfully. This could either be because the gateway didn't call the URL, or because your site blocked it for whatever reason.

Often a good place to start when debugging this sort of thing is to look at your server access logs and see if you can see the gateway calling the correct `index.php?ACT=` URL on your site, right after an order is completed. That will tell you whether or not your site is receiving the message or whether the problem is with the gateway.

# Answer
> 0 votes
I thought I'd just update this, as other people may find it useful

It turns out that the reason this started failing was that Barclaycard had done a major upgrade and migration of their payment system. They had informed the merchant, but the merchant, in their wisdom, didn't think it necessary to inform me!

I can't believe that they didn't associate the transactions failing with the email from Barclaycard informing them of a major system upgrade.

D'Oh!

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


# Question
Title: Plugin to conditionally update status via cron
I need to create a plugin to conditionally update the status on all entries in a channel each day based on a date field. I don't think I need to interact with a template in this case, so would want to call the plugin directly via cron.

What I'm looking for are any example plugins that might lessen my learning curve in how to get and loop through all entries from a channel and conditionally update the status based on the date?

# Answer
You would actually want to use a module for this, so that you can have an action ID associated.

The module development documentation section about the install method mentions how to setup action IDs, which basically allow you to load `http://yourdomain.com?ACT=123` from a cron job and run a method from your module.

From there you simply need to build out your module method. It sounds like your operation is fairly simple, and so you can probably just use the CodeIgniter active record class to query for the correct entries to deal with and then update the statuses accordingly.
> 3 votes

# Answer
An alternative: if you're comfortable having a script outside of EE access your database, you could write a simple-ish SQL update statement, and have your cron run that script.

The SQL would be something like this:

```
update exp_channel_titles
set status = 'new status'
where entry_date > 1385943600 and channel_id = 1

```

If you're using a "custom" field for the date, then you'll need to do a join, like

```
update exp_channel_titles a join exp_channel_data b
on a.entry_id = b.entry_id
set a.status = 'new status'
where b.field_id_123 > 1385943600 and a.channel_id = 1

```

Your field\_id\_123 will be the internal name of your custom field--it's just the field's ID number tacked on to field\_id\_.

PHP for accessing the database (again, outside of EE), looks something like:

```
$db = new mysqli($db_hostname, $db_username, $db_password, $db_name);
if ($db->connect_errno) {
   die('Failed to connect to DB');
}

$query = "YOUR SQL UPDATE STATEMENT";

$db->query($query);

```
> 2 votes

# Answer
I think you already have your answer but if you need an additional reference (albeit an old one) then take a look at the CRON job EE page template code for the 'Paid Members' extension, you drop this into a EE template, enable PHP and then call it using a CRON job.

https://github.com/ninefour/paid\_members.ext.ee\_addon/blob/master/templates/cron/expireUsers.php

It's EE1.x stuff but again might be useful as a reference.
> 2 votes

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


# Question
Title: Resolving conflict between variables between main loop and playa:parents loop
Playa experts out there: I thought variable prefix parameter would solve this one, but perhaps I'm misunderstanding how it's intended to be used. Here's what I'm trying to do:

```
{exp:channel:entries set="prod" dynamic="no" disable="pagination"}
<li class="{if segment_1 == url_title} active{/if} has-dropdown"><a href="{path='{url_title}'}">{title}</a>
    <ul class="dropdown">
    <li class="has-dropdown"><a href="{path='{PROD_CHANNEL_url_title}/docs'}">API Docs</a>
{exp:playa:parents channel="api" field="cf_apis_related_product"}
<ul class="dropdown">
    <li><a href="{path='{PROD_CHANNEL_url_title}/docs/{API_CHANNEL_url_title}'}">{title}</a></li>
</ul>
{/exp:playa:parents}
{/exp:channel:entries}

```

Is there a namespacing way to get the url title from within the wrapping entries loop WITHIN the playa parents loop?

# Answer
> 3 votes
This is what the `var_prefix=""` parameter is for. Update your code like this.

```
{exp:channel:entries set="prod" dynamic="no" disable="pagination"}
...
    {exp:playa:parents channel="api" field="cf_apis_related_product" var_prefix="api"}
    <ul class="dropdown">
         <li><a href="{path='{PROD_CHANNEL_url_title}/docs/{api:url_title}'}">{api:title}</a></li>
    </ul>
    {/exp:playa:parents}
{/exp:channel:entries}

```

---
Tags: playa, custom-fields
---


title: Bayesian rating values on entries page

text:
# Question
Title: Bayesian rating values on entries page
I use the Rating module. I need to get bayesian rating value for every entry but not simply average summ. Is it possible?

The part of my template (this is standard example for Rating module usage):

```
{exp:rating:rank collection="Book Reviews" orderby="bayesian:overall" limit="10" paginate="bottom" dynamic="off"}
    <div class="entries">
       <h4>{exp:rating:stats collection="Book Reviews" entry_id="{entry_id}" precision="1"}<span style="float:right;">{stars_overall_avg} ({overall_avg}/5, based on {overall_count} review{if overall_count !="1"}s{/if})</span>{/exp:rating:stats}
       <a href="{url_title_path='rating_main/entry'}">{title}</a></h4>
       <p><b><u>{entry_id}</u></b></p>
       <p>Author: <a href="{path='rating_main/author_profile'}/{author_id}/">{author}</a></p>
       <p>Description: {if summary}{summary}{if:else}{body}{/if}</p>
   </div>
   {if rating_no_results}<p>No results.</p>{/if}
   {rating_paginate}
       <hr />
      <p>Page {current_page} of {total_pages} pages   {pagination_links}</p>
   {/rating_paginate}
{/exp:rating:rank}

```

Best regards, Aleksey

# Answer
I think you would need to write a custom plugin for this. It should be simple enough to pass an entry ID to a plugin, and then from the plugin query for the needed rating data and follow an algorithm to calculate the rating you need.
> 2 votes

---
Tags: solspace, solspace-rating
---


# Question
Title: Error "The action you have requested is invalid" while fetching data via AJAX in EE 2.7.2
I try to implement infinite scrolling in EE 2.7.2.

There are 2 templates: "infinite\_scrolling\_main" and "infinite\_scrolling\_embed". There are no forms in any of these two templates. AJAX call from the page outputted by template "infinite\_scrolling\_main" should fetch the data outputted by template "infinite\_scrolling\_embed".

This setting worked correctly prior to EE 2.7. But after upgrade to 2.7.2 any AJAX call outputs error message "The action you have requested is invalid" instead of proper data.

This issue seems to be related to XID handling. If I set

```
$config['secure_forms'] = "n";

```

AJAX works correctly.

What should be done to keep secure forms and to be able to fetch data via AJAX in EE2.7.2?

# Answer
You can avoid the XID validation by making a GET request instead of a POST request. XID validation only occurs when secure\_forms is `y` and the `$_POST` array is not empty.

Or you can generate a valid XID hash by using `{XID_HASH}` in your template. Maybe something like:

```
<body data-xid="{XID_HASH}">

<script>
$.post(
  'site/inifinite_scroll_ajax',
  {
    XID: $('body').data('xid')
  },
  function(data, textStatus, jqXHR) {
    // Update the XID with a fresh one from the response headers
    $('body').data('xid', jqXHR.getResponseHeader('X-EEXID'));

    // Do whatever you want with data
  }
);
</script>

```

In the response, EE will send along a fresh XID hash in a custom HTTP header, X-EEXID. You can use that new hash for the next request. In the callback in my example, it updates the xid stored in the body data-xid attribute with the fresh hash.
> 4 votes

---
Tags: forms, ajax, xid, secure
---


# Question
Title: playa:child_ids parameters are not working
we have a big issue with the following code:

```
{event_related_media:child_ids limit="2" status="Archived" channel="video" show_expired="no" show_future_entries="no"}

```

With the following code, I get all the children entries id. None of the parameters are used to filter the results.

The official doc says explicitly that child\_ids tag "supports almost all of {exp:channel:entries}’ tag parameters", but, well, no...

To be sure, I debug all SQL requests of the template, and whatever I used as channel name parameter (for instance, 'foo'), 'foo' is never used in any sql query.

Any idea?

Pv

# Answer
> 5 votes
That’s an error in the documentation, and we’ll get that fixed. `:child_ids` only supports filtering entries with the following parameters:

* var\_id
* var
* element\_id
* field\_id
* field
* col\_id
* col
* row\_id
* child\_id
* parent\_id

If you need anything else, and you should just use a tag pair:

```
{event_related_media
    limit="2"
    status="Archived"
    channel="video"
    show_expired="no"
    show_future_entries="no"
    backspace="1"
}{entry_id}|{/event_related_media}

```

---
Tags: playa, pixelandtonic
---


title: Expresso custom payment module

text:
# Question
Title: Expresso custom payment module
I have just finished rewriting a custom payment module for Barclaycard ePDQ, and it's working up to a point.

The problem comes on the return from ePDQ, whereby the user is returned to the checkout\_confirm page instead of the /store/order/ORDER\_HASH as expected.

I just have a pretty standard purchase\_return function with

```
return new Merchant_response(Merchant_response::COMPLETE,'',$orderid);

```

The gateway is being sent $this -\> param('return\_url'); as you'd expect, and if I trap the return I get www.mydomain.mysite/?ACT=16H= etc etc as expected

Any pointers as to why I'm not getting sent to my order page?

# Answer
> 2 votes
Having found the answer, I realise my question doesn't contain nearly enough details!

I was using POST to retrieve the return parameters, whereas the merchant gateway was sending GET.

---
Tags: expresso-store
---


# Question
Title: Can you use embed variables within a css file?
I'm using a css file that uses channel entries tags so clients can update a background-image. However, I have embed variables setup on my template that I want to pass into the css file, but it doesn't seem to work. This is what I'm trying to do:

```
{exp:channel:entries channel="contact"}
    .{embed:body_class} #wrapper { background-image: url("{contact_header_photo:1920x425}"); }
{/exp:channel:entries}

```

where, in theory, `.{embed:body_class}` would output `.contact`

Anyone have any suggestions?

# Answer
> 6 votes
I've been done this sometimes.

Since this code is used just on some pages, I suggest you to not use a CSS file, but the `<style>` tag on the head of the HTML. This situation doesn't even worth the download of the CSS: it's one single rule to be used just on one single page.

This can be an `snippet`:

```
{exp:channel:entries channel="{pr_channel}"}
<style>
    #wrapper { background-image: url("{{pr_channel}_header_photo:1920x425}"); }
</style>
{/exp:channel:entries}

```

On every page, you can use a `preload_replace`, like:

```
{preload_replace:pr_channel="contact"}

```

There are some variations of this technique you can use.

---

By the way, you can use the `{path}` variable to parse EE variables on the css:

```
<link rel="stylesheet" type="text/css" media="all" href="{path='channel/channel_css'}" />

```

This article talks about this. But the CSS **will not** be an embed. An embed template is intended to be part of the current final file.

# Answer
> 1 votes
You can if you are using an EE CSS template but the question is, do you really need to?

If it's just a small bit of CSS there really is no harm in including it in the head of your HTML or even inline. The extra bit of code in your template is probably going to be much less a performance hit than shoving an entire CSS file through EE's parser.

---
Tags: css
---


# Question
Title: Solspace Calendar does not displaying past events
When I use this code (specifying an entire year of past and upcoming events), Calendar only displays upcoming events and fails to display events which have already passed.

```
{exp:calendar:events date_range_start="2013-08-01" date_range_end="2014-08-01"}

```

(The behavior is the same when I use the `{exp:calendar:cal}` tag pair.)

**How can I get past events to show up in my event list?**

# Answer
> 1 votes
I'm a fool — My client had (unbeknownst to me) added expiration dates to all the entries. (Calendar is behaving exactly as expected, showing all ***non-expired*** events within the provided date range.)

In this case, I shall clear out the expiration dates from the entries and clarify to my client that the Calendar takes care of both the starting and ending dates.

The `show_expired` parameter would also work.

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


# Question
Title: Allow multiple (assigned) members / authors to edit an entry
Currently i use safecracker in combination with author\_only="yes" to allow members to publish and edit their own news and edit their info page.

**What would be a method / procedure or what would you suggest to allow<br>multiple members to edit one specific entry (e.g. the info page)?**

* I can't just only remove the author\_only parameter and allow all members to edit all info pages. Only assigned members should be able to edit an entry.
* Is a relationship/playa field on the info-page a possible route? How would you check for access-privileges?

---

**Edit:** one approach is with categories but this gives more broad access to editors.
Limit Safecracker access to specific entries, using member groups and categories

---

**Edit2:** Possible solution, using a modified version of chosen\_member addon
(e.g. added a method to check if logged in user is selected)

```
{exp:channel entries url_title="segment_3" }
  {if chosen_member_field:is_chosen=="yes"}
    {embed="group/safecracker" entry_id="{entry_id}"}
  {/if}
{/exp:channel:entries}

```

# Answer
Something like this should work. You have to make a 2 steps verification:

```
{!-- Ensure user is logged in --}
{if logged_out}
    {redirect="/login"}
{/if}
{!-- Check if user can view this entry --}
{exp:channel:entries
    channel="mychannel"
    disable="custom_fields|categories|category_fields|member_data|pagination|trackbacks"
    dynamic="off"
    require_entry="yes"
}
    {if no_results}{redirect="404"}{/if}
    {exp:pvl_checkif value="{member_id}" is_not_in="{authorized_members}"}{redirect="/unauthorised"}{/exp:pvl_checkif}
{/exp:channel:entries}

{safecracker....}

```

{authorized\_members} is your field containing members list. It should be pipe delimited, or you can use an other delimiter and specify it an the delimiter="" parameter of pvl\_checkif.

See the doc of pvl\_checkif here.
> 1 votes

---
Tags: safecracker, channel-form, author
---


title: Stash Embed Not Parsing

text:
# Question
Title: Stash Embed Not Parsing
I used this technique on a site I just built with EE 2.7.0 and Stash 2.3.9. Now I'm trying the same technique on EE 2.7.2 and Stash 2.4.7, and it's not working! This is a simplified version just to show what's going on. Note: I'm using stash:get instead of stash:get\_list just to dump out the data.

**index.html**

```
{exp:channel:entries
    channel="white_paper|c_study|video|webinar|data_sheet"
    limit="8"
}
    {stash:embed
        name="item"
        process="start"
    }
{/exp:channel:entries}

{exp:stash:get name="resources" process="end"}

```

**item.html**

```
{exp:stash:append_list
    name="resources"
    parse_tags="yes"
}
    {stash:item_title}{title}{/stash:item_title}
    {stash:item_date}{entry_date format="{gv_date_format_short}"}{/stash:item_date}
    {stash:item_url}/resources/{url_title}{/stash:item_url}
    {stash:item_type}{channel}{/stash:item_type}
{/exp:stash:append_list}

```

Instead of outputting content from the channel:entries loop, it is just outputting the unparsed tags:

```
item_title|=|{title}|&|item_date|=|{entry_date format="%M %j, %Y"}|&|item_url|=|/resources/{url_title}|&|item_type|=|{channel}

```

So it's clearly a parse order issue, and it seems like something has changed either in EE or Stash.

# Answer
Stash 2.4.3 corrected a long-standing inconsistency with embeds set to process at the **start** of template parsing. At the other stages of parsing (`inline` and `end`) embeds are parsed by default - that is to say, `parse="yes"` is the default parameter value if not specified, and 2.4.3 added this as the default for `start` too.

To make your embed behave as it did before (to disable parsing so that the content of the embed is included in the host template without first being parsed) simply add `parse="no"` to the tag:

```
{stash:embed
    name="item"
    process="start"
    parse="no"
}

```
> 3 votes

# Answer
I'm not sure why you're using an embed for this, you're not passing anything to it so I'd use a snippet for sure.

Also may as well use set\_list, open the tags above the exp:channel call

```
{exp:stash:set_list name="resources" parse_tags="yes"}
  {exp:channel:entries channel="white_paper|c_study|video|webinar|data_sheet" limit="8"}
    {snippet:get_data}
  {/exp:channel:entries}
{/exp:stash:set_list}

{exp:stash:get_list name="resources" process="end"}
<div class="entry {item_type}">
  <h1>{item_title}</h1>
  <p class="date">{item_date}</p>
  ....
</div>
{/exp:stash:get_list}

```

**Snippet: get\_data**

```
{stash:item_title}{title}{/stash:item_title}
{stash:item_date}{entry_date format="{gv_date_format_short}"}{/stash:item_date}
{stash:item_url}/resources/{url_title}{/stash:item_url}
{stash:item_type}{channel}{/stash:item_type}

```

You could forego this markup and just replace your embed with a snippet instead and be done OR remove 'start' from your embed, you need it to be inline to get parse order working normally:)
> 2 votes

# Answer
It's your `process="start"` parameter, I believe, that's messing you up. You're telling the Stash embed to process before the channel entries tag pair. Try removing `process="start"` and adding `parse_stage="both"`.

Stuartmcd69's suggestion is solid too.

**UPDATE:**

I respectfully bow out now that Mark has spoken. :)
> 1 votes

---
Tags: stash, parse-order, embeds
---


# Question
Title: Expresso Store 2: WorldPay won't redirect after successful test payment
After checking the WorldPay settings numerous times I still can't get it to redirect back to the site after a successful test payment.

I know the settings are ok in WP as I have checked against another setup for a site that is live and working fine.

Once payment has been made WP gives me a blank page with browser page title of 'Domain Registered', so it looks as though it's just not re-directing at that point.

Has anyone experienced anything similar with success in fixing it?

EE version is 2.7.2 and Store 2.0.6

Any help appreciated, thanks.

# Answer
> 1 votes
Ok, this has been resolved now!

It turns out that the cause of the problem was an index.html holding page not allowing the redirection to take place. A simple fix in the end (remove the html file), which would have been easier to spot with the transaction log data from WorldPay that they failed to send after numerous requests.

Anyway, hopefully this answer will help anyone else with a similar issue in the future!

# Answer
> 2 votes
Is your site available to the outside world (system is on and no passwords or funny business preventing people from accessing your test site?).

Have you followed the instructions here? https://exp-resso.com/docs/payment\_gateways.html#worldpay

You need to make sure the payment response URL in WorldPay is set to `<wpdisplay item=MC_callback>`.

Also, have you disabled secure forms? Since EE 2.7 that seems to mess up pretty much everything related to off-site payment gateways. You can disable it in the CP under Admin \> Security & Privacy \> Security & Settings by setting "Process form data in Secure Mode" to "No".

# Answer
> 0 votes
Without seeing your code, we can only guess. I'd guess you need to add the domain to your return address:

```
{exp:store:checkout return="https://domain.com/order/ORDER_HASH"}

```

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


title: Stash Parse Order Issues

text:
# Question
Title: Stash Parse Order Issues
Im pretty sure the problem here is the parse order, but I'm struggling to figure out where the issue is.

I have a page with the following on it:

```
{exp:stash:set name="market_ids" parse_tags="yes"}
{exp:query sql="select GROUP_CONCAT(entry_id SEPARATOR '|') as market_ids from exp_channel_data where channel_id=3 AND field_id_12 LIKE CONCAT('%', DAYNAME(from_unixtime({exp:stash:delivery_day})), '%')" parse="inward"}
    {market_ids}
{/exp:query}
{/exp:stash:set}

```

Then further on in the page I have the following:

```
{exp:low_search:results limit="{exp:stash:paging default='12' type='snippet'}" channel="products" status="not closed" child:cf_product_market="{exp:stash:market_ids}" child:cf_product_delivery_zone="{fn_zone_id}" paginate="bottom"}
....
{/exp:low_search:results}

```

The Paging stash entry is set on another page with scope="site" and type="snippet" and that works fine, however the {exp:stash:market\_ids} is just not being recognised in the tag. I've output the value to the page and its definitely got data in the entry.

I've tried adding parse="inward" to the {exp:low\_search:results} tag, but that doesn't appear to make any difference either.

Is there something else that I need to do to make this work?

Thanks!

# Answer
OK, So I had to wrap the entire call in a {exp:stash:parse process='end'} tag and then call the values with just {stash:market\_ids}.

Now seems to be working.
> 2 votes

# Answer
Is the stash {exp:stash:market\_ids} rendering outside of your low\_search? Thats probably a good place to start.

I would also try putting

```
{exp:stash:set name="market_ids" parse_tags="yes"}
{exp:query sql="select GROUP_CONCAT(entry_id SEPARATOR '|') as market_ids from exp_channel_data where channel_id=3 AND field_id_12 LIKE CONCAT('%', DAYNAME(from_unixtime({exp:stash:delivery_day})), '%')" parse="inward"}
    {market_ids}
{/exp:query}
{/exp:stash:set}

```

In an embedded file and retrieving it with a process='start'.

```
{exp:stash:embed:folder:file_name process="start"}

```

Hope thats helpful, not completely convinced. Parsing can be confusing.
> 1 votes

---
Tags: stash, low-search, parse-order, parse
---


title: A to Z style category listing + results

text:
# Question
Title: A to Z style category listing + results
I'm wondering what's the best way of approaching a situation where you have an A to Z of categories in a sidebar and when you click the category URL it loads the results of that channel within the same page.

I know there's a plugin for this - Low AtoZ, but wondering if there is a simple way of doing this without using any commercial plugins. At the moment I'm using Freebie to break the main url segment so EE doesn't try to look for the page. A good way to start?

```
<aside>
<ul>
        {exp:channel:categories channel="resources"}
            <li><a href="{site_url}resources/{category_url_title}">{category_name}</a></li>
        {/exp:channel:categories}
        </ul>
    </aside>
    <div class="content-main">
        <div class="breadcrumbs">
            <ul>
            {exp:structure:breadcrumb here_as_title="yes" separator="/" wrap_each="li"}
            </ul>
        </div>
        <h1>{title}</h1>
        {page_content}
        {if "{freebie_1}" == 'resources' && "{freebie_2}" == ''}
        <h3>Please choose a county from the list to the left.</h3>
        {if:else}
        <div class="resources-listings">
            {exp:channel:entries channel="resources" dynamic="no" category="1"}
            <div class="listing">
                {if resources_center_type == 'Suicide Prevention'}
                <div class="label red">
                    <span>Suicide Prevention</span>
                </div>
                {if:else}
                <div class="label green">
                    <span>Bereavement Support</span>
                </div>
                {/if}
                <h3>{title}</h3>
                {if resources_role}<p class="role">{resources_role}</p>{/if}
                {if resources_address}<p><strong>Address: </strong>{resources_address}</p>
                {if resources_phone}<p><strong>Tel: </strong>{resources_phone}</p>
                {if resources_email}<p><strong>Email: <a href="mailto:{resources_email}">{resources_email}</a></strong></p>
                {if resources_info}<p><strong>Additional Information: </strong>{resources_info}</p>
            </div>
            {if no_results}
                <h3>There are currently no resources available in this county.</h3>
            {/if}
            {/exp:channel:entries}
        </div>
        {/if}

```

# Answer
> 1 votes
With wgcode\_categories, you can add an orderby="cat\_name" parameter.

---
Tags: categories, freebie
---


# Question
Title: Save template as a file error - due to MAMP?
In Template Manager I am trying to save my template (site/index) as a file. When I click update I get this error:

```
unable to save your template as a text file

```

I have asked around and searched and what I've seen is that it has to due with permissions or path to file, but I have tried messing around with both of those.

Thanks in advance.

MORE INFO-----

The template is called `index` and it is in the template group `site`: `site/index`

My Server path to site's templates is: `/Documents/ExpressionEngine/unimin/expressionengine/templates`

I am using:

```
ExpressionEngine Core (free version)
MAMP Pro
Mac OSX Mavericks
Google Chrome

```

# Answer
Here are the steps to take to ensure you are setup to save templates as files:

1. Check the file permissions of the templates folder and all the contents inside of it. They need to be set to 777 here is a link to help Mac users.
2. Make sure your Global Template Preferences are set correctly. Step three of the linked documentation will help you for this.
3. Check your server path to site's templates. Try adding a forward slash to the end (that has fixed it for several people).

Since I was using MAMP Pro my expressionengine was saved on my local device and my site path was not complete. For my sitepath I had: `/Documents/ExpressionEngine/unimin/expressionengine/templates` -- which should have been `/users/matthew/Documents/ExpressionEngine/unimin/expressionengine/templates` and that fixed it for me.

Also here are some other resources that might help you:

> Resource 1 Resource 2 Resource 3 Resource 4

And of course make sure you read the ExpressionEngine Documentation
> 1 votes

# Answer
I've found that with MAMP Pro I'm only able to save templates as files if I set the permissions on my templates folder to 777. Make sure you apply those permissions to the templates folder itself *and* its contents.

If you aren't sure how to change file permissions on your Mac, here is a help file from Apple. If you are using Finder to do it, as they show in this help file, 777 permission is "Read & Write" for everyone.

And you're right, the other thing to check is the server path to your templates folder. You edit that in Design \> Template Manager \> Global Template Preferences \> Basepath to Template File Directory (assuming you are not using a config override).

If you still end up with trouble even after setting permissions to 777 and double checking the path, please post a little more information about your template setup (directory name, whether above webroot, etc) and the current server path you're specifying.
> 1 votes

# Answer
I'm not 100% sure but when I used WAMP the server path should be as normal i.e /localhost/public\_html/sync rather than the folder location on your laptop/computer
> 0 votes

# Answer
Change your file permissions in the command line/terminal using `chmod 777 path/to/the/directory` or, if you're not confident doing that, use an FTP client to alter the permissions to 777

You can also set your template path relative to your system directory rather than the server root which might make it simpler for you.
> 0 votes

---
Tags: templates, file-manager
---


# Question
Title: Assets Upload Error: "Getting content length is not supported."
When I try to upload a file to Assets, I get this alert:

> Could not upload the file - server returned an unexpected response. Please check the server settings.

The console shows a 500 error when trying to access a url: `https://www.mysite.com/index.php?folder=16&ACT=24&qqfile=my-file.png`

When I load that URL directly in the browser I get this message:

> {"error":"There was an error uploading your file: Getting content length is not supported."}

My server's PHP error logs don't show anything.

* EE 2.7.2
* Assets 2.2.2

# Answer
I looked and saw a pale horse whose rider's name was FastCGI, and all of hell followed him.
> 1 votes

---
Tags: assets
---


# Question
Title: Why Assets writes folder with 755 write permission
I'm using assets 1.1.4 on a 2.5.3 EE install (Sorry but i cannot update now for any reason) When I create a folder in assets this folder is written as apache:apache with this permissions:

drwxr-xr-x -\> 755

is this right???

I ask this because this creates me big problems when i try to reconcile files using git.

thanks Francesco

# Answer
> 1 votes
You are probably not using a git pull as the apache user, so you're getting issues.

The 755 -- means only the apache user is allowed to write to that directory.

To fix it, either use sudo:

```
sudo -u apache git pull

```

or change the permissions to the correct owner and then reverting it back to apache

or change the permissions so everyone can write (777) and then reverting it back to 755.

---
Tags: assets
---


# Question
Title: DM Force SSL based on Stash not_empty variable
Somehow I can't seem to get this right. I have a Stash variable that I'm setting if certain pages need to be redirected to their HTTPS version.

Tried it a number of ways, but very similar to this:

```
{if {exp:stash:not_empty name="secure" parse="inward" process="inline"} == 1 }
      {exp:dm_force_ssl:force parse="inward"}
{/if}

```

This code resides in an embed btw (template partials approach, where the "secure" variable is set in the parent template partial, then the other variables are pushed into the wrapper). It ends up redirecting *every* page, not just the ones that fall into the conditional.

# Answer
Ended up solving this with a combo of Switchee and Stash:

```
{exp:switchee variable="stash:secure" parse="inward"}
      {case value="y"}
        {exp:dm_force_ssl:force}
      {/case}
      {case value=""}
         {exp:dm_force_ssl:unforce}
      {/case}
{/exp:switchee}

```

Since Stash was used to set the "secure" variable, and Switchee is Stash-aware, you can just use the variable within Switchee.
> 1 votes

# Answer
Try a couple different iterations of the conditional:

```
{if "{exp:stash:not_empty name="secure" parse="inward" process="inline"}" == "1" }

{if '{exp:stash:not_empty name="secure" parse="inward" process="inline"}' == '1' }

{if "1" == "{exp:stash:not_empty name="secure" parse="inward" process="inline"}"}

{if '1' == '{exp:stash:not_empty name="secure" parse="inward" process="inline"}'}

```

---

Also, `parse="inward"` most likely isn't needed on the `{exp:dm_force_ssl:force}` tag.
> 0 votes

---
Tags: stash, ssl
---


title: Next Entry with only the url_title

text:
# Question
Title: Next Entry with only the url_title
I am having trouble finding a way to get the next entry from an article. With the way that my URI is set up.

For example, I have the URL http ://www.***.com/learn/\[channel\]/\[url\_title\]. I use the exp:channel:entries tag with the channel parameter set to segment\_2 and the url\_title parameter set to segment\_3(I understand that segment\_2 is not really needed to get the results I am after). This displays the article I requested. However, the exp:next\_entry tag will not work unless the actual channel is in segment\_1.

I have tried other plugins such as Advanced Prev Next Entry, but I have requirements that these don't meet, such as compatibility with Channel Images.

My ultimate goal is to be able to reproduce an experience like this.

Any help on how to find the next entry would be fantastic.

# Answer
Have you tried the built in Pagination?

{exp:channel:entries channel="article" orderby="date" sort="desc" limit="1" paginate="bottom" } {title} {article\_details..etc} {paginate} {if next\_page} Next Page {/if} {/paginate} {/exp:channel:entries}
> 1 votes

---
Tags: channel-images, next-prev
---


title: 404 - don't think it's working

text:
# Question
Title: 404 - don't think it's working
I've created a `/404.group/index.html` that contains my desired 404 page. In `Design ‣ Templates ‣ Global Preferences`, I've set my 404 to `404/index`.

When I go to domain.com/some-crazy-made-up-url, I do not get the 404 page. However, I do see it when I go to domain.com/404.

What am I doing wrong? I have Enable Strict URLs set to "yes".

# Answer
> 2 votes
Check your htaccess file. It's possible you have a 404 redirect statement there too which should be removed.

# Answer
> -1 votes
Is this not a simple issue with using .html and not .php? If you create the 404 group page as 404.group/index.php see what you get when you throw in a random url.

---
Tags: templates, 404
---


# Question
Title: Check for boolean return from Channel Field of type 'matrix'
Using EE v2.4 and Matrix v2.2

I'm trying to check if the matrix '{article\_images}' rows are != '0'.

Within the channel:

```
{if article_images}
 <div class="left article_image  hide-for-small">
  <ul data-orbit>
    {article_images}
      {exp:ce_img:pair disable_xss_check="yes" src="{image_matrix_image}" width="500" quality="80" allow_scale_larger="yes"}
       <li>
         <img src="{image_matrix_image}" alt="">
         <div class="caption">
           <p>{image_matrix_cutline}{if image_matrix_byline}<em>  ({image_matrix_byline})</em>{/if}</p>
         </div>
       </li>
      {/exp:ce_img:pair}
    {/article_images}
 </ul>
</div>
{/if}

```

'{article\_images}' never evaluates to false.

I've tried:

```
{if article_images}
 {article_images}
 {if '{image_matrix_image}' != '0'}
 <div class="left article_image  hide-for-small">
  <ul data-orbit>
      {exp:ce_img:pair disable_xss_check="yes" src="{image_matrix_image}" width="500" quality="80" allow_scale_larger="yes"}
       <li>
         <img src="{image_matrix_image}" alt="">
         <div class="caption">
           <p>{image_matrix_cutline}{if image_matrix_byline}<em>  ({image_matrix_byline})</em>{/if}</p>
         </div>
       </li>
      {/exp:ce_img:pair}
 </ul>
</div>
{/if}
{/article_images}
{/if}

```

Which works as desired but means that the div containing the orbit plugin is displayed within the loop for as many images as exist.

Is there a way to check the number of rows in the matrix prior to entering '{article\_images}'?

Thanks for any input.

# Answer
You can use the `:total_rows` tag in a conditional like this:

```
{if article_images:total_rows > 0}

    // other code here

{/if}

```
> 1 votes

---
Tags: matrix, add-on, custom-fields
---


title: Multi site - Licensing query?

text:
# Question
Title: Multi site - Licensing query?
Looking to build multiple sites with EE. How many licenses would have to be purchased as require integration with Expresso Ecommerce. Do I have to get 3 separate licenses or just 1 license and run multiple sites sitting on the same server?

Thanks,

Huzza

# Answer
Licensing questions are best addressed by the respective software developer.

For ExpressionEngine, a MSM license initially covers 3 sites, all of which must be the same company, i.e. you can not use the sites in a MSM installation for multiple clients. It is best to email EllisLab if you have any questions about the license before making a purchase.

As for Expresso Store, you'll need to read the license to determine if it's per site or per installation and how the applies to MSM. Again, if there are things you're not clear on, it's always best to contact the developer.
> 3 votes

# Answer
An Expresso Store license is essentially tied to your EE license. So if you can legally use one EE license for your sites, then you can also use a single Store license as well.

You can use Store with EE's multi-site manager (MSM) to run multiple online stores from the same installation.

As others have stated, MSM can only be used for multiple properties run by the same company and hosted together. It can't be used to run various client sites from a single installation. It also can't be used to install multiple completely separate sites on the same server (or different servers).

Expresso Stores license allows you to run multiple sites if you are
> 2 votes

---
Tags: expresso-store, multi-site-manager, licensing
---


# Question
Title: Can the FREEMEMBER module be used with the EE core package?
The login form from the docs works fine and so does the password reset. However I have been unable to register a new member or show a logout link, this is the same issue I had whilst using the AUTHENTICATE module and came to the realisation that as CORE doesn't have the member module the logout and register wouldn't work (took me three days and I'd rather not spend the next three days trying to get this to work.

# Answer
If it's not working, I'd guess you're running into the same issue and you need to purchase the full license to get complete member functionality.
> 2 votes

# Answer
FreeMember simply provides a nice way to generate templates for the existing member functionality built into EE. EE core doesn't include any member functionality.

So no, FreeMember doesn't work with EE Core and never will. I doubt any other member modules would either, and if they did, I expect they would have dubious legal status.
> 0 votes

---
Tags: freemember
---


# Question
Title: Expresso Store Is there a way to "Edit" an item already in the cart?
Is there a way to "Edit" (update options etc.) an item already in the cart?

# Answer
Not really. You can only update the quantity of items already in the cart. However, if you wanted to provide some form of inline edit product functionality on the checkout, it's possible to remove an item and add another item at the same time, so you could replace the item with a new one with whatever modifiers the customer selects.

To do this, simply create an add to cart form using the product tag, and pre-fill the form fields with the existing values from the cart.
> 1 votes

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


# Question
Title: Expresso Store: 2Checkout gives Invalid key error
i have a problem with 2checkout gateway. I get "Invalid key" error. What is causing that? I entered correctly the Account number and secret word in settings. Test mode is "false" in Store settings. Demo setting is "On" in 2co settings page.

No matter witch setting i try:

i get Invalid key error.

I have EE 2.7.1, Store 2.0.6, PHP 5.3.27

Thanks

# Answer
> 2 votes
This issue is most likely being caused by either your secret word not matching or expresso store is not setup to validate the hash on demo sales. When placing 2Checkout demo sales, the MD5 hash returned by 2Checkout is intentionally broken by computing the hash with a 1 in place of the order\_number so if you are checking against the hash your return script needs to handle this change.

Example:

```
<?php

if ($_REQUEST['demo'] == 'Y')
{
    $order_number = 1;
}
else
{
    $order_number = $_REQUEST['order_number'];
}

$compare_string = $_REQUEST['secret_word'] . $_REQUEST['sid'] . $order_number . $_REQUEST['total'];
$compare_hash1 = strtoupper(md5($compare_string));
$compare_hash2 = $_REQUEST['key'];

if ($compare_hash1 != $compare_hash2)
{
    echo "Hash Mismatch";
}
else
{
    echo "Hash Matched";
}

```

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


# Question
Title: PHP Errors When Upgrading Freeform & Tag From v3 to v4
When trying to upgrade Solspace Freeform and Solspace Tag, I'm getting PHP errors.

For Freeform, I'm trying to update from 3.1.0 to 4.0.12. When I go to the Freeform module page, I get this PHP error:

> A Database Error Occurred Error Number: 1146
>
> Table 'db\_production.exp\_freeform\_multipage\_hashes' doesn't exist
>
> TRUNCATE `exp_freeform_multipage_hashes`
>
> Filename: third\_party/freeform/upd.freeform.php
>
> Line Number: 472

For Tag, I'm trying to update from 3.0.5 to 4.2.3, and I'm getting these errors when I try to access the module:

> A PHP Error was encountered
>
> Severity: Warning
>
> Message: file\_get\_contents(/path/to/my/system/expressionengine/third\_party/tag/tag.sql) \[function.file-get-contents\]: failed to open stream: No such file or directory
>
> Filename: tag/upd.tag.php
>
> Line Number: 817
>
> A PHP Error was encountered
>
> Severity: Warning
>
> Message: Cannot modify header information - headers already sent by (output started at /path/to/my/system/codeigniter/system/core/Exceptions.php:170)
>
> Filename: core/Common.php
>
> Line Number: 412
>
> A Database Error Occurred The query you submitted is not valid.
>
> Filename: third\_party/tag/upd.tag.php
>
> Line Number: 828

I've already tried completely re-uploading the files from scratch, making sure that the old files are gone from the system, but I still get these errors.

EE 2.6.1

# Answer
When updating freeform, you need to delete the old directories before uploading the new:

Updating:

```
Within your sites ./system/expressionengine/third_party/ directory, delete the freeform folder and upload the new one from the /system/expressionengine/third_party/ directory in your download package.
Within your sites ./themes/third_party/ directory, delete the freeform folder and upload the new one from the /themes/third_party/ directory in your download package.
Go to the Modules area in the ExpressionEngine control panel and click the Run Module Updates button.
Upgrading from Freeform 3.x (if applicable):
    Go to the Utilities tab in the Freeform control panel, and run the Migration utility.
    Review the Freeform 3.x to 4.x Upgrade Guide and update your templates as necessary.

```

http://www.solspace.com/docs/freeform/install\_update/
> 3 votes

---
Tags: solspace-freeform, upgrade, php-errors, solspace-tag
---


title: Infinite Scroll and Stash

text:
# Question
Title: Infinite Scroll and Stash
Anyone have luck in getting the Stash-style of pagination to work with Infinite Scroll? Is it possible?

# Answer
**UPDATE:**

Got it working. This is what I have for those following:

**set\_list template**:

```
{stash:embed:layouts:homepage}

{exp:stash:context name="100_list"}

{exp:stash:set_list
    name="movie_list"
    context="@"
    parse_tags="yes"
    save="yes"
    scope="site"
    refresh="1440"
    replace="no"
}

    {exp:channel:entries
        channel="films"
        category="1"
        disable="category_fields|member_data"
    }

        {stash:movie_name}{title}{/stash:movie_name}
        {stash:movie_url}{url_title_path='movie'}{/stash:movie_url}
        {stash:movie_poster}{exp:channel_images:images entry_id="{entry_id}" limit="1"}{image:url:grid}{/exp:channel_images:images}{/stash:movie_poster}

    {/exp:channel:entries}

{/exp:stash:set_list}

```

**homepage embed with get\_list:**

```
<ul class="large-block-grid-5 grid-infinite">

{exp:stash:get_list
    name="movie_list"
    context="@"
    parse_tags="yes"
    parse_conditionals="yes"
    limit="20"
    orderby="movie_name"
    sort="asc"
    paginate="bottom"
}
    <li class="grid-item-block">

        <a href="{movie_url}" title="{movie_name}">
            <div class="grid-item-info">
                <div class="grid-item-title">
                    <h1 class="title-cap">{movie_name}</h1>
                </div>
            </div>
                <img src="{movie_poster}" alt="{movie_name}">
        </a>

    </li>

    {paginate}
    <div class="navigation">
        {if next_page}<a class="next js_hide_next" href="{auto_path}">Next Page</a>{/if}
    </div>
    {/paginate}

{/exp:stash:get_list}

</ul>

```

**javascript settings:**

```
<script type="text/javascript">
    $(document).ready(function(){
     $('.grid-infinite').infinitescroll({
          navSelector : ".navigation",
          nextSelector : "a.next",
          itemSelector : ".grid-item-block",
          contentSelector: ".grid-infinite",
          extractLink: true,
      })
    });
</script>

```
> 5 votes

---
Tags: stash, pagination
---


# Question
Title: Using if logged_id & auther_id="CURRENT_USER" creating scattered results
I'm trying to use if logged\_id & auther\_id="CURRENT\_USER" to load a specific entry back to users. However I'm seeing mixed results. I'm using EE 2.5.2 and Safecracker and have had success with this, however I have also had have had about 1/2 of the people who have resubmitted end up with new entries vs. updating the entry already stored. The first line of code is what I'm using to check to see if a user has already submitted a entry.

```
{if logged_id}<a href="/template-group/template/{exp:channel:entries channel="my_channel_name" author_id="CURRENT_USER" status="open" dynamic="no"}{username}/{/exp:channel:entries}">

```

This line of code is the start of the template, which should display the past entry if a user has submitted one.

```
{if logged_in}
{exp:safecracker channel="my_channel_name" id="my_channel_name" return="/" url_title="{segment_3}" author_only="yes"}

```

Any help in figuring out what is causing this would be greatly appreciated, Thank you!

# Answer
The {if logged\_in} is checked last in the template (advanced conditional). There are several addons available that create early parsed global variables from user data. Use the template debugger to verify if tags and modules are or are not called at all.

```
{if logged_in_member_id} ... {/if} // mo-variables, low-vars($)
{if global_member_id} ... {/if}    // global_member_vars

```

The first part can be a channel:entries tag by itself, current\_user will be 0 when not logged in, giving the no\_results part back.

```
{exp:channel:entries channel="my_channel_name"
    author_id="CURRENT_USER" status="open" dynamic="no"
}
    {if no_results} -- redirect or show other info -- {/if}
    <a href="{path=/group/template/{username}/"></a>
{/exp:channel:entries}

```
> 2 votes

---
Tags: safecracker, conditionals
---


# Question
Title: How can I use P&T switch in channel entry tag so only entries with the Yes option are returned
I am wondering why this code isn't working as I expect it:

```
{exp:channel:entries search:feature_on_homepage="y" search:images="not IS_EMPTY"  disable="categories|member_data"}

```

I am expecting that only entries with Yes option selected and have images to be returned.

Thanks

# Answer
If your “OFF Value” setting is blank, that should work, however that IS\_EMPTY flag can be a little buggy because EE doesn’t factor in NULL values, which is exactly what all of your entries will have which haven’t been saved since you added the Switch field.

So rather than searching for "not IS\_EMPTY", you might be better off searching for the “ON Value” setting explicitly. Assuming you left it at the default value of “y”, your parameter would be:

```
search:images="=y"

```
> 1 votes

# Answer
If you output the value of the field, what do you see? Does the field output 'y' or 'n' or does it output 'y' or blank?

If the former then your criteria will fail since search:images is never empty
> 0 votes

# Answer
Not sure if this will help but, Have you tried to echo out your result of the switch? to see what it's result is?

```
  {if pt_switch == 'y'}
<h1>{title}</h1>
    switch is set to yes
    {/if}

```

and the opposite

```
 {pt_switch}
    {if pt_switch != 'y'}
<h1>{title}</h1>
    switch is not to yes
    {/if}

```
> 0 votes

# Answer
This is not working actually. I use this code

```
{exp:channel:entries channel="clanci" limit="5" dynamic="no" status="open" show_future_entries="no" orderby="date" sort="desc" search:galerijaslika="=y" disable="pagination|member_data"}
                                        <div class="panel-gallery">
                                            <div class="gallery-images">

                                                <a href="#" class="gallery-navi-left icon-text"></a>
                                                <a href="#" class="gallery-navi-right icon-text"></a>
                                                <ul>
                                                    {exp:channel_images:images entry_id="{entry_id}"}
                                                    <li class="active"><a href="{site_url}art/{url_title}"><img src="{image:url:galerija_slika_300}" class="setborder" alt="{image:description}" title="{image:title}" /></a></li>
                                                    {/exp:channel_images:images}
                                                </ul>

                                            </div>
                                            <div class="gallery-header">
                                                <b><a href="{site_url}galerija/{url_title}">{title}</a></b>
                                            </div>
                                        </div>
                                        {/exp:channel:entries}

```

and even though i use search:galerijaslika="=y" it does not return anything and I know I have entries that use that switch and it works when I use it when opening entry but when I want to show lost of entries, then it is not working correctly.
> 0 votes

---
Tags: channel-entries, playa, fieldtype, field-pack
---


# Question
Title: Postmaster, preventing further emails after the initial status change
Just purchased Postmaster, and its working great. Kind of wish I had got it ages ago and saved myself loads of manual emails!

My users submit entries via a safecracker form, that come to me with a status of "pending". I have set up two parcels. The first one sends the user a notification that I have received their entry. This is easily achieved by using the "New" entry trigger & "Pending" status trigger. Works fine.

I then review the entry, make any edits where needed, set the status to "open" and publish the entry.

My next parcel send the entry author an email to tell them the entry is now live on the site. I have set this up via the "edit" entry trigger, and the "open" status.

This works very well. However, if I was to go in and edit that entry again, say simply for a typo, when I save it, it will fire of the original email again.

i do not want this, I only want the original first email to go out, so I am wondering what would be the best way to achieve this?

The only ways I can think, are to have a custom field that maybe identifies that the entry has been edited, and use that in the extra conditionals, or to set up another status of "edited" and ensure that if I make an edit, I change the status to edited.

Can anyone think of an easier way? Ideally I would like it to be as automated as possible!

# Answer
> 1 votes
Here's how we handled this exact situation.

Create a "Send Email" Select Dropdown field with the options "Yes", "No" and within the Field Instructions add the following jQuery.

```
<script>
$(function() {
    $("#field_id_14").val('No');
});
</script>

```

**Note:** You will need to change field\_id\_14 to whatever your field's id attribute is. You can get this by saving the field, loading the publish entry screen and using Safari/Firefox "Inspect Element" debugging tools.

What this will do is reset the drop down menu to "No" every time the Publish/Edit entry page loads, thus defaulting to not sending an email.

Then within your Parcel Extra Conditionals, add the following condition:

```
{if parcel:advisory_send_email == "No"}FALSE{/if}

```

As a result, when you edit/add a new entry. You will have the option to not send, or to send a Parcel that will automatically default to not send/"No". Change the jQuery/conditional logic if you want it to always default to send/"Yes".

# Answer
> 1 votes
Thanks for purchasing Postmaster, and glad you like it.

Couple of questions to ask yourself:

* What trigger do you want to use?
* Perhaps we can use the logged\_in\_group\_id variable in some fashion in the extra conditionals?

So one way would be to use the logged\_in\_group\_id variable and say if Admins or member group X edit the post, the email will not get send. So in theory, it could look like this in the extra conditional fields:

```
{if parcel:logged_in_group_id == 1}FALSE{/if}

```

I just tested this and it doesn't work currently, but out of sheer curiosity I modified the code and added it real quick to the parcel and hook parsing routines. So if you think this method would work for you, just let me know. If not, I have a nice place to add more variables should you need them.

Email support\[at\]objectivehtml.com if you want the latest code. I won't have a chance to release for several more weeks.

---
Tags: email, postmaster
---


title: Dealing with Conditionals in Stash

text:
# Question
Title: Dealing with Conditionals in Stash
So I have the following code snippet which is working fine:

```
{exp:stash:set name="market_ids" parse_tags="yes"}
{exp:query sql="select GROUP_CONCAT(entry_id SEPARATOR '|') as market_ids from exp_channel_data where channel_id=3 AND field_id_12 LIKE CONCAT('%', DAYNAME(from_unixtime({exp:stash:delivery_day})), '%')" parse="inward"}
    {market_ids}
{/exp:query}
{/exp:stash:set}

```

This sets a value for the markets that I use later on in the page.

However, sometimes the stash value inside the SQL statement ({exp:stash:delivery\_day}) wont be set. Typically if the user has clicked a link and not entered the site through our pre-determined route.

I've tried adding a conditional around whole statement, but it doesn't appear to be working because it's still executing the SQL statement:

```
{exp:stash:set name="market_ids" parse_tags="yes"}
{if "{exp:stash:not_empty name='delivery_day'}"}
{exp:query sql="select GROUP_CONCAT(entry_id SEPARATOR '|') as market_ids from exp_channel_data where channel_id=3 AND field_id_12 LIKE CONCAT('%', DAYNAME(from_unixtime({exp:stash:delivery_day})), '%')" parse="inward"}
    {market_ids}
{/exp:query}
{/if}
{/exp:stash:set}

```

Anyone offer any advice on the best way to get this working?

# Answer
> 2 votes
Have you tried adding `parse_conditionals="yes"` to the `set` parameters? Alternatively, reversing the wrapping to put the conditional on the outside of the `set` tags?

# Answer
> 1 votes
You could just do this to check the delivery\_day value.

```
{if "{exp:stash:delivery_day}" != ""}
  ... your code ...
{/if}

```

# Answer
> 0 votes
If you use {switchee} on stash:delivery\_day you can even have a {case} to display something when the delivery day was not set:

```
{exp:switchee variable="stash:delivery_day" parse="inward"}
  {case value=""}
    No delivery day set
  {/case}
  {case default="yes"}
    ...do query...
  {/case}
{/exp:switchee}

```

---
Tags: stash, parse-order, parse
---


title: Email image replacement to reduce SPAM

text:
# Question
Title: Email image replacement to reduce SPAM
I'm creating a website that features a number of email addresses within the content.

The client is asking if we can set emails to be automatically converted into images, with hyperlinks behind the scenes, to reduce SPAM.

Firstly, does anyone know if there's a plugin or tool that can be used to do this?

Secondly, any thoughts on whether this is the best way to reduce the amount of SPAM coming to these email addresses?

Thanks in advance,

Tom

# Answer
The best way to fight with email spam is to have good spam filters :)

*set emails to be automatically converted into images, with hyperlinks beneath*

Spiders is not looking on visible text only but on hyperlinks also, so is not enough to replace text only.

You can try MD Spam Me Not or Obfuscatee \- this addons is do emails obfuscation.
> 4 votes

---
Tags: email, image, spam
---


# Question
Title: Object of class stdClass could not be converted to string
I am getting this error.I am not able to find out what is causing this error.

```
//A PHP Error was encountered
//
//Severity: 4096
//
//Message: Object of class stdClass could not be converted to string
//
//Filename: libraries/Template.php
//
//Line Number: 2929

```

I have made a service page that authinticates the user(login and signup).

I know the code is long and I should have cropped the question,but I am stuck at this since long time now and cant find where the error exist.Can any body help.

Code:

```
<?php

class autologin_signup {
    /**********SIGNUP FUNCTION************/
    public function signup($member_data_signup){

        $EE_signup = & get_instance(); //Access super Object using this instance within function
        //global $FNS, $IN, $LOC, $TMPL, $DB, $SESS, $PREFS; //deprecated
        $this->group_id     = $member_data_signup['group_id'];
        $this->email      = $member_data_signup['email'];
        $this->screen_name    = str_replace(" ","-",strtolower($member_data_signup['name']));
        $this->password     = $member_data_signup['password'];

        //error_log("Tempcode: ".$this->tempCode."-------Email--------".$this->email."-------Location-------".$this->location."-----Screen Name------ ".$this->screen_name);
        $member_id = $EE_signup->session->userdata['member_id'];

        //error_log("Member_id:".$member_id ."-------".print_r($member_data_signup, 1));

        if(!$member_id){
            $username = $this->email;
            $sql= "SELECT exp_members.password, exp_members.unique_id, exp_members.member_id, exp_members.group_id FROM exp_members WHERE email = '" . mysql_real_escape_string($username) . "'";
            $query = $EE_signup->db->query($sql);

            //  creating a new member starts
            if ($query->num_rows == 0){
                $data['username']         = $this->email;
                $data['password']         = $EE_signup->functions->hash(stripslashes($this->password));
                $data['ip_address']       = $EE_signup->input->ip_address();
                $data['unique_id']        = $EE_signup->functions->random('encrypt');
                $data['join_date']        = $EE_signup->localize->now;
                $data['email']            = $this->email;
                //many more!!!
                $query2 = $EE_signup->db->query("SELECT exp_members.screen_name, exp_members.username, exp_members.group_id FROM exp_members WHERE  screen_name like '%".$screen_name."%'");

                //making a unique screen name code

                if ($query2->num_rows != 0){

                    $countstr = $query2->num_rows;
                    $data['screen_name'] = $screen_name . $countstr;
                }else{
                    $data['screen_name'] = $screen_name;
                }

                $EE_signup->db->query($EE_signup->db->insert_string('exp_members', $data));

                $member_id = $EE_signup->db->insert_id();

                $member_data['member_id']     =   $member_id;
                $member_data['m_field_id_1']  = $this->full_name;
                $member_data['m_field_id_2']  = 0;            //isAccountLinked
                $member_data['m_field_id_8']  = $this->phone_number;
                $member_data['m_field_id_9']  = $member_data_signup['gender'];
                $member_data['m_field_id_13']  = $member_data_signup['newsletter_signed_up'];

                $sql5 = "SELECT exp_members.member_id FROM exp_members WHERE exp_members.email='" . $this->email . "'";
                $query5 = $EE_signup->db->query($sql5);

                $EE_signup->db->query($EE_signup->db->insert_string('exp_member_data', $member_data));
                $member_id = $EE_signup->db->insert_id();

                //Member Creation Complete

            } else { // already  user...
                //echo 'already user';
                echo '-3';

                //exit(0);
            }
            return true;

            /** ----------------------------------------
            /**  Update existing session variables
            /** ----------------------------------------*/
            $EE_signup->session->userdata['screen_name']  = $data['screen_name'];
            $EE_signup->session->userdata['username']     = $data['username'];
            $EE_signup->session->userdata['member_id']    = $data['member_id'];
            $EE_signup->session->userdata['group_id']     = $data['group_id'];

            /** ----------------------------------------
            /**  Update stats
            /** ----------------------------------------*/

            $data = array(
                'member_id'   => $EE_signup->session->userdata['member_id'],
                'name'      => ($EE_signup->session->userdata['screen_name'] == '') ? $EE_signup->session->userdata['username'] : $EE_signup->session->userdata['screen_name'],
                'ip_address'  => $EE_signup->input->ip_address(),
                'date'      => $EE_signup->localize->now,
                'anon'      => 'y',
                'site_id'   => $EE_signup->config->item('site_id')
            );

            $query_12 = "SELECT name FROM exp_online_users WHERE  member_id = '" . $data['member_id'] . "'";
            $query_session = $EE_signup->db->query($query_12);

            if($query_session->num_rows != 0) {
                $EE_signup->db->query($EE_signup->db->update_string('exp_online_users', $data, array("ip_address" => $EE_signup->input->ip_address(), "member_id" => $data['member_id'])));
            } else {
                $EE_signup->db->query($EE_signup->db->insert_string('exp_online_users', $data));
            }
            // login session sets ends

            echo '1'; //signup scuccess
        } else {
            //echo '-3';
            //exit(0);
        }
    }

    /**********LOGIN FUNCTION************/
    public function login($newuserdata) {
        //error_log('in login fucntion here___________________1________________________');
        $EE_login =& get_instance(); //Access super Object using this instance within function
        //echo '<pre>';print_r($newuserdata); echo '</pre>';
        $username = $newuserdata['email'];
        $password = $newuserdata['password'];

        //global $FNS, $IN, $LOC, $TMPL, $DB, $SESS, $PREFS; //deprecated

        $password = $EE_login->functions->hash(stripslashes($password));

        $sql = "SELECT exp_members.password, exp_members.unique_id, exp_members.member_id, exp_members.group_id, exp_members.screen_name
    FROM   exp_members
    WHERE  username = '$username' AND password = '$password'";

        //error_log("in login function ".$sql);

        $query = $EE_login->db->query($sql);
        //error_log('here______________________2_____________________  Member_id: '.$query->row('member_id').'-----NUm Rows: '.$query->num_rows());
        if ($query->num_rows() != 0) {

            ////error_log('here______________________3_____________________');
            /****************************** start session set code ***********************************/
            $EE_login->session->gc_probability = 100;
            $EE_login->session->delete_old_sessions();

            /** ----------------------------------------
            /**  Set cookie expiration
            /** ----------------------------------------*/
            // login session sets start

            // set default expiration to one day
            if ($EE_login->TMPL->fetch_param('expire')) {
                $expire = $EE_login->TMPL->fetch_param('expire');
            }
            /** ----------------------------------------
            /**  Log user in
            /** ----------------------------------------*/
            $expire = 60*60*24*1;

            $EE_login->functions->set_cookie($EE_login->session->c_expire , time()+$expire, $expire);
            $EE_login->functions->set_cookie($EE_login->session->c_uniqueid , $query->row('unique_id'), $expire);
            $EE_login->functions->set_cookie($EE_login->session->c_password , $query->row('password'),  $expire);
            $EE_login->functions->set_cookie($EE_login->session->c_anon , 1,  $expire);

            /** ----------------------------------------
            /**  Create a new session
            /** ----------------------------------------*/
            $EE_login->session->create_new_session($query->row('member_id'));

            /** ----------------------------------------
            /**  Update existing session variables
            /** ----------------------------------------*/

            $EE_login->session->userdata['screen_name']  = $query->row('screen_name');
            $EE_login->session->userdata['username']    = $query->row('username');
            $EE_login->session->userdata['member_id']   = $query->row('member_id');
            $EE_login->session->userdata['group_id']    = $query->row('group_id');

            /** ----------------------------------------
            /**  Update stats
            /** ----------------------------------------*/

            $ip_address = $newuserdata['ip_address'];
            $data = array(
                'member_id'   => $EE_login->session->userdata['member_id'],
                'name'      => ($EE_login->session->userdata['screen_name'] == '') ? $EE_login->session->userdata['username'] : $EE_login->session->userdata['screen_name'],
                'ip_address'  => $ip_address,
                'date'      => $EE_login->localize->now,
                'anon'      => 'y',
                'site_id'   => $EE_login->config->item('site_id')
            );

            //error_log("Member ID: ".$data['member_id']."-------Screen Name--------".$data['name']."-------Location-------".$data['ip_address']);

            $query_12 = "SELECT name FROM exp_online_users WHERE  member_id = '" . $query->row('member_id') . "'";

            $query_session = $EE_login->db->query($query_12);

            if($query_session->num_rows() != 0) {

                $EE_login->db->query($EE_login->db->update_string('exp_online_users', $data, array("ip_address" => $ip_address, "member_id" => $query->row('member_id'))));

            } else {
                $EE_login->db->query($EE_login->db->insert_string('exp_online_users', $data));
            }

            //error_log('here_________________________in login__________________');
            // login session sets ends
            //header("Location: ' . STATIC_URL . 'ee/index.php/register/post-login-normal/");
            //exit(0);
            echo '1';
        } else {
            //not valid username or password
            //do what ever you want to do
            echo 'not_valid';
        }
    }
}

?>

```

# Answer
EE 2.4, in *libraries/Template.php* on line 2929 we have

```
if (isset($this->EE->session->userdata[$val]) AND ($val == 'group_description' OR strval($this->EE->session->userdata[$val]) != ''))

```

line 226 in your code, try to add "0,":

```
        $EE_login->session->userdata['screen_name']  = $query->row(0,'screen_name');
        $EE_login->session->userdata['username']    = $query->row(0,'username');
        $EE_login->session->userdata['member_id']   = $query->row(0, 'member_id');
        $EE_login->session->userdata['group_id']    = $query->row(0,'group_id');

```
> 2 votes

---
Tags: ee2, error, login, sessions
---


# Question
Title: How can I put last edited timestamp in matrix row
How would you to post the 'last time viewed' or the 'last time modified' for a matrix row. Not just the whole entry but specific to Matrix. I also need this to appear in the Cpanel and not on the front end.

*EDIT*

So I updated this and am just using a form to update the Matrix Row when I click on the link to view the proof image.

Unfortunately it is not updating the row. Below is my code:

```
{exp:channel:entries channel="projects" entry_id="{last_segment}"}
                        <h2>{title}</h2>
                        <ul class="buttons">
                            {project_proof}
                                {if proof_file}
                                <li>
                                    {exp:channel:form
                                        channel="projects"
                                        entry_id="{last_segment}"
                                        return="images/uploads/proofs/{proof_file:filename}.{proof_file:extension}"
                                    }

                                    <input type="hidden" name="field_id_77[row_id_{row_id}][col_id_19]" value="{current_time format='%F %d, %Y - %g:%i:%s'}" />
                                    <button class="button" type="submit">View details</button>

                                    {/exp:channel:form}

                                </li>
                                {/if}
                            {/project_proof}
                                <li><a class="button" id="submitChanges">Submit changes</button></a></li>
                        {/exp:channel:entries}

```

Thanks!

# Answer
> 2 votes
It looks like to view it, the user is submitting the form ...

When you want to update something specific in a Matrix row, I think you have to call the row first, like:

`<input type="hidden" name="matrix_field_name_here[row_order][]" value="row_id_{row_id}">`

If I remember right, you have to redo any other columns in the whole Matrix table or it update all of those to be blank. All the other columns can be preloaded and hidden.

But it looks like you are setting up something where you trust the users that would access this page. But if you are allowing anyone to basically update your entry by clicking a view button, someone could change the source of these hidden inputs and actually be able to overwrite more than just the "latest view" cell.

---
Tags: matrix, channel-form
---


# Question
Title: Change cart subtotal in cartthrob using hook
I've set up the `cartthrob_pre_process` hook to look something like this:

```
public function cartthrob_pre_process($data)
{
    $data['subtotal'] = 500.00;
}

```

It then goes to PayPal, which is the selected gateway. But when I get there it's showing the old price. Am I going about this the wrong way? Should I be using a different hook?

# Answer
IIRC, you should be able to do this:

```
ee()->cartthrob->cart->set_subtotal(500);

```

Or you may have to change the total to effect the price sent to PayPal:

```
ee()->cartthrob->cart->set_total(500);

```
> 1 votes

---
Tags: cartthrob, hook
---