0

我正在Sitecore 7.1使用MVC.

我需要获取用于特定 Sitecore 项目的子布局或渲染的项目 ID。有没有办法我使用.net 获取站点核心中的项目使用的子布局/渲染列表。有人可以为此发布必要的代码。

谢谢

4

2 回答 2

5

在 Sitecore MVC 之前获取一组渲染的传统方法是:

Sitecore.Context.Item.Visualization.GetRenderings(Sitecore.Context.Device, false)

我相信这将返回 WebForms 和 MVC 上下文中的渲染列表。

具体到MVC,还可以使用currentRenderingContext或者PageContextvia获取渲染列表:

RenderingContext.Current.PageContext.PageDefinition.Renderings

或者

PageContext.Current.PageDefinition.Renderings

于 2014-02-27T14:26:32.707 回答
0

请尝试以下代码

Sitecore.Context.Database.GetItem(((Sublayout)Parent).RenderingID);

另请参阅将 DataSource 字段与 Sitecore 子布局一起使用

于 2014-06-11T13:01:17.267 回答