复制果园部分
Duplicate an orchard part
我正在尝试使用 Placement.info 而不是覆盖完整的内容模板,我需要在内容区域和页眉区域中显示一部分 (Parts_Title)。我在想 Placement.info 文件中的那个部分有两个位置就可以了,但似乎最后一个赢了。
有办法吗?我正在使用果园 1.9.1.0
根据亚历山大的回答编辑 2016-03-16:
有件事我应该做错;我在仪表板(无代码)中设计了一个名为 OffreEmploi 的内容类型。我使用 Content-OffreEmploi.cshtml 作为替代。这是代码:
@using Orchard.ContentManagement.Utilities;
@Display(Model.Header);
@Display(Model.Content);
@Display(Model.LocalZoneName);
这是我的 placement.info
<Match ContentType="OffreEmploi">
<Place Fields_DateTime-DateDebut="Header:2"/>
<Place Fields_Common_Text-Duree="Header:3"/>
<Place Fields_Common_Text-Localisation="Header:4"/>
<Place Fields_Boolean-Temporaire="Header:5"/>
<Place Fields_DateTime-DateExpiration="Header:6"/>
<Place Parts_Common_Metadata="-"/>
<Place Fields_Common_Text-TexteIntroduction="Content:1"/>
<Place Parts_Title="Header:1" />
<Place Parts_Common_Body="Content:3" />
<Place Parts_Title="LocalZoneName:1" />
</Match>
Parts_Title 部分仅在末尾呈现(在 LocalZoneName 中)
您不能仅使用 placement.info 来完成此操作。两次显示内容部分的最佳方法是为该内容部分使用特殊本地区域:
- 为内容创建备用。使用
@Display(Model.LocalZoneName)
交替显示一个区域两次
- 使用 placement.info 中的本地区域在其中渲染您的部分
Parts_Title="LocalZoneName:1"
Placement.info 允许您指定 单个 位置来放置您的部分。这就是您看到的行为背后的原因 - 最后一个条目获胜(LocalZoneName:1
).这就是您的部分内容现在所在的位置 - LocalZoneName
。
Alexander 的实际建议是,这种(并不罕见)情况的通常解决方案是使用一个单独的、独特的区域来放置您的部分,并多次渲染该区域,即:
@using Orchard.ContentManagement.Utilities;
@Display(Model.LocalZoneName);
@Display(Model.Header);
@Display(Model.LocalZoneName);
@Display(Model.Content);
这将使您的 LocalZoneName
(现在包含标题部分)呈现两次 - 在 Header
和 Content
区域之前。
我正在尝试使用 Placement.info 而不是覆盖完整的内容模板,我需要在内容区域和页眉区域中显示一部分 (Parts_Title)。我在想 Placement.info 文件中的那个部分有两个位置就可以了,但似乎最后一个赢了。
有办法吗?我正在使用果园 1.9.1.0
根据亚历山大的回答编辑 2016-03-16:
有件事我应该做错;我在仪表板(无代码)中设计了一个名为 OffreEmploi 的内容类型。我使用 Content-OffreEmploi.cshtml 作为替代。这是代码:
@using Orchard.ContentManagement.Utilities;
@Display(Model.Header);
@Display(Model.Content);
@Display(Model.LocalZoneName);
这是我的 placement.info
<Match ContentType="OffreEmploi">
<Place Fields_DateTime-DateDebut="Header:2"/>
<Place Fields_Common_Text-Duree="Header:3"/>
<Place Fields_Common_Text-Localisation="Header:4"/>
<Place Fields_Boolean-Temporaire="Header:5"/>
<Place Fields_DateTime-DateExpiration="Header:6"/>
<Place Parts_Common_Metadata="-"/>
<Place Fields_Common_Text-TexteIntroduction="Content:1"/>
<Place Parts_Title="Header:1" />
<Place Parts_Common_Body="Content:3" />
<Place Parts_Title="LocalZoneName:1" />
</Match>
Parts_Title 部分仅在末尾呈现(在 LocalZoneName 中)
您不能仅使用 placement.info 来完成此操作。两次显示内容部分的最佳方法是为该内容部分使用特殊本地区域:
- 为内容创建备用。使用
@Display(Model.LocalZoneName)
交替显示一个区域两次
- 使用 placement.info 中的本地区域在其中渲染您的部分
Parts_Title="LocalZoneName:1"
Placement.info 允许您指定 单个 位置来放置您的部分。这就是您看到的行为背后的原因 - 最后一个条目获胜(LocalZoneName:1
).这就是您的部分内容现在所在的位置 - LocalZoneName
。
Alexander 的实际建议是,这种(并不罕见)情况的通常解决方案是使用一个单独的、独特的区域来放置您的部分,并多次渲染该区域,即:
@using Orchard.ContentManagement.Utilities;
@Display(Model.LocalZoneName);
@Display(Model.Header);
@Display(Model.LocalZoneName);
@Display(Model.Content);
这将使您的 LocalZoneName
(现在包含标题部分)呈现两次 - 在 Header
和 Content
区域之前。