Vulnerability in EPiServer.Forms
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.
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.
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.