Monday, August 4, 2008

How To Create A DNN Installable Module From An OWS Configuration

For some reason, doing this with ListX or OWS has always seemed like a daunting task but after learning how to do it, it's really pretty easy.

Included in this post are the step by step instructions and the files you can use as a template to get you started.

1. To create a module you require the following files(where MyModule is your module name):
MyModule.ASCX
MyModule.ASCX.RESX
MyModule.DNN

2. If you are going to need to create or update and SQL tables:
01.01.01.SqlDataProvider - where 01.01.01 is the version number you set for the module
Uninstall.SqlDataProvider - to remove any tables when the module is uninstalled.

3. If you want to have a section for configuration in the Settings option of the module menu
MyModuleSettings.ASCX
MyModuleSettings.ASCX.RESX









For this example, I'm going to turn the configuration in my blog post "A Very Basic OpenWeb Studio Module" into an installable PA module for DNN and I'm going to call my module "Basic User Edit". First I'm going to replace "MyModule" in all the file names with BasicUserEdit, the name of my module. Next, set up BasicUserEdit.ASCX. Here there is really nothing much to do. Just make sure you have a ASCX text file that reads exactly as follows:

<%@ Control Language="vb" AutoEventWireup="false" Inherits="r2i.OWS.Wrapper.DNN.Module" TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %>
<%@ Register Assembly="r2i.OWS.Wrapper.DotNetNuke" Namespace="r2i.OWS.Wrapper.DNN" TagPrefix="cc1" %>

Next, let's set up the RESX file. If you do not have Visual Studio, you may need to get a program like Resx Editor to create your RESX or just Google for one. I rename the existing RESX file in my sample download package to BasicUserEdit.RESX. Next I go into the OWS Administration and open the Config. Then, click on Export from the Home tab, select all the module code(CTRL+A) and copy to your clipboard(CTRL+C).








Now go to Visual Studio and select File>Open>File and select your RESX file. Delete the row or existing content in the grid. In a new row add the name field exactly as Module.Text then paste your config in the Value field. Save the file and exit Visual Studio.






Now, in the BasicUserEdit.DNN, replace:

  1. All occurances of MyModule with your module name.
  2. Enter your version number for the module where appropriate
  3. In the module node, verify the section to determine the path in the DNN app you want to install the module to.
I had to replace all the "<" and ">" symbols with "[" and "]"
[dotnetnuke version="3.0" type="Module"]
[folders]
[folder]
[name]BasicUserEdit[/name]
[friendlyname]BasicUserEdit[/friendlyname]
[foldername]BasicUserEdit[/foldername]
[modulename]BasicUserEdit[/modulename]
[description]Description Of BasicUserEdit[/description]
[version]01.00.01[/version]
[!-- [businesscontrollerclass]r2i.OWS.Wrapper.DNN.Interface.iSearchable, r2i.OWS.Wrapper.DotNetNuke.Interface[/businesscontrollerclass] --]
[modules]
[module]
[friendlyname]BasicUserEdit[/friendlyname]
[cachetime]0[/cachetime]
[controls]
[control]
[src]DesktopModules/BasicUserEdit/BasicUserEdit.ascx[/src]
[type]View[/type]
[/control]
[/controls]
[/module]
[/modules]
[files]
[file]
[path]App_LocalResources[/path]
[name]BasicUserEdit.ascx.resx[/name]
[/file]
[file]
[name]BasicUserEdit.ascx[/name]
[/file]
[/files]
[/folder]
[/folders]
[/dotnetnuke]
NOTE** - you still want to add an additional Control node section AND 2 File node sections in your Files node for your DNN file, if you include Module Settings. Then follow the existing syntax for the Files Node in the DNN file above for adding the additional RESX and ASCX sections for the Module Settings. The Control node for Settings will look something like the following where the type node has Edit as a value:

[control]
[key]Settings[/key]
[title]BasicUserEdit Settings[/title]
[src]DesktopModules/BasicUserEdit/BasicUserEditSettings.ascx[/src]
[type]Edit[/type]
[/control]

To add or change table schemas in the DNN database you add a *SqlDataProvider file that is prefixed with the SAME version number that exists in your DNN file. The contents of the file are pure SQL with no special formatting other than the following:
  • EVERY database object name must be prefixed with {databaseOwner}{objectQualifier} so that the SQL objects will be created with the DNN database owner as the object owners and to be compatible with DNN object qualifier method
  • It's recommended that you "alias" your table names so you don't have to prefix everything with {databaseOwner}{objectQualifier} in your SQL. "Select username from users" becomes "Select u.username from {databaseOwner}{objectQualifier}users u"
Follow the same rules in the Uninstall.SqlDataProvider file to delete the database objects you create in your SqlDataProvider install files, when the user uninstalls your module.

To set up a unique section in Module Settings for your OWS PA modules, as mentioned earlier you need a MyModuleSettings.ASCX and MyModuleSettings.ASCX.RESX. Follow the exact same instructions above for creating these files, then follow this example to create the OWS configuration that will be your Module Settings that you save in the Setting's RESX file.






NOTE** - the section in cyan is what will display in the actual section for your module in Module Settings. The yellow section MUST be configured as displayed EVERY TIME in your config that will become your Settings.RESX file as it specifically listens for the UPDATE link the user clicks when saving module settings.

Now to package your module.... very simple.

  1. If you have no settings files or sql to execute on module install, just add the ASCX, RESX and DNN file to a ZIP file
  2. Add the 2 SqlDataProvider files to the zip if you need to execute SQL
  3. Add the ASCX and RESX Settings files to the zip if you have included Module Settings
That's it...... Upload your module and test. Don't forget to increment the version numbers in the SqlDataProvider and DNN files for each revision of your module.

Installable BasicUserEdit Module

MyModule Template Files To Create Your Own Installable DNN Module

0 comments: