Page History
...
对JSP,指令是由Templating JSP模块提供。
The directive syntax differs slightly depending on the templating language. Freemarker directives start with the # character in the case of standard directives and with the @ character for custom directives. All directives in the Magnolia cms
tag library start with @. What follows is the tag library name such as cms
, a dot character, the name of the macro, and any parameters. In JSP the limiting characters are different.
Syntax:
Code Block |
---|
[@<tag library>.<macro> <parameter>=<value> /] |
Freemarker example: Render a component
Code Block |
---|
[@cms.component content=component /] |
JSP example: Render a component
Code Block |
---|
<cms:component content="${component}"/> |
cms:init
The InitElement Java class embeds the JavaScript and CSS needed to edit pages on the author instance. The output goes in the head
element in the page HTML.
Example:
Code Block |
---|
[@cms.init /] |
cms:area
The cms:area
directive (AreaDirective) renders an area and any components inside it. Editors can add components inside the area. Available components are configured in the area definition.
Example:
Code Block |
---|
[@cms.area name="main"/] |
The directive references an area by its name. The area name is the content node that contains the area definition such as main
, footer
or stage
.
The result on the page is an area bar, a start marker and an end marker. The value of the title
property in the area definition is rendered on the bar. When an editor clicks the Add icon in the New Component box they can add components inside the area.
If the area definition contains a templateScript
property then the referenced script renders the area. If no script is given then the following default scripts are used instead:
指令的语法随模板语言而略有不同。FreeMarker指令中,标准指令以“#”字符开头,而定制指令则以“@”符号开头。所有Magnolia cms
标签库中的指令都以“@”开头,紧接着是标签库的名字,如cms
,其次是一个点符号,宏的名字,以及任何参数。在JSP里限制的字符则不同。
语法:
Code Block |
---|
[@<tag library>.<macro> <parameter>=<value> /] |
FreeMarker示例:绘制一个组件
Code Block |
---|
[@cms.component content=component /] |
JSP示例:绘制一个组件
Code Block |
---|
<cms:component content="${component}"/> |
cms:init
InitElement Java类嵌入了在编写实例上编辑页面所需的JavaScript和CSS。输出在HTML页面的head
元件里。
示例:
Code Block |
---|
[@cms.init /] |
cms:area
cms:area指令
(AreaDirective)绘制一个area以及里面的任何组件。编辑者可在区域内添加组件。可用的组件在区域定义里配置。
示例:
Code Block |
---|
[@cms.area name="main"/] |
该指令通过区域名字引用区域。区域名为包含区域定义的内容节点,如main
,footer
或stage
。
页面上的结果是一个区域栏,一个开始标记和一个结束标记。区域定义里title
属性值在此区域栏里绘制。当编辑者点击New Component框的添加图标时,组件就添加到区域里了。
如果区域定义包含一个templateScript
属性,那么由被引用的脚本绘制区域。如果没给定脚本,以下缺省脚本则会被使用:
区域类型为Area type single
Code Block |
---|
[@cms.component content=component /] |
Area type 区域类型为list
Code Block |
---|
[#list components as component] [@cms.component content=component /] [/#list] |
cms:component
The cms:component
directive (ComponentDirective) renders a component. The content
attribute defines what content the component edits. This tag is commonly used inside the list
directive to loop through the components in a map.
...