Follow vBSEO on Twitter
vBulletin Modifications
  • Forums
  • Add-Ons
  • Template Modifications
  • Styles
  • Graphics
  • Tutorials
  • Support Center
  • Register
  • vBulletin SEO

Member Log In

Site Navigation

  • Register
  • Members List
  • Social Groups
  • Search
  • Today's Posts
  • Mark Forums Read

Latest Modifications

  • [vB 3.8.4] THX - Hack for VB. 3.8.4
    By: bluedog
  • [vB 3.8.4] Cyb - Chatbox V.2.3
    By: bluedog
  • [vB 4.0.x] PHPKD - Advanced Quick...
    By: PHPKD
  • [vB 3.6.x] StopSpam
    By: flappi282
  • [vB 3.8.x] vBulletin Chat Addon for...
    By: 123flashchat

Latest Template Mods

  • [vB 4.0.x] Remove My Profile Link...
    By: Ak Worm
  • [vB 3.8.x] Images DownloadBox...
    By: cRs!MP
  • [vB 3.8.x] Adviertise Mod On Forum...
    By: MG4
  • [vB 3.8.4] Images PassWordBox...
    By: cRs!MP
  • [vB 3.8.4] Footer Follow Ups
    By: Ak Worm

Latest Styles

  • [vB 4.0.x] 4.0.3 - VB4STYLE-TWEETA...
    By: Belon
  • [vB 4.0.x] [4.0.3] vbdesigns.de...
    By: Belon
  • [vB 3.8.4] CompletevB - Skylight
    By: DreadKnight
  • [vB 3.8.3] [vB 3.8.4] Barcelona...
    By: hoiquantinhoc.com
  • [vB 3.8.3] Natures Walk by vBSkin...
    By: Chri5

Latest Graphics

  • [vB ] [anim.]Team Ranks
    By: cRs!MP
  • [vB ] Abstract Circles (3...
    By: cRs!MP
  • [vB ] PlayStation Rank Images
    By: cRs!MP
  • [vB 3.6.12] Heavy Stroked Button...
    By: Shelley
  • [vB ] Minature Ranks.
    By: Shelley
vBulletin Modifications » General vBulletin Section » vBulletin Modification Tutorials » [How To] Add Options per forum
Reply
Page 1 of 2 1 2 >

 

  • Thread Tools
Old 03-28-2006, 06:43 AM   #1
Ken Iovino
vBulletin Guru

Ken Iovino's Avatar

Activity Longevity
0/20 20/20
Today Posts
0/3 sssss2695
Location: Miami, Florida
Age: 27
Ken Iovino is on a distinguished road
Status: Offline 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:
Code:
ALTER TABLE forum ADD (
        var smallint(3) unsigned not null default ''
)
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:
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. :p
Ken Iovino / Escalate Media
Reply With Quote
Old 03-30-2006, 07:54 PM   #2
Arnoud
vBulletin Guru

Arnoud's Avatar

Activity Longevity
0/20 18/20
Today Posts
0/3 sssss3129
Location: Europe, Flanders
Arnoud is on a distinguished road
Send a message via MSN to Arnoud Send a message via Yahoo to Arnoud
Status: Offline Default
Nice guide. Very useful for comparing the changes of vB 3.0.x to 3.5 .
Reply With Quote
Old 03-30-2006, 10:37 PM   #3
Idan
Coder
Idan's Avatar

Activity Longevity
0/20 18/20
Today Posts
0/3 sssss1484
Location: Israel
Age: 29
Idan is on a distinguished road
Status: Offline Default
another GREAT valuable tutorial guide, as always.
nice work m8
Regards,
Idan.

* Support will only be given via forums !
* If this post solved/aided your problem, please click "mark as aid" / "mark as solution" as explained in here
Reply With Quote
Old 05-10-2006, 08:26 AM   #4
derf
vB Newbie

Activity Longevity
0/20 18/20
Today Posts
0/3 ssssssss9
derf is on a distinguished road
Status: Offline Default
Nice post and easy tut to get a fast grip of coding for 3.5
Thanks a'lot
Reply With Quote
Old 07-22-2006, 07:52 AM   #5
mohammed
vB Newbie

Activity Longevity
0/20 14/20
Today Posts
0/3 sssssss48
mohammed is on a distinguished road
Status: Offline Default
thanks livewire
Reply With Quote
Old 07-26-2006, 02:11 AM   #6
HDRebel88
vB User

HDRebel88's Avatar

Activity Longevity
0/20 13/20
Today Posts
0/3 sssssss98
Location: New Jersey, U.S.A.
Age: 21
HDRebel88 is on a distinguished road
Status: Offline 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?
Reply With Quote
Old 08-04-2006, 08:13 PM   #7
Nick R
vBulletin Guru

Nick R's Avatar

Activity Longevity
0/20 14/20
Today Posts
0/3 sssss4450
Location: Cyberspace, UK
Age: 30
Nick R is on a distinguished road
Send a message via MSN to Nick R Send a message via Yahoo to Nick R
Status: Offline Default
Coding the ACP is the hardest aspect of vB due to the way it works and bugger all for custom coding.
Reply With Quote
Old 08-09-2006, 02:37 AM   #8
HDRebel88
vB User

HDRebel88's Avatar

Activity Longevity
0/20 13/20
Today Posts
0/3 sssssss98
Location: New Jersey, U.S.A.
Age: 21
HDRebel88 is on a distinguished road
Status: Offline 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 10:56 AM.
Reply With Quote
Old 09-23-2006, 02:10 PM   #9
Adrian
vB Newbie

Adrian's Avatar

Activity Longevity
0/20 13/20
Today Posts
0/3 ssssssss3
Location: South Yorkshire, UK
Adrian is on a distinguished road
Send a message via MSN to Adrian Send a message via Skype™ to Adrian
Status: Offline Default
Wow, thanks.

Nice tutorial LiveWire,
Deffinately helped me!

Adrian
Reply With Quote
Old 11-28-2006, 05:59 PM   #10
ninjamaster
vB User

ninjamaster's Avatar

Activity Longevity
0/20 12/20
Today Posts
0/3 sssssss71
ninjamaster is on a distinguished road
Status: Offline Default
thanks for the tut nice work hope to see more
Reply With Quote

Reply
Page 1 of 2 1 2 >

« Photoshop - Save for Web | [How to] Add navigation groups to your admincp left panel »

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

 
Thread Tools
Show Printable Version Show Printable Version
Email this Page Email this Page

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

Forum Rules

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



All times are GMT. The time now is 05:18 AM.

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Transverse Styles
  • Top
  • Archive
  • vBSEO
  • Contact Us
LinkBack
LinkBack URL LinkBack URL
About LinkBacks About LinkBacks
Bookmark & Share
Digg this Thread! Digg this Thread!
Add Thread to del.icio.us Add Thread to del.icio.us
Bookmark in Technorati Bookmark in Technorati
Furl this Thread! Furl this Thread!