Best way to extend content module and modify layout?
How would I go about extending the Content Block module and override it's Render method for the purpose of changing the layout? I get errors every time I attempt it, adding it to the App_Code folder then trying to add it to the ContentToolBox.
Hi Preston,
What kind of errors are you getting?
Sitefinity 4.0 Beta is a web application. App_Code folder is not supported in web application projects. The App_Code folder is compiled at run time where as the web application requires pre-run compilation. Try creating a code library project, place your code there build into an assembly and add it to the bin folder of your website. Or if you insist on using App_Code, you need to compile the application first.
Best wishes,
Radoslav Georgiev
the Telerik team
Hi Preston,
Thank you for getting back to me.
When overriding built in controls you have to override the template path so that it does not try to load it from the embedded resource (original template). This principle is the same as with Sitefinity 3.x controls. Attached is sample project.
Kind regards,
Radoslav Georgiev
the Telerik team
Shouldn't I be able to override the template path via the configuration in the LayoutTemplate field?
LayoutTemplate
~/controls/CustomContentBlock.ascx
Specifies the name of an embedded layout template or the path to an external (.ascx) template.
rather than override it in the class?
Hello Preston,
ContentBlock control has a public property LayoutTemplatePath that you can set from its Advanced settings. There are some caching issues when you work with the configuration.
Of course overriding the property is an option.
Greetings,
Ivan Dimitrov
the Telerik team