XF 2.0 Possible 'for loop' in templates.xml ?

karaulov

New member
How to use 'for loop' in Xenforo 2.0 language (templates.xml)

For example pseudocode:

Code:
// create $n and $i local variables, do action while $i < 100
<xf:for var="$n = 0; $i = 0" while="$i < 100" do="$i++">
// set $n as $i % 10
<xf:set var="$n"  value="$i % 10" />
//... do something with $n ($i % 10) and $i local variables ...
</xf:for>

Someone can convert this pseudocode to Xenforo 2.0 templates.xml language?

Thanks all.
 
HTML:
<xf:set var="$range" value="{{range(0, 100)}}" />
<xf:foreach loop="$range" value="$iteration">
  <xf:set var="$n" value="{{ {$iteration} % 10 }}" />
</xf:foreach>

You can't do while cycles or alter you loop variable within cycle though.
 
Top Bottom