Sitefinity ASP.NET CMS
Skip Navigation LinksSupport / Knowledge Base / Adding a custom provider for Generic Content

Adding a custom provider for Generic Content

Problem
My custom provider for Generic Content does not get selected in the providers dropdown list and I cannot edit or view its items at the Modules > Generic Content tab.
This behavior is specific to the Generic Content module only. Multiple providers work well with News and Blogs.

Solution
The temporary solution is to override the GenericContent module. Here are the steps:
1. Add the following files to the App_Code folder of your website:

GCCommandPanel_MultipleProvidersFix.cs:

using System; 
using System.Reflection; 
using Telerik.Cms.Engine.WebControls.Admin; 
 
/// <summary> 
/// New CommandPanel which overrides the ProviderName property 
/// </summary> 
public class GCCommandPanel_MultipleProvidersFix : CommandPanel 
    public GCCommandPanel_MultipleProvidersFix(GCControlPanel_MultipleProvidersFix ctrlPanel) 
        : base (ctrlPanel) 
    { 
    } 
 
    public override string ProviderName 
    { 
        get 
        { 
            Type typ = typeof(CommandPanel); 
            FieldInfo field = typ.GetField("providerName", BindingFlags.NonPublic | BindingFlags.Instance); 
            object fieldData = field.GetValue(this as CommandPanel); 
            return fieldData == null ? null : (string)fieldData; 
        } 
        set 
        { 
            Type typ = typeof(CommandPanel); 
            FieldInfo field = typ.GetField("providerName", BindingFlags.NonPublic | BindingFlags.Instance); 
            field.SetValue(this as CommandPanel, value); 
        } 
    } 
 

GCControlPanel_MultipleProvidersFix.cs:

using Telerik.Cms.Engine.WebControls.Admin; 
 
/// <summary> 
/// A new ControlPanel class with overridden constructor to specify the new CommandPanel to use 
/// </summary> 
public class GCControlPanel_MultipleProvidersFix : ControlPanel 
    /// <summary> 
    /// New constructor which selects the CommandPanel from App_Code 
    /// </summary> 
    public GCControlPanel_MultipleProvidersFix() 
    { 
        base.commandPnls = new CommandPanel[] { new GCCommandPanel_MultipleProvidersFix(this) }; 
    } 
 

GCModule_MultipleProvidersFix.cs:

using System.Web.UI; 
using Telerik.Cms.Engine; 
 
/// <summary> 
/// Inherits from the Generic Content module to override the method which chooses a ControlPanel for the module 
/// </summary> 
public class GCModule_MultipleProvidersFix : GenericContentModule 
    public GCModule_MultipleProvidersFix() 
    { 
         
    } 
 
    /// <summary> 
    /// This method is overridden to create an instance of the new ControlPanel in App_Code 
    /// </summary> 
    /// <param name="parent">The parent control of the ControlPanel</param> 
    /// <returns>The newly created Control Panel</returns> 
    public override Control CreateControlPanel(TemplateControl parent) 
    { 
        return new GCControlPanel_MultipleProvidersFix(); 
    } 
 

2. Change the Generic content module type in the web.config:

    <framework> 
      <modules> 
        <add type="GCModule_MultipleProvidersFix" /> 
 

Article Info

Article relates to 3.2 SP2 Hotfix (1616)
Created by Vladimir Vasilev
Last modified by Rebecca
Related categories: Workarounds

About Telerik

Telerik, the publisher of Sitefinity CMS, is leading vendor of ASP.NET AJAX, Silverlight, WinForms and WPF controls and components, as well as .NET Reporting and .NET ORM solutions. Building on its solid expertise in interface development and Microsoft technologies, Telerik helps customers build applications with unparalleled richness, responsiveness and interactivity. Created with passion, Telerik products help thousands of developers every day to be more productive and deliver reliable applications under budget and on time. Read more about Telerik

Copyright © 2002-2009 Telerik. All rights reserved. Powered by Sitefinity