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
Forum rules
Please use the mailing list here: http://groups.google.com/group/joomla-dev-general rather than this forum.
sa247
Joomla! Explorer
Joomla! Explorer
Posts: 271
Joined: Sat Sep 16, 2006 8:50 pm
Location: San Antonio, Texas
Contact:

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

Post by sa247 » Tue Jul 24, 2007 9:42 pm

im creating a tabless template to meet dot mobi basic requirements and need to remove the mootools javascript paths - i know i can do this by deleting

since the site is for a cell phone and will be basic there will neither be a need for mootools... leaving it in it gets flagged...

however if i do delete i also loose all the other meta data and page title info too....

thanks in advance for any input...
Last edited by sa247 on Tue Jul 24, 2007 9:54 pm, edited 1 time in total.

User avatar
CirTap
Joomla! Explorer
Joomla! Explorer
Posts: 418
Joined: Mon Dec 12, 2005 5:34 pm

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

Post by CirTap » Tue Jul 24, 2007 10:11 pm

Hi,

make sure to add this at the very top of your template. This is the "official" way using the JDocumentHTML API

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]);

// restore
$this->setHeadData($headerstuff);
The "mootools.js" usually is the first item in the list, so key() will give you it's name == the full qualified URL to the .js file.
If that doesn't work for your setup for whatever reason, just loop through the $headerstuff['scripts'] array and get rid of the mootols entry in any other fashion you find appropriate.

Have fun,
CirTap
You can have programs written fast, well, and cheap, but you only get to pick 2 ...

"I love deadlines. I like the whooshing sound they make as they fly by." Douglas Adams

sa247
Joomla! Explorer
Joomla! Explorer
Posts: 271
Joined: Sat Sep 16, 2006 8:50 pm
Location: San Antonio, Texas
Contact:

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

Post by sa247 » Tue Jul 24, 2007 10:34 pm

thanks for the pointer it did work! :)

i really need to get my head around working with the API - i appreciate the document link thanks! :)

identity
Joomla! Apprentice
Joomla! Apprentice
Posts: 10
Joined: Sat Jul 08, 2006 9:51 am
Location: Luxembourg

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

Post by identity » Thu Jul 26, 2007 7:20 pm

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)

User avatar
CirTap
Joomla! Explorer
Joomla! Explorer
Posts: 418
Joined: Mon Dec 12, 2005 5:34 pm

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

Post by CirTap » Thu Jul 26, 2007 8:39 pm

Hi,

that's why I called the code above "official" -- there's a reason for the API ;)
Yours is an unnecessary "hack" by accessing a private property, and there's no guarantee that _scripts[] will exist in any future version. The developers could change it today w/o notice and nobody could complain.

Speaking of speed: if that's your concern, you woudn't need JFactory::getDocument(), 'cos in the context of the template file, $this is already the document instance.

Have fun,
CirTap
You can have programs written fast, well, and cheap, but you only get to pick 2 ...

"I love deadlines. I like the whooshing sound they make as they fly by." Douglas Adams

identity
Joomla! Apprentice
Joomla! Apprentice
Posts: 10
Joined: Sat Jul 08, 2006 9:51 am
Location: Luxembourg

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

Post by identity » Fri Jul 27, 2007 9:51 am

Hi,

and that's why I called mine easy and fast ;)
But still, you're right. I recently had to adapt my code to the new location of some of the js files. So what about this:

Code: Select all

<?php
// 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', 'caption.js', 'joomla.javascript.js');

// remove the js files
foreach($headerstuff['scripts'] as $key => $script) {
    foreach($search as $findme) {
        if(stristr($script, $findme) !== false) {
            unset($headerstuff['scripts'][$key]);
        }
    }
}
// restore
$this->setHeadData($headerstuff);
But as always, there are many ways to implement this.

Have fun, too ;)
Sam

P.S.: thanks for pointing out the unnecessary $document variable. I had this implemented as a system plug-in and forgot to adapt it to the template 'environment'.

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 website....

Post by Peter Clements » Fri Jul 27, 2007 10:22 am

I was also wondering about this.  I don't want it in my headers at all.  I commented out it's generation in /libraries/joomla/html/html/behavior.php (yeah, yeah , I know, not the correct thing to do, I was just hacking around) and found this was fine for the front-end (I didn't want caption.js either) but kills things in the Administrator, like the menu drop-downs.

I'm not sure exactly what it's doing on the front-end anyway?  It seems like a hefty bit of JavaScript.  All I want is the cut-down and compressed version for slimbox to function.

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 website....

Post by Peter Clements » Fri Jul 27, 2007 1:33 pm

identity wrote: Hi,

and that's why I called mine easy and fast ;)
But still, you're right. I recently had to adapt my code to the new location of some of the js files. So what about this:

Code: Select all

<?php
// 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', 'caption.js', 'joomla.javascript.js');

// remove the js files
foreach($headerstuff['scripts'] as $key => $script) {
    foreach($search as $findme) {
        if(stristr($script, $findme) !== false) {
            unset($headerstuff['scripts'][$key]);
        }
    }
}
// restore
$this->setHeadData($headerstuff);
But as always, there are many ways to implement this.

Have fun, too ;)
Sam

P.S.: thanks for pointing out the unnecessary $document variable. I had this implemented as a system plug-in and forgot to adapt it to the template 'environment'.
I don't seem to be able to get your code to work.  What am I doing wrong?  If I comment out the 'if' statement then I can get it to remove all scripts.

Is joomla.javascript.js required for front-end editing?  For that matter, are the other 2?  If so, is there a variable or some logic that can be used so we can print the links to the script files (and do other stuff with PHP etc...) when a user is logged in and only when someone is logged in?

Is there a similar "official" method to remove the META Generator tag from rendered pages too?

User avatar
CirTap
Joomla! Explorer
Joomla! Explorer
Posts: 418
Joined: Mon Dec 12, 2005 5:34 pm

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

Post by CirTap » Fri Jul 27, 2007 1:54 pm

identity wrote: I recently had to adapt my code to the new location of some of the js files. So what about this:

Code: Select all

<?php
// 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', 'caption.js', 'joomla.javascript.js');

// remove the js files
foreach($headerstuff['scripts'] as $key => $script) {
    foreach($search as $findme) {
        if(stristr($script, $findme) !== false) {
            unset($headerstuff['scripts'][$key]);
        }
    }
}
// restore
$this->setHeadData($headerstuff);
Looks ok, but you don't want my approval, do you?
As I said: "... and get rid of the mootols entry in any other fashion you find appropriate."
Peter Clements wrote: I was also wondering about this.  I don't want it in my headers at all.
if you don't want it in your front-end template, you'd need to remove it like demonstrated in this thread; there are now three ways of doing it :)
Peter Clements wrote: I commented out it's generation in /libraries/joomla/html/html/behavior.php (yeah, yeah , I know, not the correct thing to do, I was just hacking around) and found this was fine for the front-end (I didn't want caption.js either) but kills things in the Administrator, like the menu drop-downs.
Peter Clements wrote: I'm not sure exactly what it's doing on the front-end anyway?  It seems like a hefty bit of JavaScript.  All I want is the cut-down and compressed version for slimbox to function.
I confess I'm not sure either. It's used by the "slider" chrome feature of the standard template.
Keep in mind that Mootools is considered to be the official JavaScript framework of Joomla! 1.5. 3PD may already depend on this, or will do in the near future. If you kick it, you'd risk to break many new (and updated) extensions.

Be aware of what you're doing.
What you "could" do: remove the hack of behaviour.php first :) If you believe the full JS-framework is way to heavy for your site, get your own slim-down copy of Mootoos from their download area and select only those modules your site depend on. Note than with J! debug mode enabled, the file mootools-uncompressed.js will be used which is tweice as large due to the code comments. Do not replace this file.
Extensions based on Mootools usually tell you what modules to get.
Override the Front-end template as demonstrated here to drop the large mootols[-uncompressed].js entries from the template, and replace it with your custom "mootools-mine.js"
If you're sick of constantly updating you fine-grain, custom-made mootools.js lib, because more and more extensions will require yet-another-module to be added, revert your changes and use the full package ... again ;)

Have fun,
CirTap
You can have programs written fast, well, and cheap, but you only get to pick 2 ...

"I love deadlines. I like the whooshing sound they make as they fly by." Douglas Adams

identity
Joomla! Apprentice
Joomla! Apprentice
Posts: 10
Joined: Sat Jul 08, 2006 9:51 am
Location: Luxembourg

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

Post by identity » Fri Jul 27, 2007 4:05 pm

Peter Clements wrote: I don't seem to be able to get your code to work.  What am I doing wrong?  If I comment out the 'if' statement then I can get it to remove all scripts.
Uhh, sorry, my mistake! Exchange $script with $key like this

Code: Select all

<?php
if(stristr($key, $findme) !== false)
?>
and it should work.

If you want to remove all javascript libraries, the following code is way faster:

Code: Select all

<?php
$headerstuff = $this->getHeadData();
$headerstuff['scripts'] = array();
$this->setHeadData($headerstuff);
?>
Peter Clements wrote: Is joomla.javascript.js required for frontend editing?  For that matter, are the other 2?  If so, is there a variable or some logic that can be used so we can print the links to the script files (and do other stuff with PHP etc...) when a user is logged in and only when someone is logged in?
Actually I don't know, but it is easy to remove the js libraries for guests:

Code: Select all

<?php
$user =& JFactory::getUser();
if($user->get('guest') == 1) {
    // remove all js libraries or those you don't need/want
    // joomla.javascript.js doesn't get loaded for guests
}
?>
Peter Clements wrote: Is there a similar "official" method to remove the META Generator tag from rendered pages too?
I don't know of an "official" method to completely remove the META Generator tag, but if you put the following code in your template file, you can set it to an empty string:

Code: Select all

<?php
$this->setGenerator('');
?>
Hope I could help ;)
Sam

P.S.:
CirTap wrote: Looks ok, but you don't want my approval, do you?
Actually... no  ;D
Last edited by identity on Fri Jul 27, 2007 4:08 pm, edited 1 time in total.

User avatar
CirTap
Joomla! Explorer
Joomla! Explorer
Posts: 418
Joined: Mon Dec 12, 2005 5:34 pm

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

Post by CirTap » Fri Jul 27, 2007 6:04 pm

Everything "official", regarding Joomla's live, it's universe and everything, is documented in the J! 1.5 API Reference @ http://api.joomla.org
For template "tuning" in particular:
  http://api.joomla.org/Joomla-Framework/ ... ument.html
  http://api.joomla.org/Joomla-Framework/ ... tHTML.html
their interface is accesible via the $this keyword inside the template index.php
Just avoid using anything marked as @private, @abstract, or things that start with an underscore in their name (like _scripts), and you should be save :)

There's more incl. small examples:
  http://dev.joomla.org/component/option, ... references

Have fun and happy tweaking,

CirTap
You can have programs written fast, well, and cheap, but you only get to pick 2 ...

"I love deadlines. I like the whooshing sound they make as they fly by." Douglas Adams

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 website....

Post by Peter Clements » Sat Jul 28, 2007 5:35 pm

Many thanks identity and CirTap for your clear help and advice.  it's very much appreciated.

I love how everything is done 'properly' in the new Joomla!  I'm usually quite happy hacking stuff around and to be honest a lot of the new Joomla! stuff is way over my head.  I need to sit down and thoroughly read through the documentation.

I've now managed to get the demo site I'm developing to a state that I want it, with only the one hack (there were a few before reading this thread and others).  I think it would be nice if menu links opening in a new window used JavaScript instead of the invalid target attribute, by choice or by default.  A simple hack, "_blank" becomes "onclick="window.open(this.href); return false;"".  Another option where you could apply an ID to the parent UL of a menu for sucker fish drop-downs would be nice as well.  I've gotten around this by spanning the menu in a DIV using the module 'style' for that module position (another cracking function of Joomla! 1.5).  Now if I could just work out how to get the RSS function to syndicate the one feed from more than one content section I'd be a very happy man.  Going dangerously off topic here so had better shut up!
CirTap wrote:Everything "official", regarding Joomla's live, it's universe and everything, is documented in the J! 1.5 API Reference...
I was going to ask if you were a fan of The Hitchhiker's Guide to the Galaxy but then saw the Douglas Adams quote in your signature. :)
Last edited by Peter Clements on Sat Jul 28, 2007 5:36 pm, edited 1 time in total.

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 website....

Post by Peter Clements » Sun Jul 29, 2007 9:07 pm

Hi again,

I can't seem to prevent the JavaScript links from echoing in the head of the page for guests, using the following code:

Code: Select all

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

	if ($user->get('guest') == 1) {
		$headerstuff = $this->getHeadData();
		$headerstuff['scripts'] = array();
		$this->setHeadData($headerstuff);
	}
?>
I can do things like echoing Google Analytics tracking code for guests only and removing it when a user is logged in.

Is it possible that Joomla! is handling the header structure before it's checking for user type?

Also, I've tried substituting things like "Super Administrator" for "guest" in the above code but with no luck, I assumed it was simply the 'user type'.  Am I wrong?  I was wondering how easy it'd be to do specific things depending on the user type someone logs in as?

One one question, is there an easy method for telling what type of user a person is logged in as?  A bit of 'user type sniffing' etc...  That would then answer my above question about working out what goes in the code to check for that specific user type as I'd be able to find out.

EDIT:  Please ignore the bit about the above code not working, it's working just great, I think tiredness is getting the better of me this evening!
Last edited by Peter Clements on Sun Jul 29, 2007 9:12 pm, edited 1 time in total.

identity
Joomla! Apprentice
Joomla! Apprentice
Posts: 10
Joined: Sat Jul 08, 2006 9:51 am
Location: Luxembourg

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

Post by identity » Sun Jul 29, 2007 10:39 pm

Peter Clements wrote: Also, I've tried substituting things like "Super Administrator" for "guest" in the above code but with no luck, I assumed it was simply the 'user type'.  Am I wrong?  I was wondering how easy it'd be to do specific things depending on the user type someone logs in as?

One one question, is there an easy method for telling what type of user a person is logged in as?  A bit of 'user type sniffing' etc...  That would then answer my above question about working out what goes in the code to check for that specific user type as I'd be able to find out.
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

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 website....

Post by Peter Clements » Mon Jul 30, 2007 8:18 am

Sam, you're a star!  Thank you very much indeed, exactly the information I was looking for! :)  All so obvious when you have someone who knows what they are doing explain it to you! ;D

User avatar
CirTap
Joomla! Explorer
Joomla! Explorer
Posts: 418
Joined: Mon Dec 12, 2005 5:34 pm

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

Post by CirTap » Mon Jul 30, 2007 9:23 am

identity wrote: $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.
no exactly: although it is in fact the primary key of the "group" table, it's also considered the group-id, and they are unlikely to change in 1.x but rather be extended should a more advanced ACL be available. The default group-ids are not random, but part of the default data.

Code: Select all

17, 'ROOT'
29, 'Public Frontend'
  18, 'Registered'
    19, 'Author'
      20, 'Editor'
        21, 'Publisher'
28, 'USERS'
30, 'Public Backend'
  23, 'Manager'
    24, 'Administrator'
      25, 'Super Administrator'
note that some of these IDs (acl groups) do not appear literaly in a user account, i.e. "30 - Public Backend", is used internally and "inherited" by 23-25 (it's a bit more complex however)
Real users of the 'Public Backend' would have either 23, 24, or 25 as their $gid (The name is bit misleading since there's no 'Private' or 'Non-Public' Backend.)
identity wrote: But pay attention: $user->get('usertype') seems to be undefined for guests!
it is indeed, since Guests don't exists as a user account, thus they don't have a user-id, group-id or access-id, read: if any of this is "undefined", empty or zero, you have a guest.

Btw. you don't need the get() method. All information if available as public properties of the JUser object, i.e.
  if ($user->guest) {
      // stuff for guests
  } else {
    // stuff for registered members
  }
see http://api.joomla.org/Joomla-Framework/User/JUser.html
and the Framework Reference in the Development Wiki http://dev.joomla.org/component/option, ... Itemid,32/

Have fun,
CirTap
You can have programs written fast, well, and cheap, but you only get to pick 2 ...

"I love deadlines. I like the whooshing sound they make as they fly by." Douglas Adams

identity
Joomla! Apprentice
Joomla! Apprentice
Posts: 10
Joined: Sat Jul 08, 2006 9:51 am
Location: Luxembourg

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

Post by identity » Tue Jul 31, 2007 8:24 am

Peter Clements wrote: Sam, you're a star!  Thank you very much indeed, exactly the information I was looking for! :)  All so obvious when you have someone who knows what they are doing explain it to you! ;D
Ohh stop it, I'm blushing :)
Besides, CirTap is the professional here.

C ya,
Sam

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 website....

Post by Peter Clements » Tue Jul 31, 2007 8:37 am

identity wrote:
Peter Clements wrote: Sam, you're a star!  Thank you very much indeed, exactly the information I was looking for! :)  All so obvious when you have someone who knows what they are doing explain it to you! ;D
Ohh stop it, I'm blushing :)
Besides, CirTap is the professional here.

C ya,
Sam
Absolutely, a huge "Thank You" to CirTap also for his expert, professional help and advice. :D

sa247
Joomla! Explorer
Joomla! Explorer
Posts: 271
Joined: Sat Sep 16, 2006 8:50 pm
Location: San Antonio, Texas
Contact:

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

Post by sa247 » Sat Aug 04, 2007 9:18 pm

thanks guys for your input - i didnt think this would generate such a huge response! :)

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 website....

Post by newart » Thu Jan 10, 2008 6:03 pm

I'd like to observe that also in RC4 is good your code:

Code: Select all

<?php
$headerstuff = $this->getHeadData();
$headerstuff['scripts'] = array();
$this->setHeadData($headerstuff);
?>
I've tested the admin site and obviously all is good. In public site is now without any java stuff. Only 1 question: what I've missed in a simple site without those java files? Apart from the meta tag generator...
former Q&T WorkGroup Joomla member - Italian Translation Team Member

rudialex
Joomla! Intern
Joomla! Intern
Posts: 84
Joined: Tue Aug 08, 2006 9:42 pm
Contact:

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

Post by rudialex » Thu Feb 07, 2008 8:17 pm

Code: Select all

$search = array('mootools', 'caption.js');
// remove the js files
foreach($this->_scripts as $key => $script) {
	foreach($search as $findme) {
		if(stristr($key, $findme) !== false) {
			unset($this->_scripts[$key]);
		}
	}
}
this works fine with me.
rudialex.com - custom joomla templates developer

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 website....

Post by newart » Fri Feb 08, 2008 7:17 am

Your script is probably better than what posted by me as it's more specific... it doesn't permit to be downloaded those 2 files.

If you go in my signature's site you can see that using "mine" script Joomla 1.5 seems working good.

Nevertheless I like your script better than "mine" and I'm going to test it in the week-end surely. Only one question... if you know the reply: what's for those removed files?

I explain what I mean, if you go to mootools site and download the basic small file (around 2-3 Kb) the site isn't working apparently but I don't know which is the basic files (or files) for a minimum site. In the mootools site the are in the downlaod page a list of all files downloadable and I don't think Joomla 1.5 requires all full package for a new fresh installation!

I've tested something but I stopped all tests as I haven't a good knowledge for understanding what and how to have a good site with a minimum site.
former Q&T WorkGroup Joomla member - Italian Translation Team Member

rudialex
Joomla! Intern
Joomla! Intern
Posts: 84
Joined: Tue Aug 08, 2006 9:42 pm
Contact:

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

Post by rudialex » Fri Feb 08, 2008 12:48 pm

So ... in a nutshel. Many users faced problem - they dont want to make their site heavy ... for any reasons ... And they need to remove mootools scripts. But removing these scripts we cant see pop ups when we are logged in ... (login in frontend and try to see edit buttons).

So , here we must use at least this checking code (it was decribed earlier by several users in different ways). And with me it looks like:

Code: Select all

<?php
$user =& JFactory::getUser();
if($user->get('guest') == 1) {
	$search = array('mootools', 'caption.js');
	// remove the js files
	foreach($this->_scripts as $key => $script) {
		foreach($search as $findme) {
			if(stristr($key, $findme) !== false) {
				unset($this->_scripts[$key]);
			}
		}
	}
}
Sure ... It doesnt solve our problem.

But, removing mootools from head we make impossible to use properly working extensions with moo. Lets see.

When Joomla starts load template - head data is already generated. IE - each script is added like ... caption

Code: Select all

<?php
	function caption() {
		JHTML::script('caption.js');
	}
If we look at this function (script) we see

Code: Select all

<?php
	function script($filename, $path = 'media/system/js/', $mootools = true)
	{
		// Include mootools framework
		if($mootools) {
			JHTML::_('behavior.mootools');
		}		
                ...........
		$document = &JFactory::getDocument();
		$document->addScript( $path.$filename );
		return;
	}

/*-------------- from JHTMLBehavior class ------------*/
	function mootools($debug = null)
	{
		static $loaded;
		// Only load once
		if ($loaded) {
			return;
		}
                // if is not loaded - loads and assign loaded = true

		$loaded = true;
		return;
	}

/*-------------- from DOCUMENT class ------------*/
	function addScript($url, $type="text/javascript") {
		$this->_scripts[$url] = $type;
	}
That mootools will be added anyway! before each script we want to include. It means that - when we remove mootools from head - we already have mootools "included" and any further attemt to include moo this way

Code: Select all

<?php JHTML::_('behavior.mootools'); ?>
Wont be successful - as $loaded = true;

So we will need to recode each component that needs mootools.

IN the end ... I think, If JTem decided to include motoold in frontent - they should also think over how to give us the choice and provide with ability to unset mootools. Say like this way

Code: Select all

<?php
	function mootools($debug = null, $unset = false)
	{
		static $loaded;
        // with help of this var - we set $loaded to false and make possible to include mootools then ...
        if ($unset) {$loaded = false;return;}
then ... in template, after removing js scripts we past

Code: Select all

<?php JHTMLBehavior::mootools(null,true); ?>
It's not professional -  i;m not good coder - but the idea is like I descibed. And then ... in component - weh we call
JHTML::_('behavior.mootools');

we will get result =) even if we have removed some scripts at the very top of our template.
Last edited by rudialex on Fri Feb 08, 2008 4:57 pm, edited 1 time in total.
rudialex.com - custom joomla templates developer

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 website....

Post by newart » Fri Feb 08, 2008 4:33 pm

At my eyes you're surely a Great coder! I agree totally with you, if a component needs a mootools feature I think the better way is to load that moo file by that component's script directly. If you have some general needs for Joomla, well, inserting a basic strictly needing moo file is better than to upload the entire package. The same for an extension.

If a CMS needs more versatility for contents, I hope to see more versatility for what using for that content.

PS. In the next days I'll some further tests about your codes.
former Q&T WorkGroup Joomla member - Italian Translation Team Member

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 » Mon Feb 25, 2008 8:49 am

_Sash@ I'm thinking of your last post in this thread and I have an idea as I see your suggestion as a very good one!

Would you like to post your splendid idea in the White Paper for joomla 1.6 version? I'd like to see ready and working in 1.6 version the moo-system...

Please reply for informing us if you do this. I hope so!
former Q&T WorkGroup Joomla member - Italian Translation Team Member

rudialex
Joomla! Intern
Joomla! Intern
Posts: 84
Joined: Tue Aug 08, 2006 9:42 pm
Contact:

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

Post by rudialex » Mon Feb 25, 2008 11:28 am

Sure, I can post. But now this idea looks very raw ... May be some improvements? Say ... better to look at old joomla template ...

Code: Select all

if ( $my->id ) {
	initEditor();
}
And do something similar with scripts ... Very useful if this way ... So we can control script loading by this function ... say

Code: Select all

if ( $user->get('guest') == 1 ) {
	initScripts();
}
And initscripts will look like

Code: Select all

<?php
function initScripts($scripts=$this->_scripts) {
      // for each to load all scripts with JHTML::script();
}
So in template we can decide ... or load defaults or specify our own scripts ... And then we can use JHTML::_('behavior.mootools');
in components ... (just recode function JHTML::script(); to not load mootools with any script as it will be done by new init function).

Guess this way will be good old solution =)

What do you think?
rudialex.com - custom joomla templates developer

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 » Mon Feb 25, 2008 11:43 am

My idea is that - reading what is a white paper - you can simply post yours ideas and the dev team can decide how to improve / change whatever they like.

The important thing, I think, is now to post this problem with your very good considerations, then... We hope to see good news from the Joomla team :)

Please see on http://www.joomla.org/content/view/4578/1/ - as I can understand what it is important is to explain a problem and try to write some solutions, but the real solution is up to our joomla team. I'm sure if you post there, they can solve the problem as They have a wide full knowledge of Joomla itself.

Please when doing, post here your news, I'd like to see your post... :) :) :)
former Q&T WorkGroup Joomla member - Italian Translation Team Member

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 Feb 27, 2008 3:22 pm

I've posted in a thread presents in the white paper forum our link, please see on http://forum.joomla.org/viewtopic.php?f ... 2#p1218692 - I hope to be useful for solving our problems...
former Q&T WorkGroup Joomla member - Italian Translation Team Member

rudialex
Joomla! Intern
Joomla! Intern
Posts: 84
Joined: Tue Aug 08, 2006 9:42 pm
Contact:

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

Post by rudialex » Wed Feb 27, 2008 5:26 pm

Thank you for this post. I had not enough free time last week and this week actually too. Hope JTeam will do somehing.
rudialex.com - custom joomla templates developer

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 Feb 27, 2008 5:55 pm

I hope so, please stay tuned for posting something (or simply a post for agreeing about this problem) in that thread just for "promoting" our "ideas", ok? ;)
former Q&T WorkGroup Joomla member - Italian Translation Team Member


Locked

Return to “Joomla! 1.5 Coding”