Get The Current Page Level In The Tree

Vote:
 

I have searched and search for a way to get the current page level in the episerver tree.  I know back in episerver 4, there use to be an Indent Property on the pagedata object but not anymore.  Is there a good way or has someone ran into this and have a good solution for this.  We use this quite abit and my method is just plain crap but works.  Does someone have a way to do this efficiently.

#44953
Oct 21, 2010 17:59
Vote:
 

Sometimes I´ve done an extension method with a recursive call to the start page, works pretty good even though it´s not the optimal way.

#44956
Oct 21, 2010 22:36
Vote:
 

I would recommend to recurse by PageData.Parent until reaching the root page. But the information is in the database, so you could do something like this to get the nestinglevel (assuming your root page ID is 1 and the page you want to find the level for has 500):

SELECT NestingLevel FROM tblTree WHERE fkChildID = 500 AND fkParentID = 1

You should probably put that in a sproc, and if you use it frequently, build some handler which caches the result - which might be tricky because it has to be purged when pages are moved etc.

#44958
Oct 22, 2010 7:34
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.