-1

I have some special document type in Umbraco and in content tree I have one item that contains sub-items with this document type. I don't want to use VS 2012. and I want to create some partial view for read this items. and create some html markup. I created, partial view via umbraco UI,

@inherits Umbraco.Web.Mvc.UmbracoViewPage<dynamic> 

How to read all item and subitems in my view just with Umbraco API ?

Thanks.

4

1 回答 1

3

Umbraco.Web.Mvc.UmbracoTemplatePage你应该在你的局部视图中继承:

@inherits Umbraco.Web.Mvc.UmbracoTemplatePage

然后将当前模型传递给您的部分:

@Html.Partial("MyPartialName", Model.Content)

然后在您的部分中,您可以只使用 API 来获取孩子或任何您的查询

@foreach (var node in Model.Children().Where(x => x.DocumentTypeAlias == "YourDocTypeAlias")
{
   <p>@node.Name</p>
}
于 2013-07-30T19:54:01.013 回答