dotnetnukedotnetnuke-9

DNN Theme. How to populate DropDownList values from a setting?


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?


Solution

  • 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);
    
        }