XF 2.0 Use a loop with variables inside a template

Russ

Well-known member
Are you able to set a loop inside a template with it looping items that are set inside the same template?

Essentially:

Code:
<xf:set var="$customLoop">
    <xf:set var="$customlist1">test</xf:set>
    <xf:set var="$customlist2">test</xf:set>
</xf:set>
                    <xf:foreach loop="$customLoop">
                        this would show for each var set above
                    </xf:foreach>

I hope this makes sense... makes perfect sense in my head but I'm not sure I'm explaining it correctly :)
 
You can define arrays in templates (I guess that's what you want):
HTML:
<xf:set var="$custom" value="{{['1','2','3']}}" />

Edit: In your case:
HTML:
<xf:set var="$c1" value="c1" />
<xf:set var="$c2" value="c2" />
<xf:set var="$custom" value="{{[$c1, $c2]}}" />
 
A potential shortcut, in case you can set the values literally:
Code:
<xf:foreach loop="['test', 'test']" value="$test">
    {$test}
</xf:foreach>
is it possible to use range to create arrays in template?
something like:
Code:
<xf:foreach loop="{{range('1,10')}}" value="$test">
    {$test}
</xf:foreach>
or
Code:
<xf:set var="$custom" value="{{range('1,10')}}" />
 
Top Bottom