Rotating Header

For discussion and questions related to CMS Specific templates and stylesheets (CSS), and themes. or layout issues. This is not a place for generic "I don't know CSS issues"
Post Reply
Alex91
Forum Members
Forum Members
Posts: 16
Joined: Thu Jan 07, 2010 1:39 pm

Rotating Header

Post by Alex91 »

Hello,
I'm new to CMSMS, but the looks and feels are great.

In my pas CMS system i used the next code:

Code: Select all

// random header number (it was on the index.php)
$headerimg = rand(1,2);

// So i can run the script in a TPL file
$inhoud = str_replace("{headerimg}",$headerimg,$inhoud);


//This is in the view file (theme file) where {headerimg} was generated @ the index.php
 <img src="images/header_{headerimg}.jpg">
But how can i use this in CMSMS, did not find the solution on this forum.

Thanks so far.
RonnyK
Support Guru
Support Guru
Posts: 4962
Joined: Wed Oct 25, 2006 8:29 pm

Re: Rotating Header

Post by RonnyK »

There are some image-rotators in the forge http://dev.cmsmadesimple.org/projects/image-rotator which you can use.

Also some logic could be put in a UDT (User Defined Tag), which could be called at the location in the template, where the logic should be called.

First option would be to look to the plugin image-rotator.

Ronny
Wishbone
Power Poster
Power Poster
Posts: 1368
Joined: Tue Dec 23, 2008 8:39 pm

Re: Rotating Header

Post by Wishbone »

I have this in a template on one of my sites:

Code: Select all

{math equation='rand(1,26)' assign='rand'}
<img src="uploads/images/rotating/rotating_pic_{$rand|string_format:'%02d'}.jpg">
The first line picks a random number between 1 and 26 and assigns it to the variable $rand. The second line places the image and sticks the random number at the end. I also use a modifier "|string_format:'%02d'" which makes sure that there is a leading 0 for single digit numbers, i.e. 01, 02, etc, but can be omitted if that isn't your case.

If your header is a div and you want to set a background, and you have different styles, one for each image you can use:

Code: Select all

<div id="header_{$rand}"></div>
Or have one style and change the image inline:

Code: Select all

<div id="header" style="background-image: url('header_{$rand}.jpg')"></div>
Last edited by Wishbone on Thu Jan 07, 2010 9:24 pm, edited 1 time in total.
RonnyK
Support Guru
Support Guru
Posts: 4962
Joined: Wed Oct 25, 2006 8:29 pm

Re: Rotating Header

Post by RonnyK »

voorhammr
Forum Members
Forum Members
Posts: 68
Joined: Tue Nov 10, 2009 10:04 pm

Re: Rotating Header

Post by voorhammr »

Can anyone tell me how i can set the {image_rotator} within the header of the NCNBlue theme without the situation that the menu is moving downwards?
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am

Re: Rotating Header

Post by Dr.CSS »

You would most likely have to do some position:absolute to the menu div or some such thing...
Post Reply

Return to “Layout and Design (CSS & HTML)”