Custom Slot Macro

I’ve built a simple macro to help me keep my templates to a minimum when using slots:

## macro to enable using slots without needing a seperate template to render them
## Sam Rushing, July 31, 2009 
#macro(initcustomslot $slotname $params)##
#__renderpartstart($slotname 'slot')##
#__slotsetup($slotname $params)##
#if ($sys.currentslot.slot)##
#set($sys.currentslot.active = $sys.activeAssembly && $sys.currentslot.isrelationshipfinder)##
#set($sys.currentslot.assemblyItems = $user.psoSlotTools.getSlotContents($sys.assemblyItem,$slotname,$completeparams))##
#end##
#end

You can use this instead of #initslot($slotname $params) to prevent the need for another template just to handle the slot’s content. This is great for cutting down on the number of one-off templates simply for rendering an included type in another type’s output.

For example… I have a preview template that links to the preview of related items using this code:

#initcustomslot( 'RelatedArticle_Slot' '' )
#foreach( $assemblyItem in $sys.currentslot.assemblyItems )
#set( $item = $assemblyItem.getNode() )
#set( $thisrev = $assemblyItem.getParameterValue('sys_revision','0') )
#set( $thiscid = $assemblyItem.getParameterValue('sys_contentid','0') )
<a href="/Rhythmyx/assembler/render?sys_revision=$thisrev&sys_itemfilter=preview&sys_template=Article_Preview&sys_contentid=$thiscid&sys_context=0"
>$item.getProperty('rx:sys_title').string</a><br />
#end
#endslot( 'RelatedArticle_Slot' )