Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

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

SLIM_20
Level 2
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
Paul_McMahon
Correct answer by
Level 8
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
Paul_McMahon
Correct answer by
Level 8
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. 

smacdonald2008
Level 10
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.