More in this section

Forums / Developing with Sitefinity / Implementing predefined template solution KB #1200

Implementing predefined template solution KB #1200

3 posts, 0 answered
  1. Nick Pearce
    Nick Pearce avatar
    8 posts
    22 Apr 2008
    02 Mar 2009
    Link to this post
    I've successfully implemented the prototype 'predefined template' described here.

    To make it useful, I need to be able to run different 'predefined templates' for different templates (master pages).

    I've tried a few approaches and none seem satisfactory:

    - Put the code in the .master.cs file of the particular template. This works somewhat, but is called every time a page is loaded. I have to check for the existence of the controls every time. That's not efficient or elegant. I saw that I could also check for Status=Published except that it remains as 'New' while the page is created, previewed and published the first time.

    - Catch a 'template changed' PageActionExecuted event and then read the template type. However, the only events that fire seem to be "CreatePage", "Publish", "PublishNew", "DeletePage". Is there an equivalent event I can subscribe to when the template changes?

    - Add a new page property that defines the 'predefined template' and set the template and load the controls programatically when the 'CreatePage' event fires. This way, we'll know the template to use. (I'm not sure how to add an additional page property and this method wouldn't work when switching templates for an existing page).

    Can you agree with any of these approaches or suggest a better way of doing this?

    Many thanks.

    (It seems to be a basic need that a few customers have asked for so perhaps you can roll a 'predefined templates' feature into v4).

  2. Nick Pearce
    Nick Pearce avatar
    8 posts
    22 Apr 2008
    04 Mar 2009
    Link to this post
    Any bites on this from the Telerik folks?
  3. Georgi
    Georgi avatar
    3583 posts
    28 Oct 2016
    07 Mar 2009
    Link to this post
    Hi Nick Pearce,

    I think that the easiest way in this case will be to have separate templates with all the controls predefined in them. Yes, you will have a longer list of templates, but you will skip the coding, and you will maintain these templates easier. Then you can train your users to manually assign the right templates.

    We have scheduled to use the Metafields approach for the page properties as well. Now, you can try to add a page property as described in the article Page Meta Data - Intercepting Sitefinity .

    There is no event raised when the template is changed, but I have logged this. We should really raise more events to which you can attach.

    These are the only suggestions that I come up with so far.

    Best wishes,
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
Register for webinar
3 posts, 0 answered