Welcome to Geeklog Thursday, May 23 2013 @ 08:14 PM EDT
|
||||||||
![]() |
Forum Index > Support > Plugin Support |
New Topic
|
Post Reply
|
Add JavaScript before the closing body tag |
|||
| ::Ben |
|
||||||
![]() ![]() ![]() ![]() ![]() Full Member ![]() Status: offline ![]() Registered: 01/14/05 Posts: 1359 |
Hello,
What is the best way for plugins to include JavaScript just before the closing </body> tag? Thanks, ::Ben We speak french on http://geeklog.fr |
||||||
|
|||||||
| suprsidr |
|
||||||
![]() ![]() ![]() ![]() ![]() Full Member Status: offline ![]() Registered: 12/29/04 Posts: 552 |
function plugin_getheadercode_pluginName() -s FlashYourWeb and Your Gallery with the E2 XML Media Player for Gallery2 - http://www.flashyourweb.com |
||||||
|
|||||||
| ::Ben |
|
||||||
![]() ![]() ![]() ![]() ![]() Full Member ![]() Status: offline ![]() Registered: 01/14/05 Posts: 1359 |
Hello,
function plugin_getheadercode_pluginName() allow to include code in the header. This function is called from COM_siteHeader and will return additional header * information. This can be used for JavaScript functions required for the plugin * or extra Metatags I would like to include some code after the footer, just before PHP Formatted Code <script src="myscript.js" type="text/javascript"></script> </body> Thanks, ::Ben We speak french on http://geeklog.fr |
||||||
|
|||||||
| suprsidr |
|
||||||
![]() ![]() ![]() ![]() ![]() Full Member Status: offline ![]() Registered: 12/29/04 Posts: 552 |
Ah, sorry read your question wrong.
There is no built-in plugin function to add to the footer, but maybe you can:
-s FlashYourWeb and Your Gallery with the E2 XML Media Player for Gallery2 - http://www.flashyourweb.com |
||||||
|
|||||||
| Dirk |
|
||||||
![]() ![]() ![]() ![]() ![]() Admin ![]() Status: offline ![]() Registered: 01/12/02 Posts: 13027 |
FWIW, there's already a feature request for this. It includes some patches that I haven't tried yet ...
bye, Dirk |
||||||
|
|||||||
| suprsidr |
|
||||||
![]() ![]() ![]() ![]() ![]() Full Member Status: offline ![]() Registered: 12/29/04 Posts: 552 |
Here I hijacked the footer's execution_time:
PHP Formatted Code function plugin_templatesetvars_pluginName($type, &$template) { global $LANG01, $_PAGE_TIMER; $exectime = $_PAGE_TIMER->stopTimer(); $exectext = $LANG01[91] . ' ' . $exectime . ' ' . $LANG01[92].'<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>'; if ($type == 'footer') { $template->set_var( 'execution_time', $exectime ); $template->set_var( 'execution_textandtime', $exectext ); } } Not the most beautiful solution, but it works. -s FlashYourWeb and Your Gallery with the E2 XML Media Player for Gallery2 - http://www.flashyourweb.com |
||||||
|
|||||||
| jmucchiello |
|
||||||
![]() ![]() ![]() ![]() ![]() Full Member Status: offline ![]() Registered: 08/29/05 Posts: 985 |
If you are going to do something like that, at least do it the nice way. Just append your data to an existing value. Of course, this doesn't work if someone removes the timer display from their footer:
PHP Formatted Code function plugin_templatesetvars_pluginName($type, $template) { if ($type == 'footer') { $incl = '<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>'; $template->set_var( 'execution_time', $incl, 1 ); $template->set_var( 'execution_textandtime', $incl, 1 ); } } Oh, and you really shouldn't be serving javascript from a remote URL. That's just an XSS attack waiting to happen. Or worse, a non-attack to be blocked by overzealous browser plugins like Noscript. |
||||||
|
|||||||
| ::Ben |
|
||||||
![]() ![]() ![]() ![]() ![]() Full Member ![]() Status: offline ![]() Registered: 01/14/05 Posts: 1359 |
Thanks for all these ways.
Would be great to see this feature request #906 in the next geeklog release. ::Ben We speak french on http://geeklog.fr |
||||||
|
|||||||
| Content generated in: 1.36 seconds |
|
|
|