Razor getting the current node when the macro is in the masterpage
Hi,
I havea subnav script. The issue I am having is it is it in the master template and whenever I use @Model.name I get "homepage" and not the page I am currently on. Even though this is a common file in the header I would like to return the current node as eitehr an id or alias.
Razor getting the current node when the macro is in the masterpage
Hi,
I havea subnav script. The issue I am having is it is it in the master template and whenever I use @Model.name I get "homepage" and not the page I am currently on. Even though this is a common file in the header I would like to return the current node as eitehr an id or alias.
@using umbraco.MacroEngines
@inherits DynamicNodeContext
@{
var parent = @Model.AncestorOrSelf(1);
var count = parent.Children.Where("Visible").Count();
@Model;
<ul class="subnav">
@if(count > 0) {
foreach (var item in @Model.AncestorOrSelf(2).Children.Where("umbracoNaviHide!=true"))
{
var selected = Array.IndexOf(Model.Path.Split(','), item.Id.ToString()) >= 0 ? " class=\"selected\"" : string.Empty;
<[email protected](selected)><a href="@item.Url"><span>@item.Name</span></a></li>
}
}
</ul>
}
is working on a reply...