Great Lakes Designs
Toggle Content Welcome Guest! Please Register or Login
Toggle Content Contributions
Due Date: Sep 30
September Goal: 50.00
Gross Amount: 0.00
PayPal Fees: 0.00
Net Balance: 0.00
Below Goal: 50.00
Site Currency: USD
 0%

Toggle Content Main Menu

Toggle Content User Info

Welcome Anonymous

Nickname
Password

Membership:
Latest: tonyb
New Today: 0
New Yesterday: 0
Overall: 12

People Online:
Members: 0
Visitors: 1
Total: 1
Who Is Where:
 Visitors:
01: Support Forums

Staff Online:

No staff members are online!

Toggle Content Preview theme
Each user can view the site with a different theme.
Themes marked with a * also change the forum look.

Toggle Content Shopping Cart
Your cart is empty.

[ Browse ]

Support Forums › DragonFlyCMS Themes › Dragonfly Theming Tips & Tricks › Rotating Image in Header

    Forum IndexDragonfly Theming Tips & Tricks
Rotating Image in Header

Post new topic   Reply to topic   Printer Friendly Page
View previous topic :: View next topic  
Author Message
rlgura
Site Admin
Site Admin


Joined: Dec 13, 2007
Posts: 25
Location: Cleveland, OH USA

PostPosted: Wed Oct 08, 2008 7:59 pm    Post subject: Rotating Image in Header Reply with quote

This will display a random image from a pre-defined list of images

Credit for this code goes to Kristin of Dragonflied.com

Step 1:
Create a folder/directory called "random" in your theme's images directory and place all the images you want in there.
For example the path you'll be using to call your random images will be: yourtheme/images/random/01.jpg

Step 2:
In yourtheme/theme.php, add the following 2 variables ($array and $image) and add the 'RAND_IMG' var to assign_vars block

Code::
// random image at top in header
$array = array('01.jpg', '02.jpg', '03.jpg');
$image = rand(0, count($array)-1);

$cpgtpl->assign_vars(array(
    'RAND_IMG' 	   => $array[$image],
Don't forget to specify the image filenames you want in the array. Replace 01.jpg etc... with your images.

Step 3:
In yourtheme/template/header.html (or whatever template file you want to have a rotating image use the following code.
Code::
<img src="{THEME_PATH}/images/random/{RAND_IMG}"  alt="" border="0" />

_________________
Site Admin - Great Lakes Web Designs
Theme Designer - WebSite Guru Designs
Site Admin - Families with Food Allergies
Back to top
Display posts from previous:   
Post new topic   Reply to topic   Printer Friendly Page     Forum IndexDragonfly Theming Tips & Tricks All times are GMT
Page 1 of 1


Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum

Cardinal Theme orginally By: Lorkan Themes. - Ported to DragonflyCMS by: WebSiteGuru Designs
Version 9.2.1.2 - July 1, 2008