I am trying to create a simple Image controller Rendering and I don't want to add the template interface to my page type, because I want to add the image dynamicaly to my site.
So here my "problems" begin.
I've created a simple Controllerrendering with a viewmodel
public class PageImageViewModel
{
public HtmlString PageImage { get; set; }
}
as simple Controller call to my ModelBuilder
public ActionResult PageImage()
{
return View(PageImageModelBuilder.GetPageImageViewModel(RenderingContext.Current.Rendering.Item));
}
and the modelbuilder
public PageImageViewModel GetPageImageViewModel(Item currentItem)
{
var model = new PageImageViewModel();
model.PageImage = new HtmlString(FieldRenderer.Render(currentItem, Templates.PageImage.Fields.Image_FieldName));
return model;
}
and the view
@using Bazar.Feature.PageContent
@model Bazar.Feature.PageContent.Models.Models.PageImageViewModel
<div class="">
<p>Hallo Welt</p>
@Model.PageImage
</div>
thats the codeside I think that should work.
and now the sitecore elments
- I've created a Interface Template for my _PageImage
- I've created the Controller rendering
- And I've tried to add this new control to my "Home" view where I've some dynamic placeholders but I don't get the modal where I can choose what Image I want to see.
- try to add the controller rendering to my page
- but after that no image selection is opened and the final layout looks like