-
Notifications
You must be signed in to change notification settings - Fork 0
Razor Views
In order to use Concrete Models easily in your Razor Views you can inherit from the generic ConcreteViewPage, passing in a Type that was created by Concrete.
@inherits ConcreteContentTypes.Core.ViewTemplates.ConcreteViewPage<BlogPostRepository>
This will then give you a strongly typed Model property of type BlogPostRepository.
The type argument must be a class that inherits from the Concrete IConcreteModel interface.
As the Model property has been replaced by our strongly typed model there is a new RenderModel property which gives access to the underlying Umbraco RenderModel.
The ConcreteViewPage inherits from the UmbracoTemplatePage which means you still have access to the same properties you would in a standard Umbraco razor view.
All Concrete model classes have a property called Content which is the IPublishedContent item they are wrapping. This means that Model.Content will still give access to the IPublishedContent object.
Also because the ConcreteViewPage inherits from the UmbracoTemplatePage the dynamic CurrentPage object is still available. This means you can switch to the ConcreteViewPage without having to rewrite the entire template straight away.
@Model - Our Concrete Model
@Model.Content - The IPublishedContent object for the current page
@RenderModel - What used to be @Model
@CurrentPage - The standard dynamic object from UmbracoTemplatePage