Skip to content

Instantly share code, notes, and snippets.

@greystate
Forked from kgiszewski/gist:8863822
Last active August 29, 2015 14:07
Show Gist options
  • Save greystate/933394d9739eab22efdf to your computer and use it in GitHub Desktop.
Save greystate/933394d9739eab22efdf to your computer and use it in GitHub Desktop.
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@using Archetype.Models;
@using Archetype.Extensions;
@{
Layout = null;
}
//use case #1 - Covers a single Archetype
@foreach (var fieldset in Model.Content.GetPropertyValue<ArchetypeModel>("a1"))
{
<!-- get a property by name -->
<div>@fieldset.GetValue("mntp")</div>
<!-- or -->
<!-- if using a property editor with a value converter -->
<div>@fieldset.GetValue<IEnumerable<IPublishedContent>>("mntp")</div>
}
//use case #2 - Covers nested Archetypes
@foreach (var fieldset in Model.Content.GetPropertyValue<ArchetypeModel>("a1"))
{
<div>@fieldset.GetValue("firstName")</div>
<!-- get nested Archetype -->
foreach(var nestedFs in fieldset.GetValue<ArchetypeModel>("movieList")){
<h3>@nestedFs.GetValue("title")</h3>
<div>@nestedFs.GetValue("text")</div>
}
}
//use case #2; be able to iterate over the properties, however this will not pass value through converters
@foreach (var fieldset in Model.Content.GetPropertyValue<ArchetypeModel>("a1"))
{
<!-- will not go through value converters -->
foreach (var prop in fieldset.Properties)
{
<div>@prop.Value</div>
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment