I just remembered I had some troublesome code from a small lil' thing I wuz
making while bored one night about 2 months ago. I had forgotten all about
this page till I just found it ;). I called the code dynamicxygen.cfm &
planned to use it as an include. Basically what it does is this:
It'll dynamically create links to each directory from the current template
path, all the way down to root. If you included it on every page you would
have a very easy way of creating links around the site, even tho the code is
a bit clunky. It would look like this one a page:
<!--- Normal path to file. --->
Path: C:\r00t\main\newdir\currentdir\blah.cfm
<!--- The dyxgen navigation would then end up like this on the page --->
<link>main</link>/<link>newdir</link>/<link>currentdir</link>/blah.cfm
main/newdir/currentdir/blah.cfm all linked back to the correct files.
The code works great when creating links to docs in root & 2nd level
directories but when it goes deeper than that it doesnt return anything but
an empty array. I cant understand why, altho I do have to admit I havent
looked at the code in a long while.
Can anyone help me find out why this isnt working 3 or more directories deep
when it works fine any level before that??? Ill post the code below:
<cfset pathlen=ListLen(SCRIPT_NAME,"/")>
<cfset temparray=ArrayNew(1)>
<cfset y="1">
<cfoutput>
<cfloop index="x" from="#pathlen#" to="1" step="1">
<cfset getting=ListGetAt(SCRIPT_NAME,"#x#","/")>
<cfif y IS "#pathlen#">
<cfset temparray[y]=#ReReplaceNoCase(SCRIPT_NAME,"getting","","ONE")#>
<cfelse>
<cfset y=y+1>
<cfset temparray[y]=#ReReplaceNoCase(SCRIPT_NAME,"getting","","ONE")#>
</cfif>
</cfloop>
<cfloop index="z" from="1" to="#ArrayLen(temparray)#" step="1">
<cfset newlink="#ReReplaceNoCase(reverse(temparray[z]),"/","","ONE")#">
<cfif z IS "1" AND z IS NOT "#ArrayLen(temparray)#">
/<a href="http://127.0.0.1/">Home</a>/<a
href="#temparray[z]#">#Reverse(newlink)#</a>
<cfelseif z IS "#ArrayLen(temparray)#">
/<a href="#temparray[z]#">#Reverse(newlink)#</a>
</cfif>
</cfloop>
<!--- I added this code once I found the bug. This'll prove that the code
doesnt work when executed after 2 directories deep. --->
<cfif ArrayIsEmpty(temparray) IS "true">
Array is empty
<cfelse>
Array is all good.
</cfif>
</cfoutput>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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