1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / General Discussions / Best way to extend content module and modify layout?

Best way to extend content module and modify layout?

6 posts, 0 answered
  1. prespsc
    prespsc avatar
    32 posts
    Registered:
    19 Apr 2010
    10 Sep 2010
    Link to this post
    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.
  2. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    13 Sep 2010
    Link to this post
    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
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. prespsc
    prespsc avatar
    32 posts
    Registered:
    19 Apr 2010
    13 Sep 2010
    Link to this post
    I have attached screen shots to show what I am attempting to do.  The toolbox does show the custom content block, but then displays the error after I add it to the page. 
  4. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    13 Sep 2010
    Link to this post
    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
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. prespsc
    prespsc avatar
    32 posts
    Registered:
    19 Apr 2010
    15 Sep 2010
    Link to this post
    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?
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    15 Sep 2010
    Link to this post
    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
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
6 posts, 0 answered