Skip to content

Instantly share code, notes, and snippets.

@bjarnef
Last active August 29, 2015 14:19
Show Gist options
  • Save bjarnef/a55a64c89ef53ff07c50 to your computer and use it in GitHub Desktop.
Save bjarnef/a55a64c89ef53ff07c50 to your computer and use it in GitHub Desktop.
Archetype Template Example
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@using Archetype.PropertyConverters;
@using Archetype.Models;
@using Archetype.Extensions;
@{
Layout = "Master.cshtml";
}
@foreach (var fieldset in Model.Content.GetPropertyValue<ArchetypeModel>("archetype"))
{
foreach (var prop in fieldset.Properties)
{
@*<div>@prop.Value</div>*@
if (prop.Alias == "headline" && prop.Value != "")
{
<h2>@prop.Value</h2>
}
if (prop.Alias == "pages" && prop.Value != "")
{
// https://our.umbraco.org/documentation/Using-Umbraco/Backoffice-Overview/Property-Editors/Built-in-Property-Editors/Multi-Node-Tree-Picker
// var typedMultiNodeTreePickerCSV = Model.Content.GetPropertyValue<string>("mntpFeaturePickerCSV");
var typedPublishedMNTPNodeListCSV = prop.Value.ToString().Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse);
IEnumerable<IPublishedContent> pages = Umbraco.TypedContent(typedPublishedMNTPNodeListCSV).Where(x => x != null);
<ul>
@foreach (var page in pages)
{
<li><a href="@page.Url">@page.Id - @page.Name</a></li>
}
</ul>
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment