A slot in a slot - usage of $rx.asmhelper.assemble()

Hi guys.

What I’m trying to achieve:

  • I have a slot in a page (called “icr_hp_mainImagePanels”)
  • I can browse every single item in that slot
  • every single item in the slot contains a slot with the landing page location (called “icr_landing_page”)
  • from the main page I want to get that landing page location (through the first slot to the second one)

What I’ve been able to come up with using the forum:

#initslot(“icr_hp_mainImagePanels” “template=icrBnPanelImage”)
#foreach($item in $sys.currentslot.relresults)
#__slotsetup(“icr_landing_page” “template=icrSnTitleLink”)
#set($item = $sys.assemblyItem.clone())
$item.setNode($relresult.getNode())
#set($sys.currentslot.relresults = $rx.asmhelper.assemble($item,$sys.currentslot.slot))
#if($sys.currentslot.relresults.size() > 0)
#set($relresult = $tools.list.get($sys.currentslot.relresults,0))
#set($landingPage = $rx.location.generate($relresult))
#endif
#end
#endslot(“hp_mainImagePanels”)

Unfortunately it seems to refer to the same old slot (“icr_hp_mainImagePanels”) any time, surely I’m misusing the “$rx.asmhelper.assemble()” method…

Does anybody have a valid & easy explanation on how to use this method?

Cheers.

Hi,

Here’s a snip from the doc on $rx.asmhelper.assemble:

$rx.asmhelper.assemble Returns List<IPSAssemblyResult>
Used in Templates. Assembles the related Content Items in the specified Slot of the specified Content Item using the specified parameter values as overrides.
Parameters
[ol]
[li]Name: item
[/li]Description:The Content Item whose related Content Items to assemble. Use $sys.item.
[li]Name: slot
[/li]Description:The Slot whose related Content Items to assemble.
[li]Name: params
[/li]Description: Set of assembly parameters to use as overrides. e.g. Slot Parameters
[/ol]

It looks like your code should work to me…I am wondering if you need to store the value of $sys.currentslot.relresults outside the loop and loop on that. If you debug output $sys.currentslot.slot before the assemble call (or at any point after the slotsetup call), is it pointed at your slot or still the panel slot?

Here is __slotsetup. The $sys.asm.findSlotByName($slotname) call on the second line of that macro is what is setting $sys.current.slot


macro(__slotsetup $slotname $params)##
#set($sys.currentslot.slotname = $slotname)##
#set($sys.currentslot.slot = $sys.asm.findSlotByName($slotname))##
#if ($sys.currentslot.slot)##
#set($sys.currentslot.isrelationshipfinder = $rx.asmhelper.isAASlot($sys.currentslot.slot))##
#set($completeparams = $rx.asmhelper.combine($sys.params,$params))##
#else##
<h3 style="color: red">Cannot find slot: $slotname</h3>##
#end##
#end

-n

[QUOTE=DCislaghi;20872]Hi guys.

What I’m trying to achieve:

  • I have a slot in a page (called “icr_hp_mainImagePanels”)
  • I can browse every single item in that slot
  • every single item in the slot contains a slot with the landing page location (called “icr_landing_page”)
  • from the main page I want to get that landing page location (through the first slot to the second one)

What I’ve been able to come up with using the forum:

#initslot(“icr_hp_mainImagePanels” “template=icrBnPanelImage”)
#foreach($item in $sys.currentslot.relresults)
#__slotsetup(“icr_landing_page” “template=icrSnTitleLink”)
#set($item = $sys.assemblyItem.clone())
$item.setNode($relresult.getNode())
#set($sys.currentslot.relresults = $rx.asmhelper.assemble($item,$sys.currentslot.slot))
#if($sys.currentslot.relresults.size() > 0)
#set($relresult = $tools.list.get($sys.currentslot.relresults,0))
#set($landingPage = $rx.location.generate($relresult))
#endif
#end
#endslot(“hp_mainImagePanels”)

Unfortunately it seems to refer to the same old slot (“icr_hp_mainImagePanels”) any time, surely I’m misusing the “$rx.asmhelper.assemble()” method…

Does anybody have a valid & easy explanation on how to use this method?

Cheers.[/QUOTE]

Also, depending on the backend db configuration, the slot lookups are likely case sensitive. Double check the spelling / value on the second slot.

You could also call try replacing sys.current.slot with a direct call to $sys.asm.findSlotByName(‘inner slot name’) on the assemble line. This will return an IPSTemplateSlot object if the slot is found, which is what the assemble method needs.

-n

[QUOTE=natechadwick;20873]Hi,

Here’s a snip from the doc on $rx.asmhelper.assemble:

$rx.asmhelper.assemble Returns List<IPSAssemblyResult>
Used in Templates. Assembles the related Content Items in the specified Slot of the specified Content Item using the specified parameter values as overrides.
Parameters
[ol]
[li]Name: item
[/li]Description:The Content Item whose related Content Items to assemble. Use $sys.item.
[li]Name: slot
[/li]Description:The Slot whose related Content Items to assemble.
[li]Name: params
[/li]Description: Set of assembly parameters to use as overrides. e.g. Slot Parameters
[/ol]

It looks like your code should work to me…I am wondering if you need to store the value of $sys.currentslot.relresults outside the loop and loop on that. If you debug output $sys.currentslot.slot before the assemble call (or at any point after the slotsetup call), is it pointed at your slot or still the panel slot?

Here is __slotsetup. The $sys.asm.findSlotByName($slotname) call on the second line of that macro is what is setting $sys.current.slot


macro(__slotsetup $slotname $params)##
#set($sys.currentslot.slotname = $slotname)##
#set($sys.currentslot.slot = $sys.asm.findSlotByName($slotname))##
#if ($sys.currentslot.slot)##
#set($sys.currentslot.isrelationshipfinder = $rx.asmhelper.isAASlot($sys.currentslot.slot))##
#set($completeparams = $rx.asmhelper.combine($sys.params,$params))##
#else##
<h3 style="color: red">Cannot find slot: $slotname</h3>##
#end##
#end

-n[/QUOTE]

Solved with two lines (and a little help):

#set($params.template=“icrSnTitleLink”)
#set($slotLists=$user.psoSlotTools.getSlotContents($item, “icr_landing_page”, $params))
#if($slotLists.size() > 0)
#set($relresult = $tools.list.get($slotLists,0))
#set($landingPage = $rx.location.generate($relresult))
#endif

Thanks anyway!

Davide

Great, glad you got it working.

[QUOTE=DCislaghi;20876]Solved with two lines (and a little help):

#set($params.template=“icrSnTitleLink”)
#set($slotLists=$user.psoSlotTools.getSlotContents($item, “icr_landing_page”, $params))
#if($slotLists.size() > 0)
#set($relresult = $tools.list.get($slotLists,0))
#set($landingPage = $rx.location.generate($relresult))
#endif

Thanks anyway!

Davide[/QUOTE]