Anthony McLin

Using MooTools 1.2 in Joomla

MooTools is on version 1.2.3 (after completely dropping 1.1.1 as the default about a year ago), and version 2.0 is expected before years' end. Joomla however, still is including 1.1.1 because of compatibility issues with various plugins. People have been asking how to safely replace the version of MooTools included. Since I've done this several times, I figured I'd share my method here.

My first piece of advice is don't try to replace MooTools for the administrator interface. You're likely to just break all admin functionality. My second bit of advice is that if you rely on MooTools for specific plugins (like video players or enhanced menu systems), then don't do this. Again you're very likely to break things and it can be a real hassle to rewrite other people's plugins to work the way you want them to.

Since I do a lot of custom template work, and my clients usually only have the plugins I setup for them, I found that the best solution for me was to handle this from within my custom templates. This way, I don't need to modify any core files (making this a relatively future-proof technique) and I also have more control as to how it behaves.

  1. First drop your MooTools 1.2 files into a folder within your custom template. I like to use a folder called js for my template javascript.
  2. Make sure that MooTools 1.1.1 is not being included when your template is rendered. Make sure to do this somewhere before <jdoc:include type="head" />
    <?php
    //Drop the built in mootools script
    unset($this->_scripts[$this->baseurl .'/media/system/js/mootools.js']);
    //Drop the built in captions script
    unset($this->_scripts[$this->baseurl .'/media/system/js/caption.js']); 
    ?>
  3. Next, add your MooTools 1.2 files either by listing them in the head as you would with any HTML file, or by using Joomla's addScript() method. I prefer the latter:
    <?php
    $this->addScript(JURI::base() . 'templates/' . $this->template
         .  '/js/mootools-1.2.js');
    $this->addScript(JURI::base() . 'templates/' . $this->template
         . '/js/mootools-1.2-more.js');
    ?>
That's it! Now the frontend of your site will not load Joomla's version of MooTools 1.1.1, and instead will load your version of MooTools 1.2. Of course make sure the filenames and paths are correct, and you should be good to go!

Comments

"Mootools 1.2.4 Upgrage Plugin" is available in Joomla 1.5.19+

If you do clean installation only thing to do is to enabled the plugin. However if you update Joomla to the latest version plugin will not be installed in database. You can find information on how to add the "Mootools 1.2.4 Upgrade Plug-in" to Joomla after update in this article http://boolcast.com/joomla/2-updates/1-mootools-124-upgrade-plugin-for-joomla-15

Alex, you are partially correct. It should be noted that my method here is for Joomla 1.5.0 - 1.5.18. If you have implemented my method, and then upgraded your site to Joomla 1.5.20, you should try removing this code and turning on the new Mootools Upgrade Plugin.

However Alex, you are wrong about Mootools 1.2.4 not being included in upgrade installs. It is provided, just not enabled. There's no need to go through extra steps to download and install the plugin. Once you've upgraded to Joomla 1.5.20, simply go to the Plugins Manager and publish the Mootools 1.2.4 Upgrade that is already included.

Thx for the reply.

I actually went through the update process couple of days ago, just because of the Mootools 1.2 plug-in.

You are absolutely right, the plug-in is included in the Joomla Patch for the update. However the patch handles only updated files (php files), and for the plug-in to be present in the back-end it needs database record. The Download and Installation of plug-in makes it easier to add it to database, through a reinstall process. It is also possible to add the database record on it's own without re-installation (Solution #1 in the article)

Actually Alex I had no problem just enabling the plugin on sites that I've tested the update on. Check to make sure you're using Joomla 1.5.20, as 1.5.19 was a messed up installation that was quickly replaced.

Hmmm... that's great that it worked for you after update. Kind of intriguing... did you use patch update?

Yep. I just used the 1.5.18 to 1.5.20 update patch (via the JUpdater component). I think 1.5.19 was broken in this regards, which is why 1.5.20 came out so quickly.

Great post, this is very clean and manageable without hacking any core which is just what I wanted to do!

in Joomla 1.5.19 there is a Plugin called "System - Mootools Upgrade" activate it and you have upgraded your Mootools to 1.2.4 with compatibility

See: http://docs.joomla.org/What_is_the_Mootools_1.2.4_upgrade_plugin%3F

You're absolutely right sk8connection, this post was specifically before Joomla 1.5.19. My followup article after Joomla 1.5.19 was released discusses this:

http://www.anthonymclin.com/code/joomla/97-mootools-12-is-finally-in-joomla

- Anthony McLin

Please can someone help me out with where I can activate the Mootools plugin for my J1.5.5 site.

I want to install a slide show module and it keeps giving me this error '[showplus] Critical error: The extension client-side script requires MooTools version 1.2 or later. In Joomla 1.5.19 or later, enable the MooTools Upgrade system plug-in in the administration back-end. In order to suppress this error message, create a file mootools.override.js in the folder /modules/mod_showplus/js.'

Please how do I fix this?

Israel wrote:
Please can someone help me out with where I can activate the Mootools plugin for my J1.5.5....

Please how do I fix this?

Israel you have three options.

[

#1 - Upgrade to Joomla 1.5.23. In admin mode, go to Extensions->Plugin Manager and enable the MooTools 1.2 plugin.

#2 - Follow my instructions above.

#3 - Upgrade to Joomla 1.6 then 1.7

Option 1 is the easiest, but I'd recommend option 3. Option 2 is no longer necessary unless you absolutely cannot upgrade. Not upgrading is dangerous because there are security holes that can easily lead to your site being hacked.

- Anthony McLin

Add new comment