Skip Navigation

University of Nebraska–Lincoln

Web Developer Network Wiki

Herein Lies the Accumulated Knowledge of Mankind

Random Promo Images

Simple instructions on how to add a random image or flash .swf movie on a page.

To use this implementation your server must have the current templatedependents as of 1/31/2008.

  • Place a div with a unique ID on the page.
<div id="randomPromo"></div>
  • Create a XML file containing references to your images or flash files and the name of the ID (randomPromo)
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<random>
	<contentContainer>randomPromo</contentContainer>
	<promo class="image_medium" id="UNL Today 20070104">
		<media type="image">http://www.unl.edu/ucomm/unltoday/graphics/2007/20070104_blakelock.jpg</media>
		<link>http://www.unl.edu/ucomm/unltoday/</link>
	</promo>
	<promo class="image_medium" id="UNL Alert">
		<media type="flash" width="450" height="210">http://www.unl.edu/ucomm/images/promos/promo_alert.swf</media>
	</promo>
</random>

note: Each promo element must have a media element. The class attribute of a promo is optional and will default to "image_small_short" if left out. The media element must have a type attribute (image | flash) and a flash type must also have a width and a height, otherwise it will default to 210x80. A link element my be added to a promo that have an image media.

  • Put this in the editable area of your header tag (<head>)
<script type="text/javascript">
var aRandomPromo;
wraphandler.addEvent(window,"load",function(){
	aRandomPromo = new XMLrandomPromo('http://www.unl.edu/ucomm/images/promos/promos.xml', 14, 'aRandomPromo');
});
</script>

note: make sure you change the xml path (http://www.unl.edu/ucomm/images/promos/promos.xml) to point to your own xml file. The last two options of XMLrandomPromo (14, 'aRandomPromo') are optional. The number specifies the time (in seconds) until the promo rotates. If you specify a time you must also give the name of the variable ('aRandomPromo'), so the function knows where to get the other promo information from.