A few days ago I blogged about a simple slide show built using CFIMAGE and CFLAYOUT. While this worked ok, it wasn't very sexy. It had no flair. And as everyone knows, I'm all about the flair, so let's take a look at a cooler version. First I'll show the demo than talk about how it was built.


So how was this built? First off - none of the flair comes from me. It comes from a script called Slide Show. This code is pretty neat and I wish I could credit the guy who built it - but like far too many people out there, he doesn't have a "About Page". Do check out his other demos though as they are just as cool as this one. As Paris would say - that's hot.

The code uses mootools, an interesting JavaScript library. I haven't looked at it a lot - but it seems pretty nice. Although I will flaw them one thing - the download page nicely lets you select which libraries you want to grab. It will even compress them. But there is no "get all" option. As a developer, I wanted to just grab everything so I can play with it when I have time.

The ColdFusion code behind this is not really different than what I did last time. The only change was to remove the cflayouts. I used the same HTML he did for his demo and that was pretty much it. The complete code is below. It is a bit messy as I was just playing with it, but hopefully you get the idea. I think this goes to show that if you don't like ColdFusion 8's built in Ajaxy-goodness, you can definitely still play well with other Ajax libraries.

<html> <head> <script type="text/javascript" src="mootools.js"></script> <script type="text/javascript" src="BackgroundSlider.js"></script> <script type="text/javascript" src="slideshow.js"></script> <link href="slideshow.css" rel="stylesheet" type="text/css" /> <style> body { font: normal 91%/1.2 Helvetica,Arial,Verdana,Sans-serif; background-color: #fff; color: #999; padding-top: 30px; text-align: center; } </style>



  &lt;div id="thumbnails"&gt;
	  &lt;cfset folderurl = "images2"&gt;
	  &lt;cfset folder = expandPath("./images2/")&gt;
	  &lt;cfdirectory action="list" directory="#folder#" name="images"&gt;
	  &lt;cfquery name="images" dbtype="query"&gt;
	  select	name
	  from		images
	  where 	(lower(name) like '%.jpg'
	  or		lower(name) like '%.gif')
	  and		lower(name) not like '_thumb_%'
	  &lt;cfloop query="images"&gt;
		&lt;cfif not fileExists(folder & "_thumb_" & name)&gt;
		  &lt;cfimage source="#folder##name#" action="read" name="newimage"&gt;
		  &lt;cfset imageScaleToFit(newimage, 100, 100)&gt;
		  &lt;cfimage action="write" source="#newimage#" destination="#folder#/_thumb_#name#" overwrite="true"&gt;
	  &lt;cfoutput&gt;&lt;a href="#folderurl#/#name#" class="slideshowThumbnail"&gt;&lt;img src="#folderurl#/_thumb_#name#" border="0" /&gt;&lt;/a&gt;&lt;/cfoutput&gt;
	  &lt;p&gt;&lt;a href="#" onclick="show.play(); return false;"&gt;Play&lt;/a&gt; | &lt;a href="#" onclick="show.stop(); return false;"&gt;Stop&lt;/a&gt; | &lt;a href="#" onclick="show.next(); return false;"&gt;Next&lt;/a&gt; | &lt;a href="#" onclick="show.previous(); return false;"&gt;Previous&lt;/a&gt;&lt;/p&gt;

	  &lt;div id="slideshow" class="slideshow"&gt;&lt;/div&gt;

		&lt;script type="text/javascript"&gt;
			var obj = {
				wait: 3000, 
				effect: 'fade',
				duration: 1000, 
				loop: true, 
				thumbnails: true,
				backgroundSlider: true
			show = new SlideShow('slideshow','slideshowThumbnail',obj);


</body> </html>