Copied to clipboard

Flag this post as spam?

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


  • Sprite 18 posts 158 karma points
    Mar 11, 2020 @ 14:34
    Sprite
    0

    Getting composition information in navigation

    Hello,

    i have a website that runs with the igloo package. But i have an issue of how to get the composition information in the navigation

    i am trying to make a true / false for whether or not to show it as a link to the page. Because some menu parts won't actually need a page behind it.

    i am getting the pages like the following: var selection = site.Children().Where(x => x.IsVisible(); and then i foreach through the selection.

    For each item in the selection i want to check if the setting withoutLink is available and true. However i don't have any idea how i could get this information from the current item. This setting is created inside a compositions. And the composition is applied to all the document types so that each page has this individual option.

    Does anyone has any idea how i could read this information in that foreach statement?

    i hope i am clear of what i am trying to do.

  • Marc Goodson 2155 posts 14406 karma points MVP 9x c-trib
    Mar 14, 2020 @ 17:44
    Marc Goodson
    100

    Hi Sprite

    I'm not quite sure I understand why a Menu item wouldn't have a link! - but would something like the following work for you?

    @{
    var selection = site.Children().Where(x => x.IsVisible());
    }
    <ul>
       @foreach (var menuItem in selection) {
             //check if menuItem's  'withoutLink' property is set
               if (menuItem.HasProperty("withoutLink") && 
                      menuItem.GetPropertyValue<bool>("withoutLink")){
                   // then menuItem doesn't have a link...
                   <li>@menuItem.Name</li>
               }
               else {
               //menuItem has a link...!
               <li><a href="@menuItem.Url">@menuItem.Name</a></li>
               }
    }
    </ul>
    

    if I've understood correctly!

    regards

    marc

  • Sprite 18 posts 158 karma points
    Mar 18, 2020 @ 07:43
    Sprite
    0

    Hi Marc,

    Thanks for answering my question. The menuItem.GetPropertyValue

    I will mark your answer as correct.

Please Sign in or register to post replies

Write your reply to:

Draft