green field

Overview of Content Feature Development

Implementing a new feature that plugs in to the content system in mojoPortal is relatively straight forward . Features can be very simple, involving only 1 module control (see the ContactForm.ascx module for a simple example) or more complex, requiring any number of supporting .aspx pages in addition to the module control (see the Forums.ascx and Forum*.aspx pages for a more complex example)

Every feature should have 1 (and usually only 1) ModuleControl which inherits from mojoPortal.Web.SiteModuleControl, this is the part that plugs into the mojoPortal content management system and allows you to put an instance of your feature on the content system page. Instances of this ModuleControl can be placed on page(s) along with ModuleControls from other features such as the Html Content Module, Links Module etc. For a simple feature the ModuleControl may be all that is needed.

Notice that in mojoPortal, all the pages in the menu are derived from the database and don't actually correspond to any physical .aspx pages. There is actually only one page that handles requests for all these content pages and that page is Default.aspx. This page knows what content page to display based on a query string parameter pageid so the actual url is always Default.aspx?pageid=x where x is replaced with a pageid corresponding to a page in the database. Since we use url re-writing to make friendly urls, you normally do not see Default.aspx?pageid=x but instead see something like home.aspx or forums.aspx. Under the hood, these friendly urls map to Default.aspx?pageid=x

So the ModuleControls are loaded into the page based on data from the database which captures the feature module instances which the content author(s) has placed on the page. For more complex features like the forums, the ModuleControl links to supporting .aspx pages like ForumView.aspx, ForumThreadView.aspx, ForumPostEdit.aspx etc. These pages are actual physical .aspx pages that are not linked directly from the menu. You can think of the ModuleControl as the entry point to a feature, but the feature does not have to be fully implemented within the Module Control. It can have as many supporting pages as needed so that very complex features may be implemented. Your module control must know how to link to those supporting pages.

To implement a Module Control, you just create a User Control by right clicking a folder in Solution Explorer (Visual Studio 2005) and choose Add > New Item...>Web User Control. After that you need to modify the User Control so that it inherits from mojoPortal.Web.SiteModuleControl.  If your feature needs supporting pages, you need to make them inherit from mojoPortal.Web.mojoBasePage. You can refer to existing features for examples of how this is wired up. You could even copy an existing ModuleControl and supporting page and modify it to start your own feature.

Inheriting from mojoPortal.Web.SiteModuleControl, is what allows your feature to plug into the content management system of mojoPortal. Additionally it also provides a simple implementation of IWebPart which allows the module control to be exposed as a WebPart. In mojoPortal, the MyPage feature utilizes WebParts to provide user personalizable pages. In the Module Settings for any module instance you can check the box that says "Available for MyPage" and this will make the module instance available in the WebPart catalog so users can add it to their personalized page(s) under MyPage. So by inheriting from SiteModuleControl your feature will be able to be added to personalized pages as a WebPart.

Instead of adding your code right into the mojoPortal projects, its best to implement them as separate projects and your own Solution. Start by copying one of the mojoportal solution files (mojoportal-core.sln for example) and rename it. Now you can add your custom projects to this solution. Doing this makes it easier to stay up to date with the latest mojoPortal source code from the svn repository. You'll be able to update mojoPortal from svn without it touching your custom code. If you find something that needs to be changed in the mojoPortal code in order to support your feature, consider submitting the change back to the project.

For more information see Setting Up a Solution for Custom Development.

Last Updated 2007-09-04

mojoPortal Wins the 2007 Open Source CMS Awards Best Non-PHP Open Source CMS Donate Money to support the mojoPortal Project. Join the mojoPortal Group on Facebook Join the mojoPortal Group on LinkedIn View Joe Audette's profile on LinkedIn View Joe Audette's profile on The Guild of Accessible Web Designers site mojoPortal can run on GNU/Linux using Mono