PDA

View Full Version : Custom Hooks


Paul M
19 Jun 2005, 17:57
I've not seen this mentioned anywhere yet - but you don't need to edit the hooks_vbulletin.xml file to add custom hooks, you can create your own files in the same manner as cpnav files.

For instance, you could create a file called hooks_custom.xml file (as below) and just drop it in the xml folder.


Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------



They appear at the top of your hooks list in ACP.

This way your custom hooks will not get overwritten each time you upgrade. You could also supply a hooks_<hackname>.xml with custom plugins if required.

Wild-Wing
26 Jan 2006, 02:14
thats a great idea. that will come in handy sometime

Paul M
26 Jan 2006, 02:26
Good grief, I'd forgotten I even posted this ..... :)

Wild-Wing
26 Jan 2006, 03:01
lol. how could you?!

timetunnel
29 Nov 2006, 08:15
Hello.

What does this mean:

Fatal error: Cannot break/continue 1 level...


I've added a custom hook. It's located in a 'foreach' statement.

All I did was move a chunk of code that tested fine to a new plugin and added a custom hook location in its place. I used a custom 'Product' instead of vBulletin. That chunk of code started off with a conditional statement that pertained to a usergroup permission. For the usergroup that didn't meet the condition, that error message mentioned above appeared. The usergroup that met the condition had no error. This error did not exist before the custom hook-to-code replacement.

Any ideas? I love this thread's instructions.

Thanks in advance.


Edit: The answer is found at: http://www.vbulletin.com/forum/showthread.php?t=168513

It basically says that hooks can't be added to 'foreach'...
That thread does make a suggestion, though.

Muellmann
03 Jan 2007, 20:04
Thanks Paul, that's an awesome Info. Now my custom Hooks will be not overwritten if i will make an vb update again ;)
I didn't realize before that custom hooks could be also in a separate File.

Augustino
04 Jan 2007, 01:20
What adventages have the hook over the includes?

I could think than the hooks give more resources usages or not? or these are saved in the datastore?

Danny.VBT
04 Jan 2007, 02:25
What adventages have the hook over the includes?

I could think than the hooks give more resources usages or not? or these are saved in the datastore?

If your modification allows flexibility where Administrators can extend the modification, hooks will allow them to do without editing the files.

coderphp
04 Jan 2007, 12:48
thanx for the info

bchertov
05 Jan 2008, 01:21
thanx for the infoDitto! Where's the "Thanks" button??

bchertov
10 Jan 2008, 20:23
For instance, you could create a file called hooks_custom.xml file (as below) and just drop it in the xml folder.


Thanks again for this tip, Paul M!
Would you please edit your first post to specify the includes\xml folder so it don't have to hunt for it each time? Thanks!

Opserty
11 Jan 2008, 15:31
Thanks again for this tip, Paul M!
Would you please edit your first post to specify the includes\xml folder so it don't have to hunt for it each time? Thanks!Theres only one XML folder in all of vBulletin. :P

jim6763nva
18 Apr 2008, 01:56
How do you know when to use a hook and when not to. I'm very new to vb programming. :)

Jim

Boofo
21 Jun 2008, 09:42
Maybe someone should mention were these hooks are added?

yotsume
15 Aug 2009, 13:26
Ok Paul your my Code God! With this simple xml file I am now able to quickly make my own hooks to call vbblog, experience, or any other mod that was using the $template_hook[profile_left_last] hook and putting importnat tabs lost in that left side garbade pale location on profile pages!

No I just make my custom hook name plce in the the MEMBERSINFO template, change the plugin hook location from: $template_hook[profile_left_last] to my cutom hook and poof! I have complete profile tab control once and for all!

TANK YOU!!!

Illthis
07 Mar 2010, 18:23
i duplicated the forumdisplay.php renamed it into an other filename, made some changes and added some custom code. everthing works fine, but the"gars"-addon, which works on forumdisplay.php dont takes effect in the newcustom.php. seems like the hooks gars using are not working. but all hooks from forumdisplay are copied. so why? do i have to note those hooks anywhere, cant i use hooks twice in different phps, or do i have to initialize these hooks? anybody got an idea? please help

--------------- Added 1267988323 at 1267988323 ---------------

i duplicated the forumdisplay.php renamed it into an other filename, made some changes and added some custom code. everthing works fine, but the"gars"-addon, which works on forumdisplay.php dont takes effect in the newcustom.php. seems like the hooks gars using are not working. but all hooks from forumdisplay are copied. so why? do i have to note those hooks anywhere, cant i use hooks twice in different phps, or do i have to initialize these hooks? anybody got an idea? please help

its because i renamed the "THIS_SCRIPT" parameter:
define('THIS_SCRIPT', 'fdcopy');

why the forumdisplay_ hooks only work when define('THIS_SCRIPT', 'forumdisplay'); is set?

Antivirus
25 Mar 2010, 02:48
why the forumdisplay_ hooks only work when define('THIS_SCRIPT', 'forumdisplay'); is set?

iirc they should work regardless - the hooks are several instances of this within vb's code. especially between some functions_*.php scripts and the datamanagers. I have seen instances where the same hook is located in both scripts.

iDCamps
04 Jan 2011, 16:16
Is this hook approach still valid with vBulletin 4? I gave it a try and I didn't see my custom hook appear in the list, so I'm not sure if I'm doing something wrong or if it just doesn't work anymore.

Thanks.

Thunderbird8
03 Feb 2011, 05:22
Should work. Double check the XML file for syntax (I messed up a bitfields XML by forgetting a > on one tag recently).