Mootools 1.2 for Site interface, and 1.11 for Administration

Forum closed, please submit your tips and tricks to: http://docs.joomla.org/Category:Tips_and_tricks
Locked
User avatar
jiggliemon
Joomla! Intern
Joomla! Intern
Posts: 81
Joined: Wed Nov 22, 2006 6:18 am
Contact:

Mootools 1.2 for Site interface, and 1.11 for Administration

Post by jiggliemon » Sat Apr 19, 2008 5:06 am

I know all of the joomla developers hate it when we screw with the core code. But I need to use Mootools 1.2b on the site interface, and maintain the mootools 1.11 for the administrator section. So i did a little hacking to the Core "behavior" script for mootols and added an if/then...

Code: Select all

function mootools($debug = null)
	{
		global $mainframe;
		static $loaded;
		$administrator = JFactory::getApplication('administrator');
		// 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');
		}

		// TODO NOTE: Here we are checking for Konqueror - If they fix thier issue with compressed, we will need to update this
		$konkcheck = strpos (strtolower($_SERVER['HTTP_USER_AGENT']), "konqueror");

		if ($debug || $konkcheck) {
			JHTML::script('mootools-uncompressed.js', 'media/system/js/', false);
		} else {
                        // interface is for the front end show 1.2b
			if($mainframe->isSite()) 
			{
				JHTML::script('mootools2.js', 'media/system/js/', false);
                        //Otherwise, use the stable 1.11
			}else{
				JHTML::script('mootools.js', 'media/system/js/', false);
			}
		}
		$loaded = true;
		return;
	}
I just thought i would let people know.

Geoff
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 3173
Joined: Sun Apr 16, 2006 12:20 am
Location: 127.0.0.1

Re: Mootools 1.2 for Site interface, and 1.11 for Administration

Post by Geoff » Sun Apr 20, 2008 7:00 am

mod note: moved to Suggested Tips & Tricks

Just so you know, a white paper has been done for this feature and it has been accepted.
[12]Upgrade to mootools 1.2: http://forum.joomla.org/viewtopic.php?f=501&t=273960
Backup, backup, backup!
The "Master" .htacess file by Nicholas http://snipt.net/nikosdion/the-master-htaccess

ghazal
Joomla! Explorer
Joomla! Explorer
Posts: 342
Joined: Fri Aug 19, 2005 12:12 pm
Location: Out of my mind ...sometimes

Re: Mootools 1.2 for Site interface, and 1.11 for Administration

Post by ghazal » Sat Apr 26, 2008 6:26 pm

Hi,
thanks for this useful tip.
But could you tell which file you modified exactly.
Until now, to implement Moo1.2, I just hacked my template file.

User avatar
jiggliemon
Joomla! Intern
Joomla! Intern
Posts: 81
Joined: Wed Nov 22, 2006 6:18 am
Contact:

Re: Mootools 1.2 for Site interface, and 1.11 for Administration

Post by jiggliemon » Sat Apr 26, 2008 7:10 pm

libraries > joomla > html > behavior.php > function mootools()

ghazal
Joomla! Explorer
Joomla! Explorer
Posts: 342
Joined: Fri Aug 19, 2005 12:12 pm
Location: Out of my mind ...sometimes

Re: Mootools 1.2 for Site interface, and 1.11 for Administration

Post by ghazal » Sun Apr 27, 2008 8:14 am

libraries > joomla > html > behavior.php > function mootools()
TKS

Bodom78
Joomla! Intern
Joomla! Intern
Posts: 95
Joined: Fri Nov 04, 2005 9:23 am

Re: Mootools 1.2 for Site interface, and 1.11 for Administration

Post by Bodom78 » Mon Apr 28, 2008 2:07 pm

Thanks for the tip.

I don't like editing the core either but I had to use this method to include mootools1.12 into one of my admin components. I simply checked the $option and $task and called it when necessary.

ghazal
Joomla! Explorer
Joomla! Explorer
Posts: 342
Joined: Fri Aug 19, 2005 12:12 pm
Location: Out of my mind ...sometimes

Re: Mootools 1.2 for Site interface, and 1.11 for Administration

Post by ghazal » Thu Jun 12, 2008 8:56 am

Mootools 1.2 is out since yesterday.
Enjoy the 'new shiny version" !

User avatar
jiggliemon
Joomla! Intern
Joomla! Intern
Posts: 81
Joined: Wed Nov 22, 2006 6:18 am
Contact:

Re: Mootools 1.2 for Site interface, and 1.11 for Administration

Post by jiggliemon » Mon Jun 30, 2008 6:52 am

I've updated the hack a little bit since the Joomla team did a little work on the class structure as well. I made a separate method for the "more" js file. Obviously, these are the full versions of both "Core" and "More". If you wanted to get even more gangster on it, you could download or dissect both "core" and "more" and put the respective pieces into their own methods (minding the dependencies of course). But that's not something im looking forward to doing, So the full files are fine for me.

The Mootools method is fount in the JHTMLBehavior class:
libraries > joomla > html > html > behavior.php

The modified mootools method:

Code: Select all

	function mootools($debug = null)
	{
		global $mainframe;
		static $loaded;
	
		// 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');
		}
		
		// TODO NOTE: Here we are checking for Konqueror - If they fix thier issue with compressed, we will need to update this
		if ($debug || $konkcheck) {
				JHTML::script('mootools-uncompressed.js');
		} else {
			//////////////////////////THIS IS THE MOOTOOLS SWITCHER////////////////////////////////
			if($mainframe->isSite())
			{
				// Interface is for the front end show 1.2b
				JHTML::script('mootools-1.2-core.js');
			}else{
				//Otherwise, use the stable 1.11
				JHTML::script('mootools.js');
			}
		}
		$loaded = true;
		return;
	}
The bonus "More" Method:

Code: Select all

	function mootoolsMore() {
		JHTML::script('mootools-1.2-more.js');
	}

agel
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Sun Jul 13, 2008 3:37 pm

Re: Mootools 1.2 for Site interface, and 1.11 for Administration

Post by agel » Thu Jul 17, 2008 8:04 pm

Original code cause my webserver crash for some reason %)
So I've written a little improving:

Code: Select all

	function mootools($debug = null)
	{
		global $mainframe;
		static $loaded;
	
		// Only load once
		if ($loaded) {
			return;
		}
		
		if ($debug === null) {
			$config = &JFactory::getConfig();
			$debug = $config->getValue('config.debug');
		}
		
		if ($debug || $konkcheck) {

				JHTML::script('mootools-uncompressed.js');

		} elseif ($mainframe->isSite()) {

				JHTML::script('mootools-1.2.js, 'media/system/js/', false);

		}else{

				JHTML::script('mootools.js', 'media/system/js/', false);

		}
		$loaded = true;
		return;
	}
Thanks jiggliemon for idea!


Locked

Return to “Submit Your Suggested Tips & Tricks to Docs.joomla.org now please.”