Upgrading a Joomla 1.5 Module to Joomla 1.6

With more Joomla 1.6 templates coming out each day, some of the modules you are currently using with Joomla 1.5 might not work with them. Upgrading a module doesn’t have to be a lot of work though. I’ll explain the steps needed to get your module working with Joomla 1.6 in no time!

Language Files

As stated in the specifications your language files should have UTF-8 character encoding and may not contain any of the following names as ‘key’ (ini files are structured like KEY=”value”):

  • NULL
  • YES
  • NO
  • TRUE
  • ON
  • OFF
  • NONE

If you do use one of these words as key, your language file won’t be translated by Joomla, without any error message shown to alert you of that. To prevent this, prefix the keys above with a character, such as ‘J’. Some example keys that are prefixed would be: JYES, JNO, JNULL, etc. Both spaces and the following characters are also prohibited in keys: { } | & ~ ! [ ( ) ^ ”

Another change in language files is that in Joomla 1.6 you should use double quotes around values. Below an example:
COPYRIGHT_LABEL=”Show copyright”

instead of the Joomla 1.5 way
COPYRIGHT_LABEL=Show copyright

Double quotes in Joomla 1.6 languages files

But what if you want to use a double quote in your language string? According to the specifications you need to use two double quotes, but testing that showed me this doesn’t work. What does work though, is using “_QQ_” as a double quote. PHP will replace that value with a double quote.
COPYRIGHT_LABEL=”Let’s “_QQ_”quote”_QQ_” something!”

Shows the following language string:
Let’s “quote” something!

The reason why you should use “_QQ_” is that PHP’s ini file parser (parse_ini_string and parse_ini_file) seems to behave differently since PHP version 5.3.1. Using “_QQ_” you make sure everybody sees the language string correctly.

Comments in Joomla 1.6 language files

Furthermore, comments in language files are now prefixed with a semi-colon (;) instead of the pound sign (#) used in Joomla 1.5:
;COMMENT_LABEL=”Comment this line out in Joomla 1.6″

instead of the old
#COMMENT_LABEL=Comment this line out in Joomla 1.5

The XML file

There are also several changes to the XML file that is packaged with your module (for example mod_breadcrumbs.xml).

<install type=”module” version=”1.5.0″>
<extension type=”module” version=”1.6.0″ client=”site” method=”upgrade”>

Also change the matching closing tag ‘</install>’ to ‘</extension>’

The <params> section is replaced by a <config> section.

<param name=”testSetting” type=”text” default=”something” label=”Test” description=”Test” />

<fields name=”params”>
<fieldset name=”basic”>
<field name=”testSetting” type=”text” default=”something” label=”Test” description=”Test” />

If you have custom fields, set the path to your custom fields in the <fields> tag, as shown below:

<params addpath=”/modules/your_module_dir/elements”>
<fields name=”params” addfieldpath=”/modules/your_module/elements”>

Furthermore, you no longer should extend JElement if you used to do that in your module, but instead you should now extend JFormField. See this document for detailed information about that.

Your own module files

After applying the described steps, try to install your module in Joomla 1.6. With the above changes in place, the installation should probably work now. Depending on the complexity of your module however, you might need to do some additional changes to your own module files. These changes could include:

  • Getting rid of old PHP4 code as Joomla 1.6 requires PHP 5.2+
  • Change queries run on your database
  • Remove /stories from your default images folder
  • Upgrade code to work make it work with the different MooTools libraries that Joomla offers (1.12, 1.2 and 1.3) or make your life easier and just switch to jQuery instead.

If I forgot any steps to smoothen the upgrade of your module from Joomla 1.5 to Joomla 1.6, please share them in the comments!

Comments are currently closed.