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

Forums / Developing with Sitefinity / Move provider selector of Modules to controlPanel

Move provider selector of Modules to controlPanel

8 posts, 0 answered
  1. Pierre
    Pierre avatar
    433 posts
    Registered:
    16 Feb 2006
    17 Apr 2009
    Link to this post
    Hi,

    I need to move the provider selector from command panel (News, GC modules) to ControlPanel of ItemsList template and select one provider of this selector using some codebehind. Could you point where to found this selector and resources registred and some steps to make this change, plz.

    Regards
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    20 Apr 2009
    Link to this post
    Hi Pierre,

    Generally, when you register a new provider through your web.config file a drop down with collection of your providers is shown on the upper left corner. Are you talking about this section or your approach is different.

    Sincerely yours,
    Ivan Dimitrov
    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.
  3. Pierre
    Pierre avatar
    433 posts
    Registered:
    16 Feb 2006
    20 Apr 2009
    Link to this post
    Hi Georgi,

    Yes, i speak about this selector. I have added providers and some news Views to my module with steps ( choose1, choose2, and post news). This selector here is confusing. I would add at top of NewsItemsList template just before push the addnews button and be able to select some provider programmatically in codebehind of this template. Other solution is hide if is need here and change programmatically from come code in side the view or in codefile.
    Could you help me to move to the List template, is possible? and how to define the provider at page load event or similar.
    Regards.
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    21 Apr 2009
    Link to this post
    Hi Pierre,

    There is no easy way to hide ProviderSelectorPanel. Hiding require following steps.

    1.Create a class that inherits module control panel and returning a null or another control

    Example:

    public class MyPanel : NewsControlPanel 
    {   
       protected override Telerik.Web.ICommandPanel CreateProviderSelectorPanel() 
        { 
            return null
        } 

    2. Create a class that inherits desired module and using the newly created panel.

    using System; 
    using System.Collections.Generic; 
    using System.Linq; 
    using System.Web; 
    using Telerik.News; 
     
    /// <summary> 
    /// Summary description for TEST1 
    /// </summary> 
    public class MyModule : NewsModule 
        public override System.Web.UI.Control CreateControlPanel(System.Web.UI.TemplateControl parent) 
        { 
            return new MyPanel(); 
        } 
     

    3. Using the new module instead a default one.

    Greetings,
    Ivan Dimitrov
    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.
  5. Pierre
    Pierre avatar
    433 posts
    Registered:
    16 Feb 2006
    21 Apr 2009
    Link to this post

    Hi,

    Thanks, this logical could help to hide the provider selector inside the command panel. Now, I need to define programaticaly the provider and add-in NewsItemsList View using some registred statement?. Could you help us more in this steps?.

    Regards. 

  6. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    24 Apr 2009
    Link to this post
    Hello Pierre,

    The problem with the defining of the a new provider is that you should have it in the web.config file, otherwise Sitefinity will never get to know it. So, if you manage to write in the web.config file, you will be able to define providers. Note that when you change the web.config file, the application is being restarted, so you should handle this case as well. If you have more than one provider, the drop down will appear automatically so you do not need to anything in NewsItemsList.

    Kind regards,
    Georgi
    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.
  7. Pierre
    Pierre avatar
    433 posts
    Registered:
    16 Feb 2006
    24 Apr 2009
    Link to this post
    Hi Georgi,

    Sorry my question is not well formuled. My providers are defined in web.config, after hiding the provider selector inside command panel of my module what is the way to selecting the provider programmatically when load my template ItemsList?
    Thanks.
  8. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    24 Apr 2009
    Link to this post
    Hi Pierre,

    In your module you could initialize a new instance of your ModuleManager class for a specific provider

        public class MyModuleManager 
        { 
            
            #region Constructors 
     
            static MyModuleManager() 
            { 
                foreach (GenericContentElement element in ConfigHelper.Handler.GenericContentProviders) 
                    MyModuleManager.contentSettings.Add(element.ProviderName, element); 
            } 
            public MyModuleManager(string providerName) 
            { 
                if (string.IsNullOrEmpty(providerName)) 
                    providerName = DefaultContentProvider; 
                this.settingsElement = MyModuleManager.contentSettings[providerName]; 
     
            } 

    Then in the control panel you can get the manager and provider.

       public MyModuleManager MyModuleManager 
            { 
                get 
                { 
                    if(this.moduleManager == null
                        this.moduleManager = new MyModuleManager(this.ProviderName); 
                    return this.modulesManager; 
                } 
            } 
            private MyModuleManager moduleManager; 

    This you are getting the provider.
    Another option is creating a hardcoded provider.

     public override string ProviderName 
        { 
            get 
            { 
                base.ProviderName = hardCodedProvider; 
                return hardCodedProvider; 
            } 
            set 
            { 
                base.ProviderName = hardCodedProvider; 
            } 
        } 
     
     
        private const string hardCodedProvider = "LibrariesCUSTOMPROVIDER"


    Sincerely yours,
    Ivan Dimitrov
    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
8 posts, 0 answered