Hey Guys:

I've read these same type posts about search engine friendly urls, so I am posting my 
FormURL2Attributes that is suped up with the CGI.PATH_INFO method of creating friendly 
urls.

You links should all be altered from this:

http://www.yoursite.com/index.cfm?id=foo&name=MrFoo

to this:

http://www.yoursite.com/index.cfm/id.foo/name.MrFoo.html

Here is the code (let me know what you think, greg):

<cfsetting enablecfoutputonly="yes">
<cfif IsDefined("CGI.QUERY_STRING")>
  <cfloop list="#CGI.QUERY_STRING#" delimiters="&" index="valuepair">
    <cfset urlname = "#ListGetAt(valuepair, 1, "=")#">
 <cfif not IsDefined('attributes.' & urlname)>
   <cfset setvariable("CALLER.ATTRIBUTES.#urlname#","#evaluate("url."&"#urlname#")#")>
 </cfif>
  </cfloop>
</cfif>
<cfif IsDefined("CGI.PATH_INFO")>
 <cfset list_len = listlen(CGI.PATH_INFO,"/")>
 <cfset list_index = listcontainsnocase(CGI.PATH_INFO,"index.cfm")>
 <cfset list_start = list_index + 1>
 <cfloop index="i" from="#list_start#" to="#list_len#">
  <cfset valuepair = listgetat(CGI.PATH_INFO, i, "/")>
  <cfset varname = gettoken(valuepair, 1, ".")>
 <cfif not IsDefined('attributes.' & varname)>
  <cfset setvariable("CALLER.ATTRIBUTES.#varname#", "#gettoken(valuepair, 2, ".")#")>
 </cfif>
 </cfloop>
</cfif>
<cfif IsDefined("FORM.fieldnames")>
  <cfloop list="#FORM.fieldnames#" index="field">
    <cfif not IsDefined('attributes.' & field)>
   <cfset setvariable("CALLER.ATTRIBUTES.#field#","#evaluate("form."&"#field#")#")>
 </cfif>
  </cfloop>
</cfif>
<cfsetting enablecfoutputonly="no">


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to