View Full Version : Regarding hooks
veenuisthebest
09-10-2008, 11:13 AM
hii..
can anyone tell me how do we identify hook from the template.
like we have $template_hook[profile_ministats_list] in memberinfo_block_ministats template. Now, I don't see any hook with that name in the hooks list. So, how to code at that part ?
Guest190829
09-10-2008, 06:18 PM
Template hooks at PHP hooks are different...you need to use a PHP hook to hook template code into a template hook. (If that makes sense.)
So, if I wanted to add some display code to the postbit without a template edit, I'd add a plugin to the postbit_display_complete hook (I believe off the top of my head.) and utilize one of the template hooks in the postbit.
I'll post some specific code if no one else does by the time I get back to my dorm.
Lynne
09-10-2008, 06:37 PM
These are two plugin examples from this thread - Template Hook (https://vborg.vbsupport.ru/showthread.php?t=147447)
Using the $template_hook['navbar_buttons_left'] to insert stuff directly using html:
$template_hook['navbar_buttons_left'] .= '<td class="vbmenu_control"><a href="index.php">Home Page</a></td>'; Using the $template_hook[navbar_buttons_left] to insert stuff from the 'new_navbar_item' template:
eval('$template_hook[navbar_buttons_left] .= "' . fetch_template('new_navbar_item') . '";');
veenuisthebest
09-11-2008, 05:19 AM
thank you so much lynne !
btw, do I always have to use global_start hook to use template hooks ? for eg. for $template_hook[profile_ministats_list] in memberinfo_block_ministats template, which php hook should I use ?
Dismounted
09-11-2008, 05:56 AM
You don't want to run your code on every page load unless it will need to be used every page load.
Choose a hook that will always be run when the template you are hooking into is running as well.
veenuisthebest
09-11-2008, 06:23 AM
yes I do not want to run my code on every page load.
that is what I asked:-
"for $template_hook[profile_ministats_list] in memberinfo_block_ministats template, which php hook should I use ?"
Dismounted
09-11-2008, 06:59 AM
Why don't you have a look yourself? ;)
veenuisthebest
09-11-2008, 07:16 AM
oh sir that is what i asked in my first post !!
"how do we identify hook from the template?"
I DID tried to check it from the hooks list but I do not found any for $template_hook[profile_ministats_list]
Opserty
09-11-2008, 09:12 AM
First do a "Search in Templates" find out which template uses that template hook.
Look at the name of the hook it tells you.
PROFILE - This means the members profile page so member.php ?
MINISTAT - Mini-statistics block
LIST - The list section
vBulletin make sure they name each one to give as much information. So know you know what file it will probably execute in you can choose a hook from there. ;)
veenuisthebest
09-11-2008, 06:06 PM
thanks opserty !
Now, I find 5 hooks in member.php:-
member_start
member_start_fetch_user
member_execute_start
member_build_blocks_start
member_complete
I tried the following code at all the above 5 hooks but none of them show the output in the Mini Statistics Box.
$template_hook[profile_ministats_list] .= '<dt class="shade">Star Sign</dt>
<dd>Virgo</dd>';
Opserty
09-11-2008, 08:52 PM
Does:
$template_hook['profile_ministats_list'] .= '<dt class="shade">Star Sign</dt><dd>Virgo</dd>';
Work?
veenuisthebest
09-12-2008, 09:25 AM
tried the above code on all the 5 hooks, it doesn't work as well.
Lynne
09-12-2008, 02:33 PM
Are you making sure to turn the hook ON? It's off by default. Try throwing it into the global_start just for kicks to see if that works. Also, are you sure that hook is in your template and didn't get accidentally deleted?
veenuisthebest
09-12-2008, 04:58 PM
oh yes lynne, i am sure the hook is ON, and that template hook resides in the template.
no, it still doesn't work at global_start. Can you please check if it works for you, its just a small code.
Thanks
Lynne
09-12-2008, 06:30 PM
Oh boy... see this - https://vborg.vbsupport.ru/showthread.php?t=178619&highlight=%24template_hook - you need to add $template_hook to the globals.
veenuisthebest
09-12-2008, 07:27 PM
oh woww... it works now, great !!!!! thank you so so much lynne.
so as said by mrpaint, its a bug right ?
mindhunter77
09-12-2008, 07:31 PM
Oh boy... see this - https://vborg.vbsupport.ru/showthread.php?t=178619&highlight=%24template_hook - you need to add $template_hook to the globals.
Why if i'm logged in I can't see that link =(
Lynne
09-12-2008, 07:42 PM
oh woww... it works now, great !!!!! thank you so so much lynne.
so as said by mrpaint, its a bug right ?
Yes, I think it may be a bug. I'm also not sure it's been reported if it's still there (what version are you running? I was testing on 3.7.0 beta 2 which is what my test board is running.)
veenuisthebest
09-13-2008, 04:29 AM
Why if i'm logged in I can't see that link =(
Its because that thread resides in a hidden forum that is visible to those who have over 100 installs of their mods. But anyway, I'll share the solution here:-
Look at file ./includes/class_profileblock.php, line 237
Find:-
global $show, $vbphrase, $stylevar, $vbcollapse;
Modify:-
global $show, $vbphrase, $stylevar, $vbcollapse, $template_hook;
Yes, I think it may be a bug. I'm also not sure it's been reported if it's still there (what version are you running? I was testing on 3.7.0 beta 2 which is what my test board is running.)
I am running latest 3.7.3 pl1.
okk.. its already been reported and they provide a solution for it.
http://www.vbulletin.com/forum/project.php?issueid=25495
so the final solution that works for me is to put my code in member_profileblock_fetch_unwrapped hook.
Thanks
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.