Switching Page Background Image

You want to exchange page background images - not randomly but individually driven by page request.

Let’s say your page is kept inside a table with width and height of 100% x 100%. The table would start with:

<table width=”100%” height=”100%” border=”0” cellpadding=”0” cellspacing=”0”>

To switch images as proposed I suggest to use the following code:

<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0" style="background:url(<?php if ($mybackground==''){echo $pth['folder']['templateimages']; ?>default<?php }else{echo $pth['folder']['templateimages'].$mybackground;} ?>.jpg) no-repeat center 0px;">

You now have several background images called 1.jpg, 2.jpg, 3.jpg .............. default.jpg. In order to assign a specific background image to an individual page, you use the following CMSimple script:

#CMSimple $mybackground=”1“;#
or
#CMSimple $mybackground=”2“;#
or
#CMSimple $mybackground=”3“;#
etc.

In case a page does not contain a script, the default.jpg is shown as background image.

Using this method you will be able not only to rotate background images of tables non-randomly, but also of table cells and DIV containers.

tips_and_tricks/image_rotation/non-random/switching_page_background.txt · Last modified: 2008/06/26 16:55 by till
Webdesign: NMuD chimeric.de = chi`s home Creative Commons License Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0