Hi there! I am a front-end designer new to Umbraco and Razor. I'm working on a vertical subnavigation. I have an "active" class working for third-level navigation, but it's applying to the entire list. How do I ensure the active class works only for the active page, and not for other navigation items in the list? Apologies for the simpleton question, I just don't know how to write the syntax!
I thinking the reason why all all your li´s are getting the background color is because that you´re using the same class in both for each loops, you cold try to change the first one to current e.g
Try this, as you can see I have change the class at the first foreach to current.
@inherits umbraco.MacroEngines.DynamicNodeContext
@{ @*Get the root of the website *@ var root = Model.AncestorOrSelf(2); }
I think that you should use Partial view marcos instead of dynamic node razor. The DynamicNode Razoris a old legacy Razor and will be deprecated.
And the rewriting from DynamicNode Razor to Dynamic Razor or Strongly Typed Razor isn´t so hard. There are not so big difference. E.g instead of @Model you´re using the @CurrentPage. for the dynamic razor and Model.Content fro the strongly typed razor. You can see the differencehere: http://our.umbraco.org/documentation/reference/templating/macros/Partial-View-Macros/
Here are the documententation for getting data out forbuilt-in-property-editors, the both version 6 and 7.
Creating subnavigation
Hi there! I am a front-end designer new to Umbraco and Razor. I'm working on a vertical subnavigation. I have an "active" class working for third-level navigation, but it's applying to the entire list. How do I ensure the active class works only for the active page, and not for other navigation items in the list? Apologies for the simpleton question, I just don't know how to write the syntax!
This produces this result:
But what I'm really trying to achieve is this:
thanks!
bridgette
Hi Bridgette and welcome to our,
I thinking the reason why all all your li´s are getting the background color is because that you´re using the same class in both for each loops, you cold try to change the first one to current e.g
Try this, as you can see I have change the class at the first foreach to current.
And the rewriting from DynamicNode Razor to Dynamic Razor or Strongly Typed Razor isn´t so hard. There are not so big difference. E.g instead of @Model you´re using the @CurrentPage. for the dynamic razor and Model.Content fro the strongly typed razor. You can see the differencehere: http://our.umbraco.org/documentation/reference/templating/macros/Partial-View-Macros/
Here are the documententation for getting data out forbuilt-in-property-editors, the both version 6 and 7.
http://our.umbraco.org/documentation/using-umbraco/backoffice-overview/property-editors/Built-in-Property-Editors/
http://our.umbraco.org/documentation/using-umbraco/backoffice-overview/property-editors/Built-in-Property-Editors-v7/
Other good resources could be the cheat sheets for both types of razor, dynamic razor and strongly typed razor,
This one is the cheat sheet for dynamic razor v6Razorcheatsheet.pdf and this one is for the strongly typed razor. v6strongcheatsheet.pdf
Hope this helps,
/Dennis
Many thanks, Dennis!
is working on a reply...