More in this section

Forums / Developing with Sitefinity / Convert “Intra-site” module to “Pluggable”

Convert “Intra-site” module to “Pluggable”

4 posts, 0 answered
  1. Developer
    Developer avatar
    10 posts
    Registered:
    02 Aug 2007
    15 Aug 2007
    Link to this post
    Hi All,

    For a project I am working on there are some modules which used in the v2.7 and are intra-site modules.

    We are trying to make them work with V3.0, but we want to change them to be pluggable modules.

    Does it mean we need  create a classlibrary project and write all the .ascx code in the .cs file?  Eg: "HtmlGenericControl div = new HtmlGenericControl("div");               div.Attributes.Add("id", "cart");"

    We noticed there are a lot of ascx files that need to be converted and this looks very time consuming.
    Perhaps we are looking at this incorrectly and there is an easier way to do it. Could someone with more experience comment on this one for me?

    Thanks.

  2. Pepi
    Pepi avatar
    981 posts
    Registered:
    31 Jan 2017
    15 Aug 2007
    Link to this post
    Hi,

    It will be much easier for you to convert the existing Sitefinity v2.x modules to v3.0 Intra-site modules. But if you decide to convert them to pluggable it is not necessary to create the user interface programatically. You could use templates for implementing it. In fact, you already have them because templates are .ascx files where you can set inner controls declaratively and wrap them with any HTML.

    In the attachment you could find a template and the corresponding server control using it.

    Don’t hesitate to contact us if you come up with other questions.

    Best wishes,
    Pepi
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. Developer
    Developer avatar
    10 posts
    Registered:
    02 Aug 2007
    16 Aug 2007
    Link to this post
    Thank for your response.
    "You could use templates for implementing it. In fact, you already have them because templates are .ascx files where you can set inner controls declaratively and wrap them with any HTML. "

    Dose it mean we can put the ascx files into a folder , and then we write some code load the ascx file as the template ,
    Eg"
    string path = "~/Sitefinity/Admin/ControlTemplates/template.ascx
    this.template = this.Page.LoadTemplate(path);
    this.tmpPermissions.InstantiateIn( container)
    this.Controls.Add( container );
    ".
  4. Pepi
    Pepi avatar
    981 posts
    Registered:
    31 Jan 2017
    16 Aug 2007
    Link to this post
    Hello Developer,

    A good programming practice is to work with properties - in your case you need a property for the template and a property for the path to the template:

                /// <summary> 
            /// Gets or sets the template used by ImageControlDesigner control 
            /// </summary> 
            public ITemplate ItemTemplate 
            { 
                get 
                { 
                    return this.itemTemplate; 
                } 
                set 
                { 
                    this.itemTemplate = value
                } 
            } 
     
            /// <summary> 
            /// Gets or sets the path of the template used by ImageControlDesigner control 
            /// </summary> 
            public string ItemTemplatePath 
            { 
                get 
                { 
                    string value = (string)this.ViewState["ItemTemplatePath"]; 
                    return String.IsNullOrEmpty(value) ? "~/Sitefinity/Admin/ControlTemplates/ControlEditors/ImageControlDesigner.ascx" : value; 
                } 
                set 
                { 
                    this.ViewState["ItemTemplatePath"] = value; 
                } 
            } 

    After that you need to implement this piece of code in CreateChildControls() method:

       protected override void CreateChildControls() 
            { 
                this.Controls.Clear(); 
     
                this.cnt = new Container(this); 
     
                if (this.itemTemplate == null) 
                { 
                    if (this.Page != null) 
                    { 
                        string path = this.ItemTemplatePath; 
     
                        if (File.Exists(this.Page.MapPath(path))) 
                             this.itemTemplate = this.Page.LoadTemplate(path); 
                    } 
                } 
     
                this.itemTemplate.InstantiateIn(this.cnt); 
     
                this.Controls.Add(this.cnt); 
            } 

    this.cnt is a private variable of type your container. Your container is a class inheriting GenericContainer base class.

    You could find more information for building pluggable modules in Sitefinity blog.

    Hope this is helpful.

    Best wishes,
    Pepi
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
Register for webinar
4 posts, 0 answered