
Back in the spring of 2004, I was introduced to DotNetNuke via an article by Jim Duffy in Code Magizine. I got the magazine from the magazine stand in our office building at noon, and by the time I left for the day I had a site up and running (seems that it was a rather quiet day and no one questioned what I was doing). Well I was hooked and have been working with DotNetNuke ever since.
One of the first things I did was write a module -- took me several weeks of banging my head as I was completly lost in this new world. I using DotNetNuke as a learning tool to a) learn VB.Net, b) learn ASP.NET, and c) learn about the web. I have spent the better part of my life developing supervisory process control applications for material handling, so the Web stuff was a complete new territory and DotNetNuke was a nice structured working application that I could extended with my own code -- what could be better! My first module was T-Minus.
Well T-Minus is still available today (examples here) and was orignially developed for DNN version 2. The module includes my very first attempt at javascript - this was one of the many reasons this module took so long to develop. I slowly got the hang of how to develop modules -- I read every blog or article I could find on DNN module development. I also had to spend time creating a rather non-trivial javascript to create the display of the amount of time remaining before a given event.
The javascript had certain requirements:
1. Had to place javascript on page once, but allow multiple modules to exist on a single page.
2. Had to create multiple entries into a object area and have the appropriate value displayed with the correct module.
3. Had to update the display every second as seconds were the smallest unit of time displayed by T-Minus.
4. Had to start the script on page load.
I was able to manage all the requirements and eventually got the module working. In recent years I updated the module to reflect certain comments I have received over the past 5 year (yikes -- that long?).
So - this week I get a E-mail from a T-Minus user (many thanks Jerry) that T-Minus will not work with DNNStuff's Aggregator module. However, the user had passed along DNNStuff's analysis of why the module won't work and how it could be fixed. WOW!
The root cause of the problem was the javascript that I wrote 5 years ago. The script used Window.Onload to call my routine to start the display of all the time values. It works, but is as they say was "bad form" (British acsent needed). Well in fact it seems that I "hijacked" the Windows.Onload function and did allow any other apps to utilize this function. DNNStuff recommended that I use DotNetNuke.UI.Utilities.DNNClientAPI.AddBodyOnLoadEventHandler function to request the start of my display routine. Today I have corrected the issue and now have a revised version of T-Minus that will "play nice" with the other DNN modules.
While I can't say whether this routine existed back in 2004, I can say now that if I come across a requirement that seems to need coordination amongs the modules on a page, I will look at the DotNetNuke APIs to see if there does exist a function. So remember children - play nice!. I will in the future.
Enjoy
Paul.
PS. Many thanks to my fellow Canadian DNN Developer - DNNStuff - for the helpful push in the right direction.