Welcome to Geeklog, Anonymous Saturday, November 08 2025 @ 08:40 am EST
Geeklog Forums
Add JavaScript before the closing body tag
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
20
29
Quote
Status: offline
::Ben
Forum User
Full Member
Registered: 01/14/05
Posts: 1582
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
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
22
25
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
22
24
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
23
26
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
23
24
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.
29
23
Quote
Status: offline
::Ben
Forum User
Full Member
Registered: 01/14/05
Posts: 1582
Thanks for all these ways.
Would be great to see this feature request #906 in the next geeklog release.
::Ben
Would be great to see this feature request #906 in the next geeklog release.
::Ben
20
19
Quote
All times are EST. The time is now 08:40 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