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

Forums / Developing with Sitefinity / Reference edited item in customized GenericContentDesigner

Reference edited item in customized GenericContentDesigner

9 posts, 0 answered
  1. MikaelK
    MikaelK avatar
    12 posts
    Registered:
    23 Jun 2010
    22 Sep 2010
    Link to this post
    Hi all,

    I'm working on a project where I'm in the need of extending the Generic Content control designer. I've downloaded the external templates and mapped it through the ControlsConfig.xml and added a code-behind file for the template. My question: Is it possible to get a reference to the edited generic content item from that code-behind file?

    br,
    Michael
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    22 Sep 2010
    Link to this post
    Hello MikaelK,

    You cannot get a reference to the item that is being edited from GenericContentDesigner template. You can do this if you override GenericContent class or GenericContentDesigner class from where you will have access to  ContentID

    Regards,
    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
  3. MikaelK
    MikaelK avatar
    12 posts
    Registered:
    23 Jun 2010
    22 Sep 2010
    Link to this post
    Hi Ivan,

    Thank's for the quick response.

    Ok. I tried the suggested method but had some difficulties initiate the RadEditor correctly. What is the preffered steps to take when overriding GenericContentDesigner?

    Thanks in advance,

  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    22 Sep 2010
    Link to this post
    Hello MikaelK,

    You can take a look at this KB.

    Kind regards,
    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
  5. MikaelK
    MikaelK avatar
    12 posts
    Registered:
    23 Jun 2010
    22 Sep 2010
    Link to this post
    Hi Ivan,

    I've read the KB and uses that approach on another part of the site. The problem I'm facing here is that I try to implement a custom control designer by marking the wrapper class (GCWrapper in the KB) with the control attribute
    [ControlDesignerAttribute(typeof(MyCustomDesignerControl))].

    This works to an extent. The custom template is shown but the RadEditor is not initialized and I guess I have to override some of the base classes. Is there a KB for this too showing wich base classes to override (asuming this is a correct way of doing it)?

    /M
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    22 Sep 2010
    Link to this post
    Hi MikaelK,

    I checked the code and the Raditor is initialized and shows when you open the control for editing. You can also retrieve the ID inside Render. Please take a look at attached short video which uses the same control that is provided in the KB.

    All the best,
    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
  7. MikaelK
    MikaelK avatar
    12 posts
    Registered:
    23 Jun 2010
    22 Sep 2010
    Link to this post
    Hi,

    I have no problem with the render method since everything works fine in the design mode. Like in the KB I also have no problem editing when using the built-in generic content designer. It is when I try to implement a custom generic content designer by using the attribute [ControlDesignerAttribute(typeof(MyCustomDesigner))] the problem arise. The custom control designer is loaded but no content in RadEditor and I asume I have to override some of the base classes in Telerik.Cms.Engine.WebControls.Design.GenericContentDesigner

    My wrapper:

        [DefaultProperty("ContentTitle")]
        [ToolboxItem(typeof(MyCustomToolboxItem))]
        [ToolboxData("<{0}:ServerControl1 runat=server></{0}:ServerControl1>")]
        [ControlDesignerAttribute(typeof(MyCustomDesigner))]
        public class GenericWrapper : GenericContent
        {
             ...

    My custom content designer:
    public class MyCustomDesigner: Telerik.Cms.Engine.WebControls.Design.GenericContentDesigner

    In MyCustomDesigner I asume I have to override som of the base classes. 

    Is this a valid approach?

    /M

  8. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    22 Sep 2010
    Link to this post
    Hi MikaelK,

    Yes this is the correct way and inside the designer you could override LayoutTemplatePath to set the path to your template.

    Best wishes,
    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
  9. MikaelK
    MikaelK avatar
    12 posts
    Registered:
    23 Jun 2010
    22 Sep 2010
    Link to this post
    Hi,

    Ok. I solved the problem. For some reason I had to build my solution twice for the changes to have effect. Strange... Your help is much appreciated and certainly showed me in the right direction.

    Wish You the best,
    /M 
Register for webinar
9 posts, 0 answered