I hope this snippet of code is clear enough to serve as a question. I expect the results to be Result A, but instead I get Result B:
Entry has both Categories 1 and 2 assigned to it:
{categories}
{if category_id == "1" OR category_id == "2"}
<h1>Category 1 or Category 2</h1>
{/if}
{/categories}
A: Expected Result
<h1>Category 1 or Category 2</h1>
B: Actual Result
<h1>Category 1 or Category 2</h1>
<h1>Category 1 or Category 2</h1>
Think of the {categories} tag pair as a loop. So- I have 1 entry, it’s in 3 categories, (category 1 and category 2 and category 3).
I output the entry data and when I get to the categories tag pair, the first time through the loop, the category is 1, thus the conditional is true. The second time through the loop, the id is 2, the conditional is also true. The third time through the loop, the category id is 3, so it’s not true and there is no third display.
Depending on what you need to do, you might could achieve it with the show parameter.
Hrm, I’m not entirely sure what you’re asking for. In the template, no. Though with php parsed on output, you could treat it as such. That said, we don’t recommend using PHP in templates and it would likely be a case where custom coding a plugin would be a better option.
If you mean in the actual EE php code where it parses the variables and replaces the EE variables with the entry values, I believe it’s a foreach. All of the category data for the entry goes into an array and then replaced. If you want to see ‘the guts’, it’s mostly in mod.channel.php.
And if I totally misunderstood, just let me know.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.