Photo from Chile

Rotating Banner for BlogCFC - Hack Warning!

So after making my site look pretty, and creating my banner image, I decided that I'd like to create a few images and have them rotate randomly on my blog. The first complication I discovered is that all of the pages are cached by BlogCFC, so simply introducing code into layout.cfm to rotate the image wouldn't work.

Having spent a few hours last night messing with BlogCFC code, I didn't really want to delve into it again to figure out a way around the caching issue, so I came up with a solution that is probably the "hackiest" thing I've done in ages.

I set up a scheduled task in CF that will randomly select one of 5 images that I've created for banner and then copy that image overtop of an image called MyBanner.jpg. MyBanner.jpg is what my img tag points to in layout.cfm. I'm running that task hourly, so now, even though the page stays cached, the image rotates randomly every hour.

Here's the code for RotateBanner.cfm:

view plain print about
1<cfset dir = expandPath("images/") />
2<cfset ImageList = "chile_banner_2,chile_banner_3,chile_banner_5,chile_banner_6,chile_banner_7" />
3<cffile action="copy" source="#dir##ListGetAt(ImageList,RandRange(1,ListLen(ImageList)))#.jpg" destination="#dir#MyBanner.jpg">

I'm not particularly proud of the code, but hey, I got the job done in about 10 minutes.

My New BlogCFC Skin

Now that I've started trying to blog more regularly, and now that some people are actually viewing my blog, I figured it was time to ditch the lovely BlogCFC vanilla skin and make things a bit prettier around here.

I was a bit intimidated at first, being very much a back-end developer and not having done much work with css in quite awhile. With a little moral support from Paul Marcotte, I found a css template that I liked at Styleshout.com, made a couple of changes to it, including getting rid of the wood in the background graphic (thanks Paul), and started making changes to BlogCFC templates.

A few hours later my blog was reborn. It was actually pretty easy to do, and I'm quite happy with the results.

I also replaced the stock photo that comes with the template with a slice from a photo that I took during a hike in Parque Nacional Torres del Paine in southern Chile in 2004. You can see the full photo here. I plan to rotate this image with others that I've taken on my travels.

I also took this opportunity to play with Slideshows in BlogCFC, setting one up which contains a few more photos from this trip. If you enjoy nice scenery and/or are interested in Chile, check it out via the link in the sidebar.

UPDATE:

My banner image now rotates hourly, so the link above may not actually point to a full version of the banner pic. It's still a nice photo, though.