User Tools

Site Tools


techniques:counters

This is an old revision of the document!


A PCRE internal error occured. This might be caused by a faulty plugin

==== Counters ==== Use this technique to associate a counter with each element in a list. Assume you have the following model: <code> <pages> <page name="Color" /> <page name="Length" /> <page name="Time" /> </pages> </code> and you want to add an index number, starting at 7, to each page element to get something like this: <code> <pages> <page name="Color" index="7" /> <page name="Length" index="8" /> <page name="Time" index="9" /> </pages> </code> You can use something like the following tag block to accomplish this task: <code> <c:setVariable select="6" var="counter" /> <c:iterate select="\pages\page" var="p" > <c:setVariable select="1 + $counter" var="counter" /> <c:set select="$p" name="index"><c:get select="$counter" /></c:set> </c:iterate> </code>

techniques/counters.1468167140.txt.gz · Last modified: 2016/07/10 16:12 by chrisgerken