Copied to clipboard

Flag this post as spam?

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


  • jaco steketee 28 posts 185 karma points
    May 15, 2016 @ 12:54
    jaco steketee
    0

    Adding submenu in my navigation

    I really hope someone can help me. Im trying to create a submenu.(i've used the snippet) But i cannot seem to get the descentants in de sub list of the menu. Can someone please tell me how i can do that.

    Thanks, Jaco

    @inherits Umbraco.Web.Macros.PartialViewMacroPage

    @* This snippet displays a list of links of the pages immediately under the top-most page in the content tree. This is the home page for a standard website. It also highlights the current active page/section in the navigation with the css class "current". *@

    @{ var selection = CurrentPage.Site().Children.Where("Visible"); }

      @foreach (var item in selection) { if (item.Name == "Rondvaarten"){
    • @item.Name
    • } else {
    • @item.Name
    • } }
  • Dennis Adolfi 1072 posts 6378 karma points MVP 2x c-trib
    May 15, 2016 @ 14:01
    Dennis Adolfi
    100

    Hi Jaco!

    Look at this thread: https://our.umbraco.org/forum/using-umbraco-and-getting-started/77262-showing-parent-nodes-in-umbraco-snippet

    Is'nt that kind of what you are looking for? A menu that Traverse the childrens children.

    Best of luck, hope this helps!!

  • jaco steketee 28 posts 185 karma points
    May 15, 2016 @ 15:22
    jaco steketee
    1

    Thank you very much Dennis. I solved it a little bit different. but this helped a lot understanding it.

    @inherits Umbraco.Web.Macros.PartialViewMacroPage
    

    @* This snippet displays a list of links of the pages immediately under the top-most page in the content tree. This is the home page for a standard website. It also highlights the current active page/section in the navigation with the css class "current". *@

    @{ var homePage = CurrentPage.AncestorsOrSelf(1).First(); var menuItems = homePage.Children.Where("UmbracoNaviHide == false"); }

      @foreach (var item in menuItems) {
    • @if (item.Name == "Rondvaarten") { @item.Name } else { @item.Name } @{var subMenuItems = item.Children.Where("UmbracoNaviHide == false");} @if (subMenuItems.Count() > 0) {
        @foreach (var sub in subMenuItems) {
      • @sub.Name
      • }
      }
    • }
  • Dennis Adolfi 1072 posts 6378 karma points MVP 2x c-trib
    May 15, 2016 @ 16:17
    Dennis Adolfi
    0

    Awesome Jaco, looks good, great job!!! Have a great weekend!!

  • 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" button below.

    Continue discussion

Please Sign in or register to post replies