I have just realized that my first sentence might be misunderstood. So, if I create a container page from admin mode, everything behaves as it is supposed to.
When I create a "container" page (a page without a template) from admin mode, the icon looks as it is supposed to and this page is not rendered as expected (There is no preview for this page is displayed while edit mode loads).
When I create a "container" page (a page without a template) from admin mode, the icon looks as it is supposed to and this page is not rendered. This is expected (There is no preview for this page is displayed while edit mode loads).
Hi Marija,
The trick is to let your preview controller implement IRenderTemplate<BlockData> AND in the TemplateDescriptor attribute specify TemplateTypeCategory as TemplateTypeCategories.Page.
If you use something more general than BlockData the controller will be a preview for pages as well, but if you specify BlockData the controller will be registered as a partial renderer. Therefor you need to "force" it to be registered as a "full page" renderer.
Hi, Joel,
Thx a lot for your answer!
I am using MVC, so instead of TemplateTypeCategories.Page, this one works for me TemplateTypeCategories.MvcController.
When I create a "container" page (a page without a template) from admin mode, the icon looks as it is supposed to and this page is not rendered as expected (There is no preview for this page is displayed while edit mode loads).
However, when I create it programmatically, the PreviewBlockController gets called and I get the grey view instead of no view.
I cannot use BlockData instead of IContentData here (getting the exception):
public class PreviewBlockController : ActionControllerBase, IRenderTemplate<IContentData>
=>
public class PreviewBlockController : ActionControllerBase, IRenderTemplate<BlockData> (this gives an error, as the preview expects a PageData).
Is it possible to use preview page for blocks only and not as default controller?
This is the view:
This is the controller: