0

我正在尝试为阶段编写一个 freemarker 模板,该模板检查是否为此页面定义了一个阶段,如果没有,则尝试从其父页面继承该阶段。标准继承(就像它是默认的,例如页脚)对我不起作用,因为如果需要,用户仍然应该能够为子页面定义不同的阶段。

我已经有一个在 Magnolia 4.4 中工作的模板,但是由于模板 API 的各种变化,这在 4.5 中不可用。所以我尝试将其调整为 4.5:我正在使用 cmsfn.inherit() 函数查找父内容,然后访问该内容的阶段,但我不断收到错误(说它没有指定)。

我的模板:

<div id="stage" style="color: white;">
  [#if content??]
    [@cms.component content=content /]
  [#else]
    [#assign inheritedContent = cmsfn.inherit(cmsfn.content(state.mainContent.@handle)) /]
      [#if cmsfn.isEditMode()]
        Inherited content: ${inheritedContent}
      [/#if]
      [@cms.component content=inheritedContent.stage /]
  [/#if]
</div><!-- end stage -->

错误信息:

The 'content' parameter was passed but not or wrongly specified. The problematic instruction:
----------
==> user-directive cms.component [on line 17, column 17 in ***/pages/home/inheritStage.ftl]
4

1 回答 1

3

也许我回答得太晚了,但如果其他人发现这一点:在 magnolia cms 4.5 中继承内容的方式发生了一些变化 - 现在使用原型配置做了一些不同的事情:

在您的作者实例中,转到模板工具包->站点配置,然后转到模板->原型->区域->您的区域并添加一个名为“继承”的新内容节点并为其创建节点数据。

节点数据:

components - 这可以是“all”(所有组件都被继承)、“filtered”(继承属性设置为 true 的所有组件都被继承)或“none”(不言自明)启用 - 不言自明

另外,如果您决定继承“过滤”组件,请不要忘记向相关组件添加继承对话框选项

如果您想查看一个工作示例,请查看“附加”原型。

于 2012-09-24T09:51:25.670 回答