我正在尝试为阶段编写一个 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]