Based on a question I asked about looping through variables, I created the NB Cycle plugin, which lets you pass a variable, one by one, from a series of variables (i.e., “cycling” though a series of variables).
Useful for OR conditionals, passing tag parameters one after the other, etc. Example use:
{exp:nb_cycle parse="inward" values="whisky|tango|foxtrot"}
{variable}
{/exp:nb_cycle}will output:
whisky
tango
foxtrotParameters
parse=”inward” REQUIRED if you are using other plugins within the NB cycle tag pair.
values=”whisky|tango|foxtrot” The values to cycle through, separated by a pipe. Values can be anything: id numbers, weblog names, titles, etc. To pass variables containing a pipe (eg. 1|2, together), separate the variables with a comma “,”. eg. values=”1,2|3”
Single variable tag {variable} This tag will be replaced by the current cycle value set in values=”“
Another (more useful) example:
{exp:nb_cycle values="blog|products|catalog" parse="inward"}
{exp:weblogs:entries weblog="{variable}"}
{title}
{/exp:weblog:entries}
{/exp:nb_cycle}Mini-cycle I threw in a mini-cycle loop, as it might come in handy. Another set of variables can be looped within the {exp:nb_cycle} tag pair.
Example:
{exp:nb_cycle parse="inward" values="whisky|tango|foxtrot"}
<h2>{variable}</h2>
<ul>
{mini_cycle values="blog|products|catalog"}
<li>{mini_cycle_variable}</li>
{/mini_cycle}
</ul>
{/exp:nb_cycle}would output
<h2>whisky</h2>
<ul>
<li>blog</li>
<li>products</li>
<li>catalog</li>
</ul>
<h2>tango</h2>
<ul>
<li>blog</li>
<li>products</li>
<li>catalog</li>
</ul>
<h2>foxtrot</h2>
<ul>
<li>blog</li>
<li>products</li>
<li>catalog</li>
</ul>Single variable tag
{mini_cycle_variable} This tag will be replaced by the current cycle value set in values=”“
Documentation can be found here and example using conditionals is suggested in a previous forum post
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.