Getting related pages of Current Document in a widget layout.

Zach L asked on February 16, 2017 17:39

I'm trying to get the "related pages" of the current document and I'm trying to do so in a layout of a widget.Here is what I tried : <cms:CMSRepeater ID="dlContacts" runat="server" Path="/Contacts/%" RelationshipWithNodeGUID="<%=DocumentContext.CurrentDocument.DocumentGUID%>" ClassNames="test.Contact TransformationName="test.SomePage.Contacts" /> and the transformation itself :

<li data-name="<%# Eval("FullName")%>" data-title="<%#Eval("Role")%>" data-phone="<%#Eval("Telephone")%>" data-email="<%#Eval("Email")%>" data-logo="<%#Eval("AssociatedLogo")%>"></li>

This return nothing and I have no idea where I'm going wrong or if I'm even going in the right direction. I also tried to get the TreeNodes with DocumentContext.CurrentDocument.RelatedDocuments but that also returned nothing even though I'm 100% sure I have related pages asssigned to the current document.. there is probably multiple ways to do this. Any tips/clues ?

Recent Answers


Peter Mogilnitski answered on February 16, 2017 19:21 (last edited on December 10, 2019 02:30)

The macro should be {%CurrentDocument.RelatedDocuments["RelationshipCodeName"]|(identity)GlobalAdministrator%} see more on ApplyTransformation here

You can use web parts for example Related Pages web part. You can read more here

P.S. In you CMS.Repeater you should put CurrentDocument.NodeGUID not CurrentDocument.DocumentGUID

0 votesVote for this answer Mark as a Correct answer

Zach L answered on February 16, 2017 21:16

hmmm.. I was trying to implement this within the layout of the widget (which as far as i know doesn't allow for macros) just keep things consisten with the rest of the system, but if there is no way to get it doen this way then I'll have to try what you have mentioned

0 votesVote for this answer Mark as a Correct answer

Peter Mogilnitski answered on February 16, 2017 22:33

Zach, I don't really have the full picture of what you are trying to do. Are you using Portal Engine or aspx templates? The screenshot would definitely help here. Probably there is a confusion here between widgets and web parts.

0 votesVote for this answer Mark as a Correct answer

Zach L answered on February 17, 2017 00:28

I'm trying to do this in the Portal Engine (but as far as I know the layout for a web part/widget is the same as an aspx page). I could also try and do this within the code behind of a User control (i have tried this with no success) and make a web part out of that, but I have the same issue with that, actually getting to the related pages of the current document. All I need is the related documents (list of TreeNode s) of the current document. DocumentContext.CurrentDocument.RelatedPages gives me a TreeNodeRepository and it doesn't seem to have anything in it or I don't know how to get stuff out of it.

0 votesVote for this answer Mark as a Correct answer

Peter Mogilnitski answered on February 17, 2017 01:22 (last edited on February 17, 2017 02:05)

Here is how you do it using web parts:

  1. Go to Properties Tab->Related Pages and add a related page Image Text

  2. Swith back to design tab add the web part called "related pages" Image Text

  3. You can use default transformation for now and choose your relationship name (the same one as on the 1st step) Image Text

  4. Here is what you see in design mode Image Text

  5. Switch to Preview(Page tab) and now you see it: Image Text

0 votesVote for this answer Mark as a Correct answer

Peter Mogilnitski answered on February 17, 2017 02:02 (last edited on February 17, 2017 02:08)

Here is how you can do it using macros:

  1. Go your page type (CMS.Root in my example) and add new text/xml transformation Image Text

  2. Go to your page and add static text web part: Image Text

  3. Add macro as I described above to Content\Text : Image Text

  4. Save, Close, Switch to Preview

1 votesVote for this answer Mark as a Correct answer

Chetan Sharma answered on February 17, 2017 17:17

This can be achieved totally Out of the box.

Luckily I wrote an article about on how to achieve it step by step

Getting related pages of Current Document

This will definitely help you.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.