Content Driven Menus


Not recommending this as a best practice or anything because there are a lot of inherent dangers on allowing your menu navigation to be changed by a simple publish/unpublish by a content contributor.  However, if this happens to fit a specific case need and your content publishers understand the responsibility involved, then here's how to make it happen.

First, create the content structure that you want to have drive a particular menu, next create an active menu link, but instead of having the menu link refer to an external/internal page, populate the code field with velocity as in the example below.

I did not include the Javascript or styling for making the menu look pretty, that would be up to you of course. :-)


##This finds all the articles
#foreach($article in $dotcontent.pull("+structureName:Documentation +(conhost:48190c8c-42c4-46af-8d1a-0cd5db894797 conhost:SYSTEM_HOST)",0,"Documentation.title"))

##This finds out IF the article has at least one parent content, which would eliminate it as a Top level Article - we first want to print all top level Articles that have NO parent
 #set($parentContent = $dotcontent.pullRelated("Parent_Documentation-Child_Documentation","$article.identifier",true,1,"Documentation.title"))

##if the article has no parent, then it is top level lets print it and find the children
##finds/prints children of Top level parents only
		   #set($childContent = $dotcontent.pullRelated("Parent_Documentation-Child_Documentation","$article.identifier",false,0,"Documentation.title"))
			#foreach($child in $childContent)
				<h3>$velocityCount. $!{child.title}</h3>
			##You could keep searching for grandchildren at tertiary level using same methodology