七、制作主题(三) Understanding placement info

The placement.info File

大多数模块和主题都有一个placement.info文件,这是个xml文件,指定了content part中的part的位置。

下面展示了Orchard.Tags的placement.info文件:

<Placement>
    <Place Parts_Tags_Edit="Content:7"/>
    <Match DisplayType="Detail">
        <Place Parts_Tags_ShowTags="Header:after.7"/>
    </Match>
    <Match DisplayType="Summary">
        <Place Parts_Tags_ShowTags="Header:after.7"/>
    </Match>
</Placement>

 

Scope

placement.info文件在content item层次起作用。意思是你能使用它重新排序content item中的part的显示。如果shape不代表content part需要处理placement,它给你提供shape的安置机制。

 

The "Placement" Element

Placement元素必须是placement.info文档的根元素,它是一个简单的容器。

 

"Place" Element

Place元素是placement.info的主要实体,它能有许多属性,为了可读性推荐每个Place元素有一个shape place,其它的shapes,你能每行添加一个Place标签。

Place的每个属性是shape的名称(就像Parts_Tags_ShowTags),定义相关的part driver,有plcement值。决定给定content item的part的显示,你能读关于part drivers的代码,或有一个简单的方法是启用Designer Tools模块,使用shape debugging tools来检查model,

属性的名称能是任何shape的名称,也有某个fields的专门的扩展,以使placement能指定专门的field实例。例如:下面placement阻止名称为”Occupation”的text fields的显示:

<Place Fields_Common_Text-Occupation="-"/>

 

它的值分配到zone 名称加:然后是位置。位置使用.标记定义。它能是一个单独数字或是以.分隔的连续数字。

这个排序是从第一个数字开始决定,如果多个位置有同样的数字,则使用下一个数字排序。

有一个特殊的”-“值,阻止shape发送到local zone。也能使用before和after修饰一个shape的位置。

例如 :Header:after位置。

 

"Match" Element

Match元素使用规范place tags的集合,能有下面的属性:

  • DisplayType. Scopes the contained Place tags to a specific display type (such as Detail orSummary).
  • ContentType. Scopes the contained Place tags to a specific content type (such as BlogPost orPage) or stereotype (such as Widget; this feature is new to Orchard 1.1).
  • Path. Scopes the contained Place tags to a specific path or to a path and its children. For example,Path="/About" enables changes that only affect the About page (assuming you have one), andPath="/MyBlog/*" affects everything that is under the path MyBlog, such as Myblog orMyBlog/FirstPost. The Path attribute is new to Orchard 1.1.

Match能嵌套。

posted @ 2012-03-23 10:49  commanderss  阅读(504)  评论(0编辑  收藏  举报