bart
Active member
I found this post by Jake Bunch:
And now I wonder if I can get to the value of the key. I would like to have these rows:
<xen:set var="$banners.1">banner one for index page</xen:set>
<xen:set var="$banners.22">banner two for index page</xen:set>
<xen:set var="$banners.33">banner three for index page</xen:set>
<xen:set var="$banners.444">banner four for index page</xen:set>
And want to know the key. The 1, 22, 33 or 444 in this case. I need to have those two variables.
Is that possible?
Code:
<xen:comment>DEFINE AND RANDOMIZE YOUR BANNERS</xen:comment>
<xen:if is="{$contentTemplate} == 'forum_list'">
<xen:set var="$banners.1">banner one for index page</xen:set>
<xen:set var="$banners.2">banner two for index page</xen:set>
<xen:set var="$banners.3">banner three for index page</xen:set>
<xen:set var="$banners.4">banner four for index page</xen:set>
<xen:elseif is="{$contentTemplate} == 'thread_view'" />
<xen:set var="$banners.1">banner one for thread page</xen:set>
<xen:set var="$banners.2">banner two for thread page</xen:set>
<xen:set var="$banners.3">banner three for thread page</xen:set>
<xen:set var="$banners.4">banner four for thread page</xen:set>
<xen:set var="$banners.5">banner five for thread page</xen:set>
<xen:else />
<xen:set var="$banners.1">banner one for all other pages</xen:set>
<xen:set var="$banners.2">banner two for all other pages</xen:set>
<xen:set var="$banners.3">banner three for all other pages</xen:set>
</xen:if>
<xen:foreach loop="$banners" value="$curBanner" i="$i" count="$count">
<xen:if is="!{$rand}">
<xen:set var="$rand">{xen:calc '({$serverTime} % {$count}) + 1'}</xen:set>
</xen:if>
<xen:if is="{$i} == {$rand}">
{xen:raw '$banners.{$rand}'}
</xen:if>
</xen:foreach>
And now I wonder if I can get to the value of the key. I would like to have these rows:
<xen:set var="$banners.1">banner one for index page</xen:set>
<xen:set var="$banners.22">banner two for index page</xen:set>
<xen:set var="$banners.33">banner three for index page</xen:set>
<xen:set var="$banners.444">banner four for index page</xen:set>
And want to know the key. The 1, 22, 33 or 444 in this case. I need to have those two variables.
Is that possible?