Skip to content

OrchardCore.DisplayManagement

OrchardCore.DisplayManagement

Placement files

展示位置文件

Any extension can contain an optional placement.json file providing custom placement logic.

任何扩展都可以包含一个可选的placement.json文件,提供自定义放置逻辑。

Format

格式

A placement.json file contains an object whose properties are shape names. Each of these properties is an array of placement rules.

placement.json文件包含一个对象,其属性是形状名称。每个属性都是一系列放置规则。

In the following example, we describe the placement for the TextField and Parts_Contents_Publish shapes.

在下面的示例中,我们描述了TextFieldParts_Contents_Publish形状的位置。


{

 <font color=#0099ff size=4 face="黑体">{</font> 


  "TextField": [ ... ],

   <font color=#0099ff size=4 face="黑体">“文本域”: [ ... ],</font> 


  "Parts_Contents_Publish" : [ ... ]

   <font color=#0099ff size=4 face="黑体">“Parts_Contents_Publish”:[...]</font> 


}

 <font color=#0099ff size=4 face="黑体">}</font> 


A placement rule contains two sets of data:

放置规则包含两组数据:

  • Filters

  • 过滤器

  • Defines what specific shapes are targeted.

  • 定义目标特定形状。

  • Placement information

  • 展示位置信息

  • The placement information to apply when the filter is matched.

  • 匹配过滤器时要应用的放置信息。

Currently you can filter shapes by:

目前您可以按以下方式过滤形状

  • Their original type, which is the property name of the placement rule, like TextField.

  • 它们的原始类型,即放置规则的属性名称,如TextField

  • display-type (Optional): The display type, like Summary and Detail for the most common ones.

  • display-type(可选):显示类型,如最常见的SummaryDetail

  • differentiator (Optional): The differentiator which is used to distinguish shape types that are reused for multiple elements, like field names.

  • differentiator(可选):区分器,用于区分重复用于多个元素的形状类型,如字段名称。

Placement information consists of:

展示位置信息包括:

  • place (Optional): The actual location of the shape in the rendered zone.

  • place(可选):渲染区域中形状的实际位置。

  • alternates (Optional): An array of alternate shape types to add to the current shape's metadata.

  • alternates(可选):一组备用形状类型,可添加到当前形状的元数据中。

  • wrappers (Optional): An array of shape types to use as wrappers for the current shape.

  • wrappers(可选):一组形状类型,用作当前形状的包装。

  • shape (Optional): A substitution shape type.

  • shape(可选):替换形状类型。


{

 <font color=#0099ff size=4 face="黑体">{</font> 


  "TextField": [

   <font color=#0099ff size=4 face="黑体">“文本域”: [</font> 


    {

        "display-type": "Detail",

   <font color=#0099ff size=4 face="黑体">“display-type”:“细节”,</font> 


        "differentiator": "Article-MyTextField",

   <font color=#0099ff size=4 face="黑体">“微分器”:“Article-MyTextField”,</font> 





 <font color=#0099ff size=4 face="黑体"></font> 


        "place": "Content",

   <font color=#0099ff size=4 face="黑体">“地方”:“内容”,</font> 


        "alternates": [ "TextField_Title" ],

   <font color=#0099ff size=4 face="黑体">“alternates”:[“TextField_Title”],</font> 


        "wrappers": [ "TextField_Title" ],

   <font color=#0099ff size=4 face="黑体">“wrappers”:[“TextField_Title”],</font> 


        "shape": "AnotherShape"

   <font color=#0099ff size=4 face="黑体">“形状”:“AnotherShape”</font> 


    }

  <font color=#0099ff size=4 face="黑体">}</font> 


  ],

   <font color=#0099ff size=4 face="黑体">]</font> 


}

 <font color=#0099ff size=4 face="黑体">}</font> 


Placing Fields

放置字段

Fields have a custom differentiator as their shape is used in many places. It is built using the Part it's contained

Fields有一个自定义的区分因素,因为它们的形状在很多地方使用。它是使用它包含的部分构建的

in, and the name of the field. For instance, if a field named MyField would be added to an Article content type,

in,以及该字段的名称。例如,如果名为MyField的字段将添加到Article内容类型,

its differentiator would be Article.MyField. If a field named City was added to an Address part then its differentiator would

它的区别是Article.MyField。如果一个名为City的字段被添加到Address部分,那么它的区分符就会

be Address.City.

Address.City

Shapes

形状

What is a shape?

什么是形状?

Everything you need to know about Shapes is in this video.

您需要了解的有关Shapes的所有信息都在[此视频](https://youtu.be/gKLjtCIs4GU)中。

Tag Helpers

标记助手

Manipulating shape metadata

操纵形状元数据

It's possible to manipulate a shape's metadata by using the metadata tag helper as a child of the shape's tag helper. The metadata tag helper allows you to:

通过使用metadata标签助手作为形状标签助手的子项,可以操纵形状的元数据。元数据标签助手允许您:

  • Change the display type

  • 更改显示类型

  • Add, remove, or clear alternates

  • 添加,删除或清除替换项

  • Add, remove, or clear wrappers

  • 添加,删除或清除包装

Metadata tag helper example:

元数据标记帮助器示例:


<menu alias="alias:main-menu">

 <font color=#0099ff size=4 face="黑体"><menu alias =“alias:main-menu”></font> 


    <metadata display-type="summary">

        <clear-alternates />

        <add-alternate name="Menu_Alternate1" />

        <add-alternate name="Menu_Alternate2" />

        <remove-alternate name="Menu_Alternate1" />

        <clear-wrappers />

        <add-wrapper name="Menu_Wrapper1" />

        <add-wrapper name="Menu_Wrapper2" />

        <remove-wrapper name="Menu_Wrapper2" />

    </metadata>

</menu>

 <font color=#0099ff size=4 face="黑体"></菜单></font> 


Date Time shapes

日期时间形状

DateTime

约会时间

Renders a Date and Time value using the time zone of the request.

使用请求的时区呈现日期和时间值。

| Parameter | Type | Description |

|参数|输入|说明|

| --------- | ---- |------------ |

| --------- | ---- | ------------ |

| Utc | DateTime? | The date and time to render. If not specified, the current time will be used. |

| Utc | DateTime?|渲染的日期和时间。如果未指定,将使用当前时间。 |

| Format | string | The .NET format string. If not specified the long format dddd, MMMM d, yyyy h:mm:ss tt will be used. The accepted format can be found at https://msdn.microsoft.com/en-us/library/8kb3ddd4(v=vs.110).aspx |

| 格式| string | .NET格式字符串。如果未指定,将使用长格式dddd,MMMM d,yyyy h:mm:ss tt。可以在https://msdn.microsoft.com/en-us/library/8kb3ddd4(v = vs.110).aspx找到可接受的格式。

Tag helper example:

标记助手示例:


<datetime utc="@contentItem.CreatedUtc" />

 <font color=#0099ff size=4 face="黑体"><datetime utc =“@ contentItem.CreatedUtc”/></font> 


TimeSpan

时间跨度

Renders a relative textual representation of a Date and Time interval.

呈现日期和时间间隔的相对文本表示。

| Parameter | Type | Description |

|参数|输入|说明|

| --------- | ---- |------------ |

| --------- | ---- | ------------ |

| Utc | DateTime? | The initial date and time. If not specified, the current time will be used. |

| Utc | DateTime?|初始日期和时间。如果未指定,将使用当前时间。 |

| Origin | DateTime? | The current date and time. If not specified, the current time will be used. |

| Origin | DateTime?|当前的日期和时间。如果未指定,将使用当前时间。 |

Tag helper example:

标记助手示例:


<timespan utc="@contentItem.CreatedUtc" />

 <font color=#0099ff size=4 face="黑体"><timespan utc =“@ contentItem.CreatedUtc”/></font> 


Result:

结果:


3 days ago

 <font color=#0099ff size=4 face="黑体">3天前</font> 


Shape differentiators

形状差异化

You can find information about shape differenciators in the Templates documentation

您可以在[模板文档]中找到有关形状差异器的信息(../../ OrchardCore.Modules / OrchardCore.Templates / README /#contents-field-differentiator)