Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Build 'Radioactive' Web Sites with DotNetNuke 2.0 : Page 5

Save hours of valuable development time when building corporate or departmental Web portals with DotNetNuke 2.0, the latest version of the free, ASP.NET-based, open source, extensible, content management portal.


advertisement
Extending DNN with Custom Modules
DNN 2.0's redesign in the custom module architecture is another significant update. In this section I will walk you through all the steps necessary to construct and deploy your own custom modules. First I'll show you how to create a SQL Server table and its associated stored procedures (Data Store layer). I'll show you how to continue to build the Data Access layer by constructing a Business Logic layer object to retrieve and validate entered data. Next, you'll see how to build the presentation layer and edit the data being served up by the Business Logic layer object. Finally, I will show you how to package all the components of the custom module into a single zip file and upload the zip file for testing.
One of the best resources to help you understand how to build your own custom modules is to check out how the pre-built ones work.
Before I begin let me list some prerequisites. I will use Microsoft SQL Server 2000 so you will need access to SQL Server to follow along. The DNN 2.0 data access provider model allows you to work with other databases, such as Microsoft Access, but I'm not using Microsoft access as my data repository. You will also need to install the Microsoft Data Access Application Block for .NET. You can find this by searching for Data Access Application Block for .NET on http://msdn.microsoft.com. You will also need a utility that lets you create zip files.

The custom module I'll show you how to build tracks exam results. The primary user interface will consist of a grid listing the individuals and it will provide a mechanism to add new exam records and edit / delete existing ones. So without delay, I bring you the construction and implementation of a DNN 2.0 custom module. Step 1: Design and Implement the Data Store Layer
Create a table to store the individual exam records. I created a table called ExamTracker (see Figure 9) as well as the required stored procedures to access the data (see Listing 2).

 
Figure 9. The ExamTracker Table Structure: The figure shows the structure of the table in the database.
Step 2: Construct the Data Access Layer and Business Logic Layer
Create the Data Access layer (representing the testing company in the earlier example) and associated Business Logic later (representing the testing administrator). In this step I will create a couple of new projects and populate them with classes. The following list walks you through creating these layers.
  1. Open the DNN 2.0 project in Visual Studio .NET 2003. I placed my DotNetNuke project files in the C:\DotNetNuke20 folder.
  2. Right-click on the DotNetNuke solution, select Add and then choose New Project... and add a new class library project named YourCompanyNameHere.ExamTracker and store it in the C:\DotNetNuke20\DesktopModules folder (see Figure 10). You can see that I created a project named TakeNoteTechnologies.ExamTracker. Launch Windows Explorer to confirm that Visual Studio .NET created a folder under DesktopModules named YourCompanyNameHere.ExamTracker and populated it with the project and associated files.
  3. Open the Property Pages dialog box for the new project and make sure the Root Namespace field is empty. Change the Output path to ..\..\bin in the Build settings in the Configuration Properties section.
  4. Add three folders to the ExamTracker project: Components, Installation, and Providers.
  5. Add the following references to the ExamTracker project: DotNetNuke.dll, System.Drawing, and System.Web.
  6. Delete the Class1.vb file.
  7. Right-click on the Components folder. Select Add and then select Add Class... and name the new class DataProvider.
  8. Use Listing 3 as a reference for the DataProvider abstract class. You can copy the Instance method from the DataProvider class located in C:\DotNetNuke20\Components\DataProvider.vb file. Take a moment to look at the data access methods at the bottom. It is no coincidence that the method names correspond to stored procedures of the same name.
  9. Right-click on the DotNetNuke solution. Select Add and then select New Project... to add a new class library project named YourCompanyNameHere.ExamTracker.SqlDataProvider and store it in the C:\DotNetNuke20\DesktopModules\YourCompanyNameHere.ExamTracker\Providers folder (see Figure 11). Switch over to Windows Explorer to confirm that Visual Studio .NET created a folder under DesktopModules\YourCompanyNameHere.ExamTracker\Providers named YourCompanyNameHere.ExamTracker.SqlDataProvider and populated it with the project and associated files.
  10. Open the Property Pages dialog box for the YourCompanyNameHere.ExamTracker.SqlDataProvider project and make sure the Root Namespace field is empty. Change the Output path to ..\..\bin in the Build settings in the Configuration Properties section.
  11. Add the following references to the ExamTracker.SqlDataProvider project, DotNetNuke.dll, ExamTracker, and Microsoft.ApplicationBlocks.Data.
  12. Delete the Class1.vb file.
  13. Right-click on the SqlDataProvider project, select Add and then select Add Class... and name the new class SqlDataProvider.
  14. Use Listing 4 as a reference for the SqlDataProvider concrete class. This class inherits from the DataProvider class and contains methods that override the stub methods in DataProvider.
  15. Now it is time to create the Business Logic layer. In the YourCompanyNamehere.ExamTracker project, right-click on the Components folder, select Add and then select Add Class..., and name the new class file ExamTrackerDB.vb.
  16. Use Listing 5 as a reference for the ExamTrackerDB Business Logic layer class. There are two classes contained in the ExamTrackDb.vb file. The ExamTrackerInfo class contains properties that exactly match the structure of the ExamTracker table and the ExamTrackerController contains the data access methods.

Figure 10. ExamTracker Project Creation Settings: The figure shows the project creation settings for the ExamTracker project.
 
Figure 11. The SqlDataProvider Project: This project was created to store the SqlDataProvider class.
Build the DotNetNuke solution at this point. Enter information about your module in the AssemblyInfo.vb file for both projects just make sure you are consistent and enter the same information.


Referring to the standardized exam example, the DataProvider and SqlDataProvider classes combined act as the exam company. The ExamTrackerInfo and ExamTrackerController classes combined act as the exam administrator.



Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date