I am a web developer, born in PERU and now living in PDX. My platform of choice is CFML but I'm always open to learn anything. I currently work for Mentor Graphics.

I also do freelance web development and have a few open source projects that I maintain.

Where To Find Me:

Model-Glue / HomePortals Sample Application

November 17, 2009

A few weeks ago I wrote about how to use the layout management features of HomePortals on a ColdBox 3 application. This time I want to show how to do the same but with an application built with the Model-Glue framework and also explain a bit more of why would you want to do so in the first place.

Why Do It?

HomePortals by itself is not a full MVC framework, it is primarily a library or engine that renders webpages on a modular fashion. This means that when you define a page in HomePortals you define it as a collection of individual components or modules that should be displayed, however these modules are not tied to any particular page and can be reused with easy anywhere.

On top of that, HomePortals can manage libraries of user-defined resources without being tied to a relational database. Resources can be anything that your application requires, such as blocks of content, images, products, blog entries, etc.

These two features makes HomePortals a good way for rapidly adding "Content Management" features to any existing application. And the beauty is that your application will only interact with HomePortals on a purely programmatic way, like you maybe already do with ColdSpring or Transfer.

The Sample Application

The sample application shows how a Model-Glue application can integrate and render HomePortals pages. It shows how to take advantage of features such as pre-defined widgets (RSSReader, image), use of resource libraries for content blocks, and more important how to encapsulate regular Model-Glue events as modular content on the page.

I think the last item is very crucial for integrating with existing applications. By embedding regular events, you can use any predefined features in HomePortals as ancillary content that is already built (think static content resources, common widgets) but still have the main logic built as regular elements of the framework. And you are not restricted to do only one event per page, but you can mix multiple events on the same page as if they were independent of each other.

To download the sample application you can go here.

Here are some aspects worth mentioning:

  • The HomePortals engine is loaded as a regular ColdSpring bean that is persisted on the Application scope.
  • Settings are defined on a file named homePortals-config.xml.cfm in the config directory.
  • The default event (page.index) dispatches a message named "loadPage" that is intercepted by the Controller, which loads a HomePortals page. The page to load is given by the URL or FORM variable 'page'. When empty loads the default page (defined on homePortals-config.xml.cfm). The final HTML output is stored on the event context to be rendered later by the view.
  • HomePortals pages are defined on the /pages directory. And are defined as XML files.
  • The main layout or template used for output is /layouts/Layout.Page.htm

Integration With Other Frameworks

I am currently working on an integration with MachII but still have some issues to solve there. After that I'd like to explore FW/1 and the venerable FuseBox.

PS: By the way, doing integration work is a great way of learning the "guts" of a framework. Highly recommend it :)


Posted on November 17, 2009

Related:
All comments are moderated to prevent spam
Leave a comment