Hello,
i'm writing this small & simple "beginners guide" tutorial (was requested by garg @
http://www.vbhackers.com/showthread.php?t=5109).
step #1
Have some hack idea (we'll get back to it later on) :p
step #2
next stage should be to put your forums into "debug mode". for that you have 2 ways to do so:
1. edit your config.php file (under /includes/ dir) to add this line:
You must first be a
registered member to view any code.
2. download the wonderfull hack LiveWire made called VbDebug.
(
vBDebug Options)
then just install it, and under admincp -> options you should have options to turn debug mode on/off.
step #3
We'll create first the product.
go into admincp -> plugins and products - >manage products

below you should see
[Add/Import Product], click it & you'll get this screen:

fill product id, title, version & description.
you can leave blank the product url & check version url fields.
note that product id cannot be changed after it's created.
when done just click on
save & now we have some product to start work with.
step #4
for most hacks, you'll require at some point to store for it some options. that can either be simple as "enabled ? yes/no", or some other customized input that your hack requires.
to add an option, login into admincp, there go into "Vbulletin options -> vbulletin option":

now you should see something like this:

click on it (Add new settings group) & you should see this:

just fill the fields. for product choose the product we've created in the previous step we made.
when done you'll get this:

here you can add/edit all the options you need for this group.
i'll post later more details guide about that if needed, but lets for example add a yes/no option.
so click
add setting and in screen, fill for example like this:

note instead of choosing product "vbulletin" (like in the picture), just choose your product you've created in step #3.
when done hit
save button on bottom, and we've made our first option var for this product.
note that this option/var can be later access from any "hook" (will be explained in next step briefly) via using this kind of code:
You must first be a
registered member to view any code.
repeat this step till after you added all the options (vars) you think your new modification will require.
step #5
hooks system/plugins:
since version 3.5.x jellsoft provided easy way to add code without any need to update core system files.
in order to make your modification work, you'll need to add some php code to it. this where you need to think where do you want it placed.
if for example you want something to be done after every new thread started, then it would be logical to add it into newthread_xxxxx hook.
there is a big list of hooks, you don't have to remember it all - just browse the list.
to add new plugin, just go into admincp -> plugins and products -> plugin manager.
on the bottom you should see link
[Add New Plugin] .
click it. again select your product name.
now under
Hook Location choose the prefered hook location.
write some title for it. you can leave excution order with the default value of "5", unless you have several plugins under same hook and needs something to be done before the other, in that case just number it like the order you want (1 is done first)
and inside
Plugin PHP Code just write your main code (php code).
note that any php code is valid, in addition i'll provide with some common code fragements to help you through coding:
common vbulleltin arrays:
1. you can access the current logged-in userinfo data using
You must first be a
registered member to view any code.
so for example $vbulletin->userinfo[userid] will hold his id, $vbulletin->userinfo[username] his name/nick & so on.
2. another common array usefull is the $foruminfo[] - that holds some information about the current forum you're browsing.
so for example $foruminfo[forumid] will hold the forum id of the forum user is currently browsing (assuming you're inside forum hooks)
common vbulleltin mysql connections:
read from db:
You must first be a
registered member to view any code.
write/update to db:
You must first be a
registered member to view any code.
also check LiveWire datastore tutorial @
Cache System Explanation (datastore) for more information regarding that.
step #6 (optional)
if your modification contains any new templates, then be sure to make those under the admincp -> style and templates -> style manager
expand view for the skin you're using and add template you need.
Note that php vars will be available under the templates that work with the hooks. so if for example you change forumhome template, and you have inside forumhome_xxx hook php var, you will be able to do some conditional check inside the templates.
common vbulletin function to help you with when working under templates - "IF condition":
You must first be a
registered member to view any code.
anyway, this is about all i have to write for this tutorial.
this pretty much cover making new modification from idea till coding stage.
i've tried to point out few common stuff to get you going.
be sure to check other great tutorials posted here & at vb.org.
hope this helps :classic: