MODx: Simply the Best CMS

MODx Manager Interface

MODx Manager Interface

Okay, so the title may be a bit overstated. There are a number of very good Content Management Systems, and sometimes, it just comes down to personal preference. However, MODx has the power and potential to make it to the top of just about anyone’s favorites list.

What is MODx?

It’s a Content Management System (CMS). A CMS at its heart is simply a nice GUI backend for managing your site’s template and content. What makes one CMS better than another is its additional built-in features and/or extensibility. That latter is where MODx outshines all the others.

As far as built-in features go, MODx falls more on the simplistic side, but its simplicity is what makes it so great. It has all the things you would expect from a good CMS. User management, templating, content editing, document management, etc. What it doesn’t have is a lot of hard coded features you may never use and mostly just get in the way. MODx achieves this with insane extensibility, allowing you to add custom dynamic features to any part of your site or even MODx itself.

You can make MODx anything you want it to be: a simple website, ecommerce store, blog, whatever. Some other CMS solutions provide so many built-in features that it either ends up taking great effort getting it just the way you want or your site ends up cookie-cutter.

How does MODx work?

Everything you put in MODx falls into one of the following categories: template, chunk, template variable, snippet, plugin, module, or document. Let’s see what each is and how they add up to make one of the most powerful CMS solutions around.

Templates

Just as you would imagine, these hold the actual HTML code that makes up your site’s layout and structure. You can create as many as you need or want, and they can be switched out on a document by document basis. This allows you to easily create home page and sub page layouts or even entirely custom layouts just for specific portions of your site. Templates are stored in the database and don’t mix and match HTML and PHP like many CMS templates do. This doesn’t make them less customizable, though, as MODx utitlizes a parser and template tags to allow you to pull in content or dynamic code. This makes it very easy for inexperienced designers to create sites.

Chunks

Chunks are simply pieces of HTML or content, intended to be dropped-in to portions of your site. The best principle every conceived in my opinion is DRY: Don’t Repeat Yourself, and chunks give you the power to accomplish that. Anything on your site that might be used again anywhere else goes into a chunk. Then it’s simply a matter of “calling” it somewhere within your template or even another chunk, using the format: {{chunkName}}. Then, MODx will find any occurrence of this an replace it with the actual content stored in that chunk.

Template Variables

On their surface, template variables are simple things. You create a template variable and specify what type of form field it should be: textbox, textarea, dropdown, etc. Then, you tie it to one or more templates, and any documents that make use of those templates will have fields for you to specify the template variable’s value. That value can then be called anywhere on your site, much like a chunk but with a slightly different format: [*templateVariableName*]. You could almost think of template variables as chunks that you can specify on a page-by-page basis. A common use case is adding “head” and “foot” template variables which get placed before the closing </head> tag and before the closing </body> tag, respectively. With that in place you can then add additional things to the HTML meta or extra stylesheets or javascript only for specific pages.

If that’s all template variables could do, it would make them extremely powerful, but they have more tricks up their sleeve. Template variables can be used to pull data from the database, evaluate one-off PHP scripts, and many other rather complex tasks. They could be a post in themselves and might end up that way if I get properly motivated. For now, though, the main thing to take away is that if MODx could do nothing else but work with template variables, it would still be a powerhouse of a CMS. They are just that good.

Snippets

Snippets are custom PHP scripts that can do anything, limited only by PHP itself and your imagination. However, they could be better thought of as functions, since MODx expects them to return something; though, it’s not required that they do. Snippets are “called” like chunks or template variables with a few exceptions. The general format for calling a snippet is [[snippetName]]. That form will result in a “cached call”. MODx will cache what the snippet returned and use it again rather than rerun the snippet code. This can create great performance improvements for content that needs to be dynamically fetched or manipulated in some way, but remains basically static afterwards. To do an “uncached call”, the format is: [!snippetName!]. (Notice the excalamation points.) Everytime MODx parses this type of snippet call, it will rerun the snippet code for a new result.

Since snippets are essentially functions, it follows that you would often need to pass in values. Thankfully there’s a rather simplistic way to do so: [[snippetName? &parameter=`someValue`]]. Instead of closing the call after the snippet name, we now put in a question mark. (For me, it helps to look at this almost like a GET request in a URL, as they are very similar.) Then, you can specify as many parameters as you would like or need. The parameter’s value is wrapped by backticks (the key that’s typically on the far left of your keyboard just above the Tab key). This allows you to use single and double quotes in the parameter’s value without having to worry about escaping them with a forward slash. MODx will create PHP variables out of these parameters for you (much like PHP Globals would do with request variables), so any parameter you pass into the snippet will be instantly available to your snippet as $parameter.

Plugins

Plugins provide low-level access into the MODx system. MODx comes with a number of system events builtin. (The potential to add more of your own is there, but is way too complicated for the average user, though a future version promises to make it simpler. Regardless, the builtin system events cover most use cases.) The plugin itself is just PHP and just like snippets, is limited only by PHP itself and your own imagination. The main difference is that snippets are run independently during the document parsing stage, whereas plugins can tie into one or more stages of MODx’s page rendering and add to or alter portions of the page. This is extremely powerful and much simpler to set up than any other CMS’s plugin system.

Modules

Modules actually allow you to add to the MODx interface. They are composed of one or more snippets or plugins. The module code itself specifies the UI that should be set up for working with your addition. MODx comes with the DocManager module by default, which lets you change document permissions, templates, etc. to many documents at once. One of my favorite MODx modules (not pre-installed) is the DocFinder module which namely adds search and replace functionality across your entire site’s content. It’s an absolute thing of beauty.

Documents

Finally, documents are the actual pages that make up your site. They can be HTML or you can choose from other mime types such as XML, RSS, plain text, etc. You can make pages “containers” and then add sub pages into that container to set up you site structure. You can publish and unpublish pages on the fly. They become even more powerful when you have multiple site editors, as you can set up group or single-user access to documents on the fly. This also makes MODx a rather good CMS for clients, as you can allow your clients to make changes to specific portions of the site while blocking access to specific documents and site templates.

Where can I get MODx?

This was a very high-level overview of what MODx is and what it can do. I plan to go deeper into more of the internals in future posts. For the time being, though, your appetite should be sufficiently wetted enough to give MODx a try. You can get MODx from their downloads area. They also have a rather extensive repository of snippets, plugins, and modules you might want to check out. There’s also a live MODx demo now up at OpenCMS, if you want to play with it before you give it an install.

  • Del.icio.us
  • Digg
  • Facebook
  • Google Bookmark
  • StumbleUpon
  • Technorati
  • chola
    Modx is behind the times as far as a CMS goes, it's more for code monkey's who enjoy spending all their hours of the day looking at code.

    The more user-friendly CMS are far more intuitive and effective for day to day content management.

    Modx just doesn't get it, they will always be 20 years behind.
  • nyl auster
    Modx can do much more thing than CMS like Drupal and Joomla WITHOUT looking at php code. If by code you means templates and Modx tags, well you maybe not the good end user for Modx : it requires to know perfectly html.
  • Modx sucks. Another developer installed this on a site we did and everytime I have to go in and edit something I spend 50 minutes trying to decipher the difference between a chunk and a snippet and how it all flows together. It certainly isn't intuitive.

    In modx's defense it took me a little time to get up and running with Joomla, but the differences between the two are vast. Modx seems obtuse, clunky and backwards. If you're going to use a cms, just use joomla and don't waste time with this.
  • nyl auster
    @Brian : If you are not able to dechiper the reference between snippet and chunk; that's mean you are not able to see the difference PHP and HTML. I hope you are not a webmaster or a developper.
  • John
    I can't be more agree, Joomla and MODx are two different beast.

    Basically Chunks are HTML and Snippets PHP code.

    I think that you're looking for "Point & click" system like joomla or Wordpress.
    MODx is not geared toward what you're searching for and will probably never be.

    In the same way, your Joomla sites will always look like every Joomla websites, your are limited to think the Joomla way to develop your applications and the framework is not as Flexible as MODx is.

    MODx may seems obtuse, but backwards and clunky? Comparing to Joomla? You're kidding right?
  • besman
    Modx might be the best but installing it is definitely not intuitive!

    I tried using both Xampp and Wampserver. I get one step further with Xampp but a little. With Xampp, I get stuck at Database Information (Database name, Table prefix, Connection method, Collation). I'm instructed to

    "Enter the database name to use or which you wish to create for this MODx install. If no database exists, the installer will attempt to create one. This may fail depending on the MySQL user permissions"

    and to...

    "Create or test selection of your database"

    but when I do, I get...

    "Checking database: failed - could not create database"

    When I try installing it using Wampserver, i.e.
    "Enter the database host (server name or IP address), the username and password before testing the connection."
    But nothing happens.

    Perhaps there are some settings that I'm overlooking but if so, there are no clear steps to configure the required settings.
  • MODx will attempt to create a database if one hasn't been created yet, but depending on your server configuration, this may or may not be successful. Particularly on shared hosting environments, it will invariably fail, since most do not allow automatic database creation.

    That said, it seems you're trying to install MODx in development environment on your computer, and while I'm not overly familiar with either Xampp or Wampserver (both Windows, and I'm exclusively on a Mac), my guess is that they, too, are not allowing automatic database creation in their default configuration.

    You should be able to simply use whatever GUI those tools give you (most likely phpMyAdmin) to create a database and a user for MODx, though, and then provide that information to the MODx installer. If the database checks in the MODx installer are failing, it can only be caused by one of two things: 1) wrong connection information (server name, database name, database username, and database password) or 2) the database user doesn't have sufficient privileges.
  • This is a great overview of MODx. I am convineced that i can use MODx for anything :)
  • Ray
    An excellent overview! High-level, yet going into just the right amount of technical detail to explain to a potential new user how the components actually work together. I've been happily using MODx for most projects since mid-2006 and I can fully agree with your asessment.

    This is definitely a good resource that I can point people to who are "shopping" for a new CMS.
  • Thanks for your comment Ray. When I came to my current job, they had just switched to MODx for their client CMS solution. This was my first exposure to MODx, and I was instantly entranced by it. It was a lot less polished back then (early 2007) than it is now. I'm seriously impressed by 0.9.6.3.

    I just finished customizing out a new default install of our MODx (which is what prompted me to write this post). It's not really upgradeable that way, but it's amazing the features you can.

    I think there's probably a time and a place for just about any CMS, but I've yet to find something I couldn't use MODx for.
blog comments powered by Disqus