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. :-)


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

${esc.hash}${esc.hash}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
 ${esc.hash}set(${esc.dollar}parentContent = ${esc.dollar}dotcontent.pullRelated("Parent_Documentation-Child_Documentation","${esc.dollar}article.identifier",true,1,"Documentation.title"))

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