vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   Hook to header or headinclude (https://vborg.vbsupport.ru/showthread.php?t=243174)

encryption 05-23-2010 09:52 PM

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!

encryption 06-02-2010 02:20 AM

anybody? :confused:

DragonBlade 06-02-2010 07:59 AM

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


encryption 06-06-2010 08:42 PM

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

DragonBlade 06-09-2010 10:24 PM

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}

encryption 06-18-2010 04:06 AM

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


All times are GMT. The time now is 02:31 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.01192 seconds
  • Memory Usage 1,724KB
  • 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
  • (1)bbcode_code_printable
  • (1)bbcode_php_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