Saving slot content into a variable

I am reading from a navon slot. The slot definition is as follows:
#slot(“rffNav” “” “” “” “” “template=myNavTitle”)
The above code works perfectly fine when placed in the template. However, when I try to save the output of the above slot template into a variable as follows:

#set($navTit=#slot(‘rffNav’ ‘’ ‘’ ‘’ ‘’ ‘template=myNavTitle’))

or as

#set($navTit="#slot(‘rffNav’ ‘’ ‘’ ‘’ ‘’ ‘template=myNavTitle’)")

I donot get any output. So what is the syntax if you want to output the slot content into a variable?

thanks
Manvinder

You cannot set variables in this way using macros because #macros are actually execute inline and produce output directly. If you are interesting in saving the markup generated by a slot call, this boils down to using the $user.psoSlotTools.getSlotContents function, like this:

#set($list = $user.psoSlotTools.getSlotContents($cloneditem,“nhlbiTeaserImg”, null))
#foreach($aaSlotElement in $list)
#set($itemTemplate = $sys.asm.findTemplateByName(‘nhlbiSnBinaryFileURI’))
$aaSlotElement.setTemplate($itemTemplate)
#set($assemblyResult = $sys.asm.assemble([$aaSlotElement]).get(0).toResultString())
#set($imageUrl=$rx.doc.extractBody($assemblyResult))
#end

Of course, you have to have the PSO Toolkit installed. If not, you can still do this by using the #initslot macro to call the slot, then iterating over the elements in the exact same way. Also, if you have parameters to the slot, you will have to pass these in as the last paramater in a hashmap.