2012-01-20
Revolution 2.2 available: What's New?
Two weeks ago we saw the release of MODX Revolution 2.2 - you probably heard a thing or two about it already. In this article I will introduce to you the new features I think are most impressive.
One of the hardest parts of writing this article is picking which features to discuss. Of course there's the big ones like the ability to use custom resource classes and media sources, but there's also a number of little (and slightly bigger) gems that may be easier to miss and may not have been covered in much detail by others yet. I think I'll cover those here.
New Tag: Comment
This was already added in 2.1.5, but in its simplicity yet powerful application it's worth a mention here plus it's such an easy thing to miss!
Let's take an example of when this comes in handy. When working on a template you need to make some changes in the way your snippet works - but as you'll need to be able of reverting quickly (and you don't run VersionX) - it's not uncommon to copy/paste the old call and just put some random gibberish in front of the name (or was that just me?) like this, to prevent it from outputting.
This trick works because it can't find the "zzzWayfinder" snippet, so it has nothing to output. All good right?
Well, almost. MODX Tags are processed inside out which means that even if it can't find the "zzzWayfinder" snippet, it will still have processed our UltimateParent snippet call, even before it even checks if this "zzzWayfinder" thing exists. That's unneccesary processing time, slowing down your site for no reason! It wont be a devastating performance hit in this example, but every bit helps. The worst part is that, when the new snippet tag works, it's too easy to just leave the old snippet in there in case the client comes back with the request to revert it back next week... just in case that happens, the snippet is not bothering anyone there right?
The new comment tags in 2.1.5 take away that problem. Whenever you use the dash (-) as token on a tag, MODX will see it as a comment and will not execute the tag or any tags contained in it, but it simply discards it. So taking our example, this would be perfect to maximize performance but keep record of the tag (and it's just as easy!):
Move your TVs below the Resource Content
This is something we've been doing in Evolution for a while, and Revolution 2.2 now also gives you the opportunity to move your TVs to below the resource content. It's easier for clients (the tab is easy to miss and makes TVs sound like an afterthought, and what on earth is a "template variable", right?) and, well, with the all new shiny UI it doesn't look too shabby either!!
Moving down the TV panel is easily achieved by setting the "tvs_below_content" system setting to "Yes", resulting in a more familiar look for those still used to Evo. If you fancy, you can also get rid of the title of the all new verticle tabs with the "show_tv_categories_header" system setting, though I personally like to keep it there.
More OOP than ever
For the hardcore developers among us, this new 2.2 release marks an even more Object Oriented codebase then we've ever seen. Pretty much all the processors (you know, those great things you can call with $modx->runProcessor() that execute requests made to the connectors?) have been refactored to now be class-based. For example, here's what the chunk/create processor (in core/model/modx/processors/elements/chunk/create.class.php) looks like in 2.2:
<?php require_once (dirname(dirname(__FILE__)).'/create.class.php'); class modChunkCreateProcessor extends modElementCreateProcessor { public $classKey = 'modChunk'; public $languageTopics = array('chunk'); public $permission = 'new_chunk'; public $elementType = 'chunk'; public $objectType = 'chunk'; public $beforeSaveEvent = 'OnBeforeChunkFormSave'; public $afterSaveEvent = 'OnChunkFormSave'; } return 'modChunkCreateProcessor';
You can see the chunk/create processor in 2.1 for comparison on Github, I think it's too big to include here ;)
As you can probably imagine, there's some benefits there to implement that in your own Addon processors, and the three-page long Developing an Extra tutorial in the MODX docshas been updated to match.
Other big, new, fancyness in MODX 2.2
- Shiny new Manager UI, login screen and setup
- Command line setup/upgrade (anyone tried this?)
- Media Sources for better control over file access and base url/path settings
- Custom Resource Classes of which Articles is the first and I think a pretty impressive example.
- Static (file based) Elements
- Automatic minification and compression of assets in the Manager using Google Minify (thanks for the reminder ZAP!)
What's your 2.2 favorite?