我想知道是否有人可以给我一些关于如何创建 Velocity 模板以循环浏览特定结构的 Web 内容项并根据特定结构字段的值呈现内容的想法/片段?
问问题
2259 次
1 回答
0
Here is a snippet from navigation.vm
that will render group links:
#set($groupLocalService = $serviceLocator.findService("com.liferay.portal.service.GroupLocalService"))
#set($groupCount = $groupLocalService.getGroupsCount())
#set($groups = $groupLocalService.getGroups( 0, $groupCount))
<div id="community-links">
<ul>
#foreach ($group in $groups)
#if ($group.community && $group.name != 'Guest' && $group.hasPublicLayouts())
#set ($groupURL = $portletURLFactory.create($request, $group.name, $group.defaultPublicPlid, "ACTION_PHASE"))
${groupURL.setWindowState("normal")}
${groupURL.setPortletMode("view")}
${groupURL.setLifecycle("0")}
${groupURL.setParameter("groupId", ${group.getGroupId().toString()})}
${groupURL.setParameter("privateLayout", "false")}
#if ($group.getGroupId() == $themeDisplay.getLayout().getGroup().getGroupId() )
#set ($className = "selected")
#else
#set ($className = "unselected")
#end
<li class="${className}">
<a href="${groupURL.toString()}"><span>$group.getName()</span></a>
</li>
#end
#end
</ul>
</div>
于 2011-12-10T15:54:44.220 回答