Created
June 1, 2015 10:56
-
-
Save mortenbock/664eb69ea7369bb4560a to your computer and use it in GitHub Desktop.
Generic Ditto views
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>()); } | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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