如何从Umbraco中获取当前其他网站的内容?

时间:2012-03-04 13:02:21

标签: umbraco

我正在尝试在我的首页(主页)umbraco网站上创建新闻栏目。 我的想法是将新闻内容与网站内容区分开来,如下所示:

  • 主页

    • 第2页
    • 第3页
  • 新闻

    • 新闻第1项
    • 新闻第2项

但是,如果新闻内容不在同一文件夹中,我如何将新闻内容放入我的(主页)页面?

请帮忙。

1 个答案:

答案 0 :(得分:2)

如果您正在使用XSLT,那么您可以这样做:

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

如果您正在使用Razor语法,请使用:

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