vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Any simple example of how to use a hook? (https://vborg.vbsupport.ru/showthread.php?t=172443)

yellowpinky 03-08-2008 02:17 PM

Any simple example of how to use a hook?
 
I'd like to replace a hook statement with some custom code.
I presume that is possible??

Example: in Template postbit

there is a line:
Code:

$template_hook[postbit_start]
What I would like is to do a print "ZZZZZZZZZZZZZZZZZ";
right where where that line is.

What are the steps needed to make this happen?
like do I create a file called postbit_start somewhere?

Thank you.

shovel 03-08-2008 03:09 PM

$template_hook[postbit_start] is a variable for the comment within the HTML when the postbit template is rendered. If you would like to print something dynamically within that template, follow the following example.

Postbit Template:
Code:

$template_hook[postbit_start]
$myPostbitAddition

Goto...
AdminCP -> (left menu) Plugins & Products -> Plugin Manager

Fill out the form with the following information...

Product: vBulletin
Hook Location: postbit_display_complete
Title: My Postbit Addition
Execution Order: 5 (default)
Plugin PHP Code:
PHP Code:

$myPostbitAddition 'ZZZZZZZZZZZZZZZZZ'

Plugin is Active: Yes

Click "Save" and continue on to your forums and view the Postbit within a thread. You should see your variable printed within each Postbit render.

Hope this helps!

- shovel

Dismounted 03-09-2008 02:30 AM

Errr, shovel, why would you do that when you can USE the hook? A bit pointless, IMO.

Have a read of: https://vborg.vbsupport.ru/showthread.php?t=147447

shovel 03-09-2008 01:26 PM

As far as I understood he wanted to insert a variable. Either way, I can see your point Dismounted. I tend to over think at times, it happens haha.

yellowpinky 03-12-2008 11:38 AM

Code:

$template_hook[postbit_start]
So this line is in there for no reason other than a comment?

how did you make the jump to the hook: postbit_display_complete
I mean, what documentation would say, to use postbit_start
add a hook for, postbit_display_complete?

I'm so clueless here.


The other post: https://vborg.vbsupport.ru/showthread.php?t=147447
is a listing of hooks, not any instructions how how to use them. How do you use these things, called hooks?

It includes: $template_hook[postbit_start]
But why, if it is just a comment, and therefore unusable(?)
It makes no mention of postbit_display_complete, the one you presumably should use.

Dismounted 03-13-2008 05:36 AM

Code:

$template_hook[postbit_start]
It is a PHP variable you can use to insert data through plugins. You add plugins through the Admin CP > Plugins & Products > Add New Plugin.


All times are GMT. The time now is 04:34 AM.

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.01695 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
  • (4)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