Skip to content

Instantly share code, notes, and snippets.

@mortenbock
Created June 1, 2015 10:56
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 mortenbock/664eb69ea7369bb4560a to your computer and use it in GitHub Desktop.
Save mortenbock/664eb69ea7369bb4560a to your computer and use it in GitHub Desktop.
Generic Ditto views
using System.Web.Mvc;
using Our.Umbraco.Ditto;
using Umbraco.Core.Models;
using Umbraco.Core.Models.PublishedContent;
using Umbraco.Web.Models;
using Umbraco.Web.Mvc;
namespace MappingDemo.Custom.Mvc
{
public abstract class DittoTemplatePage<T> : UmbracoTemplatePage where T : class
{
private T _mapped;
public T MappedContent
{
get {return _mapped ?? (_mapped= Model.Content.As<T>()); }
}
}
}
@inherits MappingDemo.Custom.Mvc.DittoTemplatePage<MappingDemo.Custom.Models.HomePage>
@{
Layout = "Master.cshtml";
}
<h1 style="color: red">@MappedContent.Name</h1>
<p>@MappedContent.SiteTitle</p>
@CurrentPage.GetGridHtml("content", "fanoe")
using Umbraco.Core.Models;
using Umbraco.Core.Models.PublishedContent;
namespace MappingDemo.Custom.Models
{
public class HomePage : PublishedContentModel
{
public string SiteTitle { get; set; }
public HomePage(IPublishedContent content) : base(content)
{
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment