How can I "walk" up my navtree to select a navslot?

Basically i have a slot (headerLinks) on our NavTree that allows me to insert links to certain pages on our site. The idea is that with each site I can set these links to be different.

I have a requirement where one of our websites has sub-sections in the site and so i want to be able to set this at a navon level as well.

I’m in need of some macro code that will look at the current navon if item exists display it else move up to the parent navon and display it. This will keep going up the tree until it finds an item in that slot.

Has anyone done something similar or can anyone give me a hand with what my code should look like?

Shane

If you have the PSOToolkit, then you could do something like this:

WARNING: I have NOT tested this code out to see if it works…you will probably need to modify it some (in particular, i anticipate problems with $lastN-1 among other things). However this may be enough to get you started…Of course, once you get it finalized, it would be nice to post the code into the codes forum…as i’m sure it could come in handy for someone in the future :slight_smile:


#set($thisN = $sys.assemblyItem.clone())
#macro(checkLinks $node)
	$thisN.setNode($node.getNode())
	##assemble the slot items of headerLinks
	#set($headerlinkslotitems  =  $rx.asmhelper.assemble($thisN,$sys.asm.findSlotByName("headerLinks"),$completeparams))
	#if($headerlinkslotitems.size()>0)
		##items in slot, display them
		#foreach($slotitem in $headerlinkslotitems)
			$rx.doc.extractBody($slotitem).trim()
		#end
	#else
		##no items in slot, get to parent only if parent exists
		#set(parentN = $user.psoNavTools.findParentNavonNode(navonLoc))
		#if($parentN)
			##get last item in parentNode (which should be the immediate parent)
			#set($lastN = $parentN.size())
			#checkLinks($parentN[$lastN-1].getNode())
		#end
	#end
#end
#checklinks($nav.self)