0

I have a conditional statement that checks if anything is selected in a nested Playa field. It worked in EE 2.8.1 but upon upgrading to EE 2.9.2 a parse error occurs:

Error

You have an invalid conditional in your template. Please review your conditionals for an unclosed string, invalid operators, a missing }, or a missing {/if}.

Parser State: Unexpected end of Template “site/.wrapper_page” on line 2; expected ENDIF tag for opening on line 1.

The offending conditional statement is as follows:

{if '{exp:playa:children channel="sidebar_portlets" var_prefix="sidebar"}{sidebar:sidebar-text}{/exp:playa:children}' }
   Do Stuff
{if:else}
   Do other stuff
{/if}

I have tried alternating the use of single and double quotes, as well as escaping the interior quotes with a "\" as suggested in the EE docs, but to no avail.

I would appreciate any suggestions people may have.

For what it's worth, this conditional starts on line 122 of the template, not line 1 as reported in the parse error above. Not sure if that matters.

Thanks in advance.

1 Answer 1

0

It turns out this issue had nothing to do with the syntax above, which is correct. The issue is with my placement of channel:entries tags.

As I understand it (please correct if I'm wrong) in EE 2.9+ conditionals are evaluated as soon as the requisite variables are known and only the “true” condition is parsed (the rest are discarded). Prior to the update, all the possible scenarios were parsed first and then one was chosen to render based on the outcome of the conditional test.

In my case, this change in sequence results in the “true” condition being parsed outside of the channel:entries tag pair and failing.

If you're looking at my original post and scratching your head, it's because I left out some key things. A more complete representation of the code is as follows:

{!-- This is a wrapper template --}

{exp:channel:entries}    
    {if '{exp:playa:children channel="sidebar_portlets" var_prefix="sidebar"}{sidebar:sidebar-text}{/exp:playa:children}' }
{/exp:channel:entries}
       {layout:contents} {!-- Stuff from another template --}
    {if:else}
       Do other stuff
    {/if}

Doing this fixed it:

{!-- This is a wrapper template --}

{exp:channel:entries}    
    {if '{exp:playa:children channel="sidebar_portlets" var_prefix="sidebar"}{sidebar:sidebar-text}{/exp:playa:children}' }
       {layout:contents} {!-- Stuff from another template --}
    {if:else}
       Do other stuff
    {/if}
{/exp:channel:entries}

Your Answer

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

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