How to find web contents with specific structure field value?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-25 02:08:42

问题


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?


回答1:


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>


来源:https://stackoverflow.com/questions/8457663/how-to-find-web-contents-with-specific-structure-field-value

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!