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" /> |
| |