Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Rocoeh 65 posts 86 karma points
    Sep 12, 2012 @ 11:23
    Rocoeh
    0

    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>
     

    }


  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies