API
Version 7.x > API > Related Documents View modes: 
User avatar
Member
Member
tim-createwell.com - 9/11/2013 12:15:40 AM
   
Related Documents
Hi there,

I am trying to programmatically access documents that I have assigned to a page through a specific relationship: "HasPageSetting".

At the moment the following code:

if (CMSContext.CurrentDocument.RelatedDocuments["HasPageSetting"].Count > 0)

Returns "1" as there is a document related to the currently selected page, however I can't seem to find a way in which I can access the attributes/values of this related document!

I have tried:

CMSContext.CurrentDocument.RelatedDocuments["HasPageSetting"].FirstItem.GetValue("BackgroundImage");

But this fails - it complains that my related document object doesn't exist!


Unfortunately the documentation regarding related documents is very sparse, does anyone have any ideas how this is all supposed to work?


Any help would be greatly appreciated.

Regards,
Tim.

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 9/18/2013 12:55:53 AM
   
RE:Related Documents
Hi,

I just noticed you posted it on forums too. I will update this thread for others reference.

In this case you need to use TreeNodes.SelectNodes or DocumentHelper.GetDocuments methods - but in their overloads you have to specify the "classnames" parameter in order to return the coupled data for given documents in the dataset.

Best regards,
Juraj Ondrus