Rotating header image...

…checked and didn't see anything about this in the forums.

Currently, to change the header background image, you need to edit the css for this. Is there a way I can have a random background image display each time a page loads? (I know, old school, unless someone has a fancier slideshow solution?).

I have tried a rotate php file called from css, but that doesn't display anything. I also cannot see in top.tpl where the css or header image gets called in the first place (does it come from main.tpl?).

Any thoughts or ideas are appreciated, thank you!

I don't know but I guess if you find any script using smarty, you could get better result.

Google “rotate background image smarty” or “random image background smarty php”.

A quick trick to display a random image

There was a recent post mentioning you have to enable php in the config.local to make any php work.

I guess the smarty route is better.

Thanks, colortone. The link you gave and other searches gave me some techniques and code, but I have tried them and still can't get it to go. Either it messes up the rest of the page, or no image displays. ?

Any other thoughts?

The solution is there in the link, find the

and replace it with:

```php <{capture assign='num'}{1|rand:10}{/capture}

create a folder "random" and put your images there:

some skins don't give any properties to the #header, so maybe you need to declare it in your styles.css

```php #header {width: 890px; height: 80px;} ```

Thanks again, tone. I didn't have the “1” “2” “3” … file names correct or in succession. In the example of {1|rand:10}, I assume I need 10 images. After changing the 10 to a 4 for the number of images I did have, then it worked without any “blanks.”

Have to create a few more files and keep testing for speed and appearance.


Ok, just getting back to this, and I am flipping stumped as I had this working before and cannot figure out what I am doing wrong now. No images at all are being displayed.

Code in main.tpl is as follows:

{capture assign='num'}{1|rand:3}{/capture}

So, reviving this old thread as now I am testing on 4.3.4, and wondering how this could be done with a block/grid in the layout editor. Ideas? I tried using an HTML block, but my code must not be correct. Thanks for any thoughts.