vBulletin Modifications Follow us on twitter

[How To] Add Options per forum

Hey there! Welcome to vBHackers.com! A community for vBulletin enthusiasts to share modifications and offer each other support.
vBHackers Updates:

Go Back   vBulletin Modifications > General vBulletin Section > General vBulletin Support > vBulletin Modification Tutorials

Reply
 
LinkBack Thread Tools
Old 03-28-2006, 03:43 AM   #1
vBulletin Guru
Ken Iovino's Avatar
Join Date: Mar 2004
Real Name: Ken Iovino
Location: Miami, Florida
Ken Iovino is on a distinguished road

Default [How To] Add Options per forum

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:
You must first be a registered member to view any code.
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:
You must first be a registered member to view any code.
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
You must first be a registered member to view any code.
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.

You must first be a registered member to view any code.
In templates you would use

You must first be a registered member to view any code.
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:
You must first be a registered member to view any code.
Hook Name: forumdata_start
Code:
You must first be a registered member to view any code.
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.
You must first be a registered member to view any code.
You must first be a registered member to view any code.
You must first be a registered member to view any code.
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. :p
__________________
Ken Iovino / Escalate Media




Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
Old 03-30-2006, 04:54 PM   #2
vBulletin Guru
Arnoud's Avatar
Join Date: Nov 2004
Real Name: Arnoud Kuipers
Location: Europe, Flanders
Arnoud is on a distinguished road

Default

Nice guide. Very useful for comparing the changes of vB 3.0.x to 3.5 ;).




Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 03-30-2006, 07:37 PM   #3
Idan
Coder
Idan's Avatar
Join Date: Feb 2005
Real Name: Idan B.
Location: Israel
Idan is on a distinguished road

Default

another GREAT valuable tutorial guide, as always.
nice work m8
__________________
vBHackers.com - vBulletin Modification Community




Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 05-10-2006, 05:26 AM   #4
Junior Member
Join Date: Jan 2005
derf is on a distinguished road

Default

Nice post and easy tut to get a fast grip of coding for 3.5
Thanks a'lot




Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 07-22-2006, 04:52 AM   #5
vB Newbie
Join Date: Jun 2006
mohammed is on a distinguished road

Default

thanks livewire




Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 07-25-2006, 11:11 PM   #6
vB User
HDRebel88's Avatar
Join Date: Jul 2006
Location: New Jersey, U.S.A.
HDRebel88 is on a distinguished road

Default

Thanks, very useful..... but how would I go about creating a completely seperate page in the admincp so I can control my featured artist set-up? is it another php page and then what?




Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 08-04-2006, 05:13 PM   #7
vBulletin Guru
Nick R's Avatar
Join Date: May 2006
Real Name: Nick
Location: Cyberspace, UK
Nick R is on a distinguished road

Default

Coding the ACP is the hardest aspect of vB due to the way it works and bugger all for custom coding.




Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 08-08-2006, 11:37 PM   #8
vB User
HDRebel88's Avatar
Join Date: Jul 2006
Location: New Jersey, U.S.A.
HDRebel88 is on a distinguished road

Default

Instead of running a SQL query could I use:

$db->query_write("ALTER TABLE " "forum ADD
(Variable smallint(3) unsigned not null default ''
)");

in the install section for a products install code?

what would be the uninstall code for that?

$db->query("DROP TABLE `" "Variable`;");

Last edited by HDRebel88; 08-09-2006 at 07:56 AM..




Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 09-23-2006, 11:10 AM   #9
vB Modder ;)
Adrian's Avatar
Join Date: Sep 2006
Real Name: Adrian
Location: South Yorkshire, UK
Adrian is on a distinguished road

Default

Wow, thanks.

Nice tutorial LiveWire,
Deffinately helped me!

Adrian




Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 11-28-2006, 02:59 PM   #10
vB User
ninjamaster's Avatar
Join Date: Nov 2006
ninjamaster is on a distinguished road

Default

thanks for the tut nice work hope to see more ;)




Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
[How To] Run a Query Ken Iovino vBulletin Modification Tutorials 9 07-30-2008 02:29 AM
[How To] Run a vb page outside of the forum directory Junior vBulletin Modification Tutorials 7 01-10-2007 07:05 PM
How i add google ad to forum index? hkboi Off Topic 2 03-22-2005 07:36 AM


All times are GMT -3. The time now is 06:19 PM.

Powered by vBulletin® Version 3.8.3
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.3.0 ©2009, Crawlability, Inc. (Patent Pending)