Skip to content

Instantly share code, notes, and snippets.

@mortenbock
Created June 1, 2015 11:49
Show Gist options
  • Save mortenbock/19a5686939d61240ecc3 to your computer and use it in GitHub Desktop.
Save mortenbock/19a5686939d61240ecc3 to your computer and use it in GitHub Desktop.
Generic Ditto take 2
using Our.Umbraco.Ditto;
using Umbraco.Core;
using Umbraco.Core.Models.PublishedContent;
namespace MappingDemo.Custom.Mvc
{
public class ConfigFactory : ApplicationEventHandler
{
protected override void ApplicationStarting(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
PublishedContentModelFactoryResolver.Current.SetFactory<PublishedContentModel>();
}
}
}
@inherits UmbracoTemplatePage<MappingDemo.Custom.Models.HomePage>
@{
Layout = "Master.cshtml";
}
<h1 style="color: red">@Model.Content.Name</h1>
<p>@Model.Content.SiteTitle</p>
@Model.Content.GetGridHtml("content", "fanoe")
using Umbraco.Core.Models;
using Umbraco.Core.Models.PublishedContent;
namespace MappingDemo.Custom.Models
{
[PublishedContentModel("Home")]
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