gl7poa
Last Updated: April 14, 2016
·
144
· say_ten
25450 380456269365 7888582 n

"Active" navigation in Umbraco

Here's the scenario, you're building navigation in Umbraco and you want to flag the three with active classes. So you need to know if the current navigation item is part of the current page's path in the tree. Simple check the current page ID against the navigation items path property, something like:

var currentPageId = UmbracoContext.Current.PageId.ToString();
var pathIds = navigationItem.Path.Split(',').ToList<string>();
var active = pathIds.Contains(currentPageId)
Say Thanks
Respond