Skip to content

Instantly share code, notes, and snippets.

@barryokane
Last active April 14, 2016 00:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save barryokane/626e4aac093bd36966af50b205e6f86f to your computer and use it in GitHub Desktop.
Save barryokane/626e4aac093bd36966af50b205e6f86f to your computer and use it in GitHub Desktop.
Getting Nested Content property values from child pages.
@{
var root = Model.Content.AncestorOrSelf(1);
var pages = root.DescendantsOrSelf("DocTypeAlias");
foreach (var p in pages) {
var items = p.GetPropertyValue<IEnumerable<IPublishedContent>>("NestedContentPropertyName");
<div class="outer">
<h1><a href="@p.Url">@Umbraco.Field(p,"HeadingText")</a></h1>
<ul class="innerList">
@if (items != null) {
foreach(var item in items) {
var anchor = item.GetPropertyValue<string>("anchor");
<li class="list-group-item"><a href="@(p.Url()+ @siteQueryString + "#" + @anchor)">@Umbraco.Field(item, "menuLinkText")</a></li>
}
}
</ul>
</div>
</div>
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment