vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Adding Javascript with a product, (https://vborg.vbsupport.ru/showthread.php?t=216437)

Dunhamzzz 06-18-2009 09:08 AM

Adding Javascript with a product,
 
Hey, I'm making a pretty extensible mod for vb, and need to put some JS in the headerinclude template. It needs to be pulled from a database for each page too.

I know its probably well documented somewhere but I just can't search for it as the terms are pretty common. I'm guessing its a hook of some sort?

Dismounted 06-18-2009 10:02 AM

PHP Code:

$headinclude .= '<!-- something -->'

Use it at a hook just after it is fetched (style_fetch, or something similar, check it!).

Dunhamzzz 06-19-2009 10:00 AM

No joy.
Put the following code at the "style_fetch" hook and nothing was included in the header.
PHP Code:

$headinclude.= '<script type="text/javascript" src="clientscript/juice/js/jquery.min.js"></script><script type="text/javascript" src="clientscript/juice/js/jquery.juice.popover.js"></script>'

Not using vboptimize or anything.

Also, could you elaborate on "something similiar"?

Dismounted 06-19-2009 10:08 AM

Quote:

Originally Posted by Dunhamzzz (Post 1832584)
Also, could you elaborate on "something similiar"?

Meaning check the hook location - as you found out, I was wrong. Use global_setup_complete.

Dunhamzzz 06-19-2009 12:28 PM

ok thanks for the quick response + help :)

Another method I cam across used in an existing plugin was a hook at 'global_start' using the code:

PHP Code:

$vbulletin->templatecache['headinclude'] .= $js

Is there any advantage with either method? Speed/resource wise?

Dismounted 06-20-2009 03:00 AM

It doesn't really matter either way.


All times are GMT. The time now is 01:50 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01844 seconds
  • Memory Usage 1,723KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (3)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (6)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete