使用 Placement.info 在 Orchard CMS 中显示自定义内容部分的摘要视图时出现问题

发布于 2024-12-10 21:42:48 字数 1788 浏览 0 评论 0原文

我创建了一个名为PresentationPart 的自定义部件并放置了它。

在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);

I created a custom part called PresentationPart and its placed.

In the placement.info I have

<Match ContentType="Presentation">
    <Match DisplayType="Summary">
        <Place Parts_PresentationPart_Summary="Content:after"/>
    </Match>
    <Match DisplayType="Detail">
        <Place Parts_PresentationPart="Content:after"/>
    </Match>
</Match>

The folder layout is

Views ->
    EditorTemplates ->
        Parts ->
            Parts_PresentationPart.cshtml   
    Parts ->
         Parts_PresentationPart.cshtml
         Parts_PresentationPart.Summary.cshtml

The view Parts_PresentationPart_Summary is never used (attempting to have summary display in list view).

If I modify Placement.info's Presentation Summary match area to be

<Match DisplayType="Summary">
    <Place Parts_PresentationPart="Content:before"/>
    <Place Parts_PresentationPart_Summary="Content:after"/>
</Match>

The normal view will display.

What is required to get the summary view to display? Or is there something I am completely skipping?

edit: I'd skipped the CombinedResult in the display driver.

Original:

protected override DriverResult Display(PresentationPart part, string displayType, dynamic shapeHelper)
{
    return ContentShape("Parts_PresentationPart",() => shapeHelper.Parts_PresentationPart(ContentItem: part.ContentItem, Name: part.Name)));
}

So what I'll need is something like this?

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);

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

莫言歌 2024-12-17 21:42:48

将“正常”和“摘要”形状视为完全独立的形状。
话虽这么说,您在显示摘要时不应该显示“正常”方法(反之亦然):

<Match DisplayType="Summary">
    <Place Parts_PresentationPart="-"/>
    <Place Parts_PresentationPart_Summary="Content:after"/>
</Match>

您还没有发布驱动程序显示方法,所以我不确定什么您正在从中返回...

要使此方案发挥作用,您应该返回CombinedResult,其中包含正常形状和“摘要”形状。然后,显示管理器可以根据 Placement.info 中存储的数据决定显示哪一个。

Treat the "normal" and "summary" shapes as totally separate ones.
That being said you should simply not show the "normal" one when displaying the Summary (and vice versa):

<Match DisplayType="Summary">
    <Place Parts_PresentationPart="-"/>
    <Place Parts_PresentationPart_Summary="Content:after"/>
</Match>

You haven't posted the driver Display method, so I'm not sure what you are returning from it...

For this scenario to work you should return the CombinedResult with both the normal and "summary" shapes inside. The display manager could then decide which one to display based on the data stored in Placement.info.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文