Copied to clipboard

Flag this post as spam?

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


  • Dmitriy 168 posts 588 karma points
    Oct 30, 2017 @ 08:03
    Dmitriy
    0

    How to get all root-pages?

    Hello. I want to setup a 404-error page in the root of the site, and the page is using data from homepage (another root-page), so the question is how to get all root pages from other root-page and then use them?

    I use Siblings<TModel>() for now:

    var x = My404Page.Siblings<Home>();
    // do something with it... 
    
  • Alex Skrypnyk 5908 posts 22603 karma points MVP 4x admin c-trib
    Oct 30, 2017 @ 08:43
    Alex Skrypnyk
    100

    Hi Dmitriy,

    Is it working for you?

    Also, you can use, it will return all root nodes:

    var rootNodes = Umbraco.TypedContentAtRoot().OfType<Home>();
    

    Thanks,

    Alex

  • Dmitriy 168 posts 588 karma points
    Oct 30, 2017 @ 09:04
    Dmitriy
    1

    Hi, Alex.

    Yes, it works, but not universal- it can't be used in any page, only in other root-page.

    var rootNodes = Umbraco.TypedContentAtRoot().OfType<Home>();
    

    Looks like what I want. Thanks a lot!

  • Alex Skrypnyk 5908 posts 22603 karma points MVP 4x admin c-trib
    Oct 30, 2017 @ 12:08
    Alex Skrypnyk
    0

    You are welcome, Dmitriy

    Have a great day!

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

Please Sign in or register to post replies