Try our conversational search powered by Generative AI!

Default renderer

Vote:
 

I have a ContentArea that pages can be added to and rather than creating a separate render for each type using a .cshtml I want one for the base class it's inherited from. I've tried generic controllers, overiding the editor and faking it http://joelabrahamsson.com/custom-rendering-of-content-areas/ and other techniques but I can't get it working.

#77271
Nov 14, 2013 11:39
Vote:
 

I have made this working by creating one View where model is basetype and then register this view in a InitializableModule that implements IViewTemplateModelRegistrator.

public void Register(TemplateModelCollection viewTemplateModelRegistrator)
        {
            viewTemplateModelRegistrator.Add(typeof(ContentBasePage),
                new EPiServer.DataAbstraction.TemplateModel()
                {
                    Name = "PageTeaser",
                    Description = "Displays a teaser of a page.",
                    Path = "~/Views/Shared/_PageTeaser.cshtml",
                    Inherited = true
                }
            );
        }

    

#77272
Nov 14, 2013 11:56
Vote:
 

Thanks Mari, I've just got this way working myself as well using the EpiServer MVC template as an example. I love this approach because of the ability to pass tags in so you can control which is used. I'll mark this as accepted as this is the best approach I've found

#77283
Nov 14, 2013 15:21
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.