How do I get the page level of an inherited page property | Community
Skip to main content
Level 2
October 16, 2015
Solved

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

  • October 16, 2015
  • 2 replies
  • 1615 views

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.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by PaulMcMahon

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. 

2 replies

PaulMcMahonAccepted solution
Level 8
October 16, 2015

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. 

smacdonald2008
Level 10
October 16, 2015

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.