Copied to clipboard

Flag this post as spam?

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


  • Nicky Christensen 76 posts 166 karma points
    Dec 12, 2011 @ 13:17
    Nicky Christensen
    0

    Razor menu for my top level ?

    Hey guys...

    I have a sitetree looking like this: 

    Then i'ev created a razor menu like this: 

    @inherits umbraco.MacroEngines.DynamicNodeContext

    @foreach (var item in @Model.Children.Where("Visible"))

          {

          var cssClass = "";

          var selected = Array.IndexOf(Model.Path.Split(','), item.Id.ToString());

          if(item.isActive) { cssClass = "active"; }

          if(item.isFirst()) { cssClass += " first"; }

          if(item.isLast()) { cssClass += " last";}

          if(selected >= 0) { cssClass += " selected";}

          var liClass = "";

          if(cssClass != string.Empty) { 

            liClass = string.Format("class\"{0}\"", cssClass.Trim());                                

          }

              <[email protected](liClass)>

                 <a href="@item.Url">@item.Name</a>

              </li>

    }

     

    ----------------------

    However, this outputs the children of the item "Solution" - I want the menu to output: 
    Solution
    Americas
    Leasing
    Technics

    So only the four items that it in the Content Tree ? - How do i do that? 

  • gilad 185 posts 425 karma points
    Dec 12, 2011 @ 13:56
    gilad
    0

    hii nicky

    i think it will be better to put your content under a main node ( lets say home )

    content

    -- home

    ---- sulotion

    ---- americas

    etc...

    then you can use the Navigation template when you create a scripting file...

    @inherits umbraco.MacroEngines.DynamicNodeContext

    @{ 

    var level = String.IsNullOrEmpty(Parameter.Level) ? 1 : int.Parse(Parameter.Level); 

    var ulClass = String.IsNullOrEmpty(Parameter.UlClass) ? "" : String.Format(" class=\"{0}\"", Parameter.UlClass); 

    var parent = @Model.AncestorOrSelf(level);

    if (parent != null) {

     

    @foreach (var item in parent.Children.Where("Visible")) {

    var selected = Array.IndexOf(Model.Path.Split(','), item.Id.ToString()) >= 0 ? " class=\"selected\"" : "";

     

    @item.Name

     

    }

     

    }

    }

     

  • Nicky Christensen 76 posts 166 karma points
    Dec 12, 2011 @ 14:03
    Nicky Christensen
    0

    Ahh, of course :) Thx

Please Sign in or register to post replies

Write your reply to:

Draft