So I’ve been using Joomla Bamboo’s jQuery plugin for all my Joomla installations now since it makes it easier for me to specify which jQuery version so use. However, there’s something lacking after you download the plugin and that is the ability to add 3rd party hosted jQuery plugins. The only options you have are your local install (same location as your Joomla install) and Google’s FREE CDN hosted jQuery. Also, the latest version you can use with their plugin is 1.4.2 (IIRC). At the time of this blog post, the latest jQuery version is at 1.5.2 already and there’s already a lot of bug fixes done. As a webmaster you always want to have your JavaScript libraries up-to-date just in-case someone discovers a 0day exploit you know.
Anyway, there were two things I wanted to do. One is to be able to use my own jQuery files hosted in Google (not the one’s Google hosts – google-cdn.joinpgn.com) and second, the latest jQuery 1.5.2. So…let’s get it on shall we?
There’s two files you need to edit.
- plg_jblibrary.xml
- plg_jblibrary.php
Let’s edit the XML file first.
Look for…
<param name="jQueryVersion" type="list" default="1.3.2" label="jQuery Version" description="Select the jQuery Library version.">
Then add a new value like…
<option value="1.5.2">jQuery v1.5.2 min</option>
So now it looks something like this…
<param name="jQueryVersion" type="list" default="1.3.2" label="jQuery Version" description="Select the JQuery Library version."> <option value="1.5.2">jQuery v1.5.2 min</option> <option value="1.4.4">jQuery v1.4.4 min</option> <option value="1.4.2">jQuery v1.4.2 min</option> <option value="1.3.2">jQuery v1.3.2 min</option> <option value="1.2.6">jQuery v1.2.6 packed</option> <option value="none">none</option> </param>
Now look for…
<param name="source" type="list" default="local" label="jQuery Source" description="Choose to reference jQuery from either your own server or from the Google repository.">
And add your 3rd party link. Mine ended up like this…
<param name="source" type="list" default="local" label="jQuery Source" description="Choose to reference jQuery from either your own server or from the Google repository."> <option value="google-cdn.joinpgn">Google CDN - PGN</option> <option value="google">Google</option> <option value="local">Local</option> </param>
Close and save. Then move on to the next file.
Now search for something like…”if ($jQueryVersion ==”
And you’ll probably see something like this…
if ($jQueryVersion == "1.3.2") {
if ($source == "local") {
$this->_jqpath = $modbase . $jsbase . "jquery-1.3.2.min.js";
}
if ($source == "google") {
$this->_jqpath = "http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js";
}
$document->addScript($this->_jqpath);
$document->addScriptDeclaration("jQuery.noConflict();");
}
Just copy/paste it and then modify it with your new version and links. Mine ended up like this…
if ($jQueryVersion == "1.4.4") {
if ($source == "local") {
$this->_jqpath = $modbase . $jsbase . "jquery-1.4.4.min.js";
}
if ($source == "google") {
$this->_jqpath = "http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js";
}
if ($source == "google-cdn.joinpgn") {
$this->_jqpath = "http://google-cdn.joinpgn.com/js/jquery/jquery-1.4.4.min.js";
}
$document->addScript($this->_jqpath);
$document->addScriptDeclaration("jQuery.noConflict();");
}
if ($jQueryVersion == "1.5.2") {
if ($source == "google-cdn.joinpgn") {
$this->_jqpath = "http://google-cdn.joinpgn.com/js/jquery/jquery-1.5.2.min.js";
}
$document->addScript($this->_jqpath);
$document->addScriptDeclaration("jQuery.noConflict();");
}
Close and save…and you’re done!