RSS feed icon BTB Shadow Man BiteTheBullet.co.uk logo

Page 1 2 3 4 5 6 7 8

DotNetNuke Random Image Tutorial - Part 8

PART 8

Packaging The Module

We just need to package our module then we can call it a day. Packaging is really just about add the files we need for our module into a zip file, and including in the zip a DNN file which DotNetNuke will use to register and install the module.

When we package the module there are a couple of important things we need to do,

  1. Set the compile mode of the module and its data provider to Release then compile them. This will make our assembly more optimised than the debug mode.
  2. We don’t need to include the source files in the zip, so be careful what you add. Any files with a *.cs and all the Visual Studio files should NOT be included.
  3. We need to create a couple of SQL scripts, one to setup the database with our table and stored procedures, the second is an uninstall script which will remove all our database objects if the module is deleted.

If you take a look at the Installation folder in your project you’ll see the wizard we used at the start has created an empty zip file and DNN file for us to use.

I’ve built the two assemblies in release mode I just need to copy them from the bin folder into my zip file. Next add the two ascx controls and the resource files for each one.

You’re zip file should contain the following files.

ZIP file contents

Next we just need to add the two SQL scripts and the DNN file. Note if we had used the module.css, images or icons in our module we need to add these as well.

If you take a look in the SqlProvider folder you’ll see we have two empty files that we need to use to create and uninstall the database objects.

File 01.00.00.SqlProvider will contain the statements we need to create the table and stored procedures.
Uninstall.SqlProvider will contain statements to remove the table and stored procedures our module created.

Ok the SQL files are a little different from normal SQL files we need to include a couple of special keyword that DotNetNuke will replace at the time of install. These are {databaseOwner} and {objectQualifier}, at install time DotNetNuke will replace these with values that your portal uses.

We can generate the SQL scripts by two methods

  1. We can use Code Smith to generate the required SQL scripts.
  2. We can select the table and stored procedures and export them using Enterprise Manager.

I prefer to use the second method, since I sometimes change the original SQL outputted from CodeSmith, hence if I script the objects from the database with Enterprise Manager I’m sure I’ll get the latest version my module is using.

Select the database you are using for your DotNetNuke install in Enterprise Manger, right click on the tables and select “All Tasks -> Generate SQL Script”

Select the objects we need as shown below

Scripting the database objects

Make sure we have these options selected.

Scripting options

Now we need to modify the output to include the (databaseOwner} and {objectQualifier} tags.
See my file here which shows the two SQL scripts I’m going to add to my zip file.

All we need now is the DNN file to define our module then we can test our module.

The DNN file in the installation folder should be more or less completed for us, just a couple of changes to make.

<?xml version="1.0" encoding="utf-8" ?>
<dotnetnuke version="3.0" type="Module">
  <folders>
     <folder>
         <name>BTBRandomImage</name>          <description>Displays a random image</description>
         <version>01.00.00</version>
<businesscontrollerclass>
BiteTheBullet.DNN.Modules.BTBRandomImage.Business.BTBRandomImageController,
BiteTheBullet.DNN.Modules.BTBRandomImage</businesscontrollerclass>
          <modules>
               <module>
                    <friendlyname>BTBRandomImage</friendlyname>
                    <controls>
                          <control>
                               <title>RandomImage</title>
                               <src>BTBRandomImage.ascx</src>
                               <type>View</type>
                          </control>
                          <control>
                               <key>Edit</key>
                               <title>Edit Random Image</title>
                               <src>BTBRandomImageEdit.ascx</src>
                               <type>Edit</type>
                          </control>
                    </controls>
               </module>
             </modules>
             <files>
                 <file>
                    <name>BTBRandomImage.ascx</name>
                 </file>
                 <file>
                    <name>BTBRandomImageEdit.ascx</name>
                 </file>
                 <file>
                    <name>BiteTheBullet.DNN.Modules.BTBRandomImage.dll</name>
                 </file>
                 <file>
                    <name>                     BiteTheBullet.DNN.Modules.BTBRandomImage.SqlDataProvider.dll                     </name>
                 </file>
                 <file>
                    <name>01.00.00.SqlDataProvider</name>
                 </file>
                 <file>
                    <name>Uninstall.SqlDataProvider</name>
                 </file>
                 <file>
                    <path>App_LocalResources</path>
                    <name>BTBRandomImage.ascx.resx</name>
                 </file>
                 <file>
                    <path>App_LocalResources</path>
                    <name>BTBRandomImageEdit.ascx.resx</name>
                 </file>
              </files>
     </folder>
   </folders>
</dotnetnuke>

Here is my version above, right lets copy that into our zip file.

Now you need to another install of DotNetNuke setup so you can test installing the module we’re just created. Then just install the module by uploading the zip file in the Module Definitions page when logged in under the host account.

 

Wrapping Up

That’s it we’ve completed our module, easy! Hopefully you’ll have seen how quickly we can create modules for DotNetNuke.
Using the Visual Studio templates and CodeSmith can save you a look of tedious “plumbing” code allowing you to get on and write the actual module.

You don’t have to stop there, why not try changing the module we’ve just created to have a hyperlink on the random image to another page or file?

You can download the complete source code from here.

<< Previous Page

Privacy PolicyTerms and ConditionsCopyright © 2005 - 2008 BiteTheBullet.co.uk