Expand my Community achievements bar.

SOLVED

How do I get the page level of an inherited page property

Avatar

Level 2

I am using WCMUtils.getInheritedProperty to get an inherited page property.  

Is there a way to get the page level of which that property is being inherited from?

 

Thank you.

1 Accepted Solution

Avatar

Correct answer by
Level 8

Not through the WCMUtils API - if you needed that implementation you'd have to write your own inheritance logic that not only walks up the tree and gets the property value, but also returns the level. It wouldn't be the complicated - you'd have the same inputs as the WCMUtils method, but instead of returning a String you'd return some sort of object that contained both the String and the level, or perhaps the String and the Page object. 

View solution in original post

2 Replies

Avatar

Correct answer by
Level 8

Not through the WCMUtils API - if you needed that implementation you'd have to write your own inheritance logic that not only walks up the tree and gets the property value, but also returns the level. It wouldn't be the complicated - you'd have the same inputs as the WCMUtils method, but instead of returning a String you'd return some sort of object that contained both the String and the level, or perhaps the String and the Page object. 

Avatar

Level 10

One way to get a page level is to use the http://dev.day.com/docs/en/cq/current/javadoc/com/day/cq/wcm/api/Page.html API.  

Look at this method:

getDepth

int getDepth()
Returns the hierarchical depth of the page. The depth is the number of getParent() calls would be needed to reach the root node.

 

Returns:
the depth of the page.