Nov 23, 2011

Fun Project: DotNetNuke module development

This post shows you how to create a DNN module in C# using Visual Studio 2010 – from beginner to beginner – to make expectations clear.

Requirements

In time with the site going live, new requirements popped up:

  • online bookings of treatments by clients
  • manage massage treatments through my wife
  • booking selected treatments using a kind of schedule/calendar view (clients) in predefined time windows / opening hours (admin).
  • email confirmations (client and admin)

I found no module for these Sad smile.

Visual Studio Project Template

As Visual Studio and C# are my friends, I downloaded the DNN template from dotnetnuke.codeplex.com and added a new project to my VS 2010 solution:

image

which added the following structure:

image

changed to .NET framework to 4.0 and added my custom namespace

image

Performing a Release build

image

Packaging

Right clicking the module project in the solution explorer and choosing “Build Deployment Package” creates the necessary CMS upload package BookingModule_00.00.01_Source.zip in the packages sub folder.

The packing script error:

Error    1    The target "Package" does not exist in the project.   

can probably be ignored. It indicates the build script references the solution file rather than the csproj project file.

image

Note the packaging scripts are included in your DNN module project folder “BuildScripts”

image

 

Host Login

When I created the DNN site within my hoster’s portal, I got asked to create two login account credentials:

  1. Administrator: create pages, add installed modules to pages, change skins and styles, etc.
  2. Host: same as the administrator, but with additional rights, one of these is installing new modules

So you must log in with your host account

image

to see the additional site menu items “Admin” and “Host”. Clicking host shows the Extensions icon:

image

to see the DNN framework (version), Authentication System, Container, Library, Module, Provider, Skin, Skin Objects and in the bottom right pane the command to install a new module Install Extension Wizard:

image 

selecting and uploading the previously built release package, next, booom!

Install Extension

Upload Results
If you have reached this page it is because the installer needs to gather some more information, before proceeding.

Error reading the zip package - see below

StartJob
Reading Installation Manifest file

Info
Reading Package Manifest - Module - BookingModule

Failure
Install aborted - The module being installed is not compatible with your host application version ( an upgrade is required )

I spent some time googling for answers, found some useful hints, saying the module is not compatible with my DNN version. But my problem remains: I cannot update my CMS with my hoster and I’ve got the latest Visual Studio template!? Hm. The solution was in the VS project DNN manifest file (project.dnn):

<dotnetnuke type="Package" version="5.0">

  <packages>

    <package name="BookingModule" type="Module" version="00.00.01">

      <…/>

      <dependencies>

       <dependency type="CoreVersion">06.00.00</dependency>

      </dependencies>

You need to delete the dependencies node, rebuild, repackage, upload again:

image

Yeah.

image

You can now add it to you page / pane as host –> edit mode –> common task –> add module

image

and when the module has the same rights as the page, then you can see it. There’s a context menu added

image

that let’s you switch to an “Edit Module” view or “Settings” view. Do you remember the three .ascx asp.net user controls in the above module project?

I hope this blog post gave you some overview of DotNetNuke module developments to get started with, including some pitfalls (I have fallen into).

Next time, I plan to show you the development of the web stuff, including the database model, data access, UI.

3 comments:

  1. Nice Blog, the way you presented the data is appreciable, you have included many snapshots too that helps us to understand DNN development.

    ReplyDelete
  2. Nice posting, thanks for sharing with us. Your blog is great and helped me to feel better knowing about DotNetNuke module development. Your snapshots are very nice Thanks again!

    ReplyDelete