Better way to get Content Item from "submenu" in Nav

We are allowing a Generic Content type (myGeneric) to be added in the “submenu” slot of our managed navigation. As part of the slot setup, you specify the content type and template that it will render. However my question is how do I actually this display this item? Clearly “nav:url” will not work as it will point to the “landing page”. The best that i could come up with is the following, but I keep thinking that I’m missing something simple.


## $node is navigation node
## this code is within a block that makes sure that it is a particular content item (in our case myGeneric)
#set($thisN = $sys.assemblyItem.clone())
$thisN.setNode($node.getProperty("nav:proxiedNode").getNode())
#set($thisNURL = $rx.location.generate($thisN, 'myDiFull'))
#set($thisNName=$node.getProperty("nav:proxiedNode").getNode().getProperty('rx:displaytitle'))
<a href="$thisNURL">$thisNName</a>
## note for some reason it is actually rendering the above as a link.  
## its $thisNName surrounded by an "a" tag with the "href  = $thisNURL"

The problem here is that I’m specifying the template as “myDiFull”. What I’d rather the template be is “mySnTitleLink” (which is what it says, a snippet that is just a link with the title of the page). Clearly replacing the “myDiFull” with “mySnTitleLink” doesn’t work as the way this is setup it creates a link to the snippet template and doesn’t actually render the contents of the template.

Any help would be appreciated,

Thanks,
Jit

Jit,

I’m not sure what you’re asking here.

In the Nav Landing page slot, the template isn’t really used. The “snippet” template is really only used to find the appropriate “page”, which in almost all cases is the “Default” template for the content type.

The snippet itself is never actually rendered.

Dave

We would have the following:

-Folder1
– navitem1 (navon)
– page1 (myGeneric)
– page2 (myGeneric)

navitem1’s landing page would point to page1, but we want page2 to be in the submenu of navitem1.

Notice that page2 is a myGeneric Content type. (not a navon from which we can get the landingpage)

I think I understand. We never intended you to use the submenu slot of items that are not Navons.

I’d recommend that you use a separate slot for this, rather than trying to overload the Navigation tree. You’ll have to assemble the slot in the conventional way, not by using the Nav axis.

Dave

Yeah, i was afraid of that :frowning:

The issue with using a normal slot would be attempting to merge it with the navigation slot and allowing user to sort the navigation however they want. Also , if i were to go the “normal” slot then wouldn’t I run into issue where I wouldn’t be able to get at that item from someplace else?

On the bright side, i have gotten it to work with it with the previous code. You mentioned that the landing page uses the “default” template is there anyway to pass in that “default” template? The primary reason for this is that we currently have two different dispatch templates and I’d rather not have to check to see which one should be rendered for the current community (if that is even possible).

If there is no other solution, then I’d just create another navigation template that would specify the other dispatch template. Not too big of a deal, but not too scalable either (if we ever wanted more templates). Of course i could pass a parameter in for the template but now that might just be getting to far overboard…

Jit,

What’s the purpose of having 2 different dispatch templates? Can’t you just collapse the logic from these 2 templates into a single template and make this template the default? Is there something else going on here?

I don’t see a way for you to “override” how the NavHelper generates the templates.

Dave

Depending on the community you will get a unique way that the Generic Content Item will display. Ie. in Comm1, section headers, which are navigational items will display as a heading on the page template. In comm2, there are no section headers and the “generic” template is truely generic…

Granted, this would be great if we did it in the global template, but it would require a great deal of structural change to our pre-existing structure. Another issue that this will create is that we don’t want all the templates for all content-types that are using the global template to deal with the header issue (ie. we know that it will only be the Generic Content Item)

The dispatch template handle the case if there is a Right Column or not for the Generic Content item.


In terms of my solution. Once i get the proxied node, is there a way that I can get the “default” template for it? This “default” template would be the one specified in the “submenu” slot.

Thanks,
Jit

If you have an AssemblyItem (or you can make one with the clone() technique we’ve been discussing here), you can use $rx.location.findDefaultTemplate() to find the default template for the item.

This is also available as com.percussion.services.assembly.jexl.PSLocationUtils.findDefaultTemplate from Java.

Ah…wonderful!
Thanks!

The next issue that arises is that how do i know that one is on the Generic page? Ie. using “nav:axis” doesn’t work because it doesn’t have one. (for me it was getting the last available one).

Then I had the bright idea of attempting to check content ids. This also failed :frowning: as it was getting the content id of the navon (last one that worked, using $sys.item or url parameters). So the question this calls to mind is, is there anyway for the snippet navigation to get the properties of “page” calling/rendering it?