Created
October 27, 2017 10:13
-
-
Save ps-team/311eef17bb4c9c228ca59099cfa1a85f to your computer and use it in GitHub Desktop.
Resolve a list of master pages from a listing of nodes - finds the most local version of the node by checking for other nodes in top level parent folder that have the same SynchronisationSourceMasterContentID. Notes: Make sure you output SynchronisationSourceMasterContentID by ticking the box in Project Settings > Project > Metadata. Then to for…
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@functions { | |
public ContentNode ResolveSynchedLink(ContentNode link) | |
{ | |
// if this a synched link then change path to the most local synched version | |
if (link.Data.SynchronisationSourceMasterContentID >= 0) | |
{ | |
int masterPageContentID = link.Data.SynchronisationSourceMasterContentID; | |
// get all nodes in current nodes parent node where masterPageContentID = masterPageContentID | |
foreach (ContentNode navItem in CurrentNode.Parent.AncestorAtDepth(1).Descendants().Where(wP => wP.IsWebPage && wP.Data.SynchronisationSourceMasterContentID == masterPageContentID).OrderBy(wP => wP.MenuOrder)) | |
{ | |
return navItem; | |
} | |
} | |
return link; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment