I have a custom jQuery accordion menu on my site in a module, when the mod is enabled it breaks my RokSlideshow module.
I can\'t get them both to work at the same t
Joomla buffers all content with ob_start(). You can get the current buffer with:
$body = JResponse::getBody();
You can then find the JQuery and MooTools script declarations and restructure them in a system plugin using the "onAfterRender" event.
You can use preg_replace() to take the JQuery and put in after MooTools. You can then enable the no conflict mode in JQuery.
jQuery.noConflict();
Here is an example plugin that changes the MooTools from 1.1 to 1.2. You can do something slimilar for JQuery's no conflict mode.
getType();
// deactivate for backend
if ($mainframe->isAdmin()) {
return false;
}
// add mootools 1.2
if ( $doctype == 'html' ) {
$document->addScript('components/com_ajaxchat/js/mootools-1.2-core.js');
$document->addScript('components/com_ajaxchat/js/mootools-1.2-more.js');
$document->addScript('components/com_ajaxchat/js/mootools-1.2-core-compat.js');
$document->addScript('components/com_ajaxchat/js/mootools-1.2-more-compat.js');
}
}
/**
* After Templte output is in buffer
*/
function onAfterRender() {
$mainframe =& JFactory::getApplication();
$document =& JFactory::getDocument();
$doctype = $document->getType();
// deactivate for backend
if ($mainframe->isAdmin()) {
return false;
}
// Only render for HTML output
if ( $doctype !== 'html' ) {
return;
}
// get the output buffer
$body = JResponse::getBody();
// remove mootools if not needed
if (stristr($body, 'mootools.js') || stristr($body, 'mootools-uncompressed.js')) {
$body = preg_replace("//i", '', $body);
} else {
$body = preg_replace("/[\s\t\r\n]*/i", "\n", $body);
}
JResponse::setBody($body);
}
}
?>