setting flags using EE tags
I’m often confronted with a situation where I’d like to loop through a set of entries and change what happens once a certain condition has been met. Hence, I’d like to set a variable with an initial state, then when a certain kind of entry comes along change the variable so that a different set of instructions is followed from then on.
For example, for a forthcoming conference, I have sessions over two days. I’d like to start the list with the word ‘Saturday’ then loop through the entries until the entries for the next day are reached, then display ‘Sunday’ followed by those entries. However, I just want to display the day once, so I would like to create a variable called ‘day_displayed’ or somesuch and set it to ‘yes’ once the first entry for that day has been displayed.
Here’s the page, to illustrate the point:
http://www.battleofideas.org.uk/index.php/site/overview/
After the session “All tested out”, it should display “Sunday”.
Is there a way in EE of creating a variable, setting a value, then testing the value with each loop through the {exp:weblog:entries} tag, altering as required? Or should I just code it all in PHP, which wouldn’t be a huge job, but I’d prefer to do it EE tags alone if possible.
A quick point: if I stick PHP inside global conditional tags, it doesn’t seem to work eg:
{if condition==true}
<?php [some code] ?>
{/if}
Is that because the parsing order makes it impossible?
I’m running version 1.6.0
Rob