More in this section

Forums / Developing with Sitefinity / Creating module inheriting from Generic Module

Creating module inheriting from Generic Module

4 posts, 0 answered
  1. Schneider
    Schneider avatar
    29 posts
    Registered:
    02 Nov 2008
    12 Nov 2008
    Link to this post
    Hi,

    We are trying to create our first module that inherits from Generic Module.

    Not going terribly smoothly so far but we are slowly making progress. It would be helpful if there was sample code which does this but it seems they do not inherit from the Telerik.Cms.Engine.WebControls.Admin.ControlPanel and Telerik.Cms.Engine.WebControls.Admin.CommandPanel classes.

    Anyway inheriting from Cms.Engine.WebControls.Admin.ControlPanel works fine and it allows us to override the template path properties e.g.  ListTemplatePath

    But for Telerik.Cms.Engine.WebControls.Admin.CommandPanel there is no way we can see to override the template path.

    How do we set the template for the CommandPanel?

    Thanks,
    Jack
  2. Pepi
    Pepi avatar
    981 posts
    Registered:
    31 Jan 2017
    12 Nov 2008
    Link to this post
    Hello Schneider,

    Please refer to the following Developer Manual topic that provides sample code for simple implementation of a Generic Content based module: Products Module: Simple Implementation

    Hope you will find the provided information helpful.

    Best wishes,
    Pepi
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. Schneider
    Schneider avatar
    29 posts
    Registered:
    02 Nov 2008
    12 Nov 2008
    Link to this post
    Hi thanks for the response.

    In the products sample the CommandPanel does not inherit from the Generic_Content command panel.

    We wanted to avoid have to write the entire CommandPanel from scratch.

    Is there another way to modify the template of the Generic_Content CommandPanel without a complete rewrite?
  4. Pepi
    Pepi avatar
    981 posts
    Registered:
    31 Jan 2017
    12 Nov 2008
    Link to this post
    Hello Schneider,

    The reason we have reimplemented CommandPanel is simply because Products module is a simple implementation and we did not want tags, categories, permissions and other commands there. Also, it is not necessary to override ItemTemplatePath property because its value is generated dynamically depending on the provider name.

    Here is a sample implementation of the CommandPanel class in case you don't want to create it from scratch:

    CommandPanel.cs
        [ToolboxItem(false)] 
        public class CommandPanel : Telerik.Cms.Engine.WebControls.Admin.CommandPanel 
        { 
            /// <summary> 
            ///     Creates instance of the control and gets reference for the 
            ///     <see cref="Telerik.Web.IControlPanel">IControlPanel</see> control to which it 
            ///     connects to. 
            /// </summary> 
            public CommandPanel(ControlPanel ctrlPnl) 
                : base(ctrlPnl) 
            { 
            } 
            #region Properties 
     
     
            /// <summary> 
            /// Gets or sets the provider name used by this control 
            /// </summary> 
            public override string ProviderName 
            { 
                get 
                { 
                    return this.providerName; 
                } 
                set 
                { 
                    this.providerName = value; 
                } 
            } 
            #endregion 
            #region Override Methods 
             
            /// <summary> 
            /// Overriden. Creates child controls of the command panel. 
            /// </summary> 
            protected override void CreateChildControls() 
            { 
                if (this.Page != null
                { 
                    // tries to retrieve provider name from the query string 
                    if (!this.Page.IsPostBack) 
                        if (!string.IsNullOrEmpty(this.Page.Request.QueryString["provider"])) 
                            this.providerName = this.Page.Request.QueryString["provider"]; 
     
                    if (String.IsNullOrEmpty(this.providerName)) 
                            this.providerName = ConfigHelper.Handler.DefaultContentProvider; 
     
                    if (String.IsNullOrEmpty(this.providerName)) 
                        return
                } 
     
                base.CreateChildControls(); 
            } 
            #endregion 
            #region Private Fields 
     
            private string providerName; 
            #endregion 
        } 

    Please note that your CommandPanel.ascx template must contain a LinkButton with ID="permissionViewButton" as it is a required control.

    Do let us know if this helps.

    Best wishes,
    Pepi
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Register for webinar
4 posts, 0 answered