0

I have the following line in my template code

    <li class="{if node_has_children}has-dropdown{/if}{if node_id == {lv-seg1-taxonomy-node-id}} is-lvl1-active{/if}">

The conditional that contains the Low Variable {if node_id == {lv-seg1-taxonomy-node-id}} is-lvl1-active{/if} always returns true despite {node_id} != {lv-seg1-taxonomy-node-id} when output into the template, and I always get the is-lvl1-active class.

The contents of the LV is:

{if segment_1 == 'youth'}41{if:elseif segment_1 == 'open'}42{if:elseif segment_1 == 'competition'}43{if:elseif segment_1 == 'theme'}44{if:elseif segment_1 == 'films'}45{if:elseif segment_1 == 'news'}46{if:else}{/if}

The Low Variable is set to early parse. How do I compare its output to a tag in the main template?

1

If I understand you correctly, the content of the lv-seg1-taxonomy-node-id variable is that big if-statement. Then you're using the LV as part of another conditional: the one in your first example.

This will not work because of Parse Order.

Your variable is set to parse early, which means the template will change this:

{if node_id == {lv-seg1-taxonomy-node-id}}

to this:

{if node_id == {if segment_1 == 'youth'}41{if:elseif segment_1 == 'open'}42{if:elseif segment_1 == 'competition'}43{if:elseif segment_1 == 'theme'}44{if:elseif segment_1 == 'films'}45{if:elseif segment_1 == 'news'}46{if:else}{/if}}

Which is an invalid conditional.

Early parsed vars, like Snippets, will not evaluate before hitting the template. Instead, the variable name is replaced by its contents.

You will have to find a different way to set the class name.

1
  • Thank you for the explanation - looks like it's JavaScript time. – WojtekD Oct 24 '14 at 20:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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