|
Hi, First let me start off by saying all I did was tweak some great code that was already provided on the list. My reason for doing this was because of an uncooperative host and I needed some FU. With that being said, please see the following:
As a side note I also extended the dmNavigation type to auto create nav alias every time you create a node, unless you type one in manually. Not to sure if there is any interest in that, but here is a code snippet from the updated dmNavigation/edit.cfm. The concept is based on Quentin Zervaas's quick builder: <!--- get the parent node and update nav alias path ---> <!--- get ancestors ---> <cfset qAncestors = request.factory.oTree.getAncestors(objectid=stobj.objectid,bIncludeSelf=false)> <cfquery dbtype="query" name="q"> SELECT objectName FROM qAncestors WHERE nLevel >= 2 ORDER BY nLevel </cfquery> <cfscript> // take the title of the page and remove all odd characters //get the crumbs trail=valuelist(q.objectname); trail=lcase(rereplacenocase(trail, "\W+", "_", "all")); //get the title navAlias = lcase(rereplacenocase(form.title, "\W+", "_", "all")); if (len(form.lNavIDAlias)){ form.lNavIDAlias = form.lNavIDAlias; } else { form.lNavIDAlias = trail & "_" & navAlias; } ........yada yada.... --
Regards, Michael J. Sammut ________________________________________________ F O U R E Y E S P R O D U C T I O N S think | plan | create :: web site design & development :: NYC E. [EMAIL PROTECTED] | T: 718.254.9557 ext. 101 | F: 888.236.8618 W. http://www.foureyes.com |
<cfsetting enablecfoutputonly="Yes" /> <cfimport taglib="/farcry/fourq/tags/" prefix="q4">
<cfif thistag.executionMode eq "Start">
<cfparam name="attributes.target" default="_self" />
<cfparam name="attributes.bShowTarget" default="false" />
<cfparam name="attributes.externallink" default="" />
<cfparam name="attributes.class" default="" />
<cfparam name="attributes.urlOnly" default="false" />
<cfparam name="attributes.bOutput" default="true" />
<cfparam name="attributes.xCode" default="" /> <!--- extra string you'd
like in the <a> tag --->
<cfparam name="attributes.includeDomain" default="false" /> <!---
boolean: Show my domain in href attribute? --->
<cfparam name="attributes.stParameters" default="#StructNew()#" /> <!---
extra parameters to include in the URL --->
<cfparam name="attributes.typePattern" default="nav" />
<cfparam name="attributes.label" default="" />
<cfparam name="attributes.urlparams" default="" />
<cfparam name="attributes.bNUFU" default="true" /> <!--- boolean:
Enable NUFU links? --->
<cfparam name="attributes.lNavIDAlias" default="" />
<cfparam name="attributes.bSES" default="true" />
<cfparam name="attributes.style" default="" />
<!--- If no lNavIDAlias passed, check single list entry --->
<cfset thisNavAlias = "">
<cfif listLen(attributes.lNavIDAlias) eq 1>
<!--- Farcry currently doesn't check for unique alias names, so we check if
this alias has duplicates.
If yes, don't use NUFU links (or problems may occur) --->
<cfset thisNavAlias = attributes.lNavIDAlias />
<cfelseif attributes.lNavIDAlias eq "">
<cfif len(attributes.externallink)>
<cfset aResults = StructFindValue(application.navid,
attributes.externallink) />
<cfelse>
<cfset aResults = StructFindValue(application.navid,
attributes.objectID) />
</cfif>
<cfif arraylen(aResults) eq 1>
<cfset thisNavAlias = getToken(aResults[1].path,1,".") />
</cfif>
</cfif>
<cfif len(attributes.style)>
<cfset style = ' style="' & attributes.style & '"'>
<cfelse>
<cfset style = "">
</cfif>
<cfif attributes.includeDomain>
<cfset href = "http://#cgi.http_host#" />
<cfelse>
<cfset href = "" />
</cfif>
<!--- check for sim link --->
<cfif len(attributes.externallink)>
<!--- check for NUFU --->
<cfif attributes.bNUFU>
<cfif thisNavAlias neq "">
<cfset href = href & "/go.cfm/" & thisNavAlias
/>
<cfelse>
<cfset href = href & "/go.cfm/#attributes.externallink#/" />
</cfif>
<!--- check for friendly url --->
<cfelseif application.config.plugins.fu>
<cfset href = href &
application.factory.oFU.getFU(attributes.externallink) />
<cfelse>
<cfset href = href & application.url.conjurer &
"?objectid=" & attributes.externallink />
</cfif>
<cfelse>
<!--- check for NUFU --->
<cfif attributes.bNUFU>
<cfif thisNavAlias neq "">
<cfset href = href & "/go.cfm/" & thisNavAlias
/>
<cfelse>
<cfset href = href & "/go.cfm/#attributes.objectid#" />
</cfif>
<!--- check for friendly url --->
<cfelseif application.config.plugins.fu>
<cfset href = href &
application.factory.oFU.getFU(attributes.objectid) />
<cfelse>
<cfset href = href & application.url.conjurer &
"?objectid=" & attributes.objectid />
</cfif>
</cfif>
<cfif attributes.urlparams NEQ "">
<cfif attributes.bSES>
<cfset attributes.urlparams =
replaceNoCase(attributes.urlParams,"&","&","all")>
<cfset attributes.urlparams =
replaceNoCase(attributes.urlParams,"&##38;","&","all")>
<cfset attributes.urlparams =
listChangeDelims(attributes.urlparams,"/","&=")>
<cfif right(href,1) NEQ "/" >
<cfset href = href & "/" />
</cfif>
<cfset href = href & attributes.urlparams />
<cfelse>
<cfset href = href & "?" & attributes.urlparams />
</cfif>
</cfif>
<!--- check for extra URL parameters --->
<cfif NOT StructIsEmpty(attributes.stParameters)>
<cfset stLocal = StructNew()>
<cfset stLocal.parameters = "">
<cfset stLocal.iCount = 0>
<cfloop collection="#attributes.stParameters#"
item="stLocal.key">
<cfif stLocal.iCount GT 0>
<cfset stLocal.parameters = stLocal.parameters
& "&">
</cfif>
<cfset stLocal.parameters = stLocal.parameters &
stLocal.key & "=" & URLEncodedFormat(attributes.stParameters[stLocal.key])>
<cfset stLocal.iCount = stLocal.iCount + 1>
</cfloop>
<!--- check for friendly url --->
<cfif application.config.plugins.fu>
<!--- if FU is turned on then append extra URL
parameters with a leading '?' --->
<cfset href = href & "?" & stLocal.parameters>
<cfelse>
<!--- if FU is turned off then append extra URL
parameters with a leading '&' as there will already be URL params (i.e.
"?objectid=") --->
<cfset href = href & "&" & stLocal.parameters>
</cfif>
</cfif>
<!--- Send back href variable --->
<cfset caller.href = variables.href />
<!--- Are we mean to display an a tag or the URL only? --->
<cfif attributes.urlOnly EQ true>
<!--- display the URL only --->
<cfif attributes.bOutput>
<cfoutput>#href#</cfoutput>
</cfif>
<cfelse>
<!--- display link --->
<cfif attributes.bOutput>
<cfoutput><a href="#href#"#variables.style#<cfif
len(attributes.class)> class="#attributes.class#"</cfif><cfif
len(attributes.xCode)> #attributes.xCode#</cfif><cfif attributes.bShowTarget eq
true> target="#attributes.target#"</cfif>></cfoutput>
</cfif>
</cfif>
<cfelse>
<!--- Was only the URL requested? If so, we don't need to close any
tags --->
<cfif attributes.urlOnly EQ false and attributes.bOutput>
<cfoutput></a></cfoutput>
</cfif>
</cfif>
<cfsetting enablecfoutputonly="No" /><cfsetting enablecfoutputonly="yes" />
<!---
MJS
--->
<cfscript>
/**
* Returns TRUE if the string is a valid CF UUID.
*
* @param str String to be checked. (Required)
* @return Returns a boolean.
* @author Jason Ellison ([EMAIL PROTECTED])
* @version 1, November 24, 2003
**/
function IsCFUUID(str) {
return
REFindNoCase("^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{16}$", str);
}
/** end **/
/** let us grab the navalias from the path and do some magic **/
try {
if (len(cgi.path_info)){
path = replacenocase(cgi.path_info,"/","","ALL");
if (IsCFUUID(path) EQ 0){
url.objectID = application.navid[path];
}
else{
url.objectID = path;
}
}
}
catch(any except) {
// Need to redirect to a 404 or HP, page not found page
url.objectID = application.navid.page_cannot_be_found;//can really be
whatever you want
}
</cfscript>
<!--- <cfdump var="#path#"> --->
<cfinclude template="index.cfm">
<cfsetting enablecfoutputonly="no" />
