How to access to a parent document data in a widget

Hello,

I currently make a table layout to display some search results.
But in this results, I want to display metadata which can be find in a parent document of the one which is displayed. How, in a widget, I can access to this data?
I saw that it is possible to use a EL expression in a widget layout editor but i didn't find the good one.
I managed to get the parent document Ref with this : #{document.getData().getParentRef().reference()} but I can't go further.

Somebody can help me?

thanks,

0 votes

2 answers

4087 views

ANSWER



#{documentManager.getDocument(document.getData().getParentRef()).getPropertyValue(“dc:title”)}

Note that this won't handle the case where user does not have enough rights to access the parent. And as you're in a result layout, there's a good chance that this is bad for perfs.

An alternative (and more efficient) way of doing this would be to retrieve the property on the parent, and update it on the document, whenever it is created/moved.

0 votes



Ok, I find the good expression :

" #{
(document.getData().getCoreSession().getDocument(document.getData().getParentRef())).getProperty("dc:title").getValue()
} " 

But it isn't very friendly. Maybe someone knows something more easy?

0 votes



How did you get it to work? On my side, It shows me a list of dc metadata (ie Nature
Sujets
Droits
Source …)
02/13/2013

Use a generic widget set his type to "text", Add a custom property in the widget editor, id : 'value' ,and for the value : the script

Maybe the first parenthesis is useless, i think you can delete it (with a parenthesis after getParentRef()of course)

02/14/2013