I need to access to the Main Page information from any of the Secondary Pages (1,2,3,4...) using a page relationship, and then retrieve the relationship list from the main page, in this case SecondaryPage1,SecondaryPage2,SecondaryPage3, etc..
I have the following structure MainPage (Page Type e.g. Article) isRelatedTo:
- SecondaryPage1 (Page Type: e.g. Item)
- SecondaryPage2 (Page Type: e.g. Item)
- SecondaryPage3 (Page Type: e.g. Item)
- SecondaryPage4 (Page Type: e.g. Item)
- SecondaryPage5 (Page Type: e.g. Item)
Is there an easy way to do it? I am using a CMSRepeater to display the items. I am thinking on creating a custom CMSRepeater for this specific scenario but I would like to know if there is a different approach.
So, to recap, The SecondaryPage1 isRelatedTo MainPage on the right side.
MainPage -> isRelatedTo -> SecondaryPage1
I am trying the display whole list from the MainPage, I need to access to that information on any of the secondary pages.
I created this code, it works pretty well I am just trying to discover is there is simpler solution or if there is an alternative.
....
List<CMS.DocumentEngine.TreeNode> mainRelatedItems = new List<CMS.DocumentEngine.TreeNode>();
mainRelatedItems.AddRange(DocumentHelper.GetDocuments().Types(PageTypes.Split(';')).InRelationWith(CurrentDocument.NodeGUID, PageRelationship, relationshipSide));
List<CMS.DocumentEngine.TreeNode> secondaryRelatedItems = new List<CMS.DocumentEngine.TreeNode>();
foreach (CMS.DocumentEngine.TreeNode item in mainRelatedItems)
{
if(ExcludeCurrentDocument)
secondaryRelatedItems.AddRange(DocumentHelper.GetDocuments().Types(PageTypes.Split(';')).InRelationWith(item.NodeGUID, SecondLevelPageRelationship, secondaryRelationshipSide).Where(x => x.NodeGUID != CurrentDocument.NodeGUID));
else
secondaryRelatedItems.AddRange(DocumentHelper.GetDocuments().Types(PageTypes.Split(';')).InRelationWith(item.NodeGUID, SecondLevelPageRelationship, secondaryRelationshipSide));
}
....
CustomRepeater.ItemTemplate = TransformationHelper.LoadTransformation(CustomRepeater, TransformationName);
CustomRepeater.DataSource = secondaryRelatedItems;
CustomRepeater.DataBind();
....