I have a pretty basic image rotator in a sidebar widget which pulls images on a random order through the rand(1,20) function.
It is very similar to this Xenforo resource
I display them on the widget by a simple call as below
What I would like to know is how can I add a second variable, so when combining them I know which image was pulled.
The second variable can be simple as below
In this scenario I would like to combine these two variables (and maybe add the 2nd variable in a title attribute.
However combining them like this or any variations does not work
How can I make it work, so depending on which number was pulled from the rand(1,20) function, the img would be like below
It is very similar to this Xenforo resource
HTML:
<xf:set var="$image.1">image1.jpg</xf:set>
<xf:set var="$image.2">image.2.png</xf:set>
<xf:set var="$image.3">image3.jpg</xf:set>
<xf:set var="$image.4">image.4.png</xf:set>
I display them on the widget by a simple call as below
HTML:
<div><img src="{$image.{{ (rand(1,20)) }}|raw}" /></div>
What I would like to know is how can I add a second variable, so when combining them I know which image was pulled.
The second variable can be simple as below
HTML:
<xf:set var="$random">{{ (rand(1,20)) }}</xf:set>
In this scenario I would like to combine these two variables (and maybe add the 2nd variable in a title attribute.
However combining them like this or any variations does not work
HTML:
<img src="{$image.$random|raw}" />
How can I make it work, so depending on which number was pulled from the rand(1,20) function, the img would be like below
HTML:
<img src="{$image.$random|raw}" title="Image ($random)" />
Last edited: