Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I solved my own question with the code below. It's not the preferred solution, but I had success using it and it will do until DNN implements a real solution.</p> <p>All methods from the <code>Controller</code> class connect a custom table in the database. The code checks for all module definitions if they are on the current page (tab) and not already in the db. If not it will add it to the db combined with a new instance id. If 2 or more of the same modules are added to the page and this code runs later (e.g. update), it will only get the module ids that are sequential (the other module ids will be added later).</p> <pre><code>ModuleInstanceId = Controller.GetModuleInstanceId(TabModuleId); if (ModuleInstanceId == -1) { Dictionary&lt;Int32, String&gt; ModuleInstanceDefinitions = new Dictionary&lt;Int32, String&gt;(); Dictionary&lt;String, ModuleDefinitionInfo&gt; ModuleDefinitions = new ModuleController().GetModule(ModuleId).DesktopModule.ModuleDefinitions; foreach (ModuleDefinitionInfo ModuleDefinition in ModuleDefinitions.Values) { List&lt;ModuleInfo&gt; Modules = new ModuleController().GetModulesByDefinition(PortalId, ModuleDefinition.FriendlyName).ToList&lt;ModuleInfo&gt;(); foreach (ModuleInfo Module in Modules) { if (Module.TabID == TabId) { if (Controller.GetModuleInstanceId(Module.TabModuleID) == -1 || Controller.GetModuleInstanceId(ModuleDefinition.FriendlyName) == -1) { ModuleInstanceDefinitions.Add(Module.TabModuleID, ModuleDefinition.FriendlyName); } } } } // Probably shouldn't be more then specified in the manifest; // Only situatie this could occure is when the module is added to a page twice at the same page; ModuleInstanceDefinitions = ModuleInstanceDefinitions.OrderBy(ModuleDefinition =&gt; ModuleDefinition.Key).Take(ModuleDefinitions.Count).ToDictionary(Item =&gt; Item.Key, Item =&gt; Item.Value); ModuleInstanceId = Controller.SetModuleInstances(ModuleInstanceDefinitions); } </code></pre> <p>Hopefully someone will find this useful or DNN will add it in the source :)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload