Advertisement
removing mootools from the header for a cell phone dot mobi website....
-
- 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....
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...
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.
Advertisement
- CirTap
- 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....
Hi,
make sure to add this at the very top of your template. This is the "official" way using the JDocumentHTML API
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
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);
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
"I love deadlines. I like the whooshing sound they make as they fly by." Douglas Adams
-
- 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....
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!
i really need to get my head around working with the API - i appreciate the document link thanks!
-
- 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....
Even easier and faster:
unset throws no error what so ever, so just release it on all the js libraries you don't need.
This works for me (SVN 8212)
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']);
Code: Select all
unset($document->_scripts[JURI::base() . 'media/system/js/caption.js']);
unset($document->_scripts['includes/js/joomla.javascript.js']);
- CirTap
- 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....
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
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
"I love deadlines. I like the whooshing sound they make as they fly by." Douglas Adams
-
- 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....
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:
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'.
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);
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'.
- Peter Clements
- Joomla! Enthusiast
- Posts: 172
- Joined: Tue Nov 08, 2005 12:58 pm
- Location: England
- Contact:
Re: removing mootools from the header for a cell phone dot mobi website....
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.
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.
- Peter Clements
- Joomla! Enthusiast
- Posts: 172
- Joined: Tue Nov 08, 2005 12:58 pm
- Location: England
- Contact:
Re: removing mootools from the header for a cell phone dot mobi website....
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.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:
But as always, there are many ways to implement 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);
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'.
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?
- CirTap
- 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....
Looks ok, but you don't want my approval, do you?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);
As I said: "... and get rid of the mootols entry in any other fashion you find appropriate."
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 itPeter Clements wrote: I was also wondering about this. I don't want it in my headers at all.
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.
I confess I'm not sure either. It's used by the "slider" chrome feature of the standard template.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.
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
"I love deadlines. I like the whooshing sound they make as they fly by." Douglas Adams
-
- 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....
Uhh, sorry, my mistake! Exchange $script with $key like thisPeter 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.
Code: Select all
<?php
if(stristr($key, $findme) !== false)
?>
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);
?>
Actually I don't know, but it is easy to remove the js libraries for guests: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?
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
}
?>
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:Peter Clements wrote: Is there a similar "official" method to remove the META Generator tag from rendered pages too?
Code: Select all
<?php
$this->setGenerator('');
?>
Sam
P.S.:
Actually... noCirTap wrote: Looks ok, but you don't want my approval, do you?
Last edited by identity on Fri Jul 27, 2007 4:08 pm, edited 1 time in total.
- CirTap
- 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....
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
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
"I love deadlines. I like the whooshing sound they make as they fly by." Douglas Adams
- Peter Clements
- Joomla! Enthusiast
- Posts: 172
- Joined: Tue Nov 08, 2005 12:58 pm
- Location: England
- Contact:
Re: removing mootools from the header for a cell phone dot mobi website....
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!
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!
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.CirTap wrote:Everything "official", regarding Joomla's live, it's universe and everything, is documented in the J! 1.5 API Reference...
Last edited by Peter Clements on Sat Jul 28, 2007 5:36 pm, edited 1 time in total.
- Peter Clements
- Joomla! Enthusiast
- Posts: 172
- Joined: Tue Nov 08, 2005 12:58 pm
- Location: England
- Contact:
Re: removing mootools from the header for a cell phone dot mobi website....
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:
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!
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);
}
?>
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.
-
- 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....
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: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.
$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
- Peter Clements
- Joomla! Enthusiast
- Posts: 172
- Joined: Tue Nov 08, 2005 12:58 pm
- Location: England
- Contact:
Re: removing mootools from the header for a cell phone dot mobi website....
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!
- CirTap
- 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....
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.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.
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'
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.)
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.identity wrote: But pay attention: $user->get('usertype') seems to be undefined for guests!
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
"I love deadlines. I like the whooshing sound they make as they fly by." Douglas Adams
-
- 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....
Ohh stop it, I'm blushingPeter 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!
Besides, CirTap is the professional here.
C ya,
Sam
- Peter Clements
- Joomla! Enthusiast
- Posts: 172
- Joined: Tue Nov 08, 2005 12:58 pm
- Location: England
- Contact:
Re: removing mootools from the header for a cell phone dot mobi website....
Absolutely, a huge "Thank You" to CirTap also for his expert, professional help and advice.identity wrote:Ohh stop it, I'm blushingPeter 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!
Besides, CirTap is the professional here.
C ya,
Sam
-
- 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....
thanks guys for your input - i didnt think this would generate such a huge response!
- newart
- 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....
I'd like to observe that also in RC4 is good your code:
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...
Code: Select all
<?php
$headerstuff = $this->getHeadData();
$headerstuff['scripts'] = array();
$this->setHeadData($headerstuff);
?>
former Q&T WorkGroup Joomla member - Italian Translation Team Member
-
- 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....
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]);
}
}
}
rudialex.com - custom joomla templates developer
- newart
- 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....
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.
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
-
- 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....
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:
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
If we look at this function (script) we see
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
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
then ... in template, after removing js scripts we past
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.
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]);
}
}
}
}
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');
}
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;
}
Code: Select all
<?php JHTML::_('behavior.mootools'); ?>
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;}
Code: Select all
<?php JHTMLBehavior::mootools(null,true); ?>
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
- newart
- 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....
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.
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
- newart
- 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
_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!
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
-
- 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
Sure, I can post. But now this idea looks very raw ... May be some improvements? Say ... better to look at old joomla template ...
And do something similar with scripts ... Very useful if this way ... So we can control script loading by this function ... say
And initscripts will look like
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?
Code: Select all
if ( $my->id ) {
initEditor();
}
Code: Select all
if ( $user->get('guest') == 1 ) {
initScripts();
}
Code: Select all
<?php
function initScripts($scripts=$this->_scripts) {
// for each to load all scripts with JHTML::script();
}
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
- newart
- 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
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...
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
- newart
- 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
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
-
- 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
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
- newart
- 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
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
Advertisement