SQL Query: (https://www.vbulletin.com/docs/html/maintenance_query" target="new">how to run queries)
ALTER TABLE forum ADD (
var smallint(3) unsigned not null default ''
)
PHP Code:
print_input_row($vbphrase['your_phrase'], 'forum[var]', $forum['var']);
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
PHP Code:
$this->validfields['var'] = array(TYPE_STR, REQ_NO);
Notice the var again? That's telling it which row to add it to.
I want to add more then just one option!
Then you will need to repeat this tutorial for each option you would like to have.
Now that you have saved both hooks. You can now use the following code in any of your hooks.
PHP Code:
if ($foruminfo['var'] == 1)
{
// your code here
}
In templates you would use
HTML Code:
<if condition="$foruminfo['var'] == 1">
<!-- Your Code Here -->
</if>
Big Tip:
If you have 2 or more options being added to the forums, you can place all the code in each hook. For example:
Hookname: forumadmin_edit_form
Code:
PHP Code:
print_input_row($vbphrase['your_phrase'], 'forum[var1]', $forum['var1']);
print_input_row($vbphrase['your_phrase'], 'forum[var2]', $forum['var2']);
Hook Name: forumdata_start
Code:
PHP Code:
$this->validfields['var1'] = array(TYPE_STR, REQ_NO);
$this->validfields['var2'] = array(TYPE_STR, REQ_NO);
You don't have to keep creating new hooks for more options for the same hack. Is better to only create hooks for separate hacks.
Custom Fields
The following fields can also be used.
PHP Code:
// This will print an input form. Good for titles, and such.
print_input_row($vbphrase['your_phrase'], 'forum[var]', $forum['var']);
PHP Code:
//This will print a yes or no row
print_yes_no_row($vbphrase['your_phrase'], 'forum[var]', $forum['var']);
PHP Code:
//This will print a text area. Good for descriptions
print_textarea_row($vbphrase['your_phrase'], 'forum[var]', $forum['var']);
There are more that can be used. When I have some more time I will add them all here.
This tutorial was created for a member who needed to know how to do this exact thing, so I figured I would teach everyone.