Copied to clipboard

Flag this post as spam?

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


  • Simon Dingley 1474 posts 3431 karma points c-trib
    Jan 25, 2012 @ 12:25
    Simon Dingley
    0

    List All Root Nodes

    I'm working on a large multi-site install at the moment for a group. The group site needs to list out all root nodes as each root is one of the subsiduary sites. I can get the current root node using Model.AncestorOrSelf() however I want all the sibling nodes also?

    Thanks, Simon

  • Simon Dingley 1474 posts 3431 karma points c-trib
    Jan 25, 2012 @ 12:41
    Simon Dingley
    1

    OK after some experimentation and a quick peek at umbraco.config I tried to get the node with id -1 and it works:

    Model.NodeById(-1).Children
  • Rodion Novoselov 694 posts 859 karma points
    Jan 25, 2012 @ 12:42
    Rodion Novoselov
    0

    I guess something like:

    var allRoots = Model.XPath("//*[@isDoc and @level = 1]");

    could work.

  • Jeroen Breuer 4908 posts 12265 karma points MVP 5x admin c-trib
    Jan 25, 2012 @ 12:47
    Jeroen Breuer
    0

    Hmm interesting that NodeById(-1) works. Wonder if the same goes for media. With the umbraco.library methods it didn't work. I had to do it a lot harder like this: http://our.umbraco.org/forum/developers/razor/27521-Get-All-Images-in-Media-Gallery#comment102996

    Jeroen

  • Rodion Novoselov 694 posts 859 karma points
    Jan 25, 2012 @ 12:53
    Rodion Novoselov
    1

    I've looked into the code and also realized to my surprise that "-1" is supposed to work. That's not true, however for media - for content "-1" is a real node in the umbraco.config xml file, so that in the content tree. In the case of media "-1" is nothing - just a number to mark top-level media nodes that have no parent. 

Please Sign in or register to post replies

Write your reply to:

Draft