Resource icon

Display A Random Banner

Also, call the image from its relative path:

<a href=""><img src="/images/header/header1.jpg"></a>
Not from a full URL, like you are doing:

<a href=""><img src=""></a>
I thought I was very clear with my example above. :)


Well-known member
I thought I was very clear with my example above.
I also think so ;)

My Code, the result you know
With or without a slash before "images/header/"
it´s the same.

<xen:hook name="ad_below_content" />
<xen:comment>DEFINE AND RANDOMIZE YOUR BANNERS</xen:comment>

<xen:set var="$banners.1"><a href=""><img src="images/header/header1.jpg"></a></xen:set>
<xen:set var="$banners.2">images/header/header2.jpg</xen:set>
<xen:set var="$banners.3">images/header/header3.jpg</xen:set>
<xen:set var="$banners.4">images/header/header4.jpg</xen:set>
<xen:set var="$banners.5">images/header/header5.jpg</xen:set>
<xen:set var="$banners.6">images/header/header6.jpg</xen:set>
<xen:set var="$banners.7">images/header/header7.jpg</xen:set>
<xen:set var="$banners.8">images/header/header8.jpg</xen:set>
<xen:set var="$banners.9">images/header/header9.jpg</xen:set>
<xen:set var="$banners.10">images/header/header10.jpg</xen:set>

<center><img src="{xen:raw '$banners.{xen:calc '({$serverTime} % 10) + 1'}'}" /></center>
Hi @bt012ss,

Well, the error is right there. You are duplicating tasks, when putting the "src" in both the xen:set and the xen:raw.

First, I would suggest you start with just 2 banners, or even 1. Once those are working, you would have learnt and will be confident enough to add more.

Please try with this code in an empty template:

<xen:set var="$banners.1">
<a href=""><img src="/images/header/header1.jpg"></a>
{xen:raw '$banners.{xen:calc '({$serverTime} % 1) + 1'}'}
Good luck.


Well-known member

I found the right code by try and error and of course with your great tips.
Thank you very much for your time :cool:

Without a slash before the relative path the code is now correct.

<xen:hook name="ad_below_content" />
<xen:comment>DEFINE AND RANDOMIZE YOUR BANNERS</xen:comment>

<xen:set var="$banners.1"><a href=""><img src="styles/haendler/footer/mbs.png"></a></xen:set>
<xen:set var="$banners.2"><a href=""><img src="styles/haendler/footer/lutz.jpg"></a></xen:set>
<xen:set var="$banners.3"><a href=""><img src="styles/haendler/footer/motocoach.jpg"></a></xen:set>
<xen:set var="$banners.4"><a href=""><img src="styles/haendler/footer/motorcycle-service.jpg"></a></xen:set>
<xen:set var="$banners.5"><a href=""><img src="styles/haendler/footer/motorismo.jpg"></a></xen:set>
<xen:set var="$banners.6"><a href=""><img src="styles/haendler/footer/spyder.jpg"></a></xen:set>
<xen:set var="$banners.7"><a href=""><img src="styles/haendler/footer/tecbike.jpg"></a></xen:set>
<xen:set var="$banners.8"><a href=""><img src="styles/haendler/footer/aundb.png"></a></xen:set>
<xen:set var="$banners.9"><a href=""><img src="styles/haendler/footer/hafeneger.png"></a></xen:set>
<xen:set var="$banners.10"><a href=""><img src="styles/haendler/footer/jajauma.png"></a></xen:set>

<center>{xen:raw '$banners.{xen:calc '({$serverTime} % 10) + 1'}'}</center>


Well-known member
I tried putting this code and it messes up Jaxel front page portal.. What am I doing wrong?
<xen:comment>DEFINE AND RANDOMIZE YOUR BANNERS</xen:comment>

<xen:set var="$banners.1"><center><a href=""><img src="" width="468" height="60" /></center></xen:set>

{xen:raw '$banners.{xen:calc '({$serverTime} % 1) + 1'}'}

Mian Shahid

Well-known member
How can i add some text above banners?
<xen:hook name="ad_above_top_breadcrumb" />
<xen:comment>DEFINE AND RANDOMIZE YOUR BANNERS</xen:comment>
<div style="text-align: center;"><script type="text/javascript">
<xen:set var="$banners.1"><a href=""><img src="images/banner1.png"></a></xen:set>
<xen:set var="$banners.2"><a href=""><img src="images/banner2.png"></a></xen:set>

<center>{xen:raw '$banners.{xen:calc '({$serverTime} % 2) + 1'}'}</center>

Mian Shahid

Well-known member
how can i set those banner image width to 100%? is their any code to add in EXTRA.css or some ware else?
Solved :)
<xen:set var="$banners.1"><a href=""><img style="max-width: 100%" src="images/ads/banner1.jpg"" ></a></xen:set>
<xen:set var="$banners.2"><a href=""><img style="max-width: 100%" src="images/ads/banner2.gif" ></a></xen:set>