Page 1 of 1

Rotating Header

Posted: Thu Jan 07, 2010 1:44 pm
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.

Re: Rotating Header

Posted: Thu Jan 07, 2010 1:48 pm
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

Re: Rotating Header

Posted: Thu Jan 07, 2010 9:17 pm
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>

Re: Rotating Header

Posted: Fri Jan 08, 2010 6:07 am
by RonnyK

Re: Rotating Header

Posted: Fri Jan 15, 2010 10:59 pm
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?

Re: Rotating Header

Posted: Sun Jan 17, 2010 8:48 pm
by Dr.CSS
You would most likely have to do some position:absolute to the menu div or some such thing...