Get parent page content id

I am trying to figure out how get the parent page content id in Percussion for the current page in a managed navigation site.

Is there a java function or JEXL property that can get the parent page content id though the navon relationships?

How do I get the navon id that has the current page in its landing page slot, then get the parent navon of that navon and then get the page content id of that navons landing page?

I am using an autoslot to query all items of a particular content type and using a snippet template to dump the fields to a JSON file. 

I tried using a bread crumb snippet template and rffnav slot to get the parent id, but it is rendering the parent id of the content item creating the JSON file with the autoslot rather than the parent ids of each content item being rendered as an item in the JSON file. 

I need each items content id and the items parent content id so I can reconstruct the navigation structure of all the items. 

Hi,

There are several JEXL methods in the PSO Toolkit that may help.  

https://github.com/percussion/PSOToolkit

Take a look at the PSONavTools, PSORelationshipTools, and PSOFolderTools JEXL extensions.

There are methods for getting a Navon, getting a Landing Page, etc.

-n

I didn’t even know Percussion have Github account! :slight_smile: Thanks!

Thanks Nate, 

I am not a Java developer so I find it hard to figure out what the methods of the PSOTools do when looking at the JavaDocs. I found a findParentIds in the JavaDocs for PSORelationshipTools but there are no code examples of how to use it on a template. 

What kind of objects does it need to be used with? It doesn’t work with $sys.item. 

Any recommendations about how to use the PSOToolkit when there are no code examples?

How do I use findParentNavonNode in PSOToolkit on a template? And can I use it on a template attached to a content item instead of a navon template? 

Mark

I’ll work for a sample code and will post it here. 

Thanks Mythili. Could you include in your code example how to get the content id of the page in the Landing page slot once you have the parent navon node? 

Sure!

Mark,

If you have the Navon, you should be able to get the contentid of the landing page using a syntax like this (without needing the PSO Toolkit installed):

$navon.getProperty(“nav:landingPage”).getNode().getProperty(“rx:sys_contentid”).String

In regards to the PSO toolkit - I agree we should get more sample code up on that wiki.   

That said, once the toolkit is installed, in Eclipse in the Velocity editor you would  get Auto Completion for methods which can help to navigate the available extensions more easily by typing $sys. and pressing the ctrl-space key.

-n

Thanks Nate.

What method would I use to get the navon for a content item? And then what function to get the parent navon?

I know how to get the navon if the template is attached to a navon, what I am not sure is how do I get the navon of a template attached to a content item?

Hi Mark,

Can you post the Velocity that you have so far? It might be quicker to have that context. Also can you confirm that in your Auto Slot query are you including the sys_folderid in the select list?

Thanks,

-n

Something like this? It isn’t rendering JSON in the example below but this does seem to get what you are after.

Example Page type template:

#initslot("randomSlot" "query=SELECT rx:sys_contentid, rx:sys_folderid FROM rx:rffGeneric&template=snipTestNavInSlot", 3)##
#if($sys.currentslot.relresults.size() > 0)##
#foreach($relresult in $sys.currentslot.relresults)##

$rx.doc.extractBody($relresult)
#end##
#end##
#endslot("randomSlot")##

Snippet Template:

#if(!$nav)##
#initslot("rffNav" "template=NavonLink")##
#if($sys.currentslot.relresults.size() > 0)##
#set($nav = $sys.currentslot.relresults.get(0).getBindings().get('$nav') )
#end##
#end##
#crumbs($nav.self)##
#macro(crumbs $node)
    #set($bpath = $rx.nav.getAncestors($nav.self))
    #set($first = true)
    #foreach($bcrumb in $bpath)
        
        #set($landing_page = $bcrumb.getProperty("nav:url").String)
        #set($title = $bcrumb.getProperty("rx:displaytitle").String)
        #if($first)
               
            #set($first = false)
        #else
             > 
        #end        
        #if( $landing_page && $bcrumb.getProperty("nav:axis").string != "SELF")
            <a href="$landing_page">$title</a>
        #else
            $title
        #end
    #end
#end

Hi Nate,

I have been working on this problem of and on in the midst of other tasks. I have a question about your query in the above example. How does the init slot query know to grab the current sys content item? I don’t see anything in the query that passes the current content id. Does Percussion have some default parameter in the slot initialization that defaults to the current content item or does the “3” parameter in your example define that?