如何查找具有特定结构字段值的Web内容? [英] How to find web contents with specific structure field value?
本文介绍了如何查找具有特定结构字段值的Web内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道是否有人可以给我一些想法/摘要,介绍如何创建Velocity模板以遍历特定结构的Web Content项目,并根据特定结构字段的值呈现内容?
I was wondering if anyone could give me some ideas/snippets on how to create Velocity template to loop through Web Content items for a specific structure , and render the contents based on the value of a specific structure field?
推荐答案
以下是navigation.vm
的代码段,将呈现组链接:
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>
这篇关于如何查找具有特定结构字段值的Web内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文