Skip to content

Instantly share code, notes, and snippets.

@davejlong
Created July 22, 2010 18:54
Show Gist options
  • Save davejlong/486409 to your computer and use it in GitHub Desktop.
Save davejlong/486409 to your computer and use it in GitHub Desktop.
<cffunction name="dspNestedNav" output="false" returntype="string">
<cfargument name="contentid" type="string" >
<cfargument name="viewDepth" type="numeric" required="true" default="1">
<cfargument name="currDepth" type="numeric" required="true" default="1">
<cfargument name="type" type="string" default="default">
<cfargument name="today" type="date" default="#now()#">
<cfargument name="class" type="string" default="">
<cfargument name="querystring" type="string" default="">
<cfargument name="sortBy" type="string" default="orderno">
<cfargument name="sortDirection" type="string" default="asc">
<cfargument name="context" type="string" default="#application.configBean.getContext()#">
<cfargument name="stub" type="string" default="#application.configBean.getStub()#">
<cfargument name="categoryID" type="string" default="">
<cfargument name="relatedID" type="string" default="">
<cfargument name="rs" required="true" default="">
<cfset var rsSection=arguments.rs>
<cfset var adjust=0>
<cfset var current=0>
<cfset var link=''>
<cfset var itemClass=''>
<cfset var isCurrent=false>
<cfset var nest=''>
<cfset var subnav=false>
<cfset var theNav="">
<cfif not isQuery(rsSection)>
<cfset rsSection=application.contentGateway.getKids('00000000000000000000000000000000000',event.getValue('siteID'),arguments.contentid,arguments.type,arguments.today,50,'',0,arguments.sortBy,arguments.sortDirection,arguments.categoryID,arguments.relatedID)>
</cfif>
<cfif rsSection.recordcount and ((event.getValue('r').restrict and event.getValue('r').allow) or (not event.getValue('r').restrict))>
<cfset adjust=rsSection.recordcount>
<cfsavecontent variable="theNav">
<cfoutput>
<ul #iif(arguments.class neq '',de(' class="#arguments.class #"'),de(''))#><cfloop query="rsSection"><cfif allowLink(rssection.restricted,rssection.restrictgroups,event.getValue('r').loggedIn)><cfsilent>
<cfset current=current+1>
<cfset nest=''>
<cfset subnav=(((rsSection.type eq 'Page' or rsSection.type eq 'Calendar' or rsSection.type eq 'Portal') and arguments.class eq 'navSecondary' and (this.crumbData[this.navSelfIdx].contentID eq rsSection.contentid or this.crumbData[this.navSelfIdx].parentID eq rsSection.contentid) ) or ((rsSection.type eq 'Page' or rsSection.type eq 'Calendar' ) and arguments.class neq 'navSecondary')) and arguments.currDepth lt arguments.viewDepth and rsSection.type neq 'Gallery' and not (rsSection.restricted and not session.mura.isLoggedIn) >
<cfif subnav>
<cfset nest=dspNestedNav(rssection.contentid,arguments.viewDepth,arguments.currDepth+1,iif(rssection.type eq 'calendar',de('fixed'),de('default')),now(),'','',rsSection.sortBy,rsSection.sortDirection,arguments.context,arguments.stub,arguments.categoryID,arguments.relatedID) />
</cfif>
<cfset itemClass=iif(current eq 1,de('first'),de(iif(current eq adjust,de('last'),de('')))) />
<cfset isCurrent=listFind(event.getValue('contentBean').getPath(),"#rsSection.contentid#") />
<cfif isCurrent>
<cfset itemClass=listAppend(itemClass,"current"," ")>
</cfif>
<cfset link=addlink(rsSection.type,rsSection.filename,rsSection.menutitle,rsSection.target,rsSection.targetParams,rsSection.contentid,event.getValue('siteID'),arguments.querystring,arguments.context,arguments.stub)>
</cfsilent>
<li id="#createCSSID(rsSection.menutitle)#"<cfif len(itemClass)> class="#itemClass#"</cfif>>#link#<cfif subnav and find("<li",nest)>#nest#</cfif></li><cfelse><cfset adjust=adjust-1></cfif></cfloop>
</ul></cfoutput>
</cfsavecontent>
</cfif>
<cfreturn theNav />
</cffunction>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment