A LIST Apart: For People Who Make Websites

No. 186

Discuss: A Better Image Rotator

Pages

 1 2 3 >  Last »

1 what's the point?

Why go to all the trouble when you can use nicely formatted xml.

posted at 09:40 am on August 10, 2004 by pointman

2 what about handling multiple images?

great explanation! I really like this, but I’ve got a question.

I’d like it to rotate & display more than one image – how would I do that?
basically, if I’ve got 3 images listed in the .ini file, I’d like each one listed in some random order.
is that possible with some minimal tweaks?

thanks!!!

posted at 10:01 am on August 10, 2004 by nick

3 Random Order

Nick: If I understand what you’re asking – the order the images are listed in the INI file doesn’t matter, the image being displayed is always selected from the list at random.

posted at 10:12 am on August 10, 2004 by Narrator

4 xml?

Pointman:

What is your point…man?

Use XML for what? Are you suggesting he use xml for the config file? How would that be easier? The *.ini file seems nicely formatted to me and easy to use.

posted at 10:21 am on August 10, 2004 by Christopher

5 Nice, but..

As with the other interesting and handy articles published here, I’d like to see a version of this for ASP.NET. I see an XML file, dynamic XML and an XSLT. The demand for ASP.NET equivelents became obvious to me after I created this .NET version of a previous ALA article: http://www.enjoybeingsoftware.com/dev/gen_heading/

What I don’t see is a great need for random image rotation where the image would be of variable sizing, how could one work that in to a CSS layout without breaking the design?

Is there a practical example of this technique in usage? The example posted is hardly “real-world”.

posted at 10:24 am on August 10, 2004 by justin

6 RE: what's the point?

You might be right about the fact that XML is ‘the way to go’ but it isn’t an esay thing to pick up…
INI-files are so much easier and as I remeber ASP.NET can just as easy handle INI files with some built-in functions. (-> justin)

Anyway, rotators isn’t really a dificult topic anyway, you just make it incomplicated

Mathijsken

posted at 10:36 am on August 10, 2004 by Mathijs Dumon

7 Dumb question

Here’s a dumb question:

Did I read the article correctly to understand that all my pages which use this will now be “###.php” and not “###.html”?

I’m already managing a fairly big site and I don’t want to go back through and change all my links. Is there a way to keep my .html extensions?

posted at 10:39 am on August 10, 2004 by guyPaulo

8 RE: Nice But...

There is an AdRotator control that comes with .Net. If you need something special from it just inherit and extend it.

posted at 10:47 am on August 10, 2004 by Brant LeClercq

9 Extensiton Changing

guyPaulo, you might want to look into using the older technique for rotating images, which can be found here: http://www.alistapart.com/articles/randomizer/

That way your pages can continue being .html or whatever. You could also get even more abstract by using the background-image property of CSS to call the random image generator…

.random_image
{
background-image:url(../s/random_image.php);

}

You can also go into the server configuration settings and map the PHP engine to parse HTML files, but that would add a lot of processing overhead and require administrative access to your server.

As a side note, you have an entire site that is static? All HTML pages with no backend processing? You must like editing HTML pages and FTPing them a lot! :)

posted at 10:53 am on August 10, 2004 by justin

10 Not a Dumb Question

guyPaulo: not a dumb question at all. Depending on your web host, there are a couple of ways to handle this. The easiest way would be to tell the server to treat (and parse) all html files as if they were PHP files. The performance hit to the server is small, but it’s something to take note of if you have many plain html pages which would be parsed unnecessarily.

You can place the following code in a .htaccess file at the root of your web folder to enable this:

AddType application/x-httpd-php .htm .html

This should handle the switch for you – but again, remember there’s a slight performance hit for html pages that don’t contain PHP as they’ll now be parsed as if they were PHP files.

posted at 10:55 am on August 10, 2004 by Narrator

Pages

 1 2 3 >  Last »

Got something to say?

Discuss this article. We reserve the right to delete flames, trolls, and wood nymphs.

Create a new account or sign in below if you’d like to leave a comment.

Remember me

Forgot your password?

Subscribe to this article's comments: RSS (what’s this?)