1

I always seem to run into some problems with conditionals. The code in question is this:

{categories}
{if category_id != "305|325"}

Index version 1

{/if}

{if category_id == "305|325"}

Index version 2

{/if}
{/categories}

At the moment, it is always returning version 1 of the index, even when the category of the entry matches 305 or 325.

1 Answer 1

3

If I'm not mistaken, for OR conditionals you must use one of the following:

{if category_id != 305 OR category_id != 325}

{if category_id != 305 || category_id != 325}

also, please double check that you don't need to use AND instead of OR. I've tripped myself up with that many times - especially when using negative comparison.

{if category_id != 305 AND category_id != 325}
     index 1 ---- the cat id is not 305 AND it is not 325
{if:else}
     index 2  --- all other cat ids
{/if}

OR...

{if category_id == 305 OR category_id == 325}
     index 2  ---- the cat id is 305 OR it is 325
{if:else}
     index 1 ---- all others
{/if}
1
  • Oh, thank you, it was both the way the conditionals were formed and the use of OR instead of AND! Jul 11, 2017 at 17:08

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.