Extension, Module

Archived
Forum
(read-only)

Stash

ExpressionEngine 2, ExpressionEngine 3, ExpressionEngine 4, ExpressionEngine 5, ExpressionEngine 6

Back to this add-on's main page
View Other Add-ons From Mark Croxton

     

Stash throwing off conditionals

Support Request

Matthew81
Matthew81

Given the following code, as an entire template loaded on its own:

{exp:stash:set name="st_memberid"}{member_id}{/exp:stash:set}

{exp
:stash:set parse_tags="yes"}
 {exp
:channel:entries channel="news" url_title="{segment_3}" limit="1" orderby="date"}
  {stash
:st_authorid}{author_id}{/stash:st_authorid}
 {
/exp:channel:entries}
{
/exp:stash:set}

<p><b>Stash Member ID:</b{exp:stash:get name="st_memberid"}<br>
<
b>Stash Author ID:</b{exp:stash:get name="st_authorid"}</p>

{if "{exp:stash:get name='st_memberid'}" == "{exp:stash:get name='st_authorid'}"}
 Match
{
/if} 

It’s as though the conditional isn’t getting evaluated at all. Whether it should be true or should be false - there’s no output either way.  In fact, the conditional won’t even evaluate with only one Stash variable being compared against a hard-coded value.

I’ve seen other people using Stash variables in conditionals, so I’m not sure what I’m doing wrong.

Thanks,

Matthew

Mark Croxton
# 1
Developer
Mark Croxton

As you are using the same tag with the same parameters more than once you need to append ‘random’ to the second instances to stop EE caching them. The conditional will be trying to compare ‘M00o93H7pQ09L…’ and ‘M00o93H7pQ010…’

{if "{exp:stash:get name='st_memberid' random}" == "{exp:stash:get name='st_authorid' random}"}
 Match
{
/if} 

http://blog.ericlamb.net/2011/05/expressionengine-and-the-mystery-of-m00o93h7pq09l8x1t49chy01z5j4tt91fgfr/