Using Mootools 1.2 in Joomla1.5.x

Monday, July 20, 2009 21:46
Posted in category Joomla, Mootools, Tutorial, javascript

Yes! Joomla 1.5.x comes with mootools 1.1.x and it is a pity when you cannot use best of the latest mootools widgets with joomla 1.5.x.  To make the matter worse, you will rarely find forums and blogs that discusses about mootools 1.1. In this case you will definitely want to use mootools 1.2.x with Joomla in the frontend. So in this small tutorial, we will talk about how to use mootools1.2.x with Joomla 1.5.x. Remember the admin panel of Joomla will still use mootools 1.1.x.

I have written a post about how to use jQuery with Joomla earlier. This tutorial is just a slight modification of the codes from the earlier post.
To use mootools 1.2.x with Joomla 1.5.x, follow the following steps.

  1. Download the mootools core from the mootools core builder site
  2. Also Download the additional plugins you will use with your installation from more builder. I recommend downloading both compressed and uncompressed files from the mootools builder. We may need uncompressed files in debuggin mode.
  3. Copy these files in a folder that can be accessed by Joomla. I recommend media->system->js folder of joomla installation. The choice is yours! ;)

I copied four files mootools-1.2.3-core.js, mootools-1.2.3-core-compressed.js, mootools-1.2.3.1-more.js and mootools-1.2.3.1-more-compressed.js to media->system->js folder. Now locate and open a file named behavior.php which is inside libraries->joomla->html->html folder. Now find a method named mootools($debug=null) and modify it as below.

function mootools($debug = null)
{
static $loaded;
$mainframe=&JFactory::getApplication();
// Only load once
if ($loaded) {
return;
}

// If no debugging value is set, use the configuration setting
if ($debug === null) {
$config = &JFactory::getConfig();
$debug = $config->getValue(‘config.debug’);
}

$konkcheck = isset($_SERVER['HTTP_USER_AGENT']) ? strpos(strtolower($_SERVER['HTTP_USER_AGENT']), “konqueror”) : null;

if($mainframe->isSite())
{
if ($debug || $konkcheck)
{
JHTML::script(‘mootools-1.2.3-core.js’, ‘media/system/js/’, false);
JHTML::script(‘mootools-1.2.3.1-more.js’, ‘media/system/js/’, false);
}
else
{
JHTML::script(‘mootools-1.2.3-core-compressed.js’, ‘media/system/js/’, false);
JHTML::script(‘mootools-1.2.3.1-more-compressed.js’, ‘media/system/js/’, false);
}
$loaded = true;
return;

}
else
{

if ($debug || $konkcheck)
{
JHTML::script(‘mootools-uncompressed.js’, ‘media/system/js/’, false);
}
else
{
JHTML::script(‘mootools.js’, ‘media/system/js/’, false);
}
$loaded = true;
return;
}
}

This modified mootools behavior checks if the site is accessed from frontend or is it admin. if it is frontend it loads the mootools 1.2.x depending upon the debug mode. It will load uncompressed files in debug mode. This will load both core and more files in frontend. The admin still uses mootools 1.1.x as it heavily depends on it.

This is all! It worked for me. Let me know if it did or not for you. Happy reading!

VN:F [1.8.3_1051]
Rating: 10.0/10 (2 votes cast)
VN:F [1.8.3_1051]
Rating: +2 (from 2 votes)
Using Mootools 1.2 in Joomla1.5.x10.0102
http://www.sanjeevshrestha.com.np/wp-content/plugins/sociofluid/images/digg_32.png http://www.sanjeevshrestha.com.np/wp-content/plugins/sociofluid/images/reddit_32.png http://www.sanjeevshrestha.com.np/wp-content/plugins/sociofluid/images/stumbleupon_32.png http://www.sanjeevshrestha.com.np/wp-content/plugins/sociofluid/images/delicious_32.png http://www.sanjeevshrestha.com.np/wp-content/plugins/sociofluid/images/blogmarks_32.png http://www.sanjeevshrestha.com.np/wp-content/plugins/sociofluid/images/google_32.png http://www.sanjeevshrestha.com.np/wp-content/plugins/sociofluid/images/myspace_32.png http://www.sanjeevshrestha.com.np/wp-content/plugins/sociofluid/images/facebook_32.png http://www.sanjeevshrestha.com.np/wp-content/plugins/sociofluid/images/yahoobuzz_32.png http://www.sanjeevshrestha.com.np/wp-content/plugins/sociofluid/images/twitter_32.png
You can leave a response, or trackback from your own site.

7 Responses to “Using Mootools 1.2 in Joomla1.5.x”

  1. Alvin says:

    October 30th, 2009 at 4:59 am

    Hi,

    Dont work for me.

    Please tell exactly what we need to find and replace with your code also
    “isSite” is not organized and

    ’mootools-uncompressed.js’ there are not brackets

    UN:F [1.8.3_1051]
    Rating: 0.0/5 (0 votes cast)
    UN:F [1.8.3_1051]
    Rating: 0 (from 0 votes)
  2. Sanjeev says:

    October 30th, 2009 at 5:09 am

    You need to edit a file named behavior.php which is in libararies->joomla->html->html. In line 35 you will find a method named mootools.
    function mootools ($debug) {…};
    You need to replace the mootools function with the code in the post but also remember to download the latest mootools as mentioned in the post.

    Also the code above works fine. There are no missing brackets if you look it is wrapped to next line.

    Thanks
    Sanjeev

    UA:F [1.8.3_1051]
    Rating: 5.0/5 (1 vote cast)
    UA:F [1.8.3_1051]
    Rating: +1 (from 1 vote)
  3. Mike E says:

    December 15th, 2009 at 5:43 pm

    I get this:
    Parse error: syntax error, unexpected T_DNUMBER in /home3/proinkho/public_html/Lounge_Report/libraries/joomla/html/html/behavior.php on line 55

    UN:F [1.8.3_1051]
    Rating: 0.0/5 (0 votes cast)
    UN:F [1.8.3_1051]
    Rating: 0 (from 0 votes)
  4. Mike E says:

    December 15th, 2009 at 5:44 pm

    this is line 55:
     JHTML::script(’mootools-1.2.4-core.js’, ‘media/system/js/’, false);

    UN:F [1.8.3_1051]
    Rating: 0.0/5 (0 votes cast)
    UN:F [1.8.3_1051]
    Rating: 0 (from 0 votes)
  5. Sanjeev says:

    December 15th, 2009 at 11:51 pm

    @Mike: The script has no errors. Please be advised to replace the backtick (`) with a quote (‘). The quotes are replaced by backtick in the code provided.

    Let me know if it works.
    Sanjeev

    UA:F [1.8.3_1051]
    Rating: 0.0/5 (0 votes cast)
    UA:F [1.8.3_1051]
    Rating: 0 (from 0 votes)
  6. JDawg says:

    January 11th, 2010 at 9:11 pm

    You should correct your code to link to the $mainframe global variable or else it will come back with an error.

    global $mainframe;
    if($mainframe->isSite())

    UN:F [1.8.3_1051]
    Rating: 0.0/5 (0 votes cast)
    UN:F [1.8.3_1051]
    Rating: 0 (from 0 votes)
  7. Sanjeev says:

    January 11th, 2010 at 10:50 pm

    @JDawg: Thanks for your comment. I have updated the code. My Bad! I missed it.

    UA:F [1.8.3_1051]
    Rating: 0.0/5 (0 votes cast)
    UA:F [1.8.3_1051]
    Rating: 0 (from 0 votes)

Leave a Reply