Posts
6
Comments
22
Trackbacks
0
January 2010 Entries
Quick Modules

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:
    Modules/StrongEye/Catalog/QuickModules/MyModuleUserControlName.ascx

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 | Feedback (2)
Bare bone layout.master for MojoPortal module development

The code below is a bare bone Layout.Master master page for MojoPortal. I found that the default ones all still had some dependencies on MojoPortal. Since I'm trying to develop most of my features outside the portal (quicker build times), I needed to have something without dependencies that would still help me get something approximating the MojoPortal environment.

 

<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="~/App_MasterPages/layout.Master.cs"  %>
<!DOCTYPE html>
<html>
<head id="Head1" runat="server"><title></title>
</head>
<body>
<form id="frmMain" runat="server">
 
<asp:ScriptManager ID="ScriptManager1" EnablePageMethods="true" runat="server" />
<div id="wrapwebsite">
     
      <asp:contentplaceholder ID="pageEditContent" runat="server" Visible="false"></asp:contentplaceholder>&nbsp;
      <div class="wrapcenter">
          <asp:Panel id="divCenter" runat="server" visible="true" cssclass="center-nomargins" SkinID="pnlPlain">
                <asp:ContentPlaceHolder ID="mainContent" runat="server"></asp:ContentPlaceHolder>
          </asp:Panel>
          <asp:Panel id="divLeft" runat="server" cssclass="leftside" visible="True" SkinID="pnlPlain">                                         
                <asp:contentplaceholder ID="leftContent" runat="server"></asp:contentplaceholder>
          </asp:Panel>
          <asp:Panel id="divRight" runat="server" visible="true" cssclass="rightside" SkinID="pnlPlain">
                <asp:contentplaceholder ID="rightContent" runat="server"></asp:contentplaceholder>
          </asp:Panel>
      </div>                                   
</div>
</form>
</body>
</html>

 

 

Posted On Sunday, January 10, 2010 11:30 AM | Feedback (0)
MojoPortal starts up multiple Web servers in Visual Studio

When debugging, you might see that MojoPortal starts up many different ASP.NET Web servers, one for each Web project. Hidden in the readme README.VisualStudio.txt included with the SVN trunk is the workaround. Good to know!!

Additional info:

You may notice when debugging that multiple web servers are spawned. This is because there are multiple web applications in the solution as features are split into separate projects. All the files for features get copied up to the main mojoPortal.Web project ie Web folder by post build events, so the feature projects are not meant to be run directly, the mojoPortal.Web project  must always be the startup project, though you can set breakpoints and debug any of the code in any of the projects, but the main web project always has to be the startup project. You can disable those extra web apps from launching a web server as described here http://stackoverflow.com/questions/16363/how-do-you-configure-vs2008-to-only-open-one-webserver-in-a-solution-with-multi#16390

Just click the project node in Solution Explorer and then click the Properties tab on the right and you will see where to disable it. I have disabled them on my copy but it does not seem to persist those settings in the solution, they are apparently user specific.

Posted On Wednesday, January 06, 2010 2:01 PM | Feedback (0)