Yesterday I had a chance to start poking around Joomla, as one of my customers was moving his site to it. I have to say, I'm impressed. From a development perspective, Joomla is really an extensible framework that offers a clean MVC PHP library, and a CMS with lots of pre-built modules to go with it.
There's only one minor catch - the docs really only appear to cover version 1.5. Which means that, when I needed to build a custom component in a version 1.0 environment there wasn't exactly a clear how to to refer to.
So here are some dev tips I've picked up while trying to work with a 1.0 based system. Hopefully, they can save you some time if you end up in a similar situation.
- The best example of a 1.0 component I could find was here. The good news is that a 1.0 component is more straightforward to implement than a 1.5 version one. There's no framework to mess with - just create a top level PHP file that will kick off the entire process and name it appropriately. That is, if you have the foo component you'll want to create: foo.php and foo.xml (more about the XML in a second). You can, if you want, put these items in a zip file and use the installer to install them, or just push them via FTP to the directory: [Joomla root]/components/com_foo/.
- The docs mention it, but it's worth mentioning again: _JEXEC is not defined in version 1.0. If you include:
defined( '_JEXEC' ) or die( 'Restricted access' );You'll always get a Restricted access message. You want to start your scripts with:
defined( '_VALID_MOS' ) or die( 'Restricted access' );
- The variable $task is automagically available to you in your top level script.
$mainframe->addCustomHeadTag( "<link type='text/css' ...>" ); ...$mainframe is another magic variable. Don't forget to use global to get at it from inside a function.
To have your component break out of the page structure and return back a different content type, you can do:
header('Content-Type: text/xml'); echo "<?xml version='1.0' ?>"; ... more echo statements... exit();This seems like the wrong way to do this. But, from [Joomla root]/includes/feedcreator.class.php, it appears that's how it's done.
- I had a bunch of trouble finding the format description of a 1.0 xml package description. Turns out, this page has one. Note that the format is very close to the 1.5 format, but uses the outer tags: <mosinstall type='component'> ...</mosinstall>.
- I find the 1.0.11 user manual to be relatively helpful. And I found the best source of components to examine to be in the Joomla source tree under /components.
Happy 1.0 Hacking!