Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 05-23-2010, 09:52 PM
encryption's Avatar
encryption encryption is offline
 
Join Date: Sep 2005
Posts: 155
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Hook to header or headinclude

Hey guys, hopefully someone can help me here. I have searched all over vbulletin.org, .com, and Google for 3-4 hours now and can't find an answer to what should be a simple question for my first plugin experience!

I want to add some custom data to the headinclude template, and I'd like to do it via a plugin without actually editing the headinclude template. I downloaded the class_bootstrap.php include and see two different hooks: parse_templates, which seems to happen just before header processing, and process_templates_complete, which seems to happen just after processing and before rendering.

I see this code in the class_bootstrap.php include file:

Code:
		$templater = vB_Template::create('headinclude');
			$templater->register('foruminfo', $foruminfo);
			$templater->register('pagenumber', $pagenumber);
			$templater->register('style', $style);
			$templater->register('basepath', VB_URL_BASE_PATH);
		$headinclude = $templater->render();

Since $headinclude isn't touched anywhere else through the point of where process_templates_complete is called, I just assume I could add text directly to that variable from my plugin. I have tried all sorts of things to add my line of code, but from what I understand, this should work:

$headinclude = $headinclude . '<script src="djdb/ajax.js"></script>';


This line never appears anywhere in my page source. Can someone please help figure out how to insert this line into the header via a plugin? Or tell me what I'm doing wrong and how I can do a plugin correctly? Thanks!
Reply With Quote
  #2  
Old 06-02-2010, 02:20 AM
encryption's Avatar
encryption encryption is offline
 
Join Date: Sep 2005
Posts: 155
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

anybody?
Reply With Quote
  #3  
Old 06-02-2010, 07:59 AM
DragonBlade's Avatar
DragonBlade DragonBlade is offline
 
Join Date: May 2006
Posts: 189
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I would create a simple plugin and using hooks in the template:

Hook Location: Parse Templates

PHP Code:
$javascript '<script src="djdb/ajax.js"></script>';

$template_hook['headinclude_javascript'] .= $javascript
Reply With Quote
  #4  
Old 06-06-2010, 08:42 PM
encryption's Avatar
encryption encryption is offline
 
Join Date: Sep 2005
Posts: 155
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I don't see a template called headinclude_javascript in the style manager, so can you help me understand what it is? Should it be headinclude instead?

Or, if that is correct, I didn't see a headinclude_javascript hook in the php code. All I saw was the parse_templates hook. Where did the headinclude_javascript come from?

--------------- Added [DATE]1275868704[/DATE] at [TIME]1275868704[/TIME] ---------------

Thank you DragonBlade, I got this to work by using headinclude_javascript. I'm not too sure how I would know that the template hook exists as that name, but it definitely works! Can you help me understand how you chose headinclude_javascript? I need to do another hook into the newthread template, and am equally as lost.

I want to add a new field, so I think it would be at newthread_form_start, but I tried a similar hook to what you suggested for my headinclude but I'm having no luck. Once I get the new field added, I'm going to need to hook into the submit button too so I can process the results when the thread is created. I hate to be dependent on someone every time if I could learn how to do it on my own! Thanks man
Reply With Quote
  #5  
Old 06-09-2010, 10:24 PM
DragonBlade's Avatar
DragonBlade DragonBlade is offline
 
Join Date: May 2006
Posts: 189
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The hooks are within the templates

For example, headinclude_javascript is within headinclude template. And the hook looks like this:
{vb:raw template_hook.headinclude_javascript}
Reply With Quote
  #6  
Old 06-18-2010, 04:06 AM
encryption's Avatar
encryption encryption is offline
 
Join Date: Sep 2005
Posts: 155
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

oooooh. I thought those were calls, not declares. Thanks, this should help!
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 08:50 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.05780 seconds
  • Memory Usage 2,211KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_code
  • (1)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (6)post_thanks_box
  • (6)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (6)post_thanks_postbit_info
  • (6)postbit
  • (6)postbit_onlinestatus
  • (6)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete