DNN 4 Newbie: Creating a custom module

Last post 05-07-2006 10:08 AM by adefwebserver. 19 replies.

Sort Posts:

  • Computer [co] DNN 4 Newbie: Creating a custom module

    02-27-2006, 5:42 PM
    • Member
      100 point Member
    • aviens
    • Member since 07-01-2003, 10:19 AM
    • Posts 20

    Hello everyone,

    In evaluating portal solutions for our intranet, I decided to go with DNN. Since this is brand new, (no previous intranet portal exists), the sky is the limit for me. I figure starting with DNN4 is a good idea, as it is fresh new code utilizing the new ASP.NET 2.0 platform.

    I am what I consider a somewhat seasoned .NET developer. I have not coded for DNN before.

    I guess what I am lacking is a step by step guide on creating custom modules for DNN4 using Visual Studio 2005. I have the starter kit installed, and I get about as far as letting it do its thing, and renaming the folders as specified... and then things get hazy.

    I have seen different tutorials out there... and it is helping me learn this, but it seems I keep hitting walls, which is getting a little frustrating.

    So far I have looked at the following tutorials:

    1. Shaun Walker's DotNetNuke 4.0.0 Starter Kit and Templates post:

    It is a great tutorial, however it currently stops short of what I really want to know... extending the module provided in the Starter Kit. Hopefully the next post will be posted soon. Smile [:)]

    2. Todd Davis' video tutorials on module creation for DNN 3.x:

    Great videos of the step by step procedure... but unfortunately, it is geared toward DNN 3.x development, and as I have read, DNN4 and DNN3 is structured quite differently... not to mention the inclusion of the Starter Kit for DNN4.

    3. Michael Washington's step-by-step tutorial on module creation for DNN4:

    Once again, great tutorial... but where this one becomes hazy for me is on page four and on. The tutorial becomes a copy and paste operation for the Guestbook module tutorial, and I do not clearly understand what is occuring at that point. Why were the template sprocs from the starter kit created only to delete them? Should I not use a code generator like CodeSmith to create my Insert/Update/Delete procedures? And, why is a ModuleID being created but no PortalID is being created in the table? Wouldn't this break if the module were to be used in two different portals hosted in the same database?

    I guess I have a few questions in utilizing the DNN4 Starter Kit:

    1. The namespace defaults to "YourCompany". Is there any way to specify that so a find and replace is not necessary each time I create a module? I am assuming the way to fix this is to open the ZIP file for the Module Starter Kit and do a find and replace once in there on this, and my problem would be solved.

    2. Would it not make sense to utilize CodeSmith to assist in the creation of the stored procedures necessary to add/update/delete items from the database as well as the creation of the various methods needed in Visual Studio? I am not familar with using code generators, but I would definitely begin to use it if it made my job in creating those rudimentary methods in VS and sprocs in SQL. Does the latest CodeSmith version have DNN4 templates already created for the DNN community?

    3. I am assuming the universal structure of any table in the database for a custom module should be the ProgID, PortalID, and ModuleID? This would make the module 100% compatible through multiple instances of portals and modules.

    4. Books. I currently own Professional DotNetNuke ASP.NET Portals and Building Websites with VB.NET and DotNetNuke 3.0. Unfortunately, all the books that deal with DNN4 are still not out yet:

    I certainly plan on buying them all when they come out, but their current publishing dates isn't until late May to June or later, and I need to start developing now.

    I have many ideas to start developing custom modules for our intranet portal, but right now I am still trying to understand the concepts of putting together the modules.

    I plan to create some general reusable modules that I can release to the community at no charge, but also create modules specific to applications needed internally (small database trackers, calendaring tools, etc.)

    I am eager to jump into the DNN fray, but am still searching for the most efficient way to create my many modules to come!

    I am looking toward the great DNN community here to help me out in this regard. Thank you in advance.

    - Andre

  • Re: DNN 4 Newbie: Creating a custom module

    02-27-2006, 9:51 PM
    • Contributor
      5,869 point Contributor
    • adefwebserver
    • Member since 06-07-2003, 8:50 AM
    • Los Angeles, CA
    • Posts 1,186
    • TrustedFriends-MVPs
    aviens wrote:

     The tutorial becomes a copy and paste operation for the Guestbook module tutorial, and I do not clearly understand what is occuring at that point. Why were the template sprocs from the starter kit created only to delete them? Should I not use a code generator like CodeSmith to create my Insert/Update/Delete procedures? And, why is a ModuleID being created but no PortalID is being created in the table? Wouldn't this break if the module were to be used in two different portals hosted in the same database?

    I tried to explain what was happening in as much detail as I could. I have several sections that basically say "ok what just happened?". Yes it is cut-and-paste a lot. If you build the complete module and examine the code and step through it it should be helpful.

    Yes the starter kit creates a bunch of code that you delete. A lot of it you will usually keep. You will almost never keep the stored procedures and tables, just use them as examples.

    You do not need PortalID. ModuleID is a unique value across all portals..

  • Re: DNN 4 Newbie: Creating a custom module

    02-28-2006, 4:37 PM
    • Member
      100 point Member
    • aviens
    • Member since 07-01-2003, 10:19 AM
    • Posts 20

    Hi Michael,

    I do appreciate the time you took to create the tutorial. It is very helpful. I will take more time to go through it and create the example provided.

    A question for you though: Would it not be prudent to use code generators in that particular example you created to create the stored procedures and methods in Visual Studio?

    - Andre

     

  • Re: DNN 4 Newbie: Creating a custom module

    02-28-2006, 8:48 PM
    • Contributor
      5,869 point Contributor
    • adefwebserver
    • Member since 06-07-2003, 8:50 AM
    • Los Angeles, CA
    • Posts 1,186
    • TrustedFriends-MVPs
    aviens wrote:

    A question for you though: Would it not be prudent to use code generators in that particular example you created to create the stored procedures and methods in Visual Studio?

    No. For the tutorial I don't want to introduce any unneeded tools for a person to configure and learn. Also these are a few very small simple stored procedures.

    I think code generators should only be used for a large amount of code. As you can see this module is really a small amount of code.

  • Re: DNN 4 Newbie: Creating a custom module

    03-01-2006, 1:44 PM
    • Contributor
      3,090 point Contributor
    • DougV
    • Member since 02-23-2004, 4:27 PM
    • Missouri
    • Posts 618
    aviens wrote:
    1. The namespace defaults to "YourCompany". Is there any way to specify that so a find and replace is not necessary each time I create a module? I am assuming the way to fix this is to open the ZIP file for the Module Starter Kit and do a find and replace once in there on this, and my problem would be solved.

    You are correct.  Also, I've posted on my site a way to have this done automatically for you, if you're interested.  Do the stuff on page one, and download the code on page eight to accomplish what you want.
  • Re: DNN 4 Newbie: Creating a custom module

    03-01-2006, 1:45 PM
    • Contributor
      3,090 point Contributor
    • DougV
    • Member since 02-23-2004, 4:27 PM
    • Missouri
    • Posts 618

    Also this will rename your folders and run the SQL for you.

  • Re: DNN 4 Newbie: Creating a custom module

    03-17-2006, 9:44 AM
    • Member
      386 point Member
    • improwise
    • Member since 05-27-2004, 5:40 AM
    • Posts 89
    I downloaded your code and I am trying to run the DNN_Module_Step001 (which I assume is the macro I am to run, not the test ones?) but it gives me an error:
     
    "The parameter is incorrect. (Exception from HRESULT 0x80070057 (E_INVALIDARG))"
     
    This occurs at this line (the first of them):
     

    DTE.ActiveWindow.Object.GetItem(myprojectname).Select(vsUISelectionType.vsUISelectionTypeSelect)

     

    And I have so far found no way of getting past this? Any ideas? Would be really helpfull and much apprechiated!

    /pJ

  • Re: DNN 4 Newbie: Creating a custom module

    03-17-2006, 1:39 PM
    • Contributor
      3,090 point Contributor
    • DougV
    • Member since 02-23-2004, 4:27 PM
    • Missouri
    • Posts 618

    Try running the Test_001 macro.  It should certainly run without problem - just about no matter what.

    Next try running the Test_002 macro.  It should also run without problem, but I don't know given the error you are seeing.

    If you let me know what happens I'll see if I can help again (Monday?).  Also, did you have a beta version of Visual Studio 2005 previously installed?

  • Re: DNN 4 Newbie: Creating a custom module

    03-18-2006, 5:16 PM
    • Member
      386 point Member
    • improwise
    • Member since 05-27-2004, 5:40 AM
    • Posts 89
    Which is really the macro that you are supposed to use? Why are there so many of them in the download file? I am confused :-)
     
    I have assumed that the one which does not have "test" in its name is the final work and the macro that should be used, am I wrong?
     
    /pJ
     
    PS To the moderators: I've been a member for several years and used to be unmoderated but now that seems to have changed for some strange reason, would apprechiate if you could change it back so my posts dont end up in a queue every time. Thanks.
  • Re: DNN 4 Newbie: Creating a custom module

    03-20-2006, 10:40 AM
    • Member
      275 point Member
    • pchan
    • Member since 10-09-2005, 8:20 AM
    • Posts 55

    Having downloaded the macros of Power House Data, I have fiddled much on them by my own.

    Yes, the following code throws the error Incorrect parameter type:

    DTE.ActiveWindow.Object.GetItem(myprojectname).Select(vsUISelectionType.vsUISelectionTypeSelect)

    I have a workaround for this: comment out this code (There are 3 such calls). Float the macro explorer so you see it beside the solutions explorer. In the latter, selection the first line (the project itself); right click the DNN_Module_Step_001 macro and select "Run" in the popup!

    It now goes further and gets stuck in the connection string "c:\inetpub\wwwroot\PHDnet1\App_Data\Database.mdf" which is hard coded; I have the DB elsewhere !
    I corrected that in the routine GetMyConnectionString()

    Just a tip before testing on your own:
    1° ensure you run the site before running these macros, to set up the database
    2° backup the directory so that you can "rollback" to before you ran the macros !
    3° the 3rd call is after the SQL transaction is commited, so it's ok if you got the HRESULT error again, just do Ctl-F5

    It really works! A thousand Thanks to Doug ! 
    Now that there is interest in his work, hopefully he would update it.

  • Re: DNN 4 Newbie: Creating a custom module

    03-21-2006, 9:47 AM
    • Contributor
      3,090 point Contributor
    • DougV
    • Member since 02-23-2004, 4:27 PM
    • Missouri
    • Posts 618

    Sorry I wasn't able to get back in time to be of more help - I was out of town on really short notice the past three days.  Then I get back and my site was down because my host changed the server address on me!  Thankfully I have things going again now.

    Meanwhile, thanks for posting your experiences, I'm sure this will be of help to others. Smile [:)]

  • Re: DNN 4 Newbie: Creating a custom module

    03-21-2006, 5:51 PM
    • Member
      386 point Member
    • improwise
    • Member since 05-27-2004, 5:40 AM
    • Posts 89
    pchan wrote:

    Having downloaded the macros of Power House Data, I have fiddled much on them by my own.

    Yes, the following code throws the error Incorrect parameter type:

    DTE.ActiveWindow.Object.GetItem(myprojectname).Select(vsUISelectionType.vsUISelectionTypeSelect)

    I have a workaround for this: comment out this code (There are 3 such calls). Float the macro explorer so you see it beside the solutions explorer. In the latter, selection the first line (the project itself); right click the DNN_Module_Step_001 macro and select "Run" in the popup!

     

    Thanks for your reply. Do you mean that I should select the webproject or the solution? The first line in the solution window is usually the solution itself. I assume you mean the web project, as that is probably the whole idea of this faulty DTE.ActivateWindows statement...

     

    /pJ

     

  • Re: DNN 4 Newbie: Creating a custom module

    03-22-2006, 5:49 AM
    • Member
      275 point Member
    • pchan
    • Member since 10-09-2005, 8:20 AM
    • Posts 55

    >Thanks for your reply. Do you mean that I should select the webproject or the solution? The first >line in the solution window is usually the solution itself. I assume you mean the web project, as that is >probably the whole idea of this faulty DTE.ActivateWindows statement...

    Just to be precise: we're on DNN4, using Starter Kit. Although the sln file still exists, it is no longer obligatory in .NET 2.0; I always start my VS2005, pointing the directory. There is still a webproj file here but it is only 1 octet long; it can't be what you are referring to, unless things changed.

    For me, the first line is simply the repertoire of the web site. Using the default web server of VS2005, this is my hard-disk repertoire. Using IIS, it would be a virtual directory. Selecting the first line is what the faulty instruction was expected to do. So do it with the mouse for her!

    FYI: the various test_XXX macros are part of the tutorial, useful if you read the tutorial. Otherwise, ignore them. Dnn_Module_Step_001 is the one we are all interested in.

  • Re: DNN 4 Newbie: Creating a custom module

    03-22-2006, 3:36 PM
    • Member
      170 point Member
    • emaynard
    • Member since 09-15-2005, 1:58 PM
    • Posts 34
    aviens wrote:

    Hello everyone,

    In evaluating portal solutions for our intranet, I decided to go with DNN. Since this is brand new, (no previous intranet portal exists), the sky is the limit for me. I figure starting with DNN4 is a good idea, as it is fresh new code utilizing the new ASP.NET 2.0 platform.

    Aviens, I think many of us share this same thought as well.  Allow me to share some of my  DNN module development "journey" with you.

    I have seen different tutorials out there... and it is helping me learn this, but it seems I keep hitting walls, which is getting a little frustrating.

    So far I have looked at the following tutorials:

    1. Shaun Walker's DotNetNuke 4.0.0 Starter Kit and Templates post:

    It is a great tutorial, however it currently stops short of what I really want to know... extending the module provided in the Starter Kit. Hopefully the next post will be posted soon. Smile [:)]

    No doubt he is a very busy person these days... but I to am hopeful it will be posted soon...


    2. Todd Davis' video tutorials on module creation for DNN 3.x:

    Great videos of the step by step procedure... but unfortunately, it is geared toward DNN 3.x development, and as I have read, DNN4 and DNN3 is structured quite differently... not to mention the inclusion of the Starter Kit for DNN4.

    Don't let the difference in development structure deter you from watching as there is still much of the "internal" workings that remains the same and Todd is a great resource to see some in-the-trenches development work that will apply to either


    3. Michael Washington's step-by-step tutorial on module creation for DNN4:

    Once again, great tutorial... but where this one becomes hazy for me is on page four and on. The tutorial becomes a copy and paste operation for the Guestbook module tutorial, and I do not clearly understand what is occuring at that point. Why were the template sprocs from the starter kit created only to delete them? Should I not use a code generator like CodeSmith to create my Insert/Update/Delete procedures? And, why is a ModuleID being created but no PortalID is being created in the table? Wouldn't this break if the module were to be used in two different portals hosted in the same database?

    Michael's understanding and teaching interpretations of the DAL really shine in his tutorials which he even admits are cut-n-paste for a reason.  That is more to teach the structure and flow of a basic module design.

    All in all, I think you would be hard pressed to find a more generous and caring community in terms of passing of knowledge and dedication to a project in the open source Dot NET community.


    I guess I have a few questions in utilizing the DNN4 Starter Kit:

    1. The namespace defaults to "YourCompany". Is there any way to specify that so a find and replace is not necessary each time I create a module? I am assuming the way to fix this is to open the ZIP file for the Module Starter Kit and do a find and replace once in there on this, and my problem would be solved.

    2. Would it not make sense to utilize CodeSmith to assist in the creation of the stored procedures necessary to add/update/delete items from the database as well as the creation of the various methods needed in Visual Studio? I am not familar with using code generators, but I would definitely begin to use it if it made my job in creating those rudimentary methods in VS and sprocs in SQL. Does the latest CodeSmith version have DNN4 templates already created for the DNN community?

    I can't speak for CodeSmith, but I have been working at customizing a set of MyGeneration templates created by grandOpus for DNN3 to work with DNN 4 the starter kit and Michael Washington's module design tutorial.

    I think any project, even ones with a single table and small number of fields still could still make use of a generator, but I think Michael's take on this is that by keeping that stuff out of the picture as you learn the basics of framework, you will have a better understanding of how to use these for bigger projects.  That has been my experience as well to date.  I feel so much more comfortable tweaking and using the above mentinoned templates because of working through Michael's barebones module tuutorial.


    4. Books. I currently own Professional DotNetNuke ASP.NET Portals and Building Websites with VB.NET and DotNetNuke 3.0. Unfortunately, all the books that deal with DNN4 are still not out yet:


    Again, don't under-estimate what can be learned from DNN 3.x programming.  Aside from the structure changes and streamlining of areas like Michaels's DAL+ it is still pretty much the same "beast" and you will extend modules and program the "internals" in much the same fashion.


    I have many ideas to start developing custom modules for our intranet portal, but right now I am still trying to understand the concepts of putting together the modules.

    I plan to create some general reusable modules that I can release to the community at no charge, but also create modules specific to applications needed internally (small database trackers, calendaring tools, etc.)

    I am eager to jump into the DNN fray, but am still searching for the most efficient way to create my many modules to come!

    Also, note that as an experienced NET developer in need of more intranet like apps, you might find the dynamically loaded user control work-arounds that have been created to be of some use.

    Basically, the idea is that if you don't need to distribute these apps to more than a single portal, your time and experience might be better spent "plugging-in" your own user controls into DNN and forgoing the DAL's structure and complexities altogether.  Just do a search for "OpenSmart Module" or  "OpenDNNSmartModule."

    One final note, again from my own journey down the road of learning to program DNN, you will find that subscribing and/or purchsing the source code from a "professional" DNN developer to be one of the best learning tools.  I personally recommend Scott McColluch and Onyak Technologies because the do offer subscriptions and source code, but of course any of the core modules would also fall under this category as well.


    Hope this helps someone else out there on the same journey.

    -eric
  • Re: DNN 4 Newbie: Creating a custom module

    03-27-2006, 8:41 PM
    • Member
      55 point Member
    • TAGrove
    • Member since 10-14-2005, 1:32 AM
    • Posts 11

    Eric,

    You stated the following:

    Basically, the idea is that if you don't need to distribute these apps to more than a single portal, your time and experience might be better spent "plugging-in" your own user controls into DNN and forgoing the DAL's structure and complexities altogether.  Just do a search for "OpenSmart Module" or  "OpenDNNSmartModule."

    I did search, but came up empty.  Could you post a link to OpenSmartModule and OpenDNNSmartModule?

Page 1 of 2 (20 items) 1 2 Next >