Include 1 template within another for the same content item

I’m trying to build a database assembler template which will publish the assembled result of another velocity template…

I’ve tried several approaches including the following binding:
$assembledBody=$rx.doc.extractBody($rx.doc.getDocument($rx.location.generate($sys.assemblyItem,‘bodyTemplate’),’’,’’)

This, however, results in a Rhythmyx login form getting published to my target database. I’ve tried replacing the hostname with 127.0.0.1… this too results in a login page…

I’ve also tried $rx.assmHelper.assemble() but without a slotname, it does nothing or causes an error.

I even tried making an automatic slot, but I get nothing… I mean, literally, nothing outputs at all.

Anyone done anything similar and gotten it to work?

I was able to get this to work by using the following bindings:

[B]$template[/B]=<Your Template ID Here>
[B]$contentid[/B]=$rx.string.extractNumber($rx.asmhelper.getSingleParamValue($sys.params,'sys_contentid'))
[B]$revision[/B]=$rx.string.extractNumber($rx.asmhelper.getSingleParamValue($sys.params,'sys_revision'))
[B]$authtype[/B]=$rx.asmhelper.getSingleParamValue($sys.params,'sys_authtype')
[B]$siteid[/B]=$rx.string.extractNumber($rx.asmhelper.getSingleParamValue($sys.params,'sys_siteid'))
[B]$contex[/B]t=$rx.string.extractNumber($rx.asmhelper.getSingleParamValue($sys.params,'sys_context'))
[B]$itemfilter[/B]=$rx.asmhelper.getSingleParamValue($sys.params,'sys_itemfilter')
[B]$folderid[/B]=$rx.asmhelper.getSingleParamValue($sys.params,'sys_folderid')
[B]$publish[/B]=$rx.asmhelper.getSingleParamValue($sys.params,'sys_publish')
[B]$url[/B]='/Rhythmyx/assembler/render?sys_revision='+[B]$revision[/B]+'&sys_siteid='+[B]$siteid[/B]+'&sys_template='+[B]$template[/B]+'&sys_itemfilter='+[B]$itemfilter[/B]+'&sys_contentid='+[B]$contentid[/B]+'&sys_folderid='+[B]$folderid[/B]+'&sys_context='+[B]$contex[/B]t+'&sys_publish='+[B]$publish[/B]
[B]$body[/B]=$rx.doc.extractBody($rx.doc.getDocument([B]$url[/B]))

The real issue, it seems, was that the URL must be relative for the authentication error not to occur… and, for whatever reason, $rx.location.generate() occasionally returns a null value, so I couldn’t rely on that either.

Sam,

This seems like the long way around the barn to me.

You should be able to do this by calling the Assembly Service ($sys.asm) directly.

Something like (and I have not tested all of this)


$myTemplate = $sys.asm.findTemplateByName("myTemplate")
$myAssemblyItem = $sys.AssemblyItem.clone()
$xxx = $myAssemblyItem.setTemplate($myTemplate)
$results = $sys.asm.assemble($user.PSOListTools.asList($myAssemblyItem))
$body = $rx.doc.extractBody($results.get(0))

Should work better (faster and cleaner) than constructing the assembly URL directly in the code.

Dave