Recursive Slot call with index value

I have a content type which is based on the NavOn. By this I mean that it has the same cloning and submenu nature of NavOns. I am trying to build a simple recursive slot call which will trace down the hierarchy through the submenu slots. It consists of two templates, both of which are pretty simple.

The first template is the page template which is used to start the recursion when called on one of these content items.

Page Template:

#set ($contentslot = "rffCategorySubMenu")
#slot($contentslot "<div class='cmenu'>" "" "" "</div>" "template=xilTpSnCategorySupportListRecurse")

The snippet template called from the slot:

#set($slotname = "rffCategorySubmenu")	 
<div class='topcat'><a href='$link' class='catlink-cmenu'>$thisTitle</a>
#slot($slotname "<div class='cmenu'>" "" "" "</div>" "template=xilTpSnCategorySupportListRecurse")
</div>

The code works like a charm except that there is no way to denote in the code what “Level” each of these items are in the hierarchy.

The outputted page code looks like this:

<div class='cmenu'>	  	  
    <div class='topcat'><a href='/support/documentation/fpga_device_families.htm' class='catlink-cmenu'>FPGA Device Families</a>
    <div class='cmenu'>	  	  
        <div class='topcat'><a href='/support/documentation/virtex-5.htm' class='catlink-cmenu'>Virtex-5</a>
        <div class='cmenu'>	  	  
             <div class='topcat'><a href='/support/documentation/virtex-5_data_sheets.htm' class='catlink-cmenu'>Virtex-5 FPGA Data Sheets</a>
             </div>
        </div>
        </div>
     </div>
     </div>
</div>

The “level” is is important to the designer which is trying to use this outputted page in a JS function which creates a nifty navigation component.

What we need is a way to pass a param through the recursion. I have tried creating a new slot using the OOTB #slot macro as a template, but the additional value passed to the new macro (#recursion_slot) does not get passed through the $rx.doc.extractBody($relresult) call. So, the snippet template does not know the variable exists.

I tried passing the index value through the $params mechanism in the OOTB #slot macro, but that value is not found because the index param I created is not listed in the sys_RelationshipContentFinder as a valid param. I tried adding it to the valid param list, but that did not work either. I’m assuming this did not work because the underlying class (com.percussion.services.assembly.impl.finder.PSRelationshipSlotFinder) does not support new param values. I can’t find any information on the class (com.percussion.services.assembly.impl.finder.PSRelationshipSlotFinder) in the JavaDocs to find out what I might need to do to get the $param value passed through the slot call.

Any help would be greatly appreciated.

Thanks.

John

First of all, if you are trying to recreate navons and navtrees, give up now. We tried that, when we wanted to start with a completely blank slate. In the end we were told that, although they are part of the Fast Foward package, which is described in terms that make it seem like an optional set of examples, if you want any managed navigation you have to install it because navons and navtrees are “special.”

But if you are trying something different, this thread contains an ugly hack for passing parameters down the chain of templates. Also this thread covers similiar ground and has some more information on how bindings are inherited by templates.

Andrew,

Thanks. I’ll take a look at the threads.

The “Special” content type that I am working with was created by Percussion PSO. It works pretty well, but when trying to extend it is when we get in murky waters. If it worked exactly the same a Navon then it wouldn’t be so, but there are subtle differences that make it problematic.

Thanks.

John

That did it. Because of the recursion I had to add the code to both the page template and the snippet template, but it did exactly what it needed to do. It also maintained proper scope.

Here is the final code:

Page Template:


#set ($contentslot = "rffCategorySubMenu")
#set ($index = 1)
#set ($dummyindex = $sys.assemblyItem.Bindings.put('$index',$index))
#slot($contentslot "" "" "" "" "template=xilTpSnCategorySupportListRecurse")

The page template got an initial value for $index and the snippet incremented the value for $index

Snippet template:


#set ($contentslot = "rffCategorySubmenu")
#set ($dummyindex = $sys.assemblyItem.Bindings.put('$index', $tools.math.add($index,1)))
<div class='cmenu$index'>
<div class='topcat$index'><a href='$link' class='catlink-cmenu$index'>$thisTitle</a>
		#slot($contentslot "" "" "" "" "template=xilTpSnCategorySupportListRecurse")
</div>
</div>

Thanks, Andrew.

John

It seems from some of the threads that passing the binding variable from the page to the slot snippet is possible, but that it should also be possible to pick up a binding set in the slot snippet within the page, whether that is a new binding or a passed and modified one. I simply cannot get this to work and wondered if it should? I’m currently setting a bbinding in a page and successfully transferring it into the snippet, where it gets modified. But I cannot then pick up the modified value later within the page, or within a later snippet called from another slot. Possible?

That is correct Andrew. You can access the “Parent” bindings in a snippet because we clone the assembly item to assemble the snippet items. However, that clone (and any modifications made to the bindings therein), are discarded once we’re done with that item.
M.