Getting page level for navigation
Hi all.
I am designing my side navigation using the Acordion control.
So far, all is working as expected, but I would like to select in the properties which level I start showing the pages, no matter how deep I am in the structure
I already have the menu working based on the GUID of a page.
If I am to show menus starting at level 3 (level 1 being the root of the site, level 2 being the main pages, etc...)
I need to figure out a way to go up the hierarchy of pages, fin the LEVEL 3 page in the current branch, get it's GUID, and pass it to my menu.
This way, if I am at any page bellow level 3, I will always get the same menu.
Is this something dificult to do?
Thanks for your help.
Actually, I think I figured a way to achieve what I was looking for.
I first declare a public property for my widget as follows :
01.//Page level is not 0 based! 1 = the root. 02.public int PageLevel 03. 04. get05. 06. return _PageLevel; 07. 08. set09. 10. if (value < 1) 11. 12. value = 1; 13. 14. _PageLevel = value; 15. 16.01.private Guid GetSiteNavBasePageId() 02. 03. //We need to go up the chain starting from the current page ID 04. //We will try to find the page corresponding to our level specified in PageLevel public property 05. //If we are higher in the chain, we return an empty Guid. 06. //CurrentPage 07. Guid PageId = Telerik.Sitefinity.Web.SiteMapBase.GetActualCurrentNode().Id; 08. //Get the Root Guid 09. Guid rootId = App.WorkWith().Pages().Get().Single(p => p.Parent == null && p.Title == "Pages").Id; 10. //List of Guids starting from the current page 11. List<Guid> pageGuidList = new List<Guid>(); 12. //PlaceHolder for the hierarchy page Guid 13. Guid tempPage; 14. //Add our current page to the list 15. pageGuidList.Add(PageId); 16. //Set our temp page to the current page 17. tempPage = PageId; 18. //Get all pages ID up to ROOT 19. while (tempPage != rootId) 20. 21. PageNode currentPage = App.WorkWith().Page(tempPage).Get(); 22. tempPage = currentPage.ParentId; 23. pageGuidList.Add(tempPage); 24. 25. if (pageGuidList.Count < PageLevel) 26. 27. //We have an error - page is higher than the base page 28. return Guid.Empty; 29. 30. else31. 32. return pageGuidList[pageGuidList.Count - PageLevel]; 33. 34.