Raymond Camden's Blog Rss

Galleon ColdFusion 9 fix, and pagination UI update

6

Posted in ColdFusion | Posted on 07-23-2009 | 4,054 views

I got my forums back up and in the process of doing so - found two interesting issues.

First - Image.cfc (which is from the open source ImageCFC project) made use of a CFC method called Throw. This allowed code in the CFC to do:

view plain print about
1<cfset throw("Paris Hilton recommend some awesome new shoes. Shaweet!")>

Unfortunately this conflicts with ColdFusion 9's built in support for throwing via script. My "fix" was to simply rename all the throw calls to xc989082903480983894840894328093289042389. Now the code does:

view plain print about
1<cfset xc989082903480983894840894328093289042389("code readability ftw!")>

Ok... I lie. I just renamed it mythrow, and updated the method definition as well.

Now for the UI issue. The ColdFusion/General forum has a ginormous number of threads. This created the following "interesting" UI:

That's awesome, isn't it? All it needs is a unicorn or two to spruce it up.

So I thought that wouldn't fly. What I ended up doing is simply adding some logic to say - if there are so many pages, switch to a drop down:

view plain print about
1<p>Page:
2    <cfif attributes.pages gt 10>
3        <select onChange="document.location.href=this.options[this.selectedIndex].value">
4            <cfloop index="x" from=1 to="#attributes.pages#">
5                <option value="#cgi.script_name#?#qs#&page=#x#" <cfif url.page is x>selected</cfif>>Page #x#</option>
6            </cfloop>
7        </select>
8    <cfelse>
9    <cfloop index="x" from=1 to="#attributes.pages#">
10        <cfif url.page is not x><a href="#cgi.script_name#?#qs#&page=#x#">#x#</a><cfelse>#x#</cfif>
11    </cfloop>
12    </cfif>
13</p>

Which results in:

Somewhat better I think. Full City Media, who did the original skin for Galleon 2, is sending me over a small CSS tweak for it that I'll include in the new version shipping tomorrow morning.

Comments

[Add Comment] [Subscribe to Comments]

Aw... I thought it would end with 'oh yeah and you can moderate comments now, too ". Ok not really.
Sorry - not yet.
Ha! There's nothing worse than when a new ColdFusion introduces a new function that overwrites one you've made earlier. sleep() anyone?

You'd think Adobe would have the decency to check with everyone first!

NEW FOR COLDFUSION 10: xc989082903480983894840894328093289042389()

D'oh!
@Adrian: Well, to be fair, any new function has a chance of conflicting with a UDF you wrote. :)
Have you considered using this open source pagination CFC?
http://www.dopefly.com/projects/pagination/

Here are some live examples:
http://www.dopefly.com/projects/pagination/examples/" target="_blank">http://www.dopefly.com/projects/pagination/example...
Nope, didn't think to. I need to next time as I've written too many pagination systems.

[Add Comment] [Subscribe to Comments]