What this is
This guide will teach you to use the hooks system to add options to your admincp/forum.php page. One finished, you will be able to add new options to your forum with just a few lines of code.
Don't understand?
Ever wanted to turn something on, but only in one of your forums? For example, lets say you want to execute code, but only in forum I.D. 2, 16, and 45.
Lets begin!
In this tutorial we will assume that you want a yes or no option; in order to enable/disable some code. In order to do that we first need to create a new row in the database. This will hold the information of which forums will be enabled/disabled. Always remember that '1' is considered as on, or enabled. And that '0' is considered off, or disabled.
Please make sure this is all done on a test forum!
We have to store the data!
Run this SQL Query:
[sql]
ALTER TABLE forum ADD (
var smallint(3) unsigned not null default ''
)
[/sql]
Var = The name of the row in the database. This should be a name that will describe your system in one word. For example. In my vB Category Icons hack. This row is named 'forumhomeicon'
Now that we have added our new row named 'var'. We now have to add the on/off option in the forums manager area of the admin control panel.
Add the option in the ACP
To add this new option in the ACP we need to create a new hook and add some code to that hook.
The hook name should be: forumadmin_edit_form
And the code should be:
Notice the 'var'? Remember, that's the row name!
That will actually add the yes/no row to all your forums in the admincp. So when you click on the save button, it will add your selection to the database.
But how does it know which row to add it to? Glad you asked.
You have to create one more hook!
The hook name should be: forumdata_start
And the code to add there is the following
When i said incorrect, I meant not to your coding standards.
Jeez. Not mine... Jelsoft's.
Quote:
Wort Case scenario: Your Hack uses the next available Bit in forumoptions for "Show Quick Stats for this Forum".
Now the next vBulletin Version comes and redifines this Bit to "Prune this Forum every 24 hours".
Now all users of this Hack have the Bit set ...
The hack was not tested on the new version therefore it should not be installed.
Quote:
Well, what does adding a custom field do?
It adds a record to Table profilefield and alters table userfield to have a new MEDIUMTEXT columd fieldxx.
This is just an easy-to-use frontend to alter the Database, so where is the difference?
Difference is the errors on the user side.
Quote:
Keeping the Product Manager in mind, such DB alterations can be done easily, without the User having to know anything about running queries.
That's true. I still have to get used to the existence of that manager.
Oh, there is an array called $vbulletin->bf_misc_forumoptions, but I cannot find out how is it populated.
The hack was not tested on the new version therefore it should not be installed.
You don't seem to see the Problem:
The Hack was installed on the previous Version, which means the Bit is currently set.
No matter if the Users reinstalls it on the new Version (without verified compatiablilty or not), the Bit is still set.[/QUOTE]
Quote:
Oh, there is an array called $vbulletin->bf_misc_forumoptions, but I cannot find out how is it populated.
The Hack was installed on the previous Version, which means the Bit is currently set.
No matter if the Users reinstalls it on the new Version (without verified compatiablilty or not), the Bit is still set.
[/QUOTE]
Ahhh... Crap. Yes, you are right. Solution:
Upon upgrade, let upgrade.php remove all the new bits from the data storage.
No, it would mean Jelsoft taking the measures to avoid the possible negative outside influence of any previously installed hackware. :P
Would you please change the thread's title and prefix it with [How-To]? That way all the how to threads stand out Thx.
Jelsoft do not support modified boards - This would come under such a heading, therefore since you do not need to alter the bitfields with a standard installation of vBulletin, unless they alter their own bitfields in an upgrade they should not have to cater for such an scenario