Skip to content

Instantly share code, notes, and snippets.

@ps-team
Created October 27, 2017 08:11
Show Gist options
  • Save ps-team/ab722fef93e97bf21a247a2eac69a7d9 to your computer and use it in GitHub Desktop.
Save ps-team/ab722fef93e97bf21a247a2eac69a7d9 to your computer and use it in GitHub Desktop.
Loading in related content from Contensis and rendering it on a page. Useful for "shared" content.
@{
// This lets us load in content added through relationships and use it in the page
// as though it is part of the CurrentNode.
var requiredModules = CurrentNode.RelatedNodes("RequiredModules"); //name of relationship in Contensis
}
@if (!String.IsNullOrEmpty(requiredModules.ToString()))
{
if (requiredModules.Count >= 1)
{
foreach (var relatedItem in requiredModules)
{
//Then you can do...
var id = relatedItem.ID;
string itemTitle = relatedItem.Title.ToString();
// and so forth
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment