…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
```php
<{capture assign='num'}{1|rand:10}{/capture}
create a folder "random" and put your images there:
random/h_1.jpg
random/h_2.jpg
random/h_3.jpg
....
random/h_10.jpg
```
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.
VERY MUCH APPRECIATED!
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:
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. {capture assign='num'}{1|rand:3}{/capture}
and my css is as follows for the header:
#header {
/* background: url(images/header_bg9.jpg) no-repeat center top; */
background: no-repeat center top;
}
and I have 3 images in the correct folder as shown above in main.tpl code.
So what am I doing wrong? Thanks for any help…
[EDIT : ok, I put the following in the css, and now it seems to be working.
#header {
background: url(images/header_bg{$num}.jpg) no-repeat center top;
}
I know I didn't do this before (the $num call), so I dunno. If anyone sees a problem with the above or how it supposed to work, please feel free to post back. END of EDIT]