Sunday, February 20, 2011

Creating a DNN module


Below are the steps for creating a DNN module:

  1. Install DNN starter kit, this will let you to automate many of the procedures which you had to perform manually like creating manifest file, folder hierarchy, etc. You can download DNN starter kit from below link:

  1. Now create a new web project in visual studio and select DotNetNuke Compiled Module option(as shown in below image)

  1. In the newly created project you will get below:
    1. 3 user controls
    2. Classes for interacting with database and holding business logic.
    3. Files for installing and uninstalling database scripts while installing/uninstalling module.
    4. Manifest file (with extension .dnn)
    5. A documents folder containing files to tell you what to do next.
  2. Now right click the project name in solution explorer and select properties option there.
    1. Here under ‘Application’ tab set Assembly name and default namespace as desired.
    2. Under ‘Build’ tab select output path to bin folder of your DNN installation. This will save you effort to manually copy & paste .dll file from your module’s project folder to dnn website’s bin folder.
    3. Also you can place XCOPY command in “Build Events” tab to automatically copy ascx controls from your module’s project folder to DNN desktop module folder. For example in this case it will be somewhat like below:
XCOPY “/*.ascx” “” /q /y
Remember to place this on post build event only so as to avoid wrong controls from reaching your main folder.



(Above two steps are not mandatory, they are just to speed up your process by automating a few steps)

  1. By default, this template gives “YourCompany.Modules.” as default namespace for all classes, change it appropriately in all user controls, provider classes and controller classes.
  2. By default, view control has view control has a DataList control added to it, remove it and add your custom code. In this sample module I am going to show meaning of a word entered.
  3. Create logic as required in controls and controller classes and build your project.
  4. Now edit .dnn file and edit it for name, version and files.
  5. Now you need to register your newly created module with your dnn installation.
  6. For this create a new folder under desktop modules folder in your DNN installation and copy paste below files into it:
    1. App_LocalResources, whole folder
    2. ASCX files
    3. SQLDataProvider files
    4. Uninstall. SQLDataProvider files
    5. Module.css
  7. Now login as host user and go to Module Definition section under host menu, click on “create new module” option.
  8. There will be a drop down saying “Create Module From:”, select manifest in it.
  9. Now select folder you created for new module from the drop down list, after doing so “Resource” drop down will get populated with manifest file name.
  10. Now click “Create Module” link.
 

 












That’s it your module is ready to be placed on any page.

About Me

My photo
Delhi, India
Fun, music, travel and nature loving, always smiling, computer addict!!