Has something changed with the 6.7 way of creating Lists in velocity?

We have some predefined macros that we had biult to work as a some what global variable and work beautifly till the upgrade from 6.5 to 6.7. The lines that deal with creating and adding to a list nolonger work, are:
#set($cobSlotItemsList = $user.psoListTools.asList($relresult))##
#set($body = $cobSlotItemsList.add($relresult))##

Full code macro below:

#macro(cobGetListOfSlotItemsWithLimit2 $slotname $params $limitNumber)##
#initslot($slotname $params)##
#if ($sys.part.render)##
#if($sys.currentslot.slot)##
#__addAaSlotImg($slotname)##
#__startAaSlotDiv($slotname)##
#if($sys.currentslot.relresults.size() > 0)##
#set($myCount = 1)##
#set($myContentList = “”)##
#if(!$limitNumber.toString().equals(""))##
#set($myLimit = “$limitNumber”)##
#else##
#set($myLimit = “5”)##
#end##
#set($myLimit = $tools.math.toInteger($myLimit.trim()))##
#foreach($relresult in $sys.currentslot.relresults )##
#if($myCount <= $myLimit)##
#set($mySlotFlag = 1)##
#set($temp = $tools.math.toInteger($relresult.node.getProperty(“sys_contentid”).String.trim()))##
#if(!$myContentList.toString().equals(""))##
#foreach($scID in $myContentList)##
#if($temp == $scID)##
#set($mySlotFlag = 0)##
#end##
#end##
#end##
#if($mySlotFlag == 1)##
#__startAaSnippetDiv($relresult $slotname)##
#__addAaSnippetImg($relresult $slotname)##
#if($myCount == 1)##
#set($cobSlotItemsList = $user.psoListTools.asList($relresult))##
#else##
#set($body = $cobSlotItemsList.add($relresult))##
#end##
#__endAaSnippetDiv()##
#if($myCount == 1)##
#set($myContentList = $user.psoListTools.asList($relresult))##
#else##
#set($body = $myContentList.add($relresult))##
#end##
#set($myCount = $myCount + 1)##
#end##
#end##
#end##
#end##
#__endAaSlotDiv()##
#end##
#end##
#endslot($slotname)##
#end##

Can anyone give me any insight into this? :confused:
Thanks!

6.7 uses a more current version of both Velocity and Velocity Tools.

You no longer need to use .asList() to create a list, instead, use:

#set($cobSlotItemsList = [])##

Here’s a complete rewrite of your macro (untested) that should do the trick – changes in bold… biggest change also in italics:

#macro(cobGetListOfSlotItemsWithLimit2 $slotname $params $limitNumber)##
#set($cobSlotItemsList = [])## the results - set this global variable.
#initslot($slotname $params)##
#if($sys.part.render)##
#if($sys.currentslot.slot)##
#__addAaSlotImg($slotname)##
#__startAaSlotDiv($slotname)##
#if($sys.currentslot.relresults.size() > 0)##
#set($myContentList = [])## track already included content ids so we don’t get duplicates
#if(!$limitNumber.toString().equals(""))##
#set($myLimit = “$limitNumber”)##
#else##
#set($myLimit = “5”)## default limit of 5
#end##
#set($myLimit = $tools.math.toInteger($myLimit.trim()))##
#foreach($relresult in $sys.currentslot.relresults )##
#if($myContentList.size() <= $myLimit)##
#set($temp = $tools.math.toInteger($relresult.node.getProperty(“sys_contentid”).String.trim()))##
#if(!$tools.list.contains($myContentList, $temp))##
#__startAaSnippetDiv($relresult $slotname)##
#__addAaSnippetImg($relresult $slotname)##
#set($ignored = $cobSlotItemsList.add($relresult))##
#__endAaSnippetDiv()##
#set($ignored = $myContentList.add($temp))##
#end##
#end##
#end##
#end##
#__endAaSlotDiv()##
#end##
#end##
#endslot($slotname)##
#end##

I would also like to point out that you are calling all the Active Assembly macros without actually rendering any of the content from the slot… this could lead to some weird behavior when you use this macro in Active Assembly editing. However, if you’ve used this macro for a long time, you probably alreay know its quirks.

Thank you Rushing, yes we did know about the few quirks it had but it gave use the funtionality that we need when moving from the XML variants to velocity way back when.

  Hey is there any GOOD documentation on using the PSO toolkit macros?

Thanks again! :smiley:

Not that I know of… i think you have to pay for PSO implementations if you can’t do it yourself without documentation. There is very VERY minor documentation in the extensions.xml file if you can find the entries on what you’re looking for, but that really only applies to the major objects and extension functions (which are invoked in a very convoluted and unrecommended way in velocity)…

What I find myself doing is using the comments in the pop-up method auto-completion list to help me guess what the methods actually do.