Midgard Lights An Open-Source "LAMP."
By James Christensen and Martin Gottlie at 2001-10-10 00:00:00 |
Midgard has emerged as one of the leading Open Source content management systems. It has strong community support, a powerful templating architecture, and is highly customizable and extendable. It's latest and most robust administrative interface, Nadmin, is itself an Open Source Midgard extension.
Like other Open Source CM packages, customizing Midgard to your needs is not for the technically faint at heart. What follows is a fairly detailed discussion of pros and cons of the platform from a programmer's perspective.
LAMP Underpinnings
Midgard is based on "LAMP," an acronym for a set of open-source technologies that together can provide an extremely powerful platform for busy public websites. The elements are:
- Linux, a highly reliable operating system with a great "uptime" record in web environments
- Apache, an extremely fast and configurable Webserver
- MySQL, a fast, tunable, relational database frequently used for Web publishing
- PHP, a scripting language implemented as an Apache module that was built specifically for use on the web.
Apache
The core of Midgard, like the PHP engine itself, is actually an embedded Apache webserver module for templating. If you already favor Apache and the myriad of modules that can extend its capabilities, you will be very comfortable installing and using Midgard. (Midgard's tight integration with Apache is one of the reasons why IDEV selected it to manage content on the website you are visiting right now.)
MySQL
The other leg of Midgard is MySQL, a highly popular open-source database known for its ease of administration and very fast data "reads," which makes it a strong performer even for busy publishing sites. Of course, MySQL has drawbacks, too, including an absence of foreign keys, transaction support, and UNICODE compliance -- all useful attributes for highly transactional or multinational sites.
PHP
The PHP scripting language has quietly taken the Internet by storm over the past three years. Designed specifically to drive dynamic websites, PHP has been installed on more than 6.5 million websites, according to NetCraft. As a high-level scripting language, you won't be doing true object-oriented programming in PHP, but it remains a strong rapid-application environment.
Midgard uses PHP as the API into a library of lower-level functions written in "C." Although several PHP-based CM packages have emerged over the past couple of years, Midgard appears to have the strongest velocity.
Architecture
Midgard's strength lies is its templating system, which enables you to define and re-use elements.
Template elements are referred to in Midgard as "Styles" -- something of a misnomer, since in Midgard it refers to structural elements rather than presentation logic. Styles consist of a main "ROOT" element that defines the page layout and can consist of any number of sub-elements. These elements can be anything from page headers and footers, site navigation or anything else you would typically identify on a page component diagram.
Styles can be re-used to create "Substyles" that inherit all elements from the parent style and override or add individual elements as desired. This powerful feature allows you to create many similar templates that share a pool of common elements. Styles are assembled into actual website pages, allowing the content of the page to be displayed within the style template.
Similar to styles, "Pages" can also consist of individual elements that can be unique to the page itself or inherited by all sub-pages of that page. They can even override style elements, providing an extremely fine level of control over how pages or sections of a site are rendered.
Midgard supports both databased and static publishing. Static content can be easily published directly into individual, templatized web pages. Midgard provides support for dynamic content via a news topic/article infrastructure that pulls content from the MySQL database. Topic trees can be created with any number of branches. Articles are then added into the topic tree at a selected branch, although you have to script some PHP code to actually connect the databased content to the proper template.
Orginally designed to meet the needs of a modest news site, Midgard supports datatypes such as news articles and topics, to events and calendars. All of these "native" datatypes share methods for persistence (ie create a new article, change the address of a member, delete a past event) but also have object-specific code to get lists of objects, find relationship etc.
It is atop this API that web applications are built. Midgard objects are helpfully generic, but they are also fixed. This means that modifying existing objects or creating new ones requires changing -- if you dare -- the underlying C source code and recompiling the library. We have worked around this limitation by sticking with the PHP interface and using custom parameters, arbitrarily associated data, or metadata, but it's a little cumbersome and not entirely satisfying.
Nadmin
The most important application for Midgard -- the one that turns Midgard from an application framework into a relatively useful content management system -- is the administrative front end. Midgard went through two previous versions before the Hong Kong Linux Center announced "Nadmin" (now Nadmin Studio), which uses PHP and DHTML to provide an attractive and powerful interface to the underlying Midgard API.

Sample content approval screen within Nadmin
Nadmin provides facilities to manage multiple websites, as well as edit web pages and smaller shared elements of HTML or PHP code.
Permissions are not terribly granular, but they can be adjusted sufficiently to allow authors and editors to see only news, designers to see only page templates and so on.

Nadmin Permissions Interface
Nadmin adds revision control to its interface with Midgard's datatypes so that an unfortunate change to the left navigation, for example, can be "undone" and returned to a known good state. Unfortunately, Nadmin does not natively provide the ability to version an entire section or website (although a command-line tool called "Repligard" can save off a whole site or section for archival purposes -- more about that later). And editors beware: there is no native "check-out" or similar version-control mechanism to keep concurrent users from overwriting each others' work -- although the product can be extended to provide element and page locking.
One of Nadmin's other strengths is the way that it takes advantage of the versatility of Midgard's open interface to enable you to include other PHP applications within a content management framework. There are scores of quality PHP applications that can be integrated into Midgard and Nadmin with relative ease due to Midgard's (somewhat utilitarian) code management facilities. Indeed Nadmin Studio includes a forum application, some system administration applications (e.g. email), an ad server, web statistics and a search engine -- all of which are independent projects. This integration is more complete with some applications than with others, but if you have existing PHP code, expect to be able to incorporate it with little difficulty.
Repligard
Nadmin also employs Midgard's relatively new replication system, "Repligard," along with Perl and shell scripts, to accomplish a simple staging/production environment, where pages, news articles, page templates can be edited and tested in staging and pushed up to production after approval.
Repligard uses Midgard libraries to export and reimport an entire site, group of sites, or an entire database of companies and sites to an XML file, saving relationship and state information. Repligard can also be configured to export only changes made to a database since the last export. It can also pick a particular branch of the site tree to export. These export files can be used for mirroring or backup purposes.
Nevertheless, this replication is still fairly ad-hoc, but will no doubt improve as Repligard evolves to allow for finer-grained rules.
Midgard's Future
What does the future hold for Midgard? The platform's chief developers have committed to releasing a completely rewritten, stable version by December, 2001. This will probably be incorporated into a hybrid Midgard 1.6 while Midgard 2.0 is primed to completely replace the existing Midgard framework.
Interesting features slated for Midgard 2.0 include a flexible object model, so that new datatypes can be defined with little or no impact on existing code. While the present version of Midgard is wedded exclusively to MySQL, version 2.0 will be database agnostic, so that the filesystem could be used to store page templates and elements, a database could be used to store news articles and LDAP server could store user and member information.
The adoption of XML-RPC -- a cross platform protocol that allows applications to execute code on other networked machines -- raises the possibility of Perl or Python applications taking advantage of Midgard. It will also enable siteowners to off-load resource intensive applications to other servers.
Conclusion
Midgard is a powerful and flexible CMS whose strength lies in its templating system and its ability to integrate 3rd-party PHP applications.
Like other Open Source CM packages, however, Midgard is weak in areas where commercial products have made substantial investments, such as Workflow, Library Services, and Personalization. The Midgard / Nadmin combination is not for everyone, but if you have already made a commitment to Apache and/or PHP, it should join your short-list of CM platforms to consider.
