If you ever tried to write an extension for Joomla you probably know that old components, modules, plugins and templates, for Joomla version 1.0, are not compatible with version 1.5. With some minor tweaking, you could get old extensions to run quite nicely in Joomla 1.5 if you turned on the legacy mode plugin.
However, more and more Joomla users require native 1.5 extensions only and won’t bother turning on the legacy mode. The developers convert their old extensions to new ones but they are forced to distribute them separately for different Joomla versions. Here is how you can fit them together so that the same package can be installed both on Joomla 1.0 and 1.5, without legacy mode needed.
Why a single installation package?
It’s convenient both for the user and the developer to only deal with a single installation file which works for any Joomla version. However, users wanting legacy-mode free plugins complicate the situation. Even if developer manages to solve the incompatibilities on the code level he will still be faced with installation obstacles. Namely, Joomla 1.5 has a new manifest format and won’t install an old extension without legacy mode being turned on.
I’ve seen some devs instructing their users to temporarily turn on the legacy mode just for installation to be turned off immediately after. This is not ideal solution as users do not often read the instructions and, after they have been presented with a message “This extension is written for old version of Joomla” they may be giving up. So what can we do? Well, here is a solution that elegantly solves this problem creating a single package which installs on both Joomla versions with no legacy mode needed at any time.
The trick is to use two different manifest files, one for Joomla 1.0, and other for Joomla 1.5. We need to package our extension in a special way to fool the installers to load the appropriate manifest. Here is an example for packaging a simple Joomla module in a file installable on both Joomla versions with no legacy mode. The same example can be analogously applied to components, plugins etc.
I call my module mod_example and structure it as follows:
As you can see, I have files and folders for Joomla 1.0 directly under the root, but I create a new folder called “1.5″ in which I put files and folders for Joomla 1.5. You can call this folder differently but the name has to start with a character that comes before “m” in the alphabet. The trick is that Joomla 1.5 installer will take the first manifest it finds in the package, which in this case will be: 1.5/mod_example.xml, while Joomla 1.0 installer will take the manifest that resides on root: mod_example.xml.
This way we can nicely separate files for Joomla 1.0 and Joomla 1.5. Of course, we have in fact two modules in one package so we must maintain both but it’s worth it since we can take advantage of Joomla 1.5 framework and we avoid mixing things together if we would to have everything in same files. If we now zip it together we get a single package that installs both on Joomla 1.0 and 1.5!
Finally, I attach the zipped example module that you can play with and try to install on both Joomla 1.0 and Joomla 1.5 without legacy mode.