1

我是 Magnolia CMS 的新手,现在在我的 jsp 上迭代 ContentMap 时遇到了一些问题 在此处输入图像描述

我希望我的页面分别显示链接和链接文本。像 forEach 这样的 JSTL 标签在这种情况下不起作用,例如我输入

<c:forEach items="${content.events}" var="item">
  <a href="${item.link}" target="_blank">${item.linkText}</a>
</c:forEach>

因此我的问题是在 Magnolia 中迭代 contentMap 的正确方法是什么?

4

1 回答 1

1

ContentMap 是作为 Map 公开的节点属性。您要迭代的是子节点,因此它无法工作。查看您的结构,它看起来像一个链接列表区域,如果是这样的话,<cms:area name="events" />在呈现区域的组件和区域本身中应该足够了,例如:

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="cms" uri="http://magnolia-cms.com/taglib/templating-components/cms"%>
<div id="${def.parameters.divId}">
  <c:forEach items="${components}" var="component">
    <cms:component content="${component}" />
  </c:forEach>
</div>

wherecomponents应该隐式暴露在该区域中。尝试从 git/nexus 获取 magnolia-template-samples 模块以获得更多类似的示例。

HTH,一月

于 2014-05-14T11:52:03.967 回答