I have been working on a DNN theme for several clients. The theme has a DropDownList and its values are different for each client. I do not want to create many themes (one per client) because the DropDownList values are the only difference between them.
How can I fill in the DropDownList values based on some theme configuration?
In order to implement this behivor on my theme I use DotNetNuke.Common.Utilities.Config class.
You can do this manually:
<add key="DropDownListValues" value="Value1,Value2,Value3" />
...or you can add these values from code:
public static void AddAppSetting(string name, string value)
{
var xmlDocument = DotNetNuke.Common.Utilities.Config.AddAppSetting(DotNetNuke.Common.Utilities.Config.Load(), name, value);
DotNetNuke.Common.Utilities.Config.Save(xmlDocument);
}
Having this property you can always populate your DropDownList this way:
var stylesCommaSeparated = DotNetNuke.Common.Utilities.Config.GetSetting("DropDownListValues");
stylesCommaSeparated.Split(',').ForEach(setting=>DropDownList1.Items.Add(setting));