dotnetnukedotnetnuke-module

How to Programatically Create Page on Module Installation?


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?


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!!