Copied to clipboard

Flag this post as spam?

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


  • Yaco Zaragoza 88 posts 362 karma points
    Mar 11, 2024 @ 16:24
    Yaco Zaragoza
    0

    Getting all the pages

    var navAdministration = Umbraco.Content(Guid.Parse("16eaeea1-a39b-4482-95f6-b6d27c6584a3"))
    .Children<ContentPage>()
    .Where(x => x.IsVisible())
    .Where(x => x.ShowOnLeftNavigation == true)
    .Where(x => x.LeftNavigationSection == "Administration"); 
    

    How can I have the query return all Content Types and not only the pages that are "contentPage"

  • Alex Skrypnyk 6163 posts 24143 karma points MVP 8x admin c-trib
    Mar 11, 2024 @ 16:48
    Alex Skrypnyk
    0

    hi

    Try this

    var navAdministration = Umbraco.Content(Guid.Parse("16eaeea1-a39b-4482-95f6-b6d27c6584a3"))
        .Descendants()
    
  • Yaco Zaragoza 88 posts 362 karma points
    Mar 13, 2024 @ 15:14
    Yaco Zaragoza
    0

    That worked for getting all the pages but now How do I get the section they belong to? Where and/or How would I add

    .Where(x => x.ShowOnLeftNavigation == true)
    .Where(x => x.LeftNavigationSection == "SECTION-NAME");
    

    P.S Every Page/Content Type has the 2 properties (ShowOnLeftNavigation and LeftNavigationSection)

  • Alex Skrypnyk 6163 posts 24143 karma points MVP 8x admin c-trib
    Mar 13, 2024 @ 15:57
    Alex Skrypnyk
    0

    like this

    var navAdministration = Umbraco.Content(Guid.Parse("16eaeea1-a39b-4482-95f6-b6d27c6584a3")) .Descendants().Where(x => x.ShowOnLeftNavigation == true) .Where(x => x.LeftNavigationSection == "SECTION-NAME");

  • Yaco Zaragoza 88 posts 362 karma points
    Mar 13, 2024 @ 16:12
    Yaco Zaragoza
    0

    This is what happends when I do that

    enter image description here

    enter image description here

  • Alex Skrypnyk 6163 posts 24143 karma points MVP 8x admin c-trib
    Mar 13, 2024 @ 16:13
    Alex Skrypnyk
    0

    looks like models builder issue

  • Yaco Zaragoza 88 posts 362 karma points
    Mar 13, 2024 @ 16:19
    Yaco Zaragoza
    0

    I rebuild the models and restarted the application, but still the same issue

    enter image description here

  • Alex Skrypnyk 6163 posts 24143 karma points MVP 8x admin c-trib
    Mar 13, 2024 @ 16:26
    Alex Skrypnyk
    100

    try this one:

    var navAdministration = Umbraco.Content(Guid.Parse("16eaeea1-a39b-4482-95f6-b6d27c6584a3"))
    .Descendants()
    .Where(x => x.Value<bool>("showOnLeftNavigation") == true)
    .Where(x => x.Value<string>("leftNavigationSection") == "SECTION-NAME");
    
  • Yaco Zaragoza 88 posts 362 karma points
    Mar 13, 2024 @ 17:52
    Yaco Zaragoza
    1

    You are amazing, that seems to be working, I will do some testing to make sure.

    The final query I am using is:

    var navAdministration = Umbraco.ContentAtRoot().FirstOrDefault()
    .Descendants()
    .Where(x => x.IsVisible())
    .Where(x => x.Value<bool>("showOnLeftNavigation") == true)
    .Where(x => x.Value<string>("leftNavigationSection") == "SECTION-NAME");
    

    Just in case someone else is having a similar issue

Please Sign in or register to post replies

Write your reply to:

Draft