"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)
Written by Matt Cheale
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Umbraco
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#