switching template (params) inside #initslot

Hi all,

I am trying to apply a different template to items inside my #initslot call but I do not know which method to use. Can anybody let me know if you have done this before and how?

Cheers
Valérie

Here is my code:
#set($slotname = “icrcSlotRelated”)##
#set($slotparams = “template=defaulttemplate”)##
#initslot($slotname $slotparams)##
#if ($sys.part.render)##
#if($sys.currentslot.slot)##
#__addAaSlotImg($slotname)##
#__startAaSlotDiv($slotname)##
#if($sys.currentslot.relresults.size() > 0)##
#set($count=$sys.currentslot.relresults.size())##
#foreach( $relresult in $sys.currentslot.relresults)##
#__startAaSnippetDiv($relresult $slotname)##
#__addAaSnippetImg($relresult $slotname)##
#if($velocityCount==1)##
############################
##use defaulttemplate for the first item
############################
#slotItem($relresult)##
#else##
############################
## here change “template = secondtemplate” ???
## use the second template for remaining items
############################
#slotItem($relresult)##
#end##
#__endAaSnippetDiv()##
#end##
#end##
#__endAaSlotDiv()##
#end##
#end##
#endslot($slotname)##

You can copy the result, set the template and reassemble the item. The best way would be to init the slot with the template to use for the rest of the results then replace it for the first one. You do need the PSO toolkit installed for this to work.

Not sure if there is another way?

#if($velocityCount==1)##
#set($firstitemTemplate = $sys.asm.findTemplateByName(‘firstitemTemplateName’))
#set($firstItem = $relresult)
$firstItem.setTemplate($firstitemTemplate)
#set ($result = $sys.asm.assemble($user.psoListTools.asList($firstItem)).get(0))
#set($resultBody = $rx.doc.extractBody($result))
$resultBody
#else##
#slotItem($relresult)##
#end##

Brillant I have tried and it works fine. I thought I need to reassemble but didn’t have a clue how to!!!