Search code examples
umbraco

How can i get content from other site than current in Umbraco?


I am trying to create a news section on my frontpage (Home) umbraco site. My idea is to keep the news content apart from the site content in a folder like this:

  • Home

    • Page2
    • Page3
  • News

    • News item 1
    • News item 2

But how can I get the news content into my (home) page, when it's not in the same folder?

Please help.


Solution

  • If you're using XSLT then you'd do this:

    <xsl:for-each select="$currentPage/ancestor-or-self::root/News/NewsItem">
      <!-- do whatever here -->
    </xsl:for-each>
    

    If you're doing Razor syntax, then use:

    @foreach (var newsitem in Library.NodeById(-1).Descendants("News").ChildrenAsList) {
      // Your processing/rendering code in here
    }