Question

I have a custom DNN module that I'm working on that I need to create an Admin Page when the module is installed within a DNN instance. I have creating the page handled, but getting code to run when the module is installed/upgraded is something I haven't figured out.

How do you wire up code to be executed as part of the installation/upgrade of a DNN module?

Was it helpful?

Solution

I've been successful with using IUpgradeable as part of the install. You specify a method in a core module class (FeatureController.cs if using the Christoc.com template) in the dnn install manifest file.

This [class].UpgradModule is executed after the app restart (happens after a module install/config change for the module version(s) specified).

It's quite "elegant"...the DNN install schedules an "eventexecution" as specified in the manifest and you can run whatever code you desire.

My manifest (modulename.dnn) had an eventMessage attribute (placed after the desktopModule element). Ex:

<eventMessage>
  <processorType>DotNetNuke.Entities.Modules.EventMessageProcessor,DotNetNuke</processorType>
  <processorCommand>UpgradeModule</processorCommand>
  <attributes>
    <businessControllerClass>SSI.DNN.SSIReplicationModule.Controllers.FeatureController, SSIReplicationModule</businessControllerClass>
    <desktopModuleID>[DESKTOPMODULEID]</desktopModuleID>
    <upgradeVersionsList>00.00.01</upgradeVersionsList>
  </attributes>
</eventMessage>

Whatever is in:

<businessControllerClass>SSI.DNN.SSIReplicationModule.Controllers.FeatureController, SSIReplicationModule</businessControllerClass>

With the method name:

<processorCommand>UpgradeModule</processorCommand>

will get executed at install.

Hope that helps...if you need code for the page creation and module add let me know.

My first SO post ever!!

OTHER TIPS

Apparently, there's a new way to do it, but so far I haven't found documentation. It looks like this:

<desktopModule>
...
  <page type="Admin" common="true">
    <name>Configuration Manager</name>
    <icon>~/Icons/Sigma/Configuration_16X16_Standard.png</icon>
    <largeIcon>~/Icons/Sigma/Configuration_32X32_Standard.png</largeIcon>
    <description>Modify configuration settings for your site</description>
  </page>
  ....
</desktopModule>

Not sure when this was added, but I found it in source code of DNN 8.0.3.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top