Welcome to Geeklog, Anonymous Sunday, December 22 2024 @ 07:33 am EST
Geeklog Forums
Add JavaScript before the closing body tag
Status: offline
::Ben
Forum User
Full Member
Registered: 01/14/05
Posts: 1569
Location:la rochelle, France
Hello,
What is the best way for plugins to include JavaScript just before the closing </body> tag?
Thanks,
::Ben
I'm available to customise your themes or plugins for your Geeklog CMS
What is the best way for plugins to include JavaScript just before the closing </body> tag?
Thanks,
::Ben
I'm available to customise your themes or plugins for your Geeklog CMS
13
12
Quote
Status: offline
suprsidr
Forum User
Full Member
Registered: 12/29/04
Posts: 555
Location:Champaign, Illinois
function plugin_getheadercode_pluginName()
-s
FlashYourWeb and Your Gallery with the E2 XML Media Player for Gallery2 - http://www.flashyourweb.com
11
18
Quote
Status: offline
::Ben
Forum User
Full Member
Registered: 01/14/05
Posts: 1569
Location:la rochelle, France
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
<script src="myscript.js" type="text/javascript"></script>
</body>
Thanks,
::Ben
I'm available to customise your themes or plugins for your Geeklog CMS
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
Text Formatted Code
<script src="myscript.js" type="text/javascript"></script>
</body>
Thanks,
::Ben
I'm available to customise your themes or plugins for your Geeklog CMS
14
14
Quote
Status: offline
suprsidr
Forum User
Full Member
Registered: 12/29/04
Posts: 555
Location:Champaign, Illinois
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
There is no built-in plugin function to add to the footer, but maybe you can:
- retrieve a footer template variable
- add to it
- re-add it to the footer using plugin_templatesetvars_pluginName
-s
FlashYourWeb and Your Gallery with the E2 XML Media Player for Gallery2 - http://www.flashyourweb.com
12
15
Quote
Status: offline
Dirk
Site Admin
Admin
Registered: 01/12/02
Posts: 13073
Location:Stuttgart, Germany
FWIW, there's already a feature request for this. It includes some patches that I haven't tried yet ...
bye, Dirk
bye, Dirk
13
15
Quote
Status: offline
suprsidr
Forum User
Full Member
Registered: 12/29/04
Posts: 555
Location:Champaign, Illinois
Here I hijacked the footer's execution_time:
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
Text 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
14
13
Quote
Status: offline
jmucchiello
Forum User
Full Member
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:
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.
Text 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.
14
11
Quote
Status: offline
::Ben
Forum User
Full Member
Registered: 01/14/05
Posts: 1569
Location:la rochelle, France
Thanks for all these ways.
Would be great to see this feature request #906 in the next geeklog release.
::Ben
I'm available to customise your themes or plugins for your Geeklog CMS
Would be great to see this feature request #906 in the next geeklog release.
::Ben
I'm available to customise your themes or plugins for your Geeklog CMS
13
10
Quote
All times are EST. The time is now 07:33 am.
- Normal Topic
- Sticky Topic
- Locked Topic
- New Post
- Sticky Topic W/ New Post
- Locked Topic W/ New Post
- View Anonymous Posts
- Able to post
- Filtered HTML Allowed
- Censored Content