Top Level Navigation - Umbraco Razor - Drop Down Navigation - With Home Page Active Checl




@using umbraco.MacroEngines
<ul class="clear">


@if (@Model.AncestorOrSelf(1).Id == @Model.Id)
{
    <li class="active"><a href="/" >Home</a> </li>
}
else
{
<li><a href="/">Home</a> </li>
}

    @foreach (var page in @Model.AncestorOrSelf(1).Children.Where("visible"))
    {
        string style = "";

if (Model.Id == page.Id)
{
@Html.Raw("<li class=\"active\">");
}
else
{
@Html.Raw("<li>");
}

if (page.Childen != null && page.Children.Count() > 0 && page.NodeId != "1093" && page.Id != 1688)
{
@Html.Raw("<a href=\"" + @page.Url + "\"  class=\'drop\'>" + @page.navigationName  +  "</a>");
}
else
{
<a href="@page.Url" @Html.Raw(style)>@page.navigationName</a>
}
if (page.Childen != null && page.Children.Count() > 0 && page.Id != 1688)
{
<ul>
@foreach (dynamic secondPage in page.Children.Where("visible"))
{
<li>
<a href="@secondPage.Url">@secondPage.navigationName</a>
</li>
}
</ul>
}

  @Html.Raw("</li>");

    }
</ul>

Comments

Popular posts from this blog

Umbraco Razor Sort Nodes Ascending or Descending

Umbraco Razor get Querystring

Create a .NET Contact Form that Gets the Last Url Visited in C# Can also be Used in Umbraco