How To Change the Slot template for a specific slot item

How can the $params.template be changed for a specific item in a slot?

The slot marco has the for loop

#foreach($relresult in $sys.currentslot.relresults )##
$before##
#__startAaSnippetDiv($relresult $slotname)##
#__addAaSnippetImg($relresult $slotname)##
#set($body = “$rx.doc.extractBody($relresult)”)##
$body##
#__endAaSnippetDiv()##
$after##
#end##

How can the slot’s $params.template be changed for a specific item depending on the slot items content type. In our system all the content types have a field called
contenttypename.

So we can use the following code to get the content type

#if ($relresult.Node.getProperty(“contenttypename”).String==“rffGeneric”)
##Code to change slot item template
#end

So all I need is the code to change the slot item template, any takers?

Thanks in advance
Tyrone

FYI, you don’t need a custom field for each content type to figure out the content type name…that is available via:

$relresult.getNode().getPrimaryNodeType().getType()

Yeah, I know…probably too late to make a change :frowning:

To your question, you may be able to use $rx.asmhelper.assemble to pass it the item and a specific template, but I haven’t actually tried that…Why exactly do you need the template changed? (Ie force a particular template regardless of what the user chooses?)

Jit/Tyrone,

You can also use $relresult.Node.definition.internalName to return the ContentType name ( without the rx:).

Tyrone, I’d suggest using a Dispatch template. Set $params.template to your Dispatch template and set the logic of which snippet to display based on the content type.

M.

Michael

Thanks for the Dispatch template suggestion, that should definately work.

Tyrone