Hi,
I'm not a expert in developing modules or anything else. I'm just a guy that, just like you, have needs to develop modules in order of extending DNN for the Corp that I'm working.
I'm posting this forum so you can understand, in a easy way, how to develop a module for DNN and what is necessary for that. Maybe isn't the best way to do it but is going to help you how to create the module.
Developing a Module is not a hard or very difficult thing but there are some guidelines that you need to follow and so the module works fine with a DNN installation. The tutorial bellow should be used as a guideline about how to develop a DNN Module and the Module was developed to work with DNN 4.
Before start the module that I created was a variation of the FAQ's module from DNN. I added 2 more fields in the database and added settings for display on the module. I start the creation of the module from an existing module so I could use it as a guideline.
The module and source files can be downloaded at:
http://www.parkavenuerealtycorp.com/MyFAQsModule/tabid/366/Default.aspx
Pre-Requesites for development
- SQL Server
- .NET Framework
- Visual Web Developer 2005 (VWD205)
- DNN Starter Kit
Install the DNN Starter Kit. Open the VWD and create a new website. On the new screen that shows you going to have, if your installation of the DNN starter kit was successful, under my templates a template of DotNetNuke Web Application Framework.
It is going to create a new DNN website where you are going to use, for a start, to create your module. Right click on the website and add a new item. Another screen is going to shown and you have to choose the DotNetNuke Dynamic Module. Choose a name for your module and create.
It's going to create a new structure for the module and that what is important about this step. If you going to use the existing website to create and test your module or not that's up to you.
There are 2 folders that you need to change files in order to make your module work. What I did and worked was to copy all the files from this 2 folder to another folder and finished my development from there.
The first folder is the [app_code] folder. All the providers, controllers and module info are going to be here. Let's not get into what is what. You can find very reliable information in the Dotnetnuke.com about this. It's all about the Data Layer and what you really need to know is:
The DataProvider, SQLDataProvider and the Controller got to have the same structure in all Functions and Subs. Same order, same types, same everything or it simple won't work giving you errors such as "This cannot overright (...) because is not in the base class"
The Info file carries all the structure of the table or tables that you need for your module. If you need to develop more than one table you going to need a second info file and so on.
The second folder is the DesktopModules Folder. This folder holds all the user interface (aspx, aspx.vb files), the DNN configuration file (.dnn), the application local resources folders and files and the sql creation script.
Working with the SQL creation file (01.00.00.SQLDataProvider)
This is the first file that you need to work. There are 2 ways to work with this file. The first way is creating the tables and procedures in the database and then copy and past the creation scripts for this file but adding the {databaseOwner} and {objectQualifier} in the script. The second way is to create the tables and procedures in the file and then test in the database. As soon you finish this file change the Uninstall file so once your module is deleted in DNN, all tables and procedures have been delete also from the database.
Working with the [app_code] files
Before you go start creating the Providers files, create the Info files. These files will recreate the exact structure of each single table that you need to work in the database and they will help you with the parameter passing when adding, updating information or getting information from the database. All the columns of your table are going to be private members and the class will carry the Public Property functions that will set or retrieve the value of the private member.
Now you ready to create the providers class. In the SQLDataProvider most of the coding is already done for you but you will need to add or modify the public methods. The public methods will interact with your stored procedures so the best way to write them is following the same order that you used in the procedure for work. In the DataProvider file you will need to modify all the abstract methods. They have to carry the same order of parameters used in the SQLDataProvider. Finally the Controller file. In this file you will need to create all the public methods that will be called by your user interface class in the DesktopModules folder. If these 3 files have the same structure in parameter passing, method names and type, you should not have a problem.
The DesktopModules user interface files
Start developing the Edit and Settings files and then develop the viewer file. These files are divided in 2. The aspx file will carry the HTML with the asp.net (or C#) and DNN tags (e.g. DNN Text Editor). Creating this file is the same way that you create a simple web page but without functions scripts. The aspx.vb file will carry all the scripts and methods that you need to make the aspx file work. If you already did a site that calls a DLL them you know how this works. What you need to know here is that you need to register the aspx.vb file in the aspx file in order to work. For that you need to use a command line like this:
@ Control language="vb" Inherits="McLoide.Modules.MyFAQs.EditMyFAQs" CodeFile="EditMyFAQs.ascx.vb" AutoEventWireup="false" Explicit="True" %>
Add this line after the register tags of DNN. It will avoid occurring errors during deploy.
When deploying this files double check the spell on your tags or you will have a huge error on your module screen saying that you have a HTML tag formation problem.
On each aspx.vb file you will need to change the Page load and the Update Method. In some files, like the Edit, you need to change other methods like Delete method.
Anyway in these methods you are going to create at least 2 types of objects. The first type is the Controller object. With this object you can call all the procedures that you have. The second type is the Info object. This object will receive or will be used as a parameter for the controller object and is the object that will pass its value to the textbox, label, etc that you use in your aspx file.
Tip: If you use a expression like this: If objModuleInfo Is Nothing Then and you are going to pass or read values from the object, create a new object. This will avoid a object reference error that can be a headache (see my posts I have one with this error).
The App_Local Resources files
This files provides information for the DNN site about help and messages of the validation types. Every single field that you have in your aspx file you need to put in this files.
The DNN Configuration file
Follow an existing dnn file to create your own. Every file that needs to be in the [app_code] and DesktopModules folder you need to put in this file. Double check the folders and files names before you finish this file or the module will not be installed in the dnn site.
Create the package
Create a TEMP folder that you can use to copy the files into.
Notice that this folder doesn't have any subfolders.
You will need to copy to this folder:
- all the files in the app_code folder
- all the files in the DesktopModules folder
- all the files in the App_Local Resources folder
Check if all the files in this folder are the same that you have inserted in the DNN configuration file.
Select all files in the TEMP folder and create the ZIP file. That's it. Your package is done and you can upload to your website.
Testing
when developing you can make the VWD or the Visual Studio to check for errors but there are some errors that will be shown only in runtime. Upload your package in a website for testing and start to test your module. If you need to fix something, change the file in the VWD and copy the file to the module folder in your dnn website.
Remember that your [app_code] files will be in the [app_code] files from the website under the folder named after your module and the DesktopModules files will be in the DesktopModules folder under a folder named after your module.
That's how I developed the module MyFAQs and like I said maybe isn’t the best way to do it but will help you to develop your module.
Any comments post here... ;)
McLoide