• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

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

#1
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.
 

CyberAP

Well-known member
#2
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.
 
#3
Thanks you.

I can read more about it in Xenforo add-on 2.0 documentation ?
(Xenforo tags in templates.xml)

Or documentation isn't completed ?