How to upgrade a Joomla 1.5 module to Joomla 1.6

How to upgrade a Joomla 1.5 module to Joomla 1.6 

If you need to upgrade modules you are currently using with Joomla 1.5 to Joomla 1.6, this is not as difficult as it sounds. The following are the basic steps need to upgrade a module from Joomla 1.5 to Joomla 1.6


Step 1. - Language Files

As stated in the specifications 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
  • FALSE
  • 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

 

Step 2. - 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.

 

Step 3. - 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

 

Step 4. - The XML file

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

Change:
<install type="module" version="1.5.0">
To:
<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.

Change:
<params>
<param name="testSetting" type="text" default="something" label="Test" description="Test" />
</params>

To:
<config>
<fields name="params">
<fieldset name="basic">
<field name="testSetting" type="text" default="something" label="Test" description="Test" />
</fieldset>
</fields>
</config>

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

Change:
<params addpath="/modules/your_module_dir/elements">
To:
<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.

 

Final Step - 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.

Translate

10,000+ Users trust us - Subscribe

Follow us on Facebook!

Joomla Facebook Like Popup