removing mootools from the header for a cell phone dot mobi website....

For Joomla! 1.5 Coding related discussions, please use: http://groups.google.com/group/joomla-dev-general
Bodom78
Joomla! Intern
Joomla! Intern
Posts: 95
Joined: Fri Nov 04, 2005 9:23 am

Re: removing mootools from the header for a cell phone dot mobi

Post by Bodom78 » Sat Apr 26, 2008 1:11 pm

I don't mean to double post, stumbled onto this post after asking my question in another thread but perhaps someone here may be able to help me as my problem is semi-related to the current discussion.

Is there any documentation on how to remove the addition of Mootools from the admin portion of a component.

I need to use a trunk version for my component and updating the media/system/js/mootools.js file stops the admin menu from working.

I want to remove the current version from being included and then use $document->addScript to include the trunk version.

Cheers

(Mods if you want to remove the other post for doubling up on questions, it's located Here)

 
User avatar
dizzi
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 3136
Joined: Fri Dec 21, 2007 9:36 pm
Location: Yorkshire, UK

Re: removing mootools from the header for a cell phone dot mobi

Post by dizzi » Sun Aug 24, 2008 2:54 am

Informative thread indeed. However suppose I only wanted to remove mootools (but not caption.js, joomla.javascript.js, etc) for solely guests and the "Registered" user group, what would be the code block for this?

Cheers
Freedom of expression ... some may try to suppress it but they can never take it away ...
There is no problem a good miracle can't fix.

User avatar
Peter Clements
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 172
Joined: Tue Nov 08, 2005 12:58 pm
Location: Kent, England, UK
Contact:

Re: removing mootools from the header for a cell phone dot mobi

Post by Peter Clements » Sun Aug 24, 2008 9:09 am

dizzi wrote:Informative thread indeed. However suppose I only wanted to remove mootools (but not caption.js, joomla.javascript.js, etc) for solely guests and the "Registered" user group, what would be the code block for this?

Cheers
This is what I'm doing in my template to strip out all references to JS files for all unregistered visitors:

Code: Select all

$user =& JFactory::getUser();

if ($user->guest) {
	$header = $this->getHeadData();
	$header['scripts'] = array();
	$this->setHeadData($header);
}
And if we jump back to this post, we're told how to strip out just mootools.js, so if we put the two together:

Code: Select all

$user =& JFactory::getUser();

if ($user->guest) {
	$headerstuff = $this->getHeadData();

	// mootols are usually found as the very first entry
	reset($headerstuff['scripts']);
	$moo = key($headerstuff['scripts']);
	// kick it
	unset($headerstuff['scripts'][$moo]);

	// restore
	$this->setHeadData($headerstuff);
}
Then that would do what you want for all guests/unregistered users. You'll need someone who knows what they're talking about to tell you what modifications you'll need to make to do this for registered users as well though. :D

User avatar
dizzi
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 3136
Joined: Fri Dec 21, 2007 9:36 pm
Location: Yorkshire, UK

Re: removing mootools from the header for a cell phone dot mobi

Post by dizzi » Sun Aug 24, 2008 11:32 am

Cheers Peter M8 for responding, explaining things clearly and providing the code :) . I tried to modify your submission to include the "Registered" group, based on the information quoted below:
identity wrote:
I've had the same question some time ago, so here are a few usefull $user variables concerning it's state, group and the like:

$user->get('guest') == 1 for guests and 0 for logged in users.
$user->get('aid') == 0 for public users (= guests), 1 for registered users who are logged in and 2 for special users (everything beyond the normal registered user)
$user->get('usertype') gets the user's usertype (duh ;)) (Public Frontend, Registered, Author, Editor, Publisher, Public Backend, Manager, Administrator, Super Administrator)
$user->get('gid') is 'bad' thing... It returns the MySQL row id of the user's usertype. But those could change in future versions of Joomla.

But pay attention: $user->get('usertype') seems to be undefined for guests!

Happy coding and sleep well,
Sam
I tried this:

Code: Select all

<?php  
$user =& JFactory::getUser();

if ($user->guest || $user->get('aid') == 1) {
   $headerstuff = $this->getHeadData();

   // mootols are usually found as the very first entry
   reset($headerstuff['scripts']);
   $moo = key($headerstuff['scripts']);
   // kick it
   unset($headerstuff['scripts'][$moo]);

   // restore
   $this->setHeadData($headerstuff);
}
?>
and this:

Code: Select all

<?php  
$user =& JFactory::getUser();

if ($user->guest || $user->get('usertype') == 'Registered') {
   $headerstuff = $this->getHeadData();

   // mootols are usually found as the very first entry
   reset($headerstuff['scripts']);
   $moo = key($headerstuff['scripts']);
   // kick it
   unset($headerstuff['scripts'][$moo]);

   // restore
   $this->setHeadData($headerstuff);
}
?>
Whereas both worked fine for guests, neither provided the required effect for logged in Registered users. I guess as you indicated, a bit more tweaking is required to get it to work for the Registered usergroup :) .

Thanks once again for the help
Freedom of expression ... some may try to suppress it but they can never take it away ...
There is no problem a good miracle can't fix.

User avatar
dizzi
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 3136
Joined: Fri Dec 21, 2007 9:36 pm
Location: Yorkshire, UK

Re: removing mootools from the header for a cell phone dot mobi

Post by dizzi » Sun Aug 24, 2008 2:33 pm

Ok, the following, adapted from identity's code posted here, worked for both guests and the "Registered" users group who are logged in:

Code: Select all

<?php
  /**
    Code block to remove auto-generate mootools header for guests and logged in Registered users
  **/
  $user =& JFactory::getUser();
  if($user->get('guest') == 1 || $user->usertype == 'Registered') {
    // get the headdata
    $headerstuff = $this->getHeadData();
    // (part of) the filenames to be removed
    // 'mootools' will find 'mootools.js' and 'mootools-uncompressed.js'
    $search = array('mootools');

    // remove the js files
    foreach($headerstuff['scripts'] as $key => $script) {
      foreach($search as $findme) {
        if(stristr($key, $findme) !== false) {
          unset($headerstuff['scripts'][$key]);
        } // end inner if
      } // end inner for
    } // end outer for
    // restore
    $this->setHeadData($headerstuff);
  } // end if
?> <!--end mootools removal-->
Regards
Last edited by dizzi on Tue Aug 26, 2008 9:03 am, edited 1 time in total.
Freedom of expression ... some may try to suppress it but they can never take it away ...
There is no problem a good miracle can't fix.

User avatar
newart
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 3177
Joined: Fri Sep 02, 2005 10:06 am
Location: Solar system - Earth - European Union

Re: removing mootools from the header for a cell phone dot mobi

Post by newart » Tue Aug 26, 2008 7:20 am

WOW, thank you very much for your good solutions! If interested please take a look at http://forum.joomla.org/viewtopic.php?f=501&t=266809 too.
former Q&T WorkGroup Joomla member - Italian Translation Team Member

User avatar
dizzi
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 3136
Joined: Fri Dec 21, 2007 9:36 pm
Location: Yorkshire, UK

Re: removing mootools from the header for a cell phone dot mobi

Post by dizzi » Tue Aug 26, 2008 9:43 am

Thanks for the link newart. Its a very informative thread plus it includes more links to educational material on this topic :) . Nice one m8.

Cheers
Freedom of expression ... some may try to suppress it but they can never take it away ...
There is no problem a good miracle can't fix.

User avatar
newart
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 3177
Joined: Fri Sep 02, 2005 10:06 am
Location: Solar system - Earth - European Union

Re: removing mootools from the header for a cell phone dot mobi

Post by newart » Tue Aug 26, 2008 10:30 am

you're welcome :) I hope you can post there your need of an option inside the joomla gear too. It's important to see more posters there promoting the urgence of an option, do you agree? I hope so! ;)
former Q&T WorkGroup Joomla member - Italian Translation Team Member

User avatar
dizzi
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 3136
Joined: Fri Dec 21, 2007 9:36 pm
Location: Yorkshire, UK

Re: removing mootools from the header for a cell phone dot mobi

Post by dizzi » Tue Aug 26, 2008 8:19 pm

Yup indeed I most certainly agree. Providing choices to users, especially on a subject which affects the important area of Website accessability is a positive move in my book :). We have to be concious of the fact that not everyone has access to Gazillion Gigabit speed broadband connections :) . Thanks for highlighting and promoting the issue.

Regards
Freedom of expression ... some may try to suppress it but they can never take it away ...
There is no problem a good miracle can't fix.

User avatar
newart
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 3177
Joined: Fri Sep 02, 2005 10:06 am
Location: Solar system - Earth - European Union

Re: removing mootools from the header for a cell phone dot mobi

Post by newart » Wed Aug 27, 2008 10:10 am

good news so, I hope to see you in that thread for promoting that idea ;) bye bye :)
former Q&T WorkGroup Joomla member - Italian Translation Team Member

User avatar
dizzi
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 3136
Joined: Fri Dec 21, 2007 9:36 pm
Location: Yorkshire, UK

Re: removing mootools from the header for a cell phone dot mobi

Post by dizzi » Wed Aug 27, 2008 6:06 pm

newart wrote:good news so, I hope to see you in that thread for promoting that idea ;) bye bye :)
Oh Yessss :) !
Freedom of expression ... some may try to suppress it but they can never take it away ...
There is no problem a good miracle can't fix.

pbvkrishna
Joomla! Apprentice
Joomla! Apprentice
Posts: 28
Joined: Fri Sep 22, 2006 6:19 am
Location: Kakinada
Contact:

Re: removing mootools from the header for a cell phone dot mobi

Post by pbvkrishna » Sat Mar 14, 2009 10:26 am

The following code worked for me to remove the moo tools. After disabling the yooeffects plugin from the administrator I added the following code at very top of the templete index.php file

Code: Select all

<?php
$headerstuff = $this->getHeadData();

// mootols are usually found as the very first entry
reset($headerstuff['scripts']);
$moo = key($headerstuff['scripts']);
// kick it
unset($headerstuff['scripts'][$moo]);
unset($headerstuff['scripts']['/media/system/js/caption.js']);
// restore
$this->setHeadData($headerstuff);

?>
With Regards
Krishna
Krishna
http://www.cinealerts.com - Movies Information
http://www.aaspiretechnologies.com - My Company

Brianbestwish
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Tue Nov 16, 2010 2:10 am

Re: removing mootools from the header for a cell phone dot m

Post by Brianbestwish » Tue Nov 16, 2010 2:20 am

identity wrote:Even easier and faster:

Code: Select all

$document =& JFactory::getDocument();
unset($document->_scripts[JURI::base() . 'media/system/js/mootools.js']);
unset($document->_scripts[JURI::base() . 'media/system/js/mootools-uncompressed.js']);
unset throws no error what so ever, so just release it on all the js libraries you don't need.

Code: Select all

unset($document->_scripts[JURI::base() . 'media/system/js/caption.js']);
unset($document->_scripts['includes/js/joomla.javascript.js']);
This works for me (SVN 8212)
Yeah, I encountered the same problem, now it has been fixed by using the similar code, thanks.

User avatar
newart
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 3177
Joined: Fri Sep 02, 2005 10:06 am
Location: Solar system - Earth - European Union

Re: removing mootools from the header for a cell phone dot m

Post by newart » Wed Jan 12, 2011 10:52 am

Now, we have to solve this problem with the 1.6x generation!
former Q&T WorkGroup Joomla member - Italian Translation Team Member

User avatar
spike1968
Joomla! Explorer
Joomla! Explorer
Posts: 427
Joined: Fri Aug 25, 2006 2:39 pm
Location: United Kingdom - Aldershot
Contact:

Re: removing mootools from the header for a cell phone dot m

Post by spike1968 » Fri Jun 03, 2011 4:05 pm

... and is there a fix for 1.6.3?
I may be wrong and I often am.
http://www.yourparish.co.uk - Free listing directory
IMHO Chrome is the best

 

Locked

Return to “Joomla! 1.5 Coding”