Jake Bunce
Well-known member
Here is some template programming to define and randomize your banners:
This code works in any template. For randomizing banner advertisements you are probably working in one of the ad_ templates. For example:
Admin CP -> Appearance -> Templates -> ad_above_content
Use this code:
Replace the red parts with your banner code. Just be sure to use a new number for each new banner you add. And the highest number needs to be entered into the rand calculation. For example, if you have 5 banners defined then it will look like this:
This code works in any template. For randomizing banner advertisements you are probably working in one of the ad_ templates. For example:
Admin CP -> Appearance -> Templates -> ad_above_content
Use this code:
Rich (BB code):
<xen:comment>DEFINE AND RANDOMIZE YOUR BANNERS</xen:comment>
<xen:set var="$banners.1">banner one</xen:set>
<xen:set var="$banners.2">banner two</xen:set>
<xen:set var="$banners.3">banner three</xen:set>
{xen:raw '$banners.{xen:calc '({$serverTime} % 3) + 1'}'}
Replace the red parts with your banner code. Just be sure to use a new number for each new banner you add. And the highest number needs to be entered into the rand calculation. For example, if you have 5 banners defined then it will look like this:
Rich (BB code):
<xen:comment>DEFINE AND RANDOMIZE YOUR BANNERS</xen:comment>
<xen:set var="$banners.1">banner one</xen:set>
<xen:set var="$banners.2">banner two</xen:set>
<xen:set var="$banners.3">banner three</xen:set>
<xen:set var="$banners.4">banner four</xen:set>
<xen:set var="$banners.5">banner five</xen:set>
{xen:raw '$banners.{xen:calc '({$serverTime} % 5) + 1'}'}