Products

Solutions

Resources

Partners

Community

About

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

The Community Blog is a personal opinion of community members and by no means the official standpoint of DNN Corp or DNN Platform. This is a place to express personal thoughts about DNNPlatform, the community and its ecosystem. Do you have useful information that you would like to share with the DNN Community in a featured article or blog? If so, please contact .

The use of the Community Blog is covered by our Community Blog Guidelines - please read before commenting or posting.


(Re-)Announcing the DotNetNuke Announcement Module

Creating a good module makes it sometimes very hard to improve upon that. The (still current) old release of the DotNetNuke Announcements module was such a module. Created in an era long forgotten, as a DotNetNuke 4 module, it was quite good at the time when it was released. The announcement module is a fairly simple module that is a useful tool on most websites, while at the same time showcasing important DotNetNuke API features, and thus playing also a role in helping developers understand DotNetNuke module development.

I feel pretty bad when I look at the last release date of the module though. May 15, 2009. More than 3 and a half years ago. The module might have been a good module back than, but it certainly is not anymore right now. What was regarded as using best practices back then, is currently not much more than using legacy code.

So… it is time to fix this with a new and shiny release, ready for the DotNetNuke 7 era that is upon us!. Let’s review the plans for this new version of the module:

DotNetNuke UI

The old module doesn’t look very nice anymore in the current DotNetNuke versions. Of course, in this reincarnation the DotNetNuke form pattern, as explained in the UX Guide is implemented. This is a screen shot of the Edit Announcement popup:

EditAnnouncements (click to enlarge)

Rewrite to C#

Some people in the DotNetNuke community used to think that the VB my nickname ErikVB was short for VisualBasic. It is of course nothing more than a coincidence that the VB happen to be the first letters of my last name. The switch to to C# may come as a surprise to some, but really it doesn’t matter that much. As it currently stands, there seems to be a movement in the direction of using C#. In my mind, one of the raisons d’être for this module is to be a good sample module for starting DotNetNuke developers.

As for the process of converting, I used Instance C# from Tangible Software. This automated conversion tool works pretty well, the only area of the project it had trouble with was the DAL (specifically the SqlDataprovider class). Of course that was not a huge problem, since the old DAL code was slated to be removed in the first place.

Implement DAL 2

One of the very nice new features is the introduction of the DAL 2. In a series of blog posts, starting with this one, Charles Nurse, Chief Architect of DotNetNuke Corp., outlines how the the face of Data Access is changing with DotNetnuke 7. We are implementing a Micro-ORM called PetaPoco, which provides us with a number of advantages. The bottom line of that is that it has become a lot less work for developers to access the DotNetNuke database. No more writing of StoredProcedures (well, to be fair, you can still do that if you need that), which apart from being faster, is also good for making less mistakes. In my experience, a lot of errors in modules actually originate in issues with missing ObjectQualifiers in the SQL scripts. The new DAL 2 automatically factors in the ObjectQualifier of the installation, so that leaves one less thing for the developer to think about.

In the new Announcements module, the AnnouncementInfo class now looks like this:

AnnouncementsInfo_Class

And in the AnnouncementsController class, the AddAnnouncement method changed to this:

AnnouncementsController_Class

I must say, this code is much cleaner than under DAL 1, and on top of that, as a bonus, we now get top notch caching of our business objects, by just marking them as being Cacheable.

Implement DotNetNuke WebAPI

Of course another very cool new feature of DotNetNuke 7 is the support for ASP.NET Web API. Many things have been written about it, and it is good to see that a lot of developers in the community are jumping on this new feature.

The new Announcements module will use the new WebAPI for a couple of different things: templating (think KnockoutJS), being able to generate an XML view on the module content, RSS/ATOM support etc. Of course WebAPI supports automatic output formatting based on what the client requests. By default this means that the output is either XML or JSON, however, I was particularly interested in the option to extend the output formats with your own.

My idea is to offer an alternative RSS feed for the module, that allows me to do something special: offer a combined feed of all the modules in a DotNetNuke site, that is filtered to the ones that you are actually allowed to see. I came across an interesting blog by Filip Woj, dealing about creating a RSS / Atom MediaTypeFormatter for WebAPI. Implementing this is very simple, and the beauty of it is that with the same code we can now also serve RSS and Atom feeds.

The first step in adding support for WebAPI starts with adding at least one route. In my case, i wanted to include an option to force the output in a certain format in the route, which let to this:

RegisterRoutes

and to this implementation for GetCurrentAnnouncements:

GetCurrentAnnouncements (click to enlarge)

As you can see, the ActionName is defined as “Current”, which means that, according to the defined route, the URL for this action is:

/DesktopModules/Announcements/API/Current

and optionally for instance this:

/DesktopModules/Announcements/API/Current/rss

The default value for the Output parameter is “default”, which means that in that case the auto formatting feature of WebAPI is used. All methods that return results based on a list of AnnouncementInfo objects, will use a single GenerateOutput method to send the output to the client, which means that all these methods will share in the goodness. GenerateOutput looks like this:

GenerateOutput (click to enlarge) 

The future

All of this is currently available in a CTP release that was released today. As much as I had wanted, the module is far from ready. The work that has been done so far is, apart from the UX upgrade, mainly in the invisible parts of the module. I feel this is the right direction to go, as the module really needed a new, strong, foundation. The next major enhancement will be the templating system. As it stands now, I am strongly considering adding support for multiple different templating systems:

  • DotNetNuke TokenReplace
  • KnockoutJS
  • Razor
  • XSL

Other than the current system, the new templating will be file based.. which will make some skinners out there a little bit more happy I would guess.

Other than that, I would say the module also needs support for the DotNetNuke Taxonomy system, and also for the Social API… but more about that later… For now, take a look at the CTP for the new Announcement module for DotNetNuke 7, available here: http://dnnannouncements.codeplex.com/releases/view/98256. Enjoy, but please do not use it in a production site yet! If you find any issues, please log them in the issue tracker on CodePlex.

 

(This is a repost from my personal blog)

Comments

Comment Form

Only registered users may post comments.

NewsArchives


Aderson Oliveira (22)
Alec Whittington (11)
Alessandra Daniels (3)
Alex Shirley (10)
Andrew Hoefling (3)
Andrew Nurse (30)
Andy Tryba (1)
Anthony Glenwright (5)
Antonio Chagoury (28)
Ash Prasad (37)
Ben Schmidt (1)
Benjamin Hermann (25)
Benoit Sarton (9)
Beth Firebaugh (12)
Bill Walker (36)
Bob Kruger (5)
Bogdan Litescu (1)
Brian Dukes (2)
Brice Snow (1)
Bruce Chapman (20)
Bryan Andrews (1)
cathal connolly (55)
Charles Nurse (163)
Chris Hammond (213)
Chris Paterra (55)
Clint Patterson (108)
Cuong Dang (21)
Daniel Bartholomew (2)
Daniel Mettler (181)
Daniel Valadas (48)
Dave Buckner (2)
David Poindexter (12)
David Rodriguez (3)
Dennis Shiao (1)
Doug Howell (11)
Erik van Ballegoij (30)
Ernst Peter Tamminga (80)
Francisco Perez Andres (17)
Geoff Barlow (12)
George Alatrash (12)
Gifford Watkins (3)
Gilles Le Pigocher (3)
Ian Robinson (7)
Israel Martinez (17)
Jan Blomquist (2)
Jan Jonas (3)
Jaspreet Bhatia (1)
Jenni Merrifield (6)
Joe Brinkman (274)
John Mitchell (1)
Jon Henning (14)
Jonathan Sheely (4)
Jordan Coopersmith (1)
Joseph Craig (2)
Kan Ma (1)
Keivan Beigi (3)
Kelly Ford (4)
Ken Grierson (10)
Kevin Schreiner (6)
Leigh Pointer (31)
Lorraine Young (60)
Malik Khan (1)
Matt Rutledge (2)
Matthias Schlomann (16)
Mauricio Márquez (5)
Michael Doxsey (7)
Michael Tobisch (3)
Michael Washington (202)
Miguel Gatmaytan (3)
Mike Horton (19)
Mitchel Sellers (40)
Nathan Rover (3)
Navin V Nagiah (14)
Néstor Sánchez (31)
Nik Kalyani (14)
Oliver Hine (1)
Patricio F. Salinas (1)
Patrick Ryan (1)
Peter Donker (54)
Philip Beadle (135)
Philipp Becker (4)
Richard Dumas (22)
Robert J Collins (5)
Roger Selwyn (8)
Ruben Lopez (1)
Ryan Martinez (1)
Sacha Trauwaen (1)
Salar Golestanian (4)
Sanjay Mehrotra (9)
Scott McCulloch (1)
Scott Schlesier (11)
Scott Wilkinson (3)
Scott Willhite (97)
Sebastian Leupold (80)
Shaun Walker (237)
Shawn Mehaffie (17)
Stefan Cullmann (12)
Stefan Kamphuis (12)
Steve Fabian (31)
Steven Fisher (1)
Tony Henrich (3)
Torsten Weggen (3)
Tycho de Waard (4)
Vicenç Masanas (27)
Vincent Nguyen (3)
Vitaly Kozadayev (6)
Will Morgenweck (40)
Will Strohl (180)
William Severance (5)
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out