0

在 Magnolia 4.5.3 中,如果没有为此定义父页面,我将尝试继承父页面的阶段。Java 类TemplatingFunctionscmsfn在 freemarker 中公开)提供了一个方法inherit(Node content),所以我正在尝试以下方法:

[#if component??]
    [@cms.component content=component /]
[#else]
    [#assign inheritedContent = cmsfn.inherit(cmsfn.content(state.mainContent.@handle)) /]
    [@cms.component content=inheritedContent /]
[/#if]

但后来我得到一个错误:

The 'content' parameter must be a ContentMapModel and is a StringModel.

(我的例子中的第 6 行)

为什么会出现这个错误,即我该如何解决这样的错误?

4

2 回答 2

1

我猜问题是cmsfn.content(path)返回 a javax.jcr.Node,因此重载的cmsfn.inherit方法也会返回 a Node,但@cms.component需要 a info.magnolia.jcr.util.ContentMap。所以,也许你应该将 转换NodeContentMapwith cmsfn.asContentMap(someNode)。(我在不了解 Magnolia 的情况下这么说,只是查看它的 API javadoc,所以也许我错了。)

于 2012-08-23T12:40:45.860 回答
0

我编写了自己的继承方法,手动搜索具有阶段的父节点,但最后,我没有返回节点,而是返回new ContentMap(node).

于 2012-08-27T09:54:23.307 回答