Building Custom Modules For DotNetNuke v5.0 Stan Schultes – Sarasota, FL Florida Community Leader http://www.vbnetexpert.com stan@vbnetexpert.com Book due March 2009 (Wrox): Professional DotNetNuke 5: Open Source Web Application Framework for ASP.NET This talk will begin with a quick technical overview of DotNetNuke, and a discussion of why you might build a custom DNN module. Demos will include how to install the DNN portal on a development machine, and how to install a custom module into the portal. Then we'll dive into setting up Visual Studio 2008 for module development and demonstrate how to install a module source package and run it in design mode. Finally, we'll walk through the process of developing a custom module using the sample module to provide details, and we'll see some development tips & tricks along the way. This is a 300-level session - some experience with DotNetNuke will be assumed. © 2005 Stan Schultes and VBNetExpert.com. All rights reserved. This presentation is for informational purposes only - no warranties, express or implied, are included in this summary.
Audience Experience Who is using DNN in production today? Who has seen DNN v5? Used it? Who has done DNN module development? © 2005 Stan Schultes and VBNetExpert.com. All rights reserved. This presentation is for informational purposes only - no warranties, express or implied, are included in this summary.
Agenda Level 300 DNN Technical Overview Why Custom Module Development? Visual Studio Environment Setup, Design Mode DNN Architecture, Development Overview Custom Module Project Setup Create Database Objects Build Data and Business Objects Layer Create User Controls Package Modules for Deployment Module Development Concepts Developing & Debug, Tips & Tricks, More Info Level 300
DNN Technical Overview DotNetNuke is a “Live CMS” Modular, extensible, framework application Dynamically loaded user controls Provider model allows pluggable services Module loader mechanism allows easy extensibility Major Components: Portals = web sites (unique URLs) Pages = portal organizational units Modules = information containers Online configuration & content mgmt by role Many portals per DNN install Framework app –a dynamically generated application with a provider structure for plumbing (data access, membership, scheduler, logging, exceptions, etc.) Modular construction – modules plug in easily through an install/uninstall interface. You can deploy your portals with whatever modular options you want. Portals: Parent Portals are sites which have a unique URL ( ie. www.domain.com ) associated to them. Child Portals are subhosts of your Hosting Provider account. Essentially this means a directory is created on the web server which allows the site to be accessed through a URL address which includes a Parent domain name as well as the directory name ( ie. www.domain.com/directory ). Provider model: data access, membership, html editor, search, scheduling, logging, friendly urls
Why Custom Module Development? Adding functionality to DNN: Install Custom Modules Build Custom Modules Change Providers Modify the DNN Core Custom Modules are pluggable extensions to core DNN functionality Easily modify existing modules as a starting point Key concept: Reuse core code without changing it DNN is an application development platform Tons of pluggable, flexible infrastructure is provided DNN Providers: data, membership, search, friendly URLs, HTML editor, logging, exceptions, scheduling… © 2005 Stan Schultes and VBNetExpert.com. All rights reserved. This presentation is for informational purposes only - no warranties, express or implied, are included in this summary.
Visual Studio Environment Setup DNN v5 developer prerequisites: Vista, Server 2003/2008, Windows XP Visual Studio 2008/2005, .NET FW v2.0-3.5 SQL Server 2005/2008 (Express or Dev) IIS, SMTP Install DNN Starter Kit (for project templates) Configure DNN (use Install Package) and test Consider portal tags: objectQualifier, databaseOwner © 2005 Stan Schultes and VBNetExpert.com. All rights reserved. This presentation is for informational purposes only - no warranties, express or implied, are included in this summary.
DNN v5 in Design Mode Install module source package Edit project file for URL Open solution and check references Create new module project Project templates from Starter Kit Run database scripts & test Add module definitions & test Host Module Definitions Run in Design mode: Set project to Debug mode Site web.config: <compilation debug=true> Tools Attach to Process (ASP.NET worker process)
Demo Visual Studio 2008 in Design Mode All standard modules are now separate projects Custom Module: WROX.Suggestion
DotNetNuke Architecture Image from DotNetNuke Module Development Document
Module Development Overview Custom Modules consist of: Module container (provided by DNN) Dynamically loaded user controls (.ascx) Data layer components Development process: Project setup Build the data & business logic layers Create the user controls Package for installation Deployment Develop modules in any .NET language
Create Database Objects Tables and Stored Procedures Create tables manually Use an unique object prefix: WROX_Suggestion Generate SPs with code gen tools Test all SPs as you create them Fields typically included in database: ModuleID, ItemID, CreatedBy, CreatedDate Create DB scripts for quick drop/add during dev Build scripts for sample data Resources: Data Access & Module Dev guides CodeGen: CodeSmith, any O/R mapper © 2005 Stan Schultes and VBNetExpert.com. All rights reserved. This presentation is for informational purposes only - no warranties, express or implied, are included in this summary.
Build Data and Business Logic Layer Easiest starting point – rename existing module Project templates in Starter Kit CodeSmith templates (these are for DNN v3) Create the SPs, data classes, business objects Do other templates exist? Templates provide a jumpstart Add your UI, business logic, and other functionality Interfaces: IPortable, ISearchable, IHydratable IUpgradeable, IModuleControl, ISkinControl Resources: Data Access & Module Dev guides CodeSmith project setups: Project: CodeSmithDemo in DesktopModules folder Project: CodeSmithDemo in Desktopmodules\CodeSmithDemo\Providers\DataProviders (create last directory) After adding SqlDataProvider project, delete the DAAB reference and re-add Show generated code Tools CodeSmith Explorer Run Stored Procedures template Use company object qualifier throughout Mutisource table connection string: Server=(local);Database=CMDev;Integrated Security=true; Run other templates and paste in code © 2005 Stan Schultes and VBNetExpert.com. All rights reserved. This presentation is for informational purposes only - no warranties, express or implied, are included in this summary.
Create User Controls Module Definitions – tables affected DesktopModules – module name & description ModuleDefinitions – multiple definitions possible ModuleControls – user controls by control key User Controls inherit from PortalModuleBase Typical controls: View, Edit, Settings IActionable – implement to create menu items EditURL, NavigateURL methods Localization and Styling Reusable DNN core controls Url, Url Tracking, Address, Dual List, Label, User, etc. Existing .aspx pages can be converted to .ascx
Package Modules for Deployment Traditional deployment unit is a zipfile including .dnn manifest file – name & location of all contained files with directory structure Required .ascx’s and .dll’s Resource files such as images Source code New Package Installer – ‘Extensions’ Module, container, skin, provider, language, etc. Compatible with old deployment zipfile Host Module Definitions: edit a module Link at bottom: Create Package Creates zipfile in Host directory (\Portals\_default) © 2005 Stan Schultes and VBNetExpert.com. All rights reserved. This presentation is for informational purposes only - no warranties, express or implied, are included in this summary.
Demo Look at custom module: WROX.Suggestion Deployment package Jumpstart – creating a new module
Custom Module Project Setup Requires the DNN Starter Kit to be installed Create new project Web DNN Compiled Module Yes at the localhost\DotNetNuke_2 directory dialog Update Project Properties Web Urls Create Providers\DataProviders directory Add new project Windows Class Library Name it SqlDataProvider in DataProviders directory Manually move SqlDataProvider.vb from Components Rename projects Company.Modules.CustomModule Company.Modules.CustomModule.SqlDatProvider Reference DotNetNuke and MS DAAB Resources: Starter Kit documentation
Module Development Concepts Namespaces Portal data structures and methods Module settings – instance data cached in IIS Page navigation – EditURL, NavigateURL Users, Roles and Security Reusable core controls Localization – create resources for all strings Client API / AJAX / jQuery Exceptions and logging Inter-module communication
Developing and Debugging Debugging your module: attach to process w3wp.exe in Vista/Servers, aspnet_wp.exe in XP set a breakpoint in Page_Load Common troubleshooting Exception log: Admin Event Viewer Read the error messages carefully Code flow through the portal core HTTPHandlers – Global.asax – Default.aspx – LoadSkin – InjectModule – module Page_Load © 2005 Stan Schultes and VBNetExpert.com. All rights reserved. This presentation is for informational purposes only - no warranties, express or implied, are included in this summary.
Tips & Tricks Be familiar with the standard modules Look for examples of calling core functions Start here rather than working from scratch Code generation tools can save a lot of time ObjectBrowser is your friend! Goal: modify DNN core only for critical bug fixes Switch providers to change core functions Useful documents: Module Dev Guide, Data Access, Localization, Membership, Skinning
More Information DotNetNuke home: http://www.dotnetnuke.com DNN forums Resources directory Gemini bug tracking DNN Documents Resource sites: http://www.adefwebserver.com/DotNetNukeHELP/ http://www.dnncreative.com http://www.dnn.com.au Search – there’s a lot of information out there
Contact Website: www.VBNetExpert.com Slide deck is available (DotNetNuke Downloads) Email: stan@vbnetexpert.com Blog: StanSchultes.spaces.live.com