0

I've gone every which way to get the following conditional to work, but it never renders the if:else variable:

<!-- matrix field -->
{show_override_age_policy}
  <!-- loop through Playa column and collect entry_ids of entries, if entry_id in Playa column matches the entry_id of current entry then display Low Variable from related Playa column -->
  {if "{override_market:child_ids}" == "{exp:stash:get name='market_entry_id'}"}
    {override_age_policy:var}
  <!-- if no matched entry_id than display default Low Variable -->
  {if:else}
    {show_age_policy:var}
  {/if}
{/show_override_age_policy}

The first part of the conditional when it matches displays both the matched and non-matched results. And when I'm on an entry that does not have a matching entry_id it should display whatever is in if:else. Instead it displays the if:else conditional twice. Any thoughts on how I might approach this?

2
  • Can you dump {show_age_policy:var} outside of the if conditional? Does it present with the correct field value?
    – jrothafer
    Commented Jul 19, 2015 at 1:29
  • It does. I even just tried adding a generic sting like "Yes" within the if:else and it doesn't render. Commented Jul 19, 2015 at 2:26

1 Answer 1

1

As with others you've spoken to, I'm very out of practice with EE. However, if you look at the EE manual for conditionals, the way you've written this is recommended against. If you look here, it will tell you not to use brackets or quotes for variables in conditionals:

https://ellislab.com/expressionengine/user-guide/templates/conditionals.html#embedding-tags

I'd try remedying this, as I recall EE has always been very touchy on such points, and it may solve your problem. In other words, no quotes or brackets on that left-hand variable.

In your next troubleshooting step, I think you mean a simple string value for "generic sting", but I think you'll find that "Yes" wouldn't be a logic value within a conditional, so this seems unlikely to tell you anything.

I'd try getting rid of the quotes and brackets around your variable first.

If this doesn't solve the problem by itself, you might try replacing that whole Stash call with a quoted string value that matches your override_market:child_ids variable exactly. I'm a little concerned that this variable appears by name to be plural - is it an array? In which case it will never by itself work in an EE conditional, would seem.

Given the problem shows to be in the stash call, it's possible you have one of the cases where parse="inward" is needed, in order to get the right order of evaluation so that the stash value is returned before the conditional is evaluated. Here's a stackexchange where that's mentioned and illustrated:

plugin value in a template conditional

Here also is a famous cheat sheet on EE parse order, and you can look up how parse inward relates to this.

http://loweblog.com/downloads/ee-parse-order.pdf

Finally, there's also a new conditionals parser in EE 2.9, and you can read about that here, if you happen to be on that or a later version.

https://ellislab.com/blog/entry/new-conditionals-parser-in-2.9

Good fortune - really the answer here should be simple, if you haven't been trying to compare two values that can't be compared (for example, if your variable is an array). Parse order can make it a bit trickier, but again parse inward properly applied should fix that without more complication if it's needed, from the look of this.

1
  • just added the parse order cheat sheet link, as had somehow originally left it out. Commented Jul 21, 2015 at 4:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.