Search code examples
asp.netrazordotnetnukedotnetnuke-5dotnetnuke-module

A whole website section as a DotNetNuke module


I need to develop a whole section of a website (around 10 different pages) as a DotNetNuke module. The site will be using DNN as the CMS, where editors will manage HTML content for most of the website (exception that section I'll be developing).

I've already made a rather extensive research on DNN Module Development (even watched some recorded Webinars by DNN Corp). Unfortunately, most of what I could find online is about developing simple, widget-like modules. Also, most of it uses a step-by-step "how to use visual studio to acomplish x" approach, while I was trying to understand how DNN works. So it seems I have to figure it out for myself...

At this point I'm already somewhat familiar with DNN, and I see several different solutions to my problem:

  1. Creating a module for every page on my custom section. I don't like this idea very much, specially because I have code that need to be shared across multiple pages.
  2. Developing a single module with several User Controls inside (one for each page), and use custom module settings to let each page know which control to display.
  3. Develop a "bogus" module that will work as a library, and additional modules for each page.
  4. Develop the library module, then use the Razor Host Module and Razor scripts for the views (I don't need/want WebForms on my app).

So I decided to ask you guys for advice. Which is the the preferred way to go? Maybe none of the above? I know all four options above should give me the result I want, but I also don't want to go against the "DNN way" too much...


Solution

  • I wouldn't recommend #1 (multiple modules) or #3 (also multiple modules) at all, and though #2 (single module w/ module level setting that determines view) is definitely a solid option used widely by DNN module developers, it sounds like you'd prefer #4 (Razor) over #2 because you like the development style.

    So - I'd recommend going with the Razor approach, which though it seems like you understand the approach just fine, I wanted to elaborate on for posterity:

    • Build a library (assembly/DLL) to encapsulate all of your reusable business logic
    • Build out Razor views for each page that make use of that logic and render your data on the page
    • Drop the Razor Host module on each page that you need it and point it to the correct view

    That should work out quite well.