Building Custom Modules DotNetNuke Portal v3.0 Stan Schultes Microsoft MVP – Developer, Author, Speaker http://www.vbnetexpert.com stan@vbnetexpert.com
Session Prerequisites DotNetNuke v3 – installation & operation DNN Custom Module Developer’s Guide DotNetNuke WebCasts: 1 – DotNetNuke v3 Overview (id 1032266671) 2 – Installation and Configuration (id 1032266674) 3 – DNN Portal Management (id 1032267551) 4 – Custom Module Development (id 1032267561) http://www.microsoft.com/communities/webcasts/default.mspx Other Assumptions: Installed, used and managed DNN v3. Familiar with SQL Server management & development. Understand what CMs are, and how to install them. Understand CM architecture (session 4). Using VS 2003 (no Whidbey yet). Disclaimers: Only have 2 hours total – CM development is a deep topic. Covering as much as I can – mainly through examples with references. This is a practical, hands-on walkthrough for CM development – based on my experience and pain points. Level 300 © 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 What is Custom Module Development? Visual Studio Environment Setup Create Database Objects Create Custom Modules from Templates Configure an Existing Custom Module Modules & User Control Basics Package Modules for Deployment Convert v2 Modules to v3 (review) Tips & Tricks
Building Custom Modules What is Custom Module Development? Adding functionality to DNN: Modify the core, change providers, build Custom Modules Custom Modules (CMs): pluggable extensions to core DotNetNuke functionality CMs consist of: Module container (provided by DNN) Dynamically loaded user controls (.ascx) Data layer components Develop CMs in any .NET language (VB.NET, C#) Process: project setup, create data layer, create user controls, package, and deploy DNN Providers: data, membership, search, friendly URLs, HTML editor, logging, exceptions, scheduling… Using DNN v3.0.13 for this webcast. © 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.
Building Custom Modules Visual Studio Environment Setup DotNetNuke v3 prerequisites: Visual Studio 2003, .NET Framework v1.1 SQL Server 2000 (or MSDE), IIS, SMTP Install DNN and test Edit .sln and .webinfo files for virtual dir name Open solution and check references Run in Design mode Project Debug mode Web.config: <compilation debug=true> Configuration Manager – uncheck projs not needed Set default start page Build whole project, then setup Configuration Manager for just BuildSupport. © 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.
Building Custom Modules Create Database Objects Tables and Stored Procedures Generally want to use an unique object prefix SPs can be generated with CodeSmith templates Test all SPs as you create them Fields typically included in database: ModuleID, CreatedBy, CreatedDate, Name, Desc Create DB scripts for quick drop/add during development May want to create scripts for sample data Resource: Data Access & Module Dev guides Point out vne_ object prefix © 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.
Building Custom Modules Create Custom Modules from Templates Find project templates at: http://dnnjungle.vmasanas.net (under Development Templates) Visual Studio templates: Create the base Visual Studio solution files CodeSmith templates: Create the SPs, data classes, business objects These templates provide a jumpstart Add your UI, business logic, and other functionality 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 vne_ 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.
Building Custom Modules Configure an Existing Custom Module When would you need to do this? Move CM code to another machine Upgrade code to another DNN version Process: Clear vswebcache Configure DNN in design mode & test Add your code to DesktopModules directory Add your projects to DNN solution & set ref’s Add your database objects (run scripts) Add Module Definitions & test Host Module Definitions: Name: VBNetExpert.DemoControl, Desc: DemoControl shows how multi-control modules can be built Definition: DemoControl Controls: Key: “”, Type: View, Title: “” Key: SecondView, Type: View, Title: Secondary DemoControl Viewer Key: Edit, Type: Edit, Title: Main DemoControl Editor Key: SecondEdit, Type: Edit, Title: Secondary DemoControl Editor Key: Settings, Type: Edit, Title: DemoControl Settings Definition: DemoControlDisplay © 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.
Building Custom Modules Package Modules for Deployment Deployment unit is a zipfile containing: .dnn manifest file – name & location of all contained files and directory structure Required .ascx’s and .dll’s Resource files such as images Host Module Definitions: edit a module Link at bottom: Create Private Assembly CM distributions: runtime files only or including source code 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.
Building Custom Modules Modules & User Control Basics User Controls inherit from PortalModuleBase Typical controls: View, Edit, Settings Module Definitions DesktopModules – module name & description ModuleDefinitions – multiple definitions possible ModuleControls – user controls by control key Standard module interfaces: IActionable – create menu for CM ISearchable – allow searches of your module content IPortable – allows export/import of your module IUpgradeable – allows upgrade code to run IActionable: Links.ascx.vb Other interfaces: implemented in LinksController.vb © 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.
Building Custom Modules Developing and Debugging User Controls Custom Module development – key concept: Reuse core code without changing it Code flow through the portal core: HTTPHandlers – Global.asax – Default.aspx – LoadSkin – InjectModule – module Page_Loads Debugging your module: set a breakpoint in Page_Load Common troubleshooting Exception log: Portals\_default\logs\exception.xml.resources Read the error messages carefully Source code tour Building Websites with DotNetNuke 3.0: Egan’s book shows simple flow InjectModule – in admin\skins\skin.vb, called from Page_Init Breakpoints in DNN project – may need to set project to build in Configuration Manager to get it to stop on these breakpoints. © 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.
Building Custom Modules Convert v2 Modules to v3 (review) DNN Core Framework forum lists 10 breaking changes and their impacts Create proper namespaces and module prefixes Legacy files removed – redirects must change Some replaced by skins / containers Refer to glbDefaultPage instead of Default.aspx Database changes: addition of TabModules table ModuleSettings vs. TabModuleSettings Menu changes: implement IActionable (plus new interfaces) Module options: change Edit control key to Settings Refer to routine HasNecessaryPermission in components\security\security.vb for permissions checks
Building Custom Modules 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
For More Information DotNetNuke: http://www.dotnetnuke.com DNN help: http://www.dotnetnukehelp.com Resource sites: http://www.dnn.com.au http://dnnjungle.vmasanas.net http://www.ericjsmith.net/codesmith (now commercial tool) http://blogs.speerio.net/peerio Developer sites: http://www.wwwcoder.com http://www.dotnetnuke.dk http://www.cathal.co.uk http://www.smcculloch.net
Additional Resources DNN docs: site documentation subfolder Provider Model: http://msdn.microsoft.com/library/en-us/dnaspnet/html/asp02182004.asp FW 1.1: http://www.asp.net/download-1.1.aspx
Questions and Answers Submit questions using the text box
© 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.