Code: Friendly URLs
Ever notice the way some sites would write a URl like:
as something a little more URL friendly like:
To get this, simply include the following code in your application.cfm file!:
<cfif ListLast(CGI.PATH_INFO,".") NEQ "cfm">
<cfif Find(".cfm",CGI.PATH_INFO)>
<cfset lenRHSofDotCFM = Len(CGI.PATH_INFO) - (Find(".cfm",CGI.PATH_INFO)+4)>
<cfelse>
<cfset lenRHSofDotCFM = Len(CGI.PATH_INFO)>
</cfif>
<cfif lenRHSofDotCFM GT 0>
<cfset RHSofDotCFM = Right( CGI.PATH_INFO, lenRHSofDotCFM )>
<cfset numURLItems = listLen(RHSofDotCFM,'/')>
<cfset numURLItems = numURLItems - (numURLItems mod 2)>
<cfloop from="1" to="#numURLItems#" index="i" step="2">
<cfset URL[ GetToken(RHSofDotCFM,i,'/') ] = GetToken(RHSofDotCFM,i+1,'/')>
</cfloop>
</cfif>
</cfif>
PS. I made this site wider since I figure that anybody reading this site must be working with at least a 1024x768 resolution and the text is easier to read this way, don'tcha think. If the site looks a little odd, try deleting your browser cache - the flash headers on the blog posts are caching big time. I've deleted Internet Explorers cache a few times now and its still cached. Looks fine in Firefox though so I guess it'll sort itself out.
Peter Coppinger aka Topper is a neurotic web monster who spends most of his chaotic life developing ColdFusion web applications when not drinking himself into a stupor and scheming his plans for world dominance.