Closed ssatpa closed 7 years ago
Did you mean the possibility to pass a model to your view? If you are using a Sitecore ControllerRendering, you could execute every view with your custom model as you like.
Please read The Samples Page to get some examples about the usage of ControllerRenderings and special cases like "Model on layout level" made with the Sitecore IModelRendering
.
Hi @daniiiol ,
No I have created a ViewRendering and want to pass a model as we do using Sitecore model
Hello @ssatpa
Yes, of course! :)
Take the example I already mentioned in my post above to create a View Rendering or see my custom code below:
SampleContact RenderingModel:
public class SampleContactModel : IRenderingModel
{
public string Title { get; set; }
public void Initialize(Rendering rendering)
{
Title = FieldRenderer.Render(Sitecore.Context.Item, "Title");
}
}
And here my HBS File:
<div class="m-contact m-contact--" data-t-name="Contact">
<div class="m-contact__title">Test: {{{Title}}}</div>
</div>
Sitecore ViewRendering configuration
... and here my Model definition
... aaaannd finally you should see the result in the Experience Editor of Sitecore
Conclusion:
You could use View Renderings in NitroNet.Sitecore with creation of an own RenderingModel
class, derived from IRenderingModel
. But, you couldn't use View Renderings and enter Sitecore-Fields directly in your Handlebars-View as like as in Razor with the Sitecore @Html.Sitecore()
-Helper. For that, you need a special RenderingModel
or a ControllerRendering
.
Can I use NitroNetSitecore for a view rendering where I want to pass a sitecore model or using glassmapper ?