ThemePartner, Professional Joomla! Business Templates

koen

Upgrading a Joomla 1.5 Module to Joomla 1.6

January 22nd, 2011 at 1:17 PM CET in 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!

Rubiks

Photo credits: kirtaph

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
  • 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

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).

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.

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!

Follow us on Twitter

User Comments (6)

Add comment

unscorpio

March 25th, 2011 at 11:50 PM CET
i need openinviter for 1.6

gugum

July 24th, 2011 at 6:12 AM CEST
but anyway how if inside the language file of the joomla 1.5 native module containing this one;

DESC ARTICLE ID=The ID of the Article to parse <b>MANDATORY</b>

Should we change it to be like this one;

DESC_ARTICLE_ID="The ID of the Article to parse <b>MANDATORY</b>"

which one is valid in migrating from joomla 1.5 module into 1.6?

Web Design Perth

July 28th, 2011 at 9:18 AM CEST
Thanks for Posting this.. I think joomla.org had more extensions listed that were compatible. I would like the steps by step guide written out so I can have it handy when I do it. Thanks again, you're the best.

Byron

December 9th, 2011 at 5:51 AM CET
This was really helpful and easy to follow, I managed to convert my 1.5 modules to work with 1.7 in a matter of minutes!

Leaidan

December 26th, 2011 at 6:45 AM CET
We need a lot more iinsgths like this!

Grego606

March 22nd, 2012 at 5:50 PM CET
My 2¢:
<?php echo $this->baseurl; ?> changes to: <?php echo $document->baseurl; ?>

Add a comment

*
*
*

*

 

Buy 2 Templates, Get Your Third Free!

Buy 2 Templates, Get Your Third Free!

By popular demand we've introduced a way to purchase multiple templates, at a discounted rate! If you add any three templates to your shopping cart, you'll only have to pay for two!

Blog categories

Conferences

Upcoming conferences

Past conferences

Reports on past conferences