0

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?

experimenter
  • 768
  • 1
  • 9
  • 30

1 Answers1

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>
btiernay
  • 7,873
  • 5
  • 42
  • 48
  • Hi , i was more after something showing looping through a group of Web Content items sharing the same structure but thanks for your input – experimenter Dec 11 '11 at 01:05
  • 1
    Okay, sorry I misread that part. Perhaps the following article and its links are of more use to you. http://www.liferay.com/es/community/forums/-/message_boards/message/4887040 – btiernay Dec 11 '11 at 16:17
  • Thanks i'll have a look at that post – experimenter Dec 12 '11 at 12:39