Search code examples
dotnetnukednn9

How do I create a DNN module which can be placed on the same page multiple times with different content in the settings?


I am creating a module which will allow me to save HTML content in the settings section of the DNN module which will be stored on the Portal Settings.

How do I ensure my setting is unique only for the current container it is placed on? How can I get the ID of the current div the module is placed on?

Then I would be able to place the module in the exact same place. For example the Header and Footer section of the website.

So, if I can get ParentDivID and then append it at the end of the settings key.

For example: if (dictSettings.ContainsKey("GlobalHTML" + ParentDivID))

This is my current code for the DNN module Settings Codebehind

if (Page.IsPostBack == false)
{
    //Updated to use Portal Settings instead of per page per tab settings
    var dictSettings = m_PortalController.GetPortalSettings(PortalId);

    if (dictSettings.ContainsKey("GlobalHTML"))
    {
     txtGlobalHTML.Text = dictSettings["GlobalHTML"];
    }

}

Solution

  • You normally store store module settings in the ModuleSettings table of the ModuleController.

    var modules = new ModuleController();
    modules.UpdateTabModuleSetting(TabModuleId, "SettingKey", "SettingValue");
    

    But for HTML I would create a custom table that stores the HTML with a Primary Key and a TabModuleId column.