Orchard CMS 按字段名放置

Orchard CMS Placement by field name

对于专业问题,文档太没用了。 假设我有一个包含多个字段的 contentPart(例如 Fields_Common_Text)。现在假设我有一个 name 字段和一个 email 字段(这些只是示例,实际情况可能更复杂。

还假设我的部分有另一个字符串字段,我们称之为 title。所以

CustomContentPart:
    Fields_Common_Text name
    Fields_Common_Text email
    this.As<TitlePart>().Title

现在真正的问题从这里开始。如何使用 placement.info 文件将标题放在这两者之间。由于我可以执行以下操作:

<Place Parts_CustomContent="Content:0" />
<Place Fields_Common_Text="Content:1"/>

但这会将两个文本字段都放在标题之后。如何按名称放置字段? (或者以任何其他方式进行,使用替代不起作用,因为替代是形状和渲染区域的继承,因此这些属性无法从 parent 形状访问(以干净的方式))

我实际上设法解决了这个问题

解决方案正是我所怀疑的方式。现在让我们假设我的 CustomPart 的形状也在其中呈现标题(因此实际的 TitlePart 被放置在其他地方并呈现在 Header 区域中) 所以一共有三种形状:

Parts_CustomContent
Fields_Common_Text 
Fields_Common_Text

现在为了将它们按照 name 文本字段、CustomContentPartemail 文本字段的顺序放置在内容中,请将以下内容添加到您的 placement.info 文件中:

<Place Fields_Common_Text-name="Content:0"/>
<Place Parts_CustomContent="Content:1" />
<Place Fields_Common_Text-email="Content:"/>

注意:记住 nameemail 是您分配给 TextField 的正式名称(通过 gui 或迁移) .当然,大写 NameEmail 是更好的名字,我只是想与问题 body 保持一致。

只有特定的 ContentType

我尝试使用内容类型签名和字段名称,但没有用。如果您只想将该展示位置应用于某些内容类型,您必须使用:

<Math ContentType='YourDesiredContentType'>
    <!-- Your Place tags -->
</Match>