Geeks With Blogs
Steve Land StrongEye Solutions LLC

If you saw my earlier post about creating a MojoPortal Module, you might have been daunted at the number of steps. This article outlines a simpler approach for simpler modules.

The earlier article followed Joe Audette's examples, and generally this is the correct approach in cases where you want a full feature added to the Web site.

Note: this article is for developers who already have set up their project to develop new custom code for mojoportal, and who already have a project similar to my earlier post. If this is true, and you want to add a new simple one-ascx-module to your portal, keep reading...

This approach is a quicker one and is for situations where the module you are creating is simple. For example, I wanted to add a single page (a la ASCX controls) to the portal and did not want this to be a starting point for many other aspx pages.

To create quick modules that contain all their functionality in a single control, I did the following:

  • Created a subfolder in my other web project that is setup a'la my earlier article called "QuickModules"
  • Inside this subfolder, created a new .ASCX User Control
  • in this User control, copied the guts from the mojoportal EmptyModule.ascx.cs file (found under Web/Modules/ ) into the code-behind file inside my new control. Salient points to watch:
    • Your ascx must inherit SiteModuleControl
    • You should copy the #region OnInit and all the methods (Page_Load, PopulateControls, PopulateLabels(), Loadsettings() ) into your new control's code behind
  • Once finished, update your projects' Build Events section (Post-build event command line:, for details see my earlier post)  and add a line specifically for this new control. If the build events copy this directly into the MojoPortal /Modules/ folder, it can then be added as a Feature. For example, my entry looked like this (I added extra subfolders to keep my code very separated from the core code):

    xcopy /s /y "$(ProjectDir)QuickModules\*" "D:\projects\mojodev\Web\Modules\StrongEye\Catalog\QuickModules\"

  • Build and run your mojoportal so your new control gets copied.
  • Finally, in the mojoportal UI, go to Administration > Advanced Tools > feature installation/configuration. Choose "Add new feature" and in Control Source put the destination mojoportal path. In my case it was this:

That's it!  It's a real time saver for those cases when you just need something fast and simple. Obviously, more elaborate features probably deserve their own projects, but I'm pretty happy with this for many scenarios.


Posted on Friday, January 15, 2010 4:44 PM | Back to top

Comments on this post: Quick Modules

# re: Quick Modules
Requesting Gravatar...
Any thoughts on the best way to develop new modules for MojoPortal without having all the code in your solution? I've followed your steps and created a folder structure with all the Mojo projects linked in but it's so slow to run when I want to test things. There must be a better way? I note that you say you're developing your features outside MojoPortal - have you got time to write up how you then link them in? Thanks.
Left by Suzy Smith on Feb 05, 2010 8:49 AM

# re: Quick Modules
Requesting Gravatar...
Basically most of my features are developed as vanilla .ASCX controls that have properties exposed that are needed for integration, such as UserId. During development, I build test harness ASPX pages to contain these and stub out the values for mojoPortal data until the feature is nearly complete. Only after it's built do I then integrate it with pages that inherit from MojoBasePage. These pages pass the dynamic values to my controls.
See Joe's new video series on how he does it, you can set up your projects so you don't need to build all of mojoportal every time, that speeds things up considerably too.
Left by Steve Land on May 03, 2010 2:47 PM

Your comment:
 (will show your gravatar)

Copyright © strongeye | Powered by: