Randomise Banner Graphic

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
Andrew Prior
Forum Members
Forum Members
Posts: 248
Joined: Sun Oct 28, 2007 4:14 am

Randomise Banner Graphic

Post by Andrew Prior »

Hi all.
I have the following code from the Layout: Top menu + 2 columns stylesheet in v 1.2.3 Black Rock


div#header h1 a {
/* you can set your own image here */
  background: #385C72 url(uploads/images/banners/banner_1.jpg) no-repeat 0 1px;
  display: block;
  height: 87px;            /* adjust according your image size */
  text-indent: -999em;  /* this hides the text */
  text-decoration:none; /* old firefox would have shown underline for the link, this explicitly hides it */
}

Is there anyway I can randomise the choice of that image. I have a couple of ramdomising methods, but the
url(uploads/images/banners/banner_1.jpg)
fouls them up.

Andrew
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am

Re: Randomise Banner Graphic

Post by Dr.CSS »

Have you looked in forge for a random image module?...
Andrew Prior
Forum Members
Forum Members
Posts: 248
Joined: Sun Oct 28, 2007 4:14 am

Re: Randomise Banner Graphic

Post by Andrew Prior »

Yes, doesn't work in this context unfortunately
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

Re: Randomise Banner Graphic

Post by calguy1000 »

Using this thread (in the tips & tricks forum):  http://forum.cmsmadesimple.org/index.php/topic,15706.0.html

You could do something like this:

Code: Select all

{capture assign='num'}{1|rand:10}{/capture}{* generate a random number between 1 and 10, assign it to 'num *}
<div id="background" style="background #385C72 url(uploads/images/banners/banner_{$num}.jpg) no repeat 0 1px"></div>
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
hexdj
Power Poster
Power Poster
Posts: 415
Joined: Sat Mar 24, 2007 8:28 am

Re: Randomise Banner Graphic

Post by hexdj »

Try image rotator by Alby

You can't use it for bg images, but it will randomize 's
Andrew Prior
Forum Members
Forum Members
Posts: 248
Joined: Sun Oct 28, 2007 4:14 am

Re: Randomise Banner Graphic

Post by Andrew Prior »

Hi Calguy.
I use your random image code a lot; it's extremely useful, thanks.
But it will not work in this location. It seems not to parse the code when I put {$num} in place of the file name. There is simply no image appears. I've assumed that this is because it is in  a stylesheet rather than in a template.
Andrew
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

Re: Randomise Banner Graphic

Post by calguy1000 »

if you look at the example above.... I'm using doing it all in HTML by passing an additonal style attribute on the div.  and smarty will work there.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
Post Reply

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