cancel
Showing results for 
Search instead for 
Did you mean: 

Displaying associations

willdavidson
Champ in-the-making
Champ in-the-making
I've adapted the folder.get web script from the samples (I'm running Alfresco Community 3.2) in order to display content on our intranet.

I've also added a custom content type that holds related documents as associations, and I'm now trying to adapt the folder.get script further to display links to related documents (if the associations exist) below the link to the 'main' document.

I hope I've explained this well enough - can anyone give me some pointers on how to achieve this?

Thanks in advance.
3 REPLIES 3

lista
Star Contributor
Star Contributor
Hi,

http://wiki.alfresco.com/wiki/3.0_JavaScript_API

will be a good starting point.
Note the ScriptNode API part of the Cookbook:

- assocs
A readonly associative array (map) of the target associations of the node. Each named entry in the array contains an Array of the ScriptNode objects on the end of the association. For example: mynode.assocs["cm:translations"][0].

- sourceAssocs
A readonly associative array (map) of the source associations to this node. Each named entry in the array contains an Array of the ScriptNode objects on the start of the association. For example: mynode.sourceAssocs["cm:translations"][0]. 

Cheers!

willdavidson
Champ in-the-making
Champ in-the-making
Thanks - that helps.

I'm a bit further on now, have got documents displaying with the associations listed beneath where they exist.

BUT the associations are node refs (e.g. workspace://SpacesStore/ae8813d6-11da-4a2f-8817-79426c5bc3a3). I've read about the DownloadContentServlet at http://wiki.alfresco.com/wiki/URL_Addressability but this servlet wants the file name, which I don't have.

So

i) Is there a way to get the file name of the content from the node ref so I can build the full URL for the DownloadContentServlet

or

ii) Am I barking up the wrong tree and there's a better way to get from my node ref associations to a 'download content' URL?

Thanks for the help, it is appreciated.

willdavidson
Champ in-the-making
Champ in-the-making
I've cracked it. My code is too ugly to post right now but I'm happy to share once I've tidied it up.  Smiley Very Happy