Thank you guys. My main goal was to know when to display navigation links. Sometimes I need to make a dmNavigation with no objects in it other than nested dmNavigations

for example: I might make a dmNavigation for footer and place all of my footer pages (navigation nodes) in there. Then I just loop through the main footer nav and display its nested nav nodes as links. However, I often make complex navigation trees (for display) where I don't want links to display unless they have useable information under them.

So I combined a little of Tim's and Andrew's snipets to make a CFC that tells me whether or not to display the dmNavigation to the user (if it has a dmHTML, dmLink, or dmInclude in it OR if it has an External Link (symbolic link)). So if anyone is intersted here is the CFC and a code example to call it (code below). The only thing I haven't coded in yet is to check whether the dmHTML, dmLink, and dmIncludes were in draft mode only or "incomplete" (not sure how I'm gonna check for these yet. This generally happens when someone has approved the dmNavigation, but not the nested object).

If you happen to see something wrong with this code (other than the fact that I'm looping over queries. Its really not that many loops though.) please let me know. I'm going live with this site very soon.

(Code below)

-Jeff C.

--------------
objectInfo.cfc
--------------
<cfcomponent displayname="ObjectInfo" hint="I get Object information">
<cffunction name="getObjectsUnderNav" access="public" returntype="query" output="false">
<cfargument name="objectid" type="uuid" required="true" />
<cfargument name="type" type="string" required="false" default="dmHTML" />
<cfargument name="parenttype" type="string" required="false" default="dmNavigation" />
<cfargument name="parentcolumn" type="string" required="false" default="aObjectIDs" />
<cfset var qDescs = 0 />
<cfquery name="qDescs" datasource="#application.dsn#">
select t.*, tree.* from #application.dbowner##arguments.parenttype#_#arguments.parentcolumn# n
left join #application.dbowner##arguments.type# t on t.objectid = n.data
left join #application.dbowner#nested_tree_objects tree on tree.objectid = n.data
where n.objectid = '#arguments.objectid#'
and t.objectid is not null
order by seq asc
</cfquery>
<cfreturn qDescs />
</cffunction>


<cffunction name="bDisplayNavigation" access="public" returntype="boolean" output="false">
<cfargument name="objectid" type="UUID" required="yes" />
<cfargument name="lTypes" type="string" required="yes" default="dmHTML,dmInclude,dmLink" />
<cfscript>
var bDisplayNavigation = false;
var oNodeCheck = CreateObject("component", "#application.types.dmNavigation.typePath#");
if (isDefined("nodeData.ExternalLink") and len(nodeData.ExternalLink)){
bDisplayNavigation = true;
}
if (bDisplayNavigation is false){
for (i=1; i lte listLen(#arguments.lTypes#); i=i+1){
if (bDisplayNavigation is false and getObjectsUnderNav(objectid="#arguments.objectid#", type="#listGetAt(arguments.lTypes, i)#").recordcount gt 0){
bDisplayNavigation = true;
}
}
}
</cfscript>
<cfreturn bDisplayNavigation />
</cffunction>
</cfcomponent>



---------------
callingPage.cfm
---------------
<cfset oObjectInfo = CreateObject("component", "#application.custompackagepath#.custom.objectInfo") />


<cfloop query="qNav">
  <cfif oObjectInfo.bDisplayNavigation(objectid=qNav.objectid)>
    DISPLAY LINK
  </cfif>
</cfloop>

---
You are currently subscribed to farcry-dev as: [email protected]
To unsubscribe send a blank email to [EMAIL PROTECTED]
Aussie Macromedia Developers: http://lists.daemon.com.au/

Reply via email to