-
Notifications
You must be signed in to change notification settings - Fork 49
Home
Copyright (C) Pilotine - ZpqrtBnk 2013
Distributed under the MIT license
An experimental tool that can generate a complete set of strongly-typed published content models for Umbraco 6.2+ to be used in the MVC views. Either from the Umbraco UI, from the command line, or from Visual Studio.
DISCLAIMER: THIS CODE IS UNSTABLE AND FOR INFO ONLY !!
It runs on a modified 6.2.0 Umbraco version so it will not compile on the stock code from Umbraco's repo.
Install the Visual Studio extension.
Create a file named "Foo.cs" in your solution.
Set the "Custom Tool" for that file to "ZbuModelsBuilder"
Set the "Custom Tool Namespace" for that file to "MyModels"
Save the file...
And it will generate, underneath that file, NewsItem.generated.cs, corresponding to your NewsItem content type, looking like:
public partial class NewsItem : PublishedContentModel
{
public string Title { get { return this.GetPropertyValue<string>("title"); } }
public IHtmlString BodyText { get { return this.GetPropertyValue<IHtmlString>("bodyText"); } }
}
And then create an MVC view such as
@inherits UmbracoViewPage<NewsItem>
<h1>@Model.Title</h1>
@Model.BodyText
And enjoy!
Well -- it won't work for you, because a few stuff are missing or hard-coded (connection string...) at the moment. Plus it requires a version of 6.2.0 that has a few things made public instead of internal.
But... time will come...