This project is read-only.

N2.Web.Tree current item class

Topics: Developer Forum
Feb 20, 2009 at 5:28 AM
I've just started looking at a real world implementation of the MVC example.

I really like the idea of the N2.Web.Tree class as it’s a real time saver in producing ULs for navigation as in the example.

Practically though I'm not sure how much use it is unless there is some way of distinguishing the current item i.e. through the use of a class (like <li class="current">).

Is there some way of making this work or will I have to abandon using the N2.Web.Tree methods for navigation and iterate through the collection?
Feb 21, 2009 at 1:35 PM
You can insert custom css classes through the use of delegates. Take a look at the unit tests to see how.
Feb 22, 2009 at 3:06 AM

Thanks so a really simple example to set the current li to class=”selected” might be:
N2.Web.Tree.From(N2.Find.StartPage,2).ClassProvider(delegate(N2.ContentItem item){ return (N2.Find.CurrentPage == item)? "selected":"none"; })

The commented out DecorateLinks method in the tests looks to be an ideal helper. Has this been abandoned?

Feb 22, 2009 at 3:13 PM
I think you can use "LinkProvider". Look at the test CanChangeLinkProvider.