Getting the assembly link from a Node Object in a slot

How would I get the assembly link from the Node in a slot?

I have a Node Object, but I cannot find any way to use the $rx.location.generate($sys.assemblyItem) method to get the link from the Node Object.

Thanks

John

John,

As I’m sure you’ve figured out, the location scheme depends on a bunch of other variables besides the Item (e.g. site, context, folder, etc) all of which are encoded in the AssemblyItem.

You have to clone the IPSAssemblyItem and call setNode() with the new node that you obtained from the slot.

In 6.5, this can be done directly:


IPSAssemblyItem mySlotItem = originalItem.clone().setNode(mySlotNode);

In 6.1 you have to downcast to PSAssemblyWorkItem first, as the setNode() method was not exposed in the interface.

This assumes you are working in Java (writing a Binding Function) rather than in JEXL directly. In 6.5 you might well be able to do this in JEXL, but I’ve not had the occasion to try it.

I hope this helps

Dave

David,

Thanks. I was able to get it to work directly in JEXL. Since I am not sure how to do a binding function yet.

$itemclone = $sys.assemblyItem.clone()
$vendoritem = $itemclone.setNode($vendornode) 
$vendorlink = $rx.location.generate($itemclone)

I started out by having everything combined and it would not work. It kept giving me a NullPointerException. Once I broke each method out on a separate line with new variable for each line it worked.

Thanks.

John

Sorry, I think I misled you on that. You have to break it up the way you did.

Glad I could help.

Dave

Hi all, OK I’m just resurrecting this thread as I’m looking to do exactly as the title suggests, although I can’t deduce from jblakie’s solution how I can achieve this.

I have a slot called “NewsRelatedDocuments” which users can add file uploads to (the template they add to the slot is a binary template called “bFile”). I’m currently setting up bindings to extract information about the content items in this slot.

I need to set up a binding which will get the publishing location for the content items in the slot. I understand how to get information about the content items from individual fields, an example of how I do this is shown below:

[B]
$slotContents = $user.psoSlotTools.getSlotContents($sys.assemblyItem, “NewsRelatedDocuments”, $slotparams)

$child[4].srdDocumentRymxID = $mySlotItem.getNode().getProperty(“rx:sys_contentid”).String
[/B]

However what I’m trying to do now is set up a binding between the assembled location of the content item in my slot and a field in my database. I’ve recently learnt how to set up bindings to assembled templates using the $sys.assemblyItem.clone() method, but I’m still unclear on how I can do this for a node from my slot item. Any advice would be appreciated, Thanks!