我創建了一個名爲PresentationPart的自定義零件及其放置位置。使用Placement.info顯示Orchard CMS中自定義內容部分的摘要視圖的問題
在placement.info我有
<Match ContentType="Presentation">
<Match DisplayType="Summary">
<Place Parts_PresentationPart_Summary="Content:after"/>
</Match>
<Match DisplayType="Detail">
<Place Parts_PresentationPart="Content:after"/>
</Match>
</Match>
該文件夾的佈局是
Views ->
EditorTemplates ->
Parts ->
Parts_PresentationPart.cshtml
Parts ->
Parts_PresentationPart.cshtml
Parts_PresentationPart.Summary.cshtml
視圖Parts_PresentationPart_Summary從不使用(嘗試在列表視圖摘要顯示)。
如果我修改Placement.info的演示文稿摘要比賽區域爲
<Match DisplayType="Summary">
<Place Parts_PresentationPart="Content:before"/>
<Place Parts_PresentationPart_Summary="Content:after"/>
</Match>
正常視圖將顯示。
需要什麼來獲取摘要視圖來顯示?還是有什麼我完全跳過?
編輯:我在顯示驅動程序中跳過了CombinedResult。
原文:
protected override DriverResult Display(PresentationPart part, string displayType, dynamic shapeHelper)
{
return ContentShape("Parts_PresentationPart",() => shapeHelper.Parts_PresentationPart(ContentItem: part.ContentItem, Name: part.Name)));
}
所以我需要的是這樣的?
var driverResults = new List<DriverResult>();
driverResults.Add(ContentShape("Parts_PresentationPart",() => shapeHelper.Parts_PresentationPart(ContentItem: part.ContentItem, Name: part.Name)));
driverResults.Add(ContentShape("Parts_PresentationPart_Summary",() => shapeHelper.Parts_PresentationPart(ContentItem: part.ContentItem, Name: part.Name)));
return new CombinedResult(driverResults);
您使用CombinedResult發佈的代碼正是完成一切工作所應做的事情。 –