Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 09-25-2007, 11:31 PM
Cars2007 Cars2007 is offline
 
Join Date: Jun 2007
Posts: 26
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default How do you add extra per-forum setting fields?

I would like to add a couple of per-forum settings that can be modified in the forum editor. I've already added the fields to the forum table. I know you have to hook forumadmin_edit_form to do this, but I'm not sure how to wire it up so that it actually loads & saves the fields from/to the forum table.

I also don't know how to get the field to show up in the $foruminfo array. I am looking at forumdisplay.php and seeing an array called $foruminfo, but when I print the contents of the array (print_r) I see a whole lot of fields - but not the two I added to the database. I looked up the datamanager documentation, and added this to the forumdata_start hook:
Code:
$this->validfields['thread_title_open_tag'] = array(TYPE_NOTRIM, REQ_NO);
$this->validfields['thread_title_close_tag'] = array(TYPE_NOTRIM, REQ_NO);
Yet, print_r-ing the $foruminfo array reveals the fields are NOT showing up.

I've spent a good deal of time searching for this info, and I've found a few useful pieces of information, but feel like there must be some kind of "starting point" that I'm missing. Is there some kind of walkthrough for doing all this? Otherwise, help on the above would be greatly appreciated.
Reply With Quote
  #2  
Old 09-26-2007, 07:08 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

<a href="https://vborg.vbsupport.ru/showthread.php?t=116370" target="_blank">https://vborg.vbsupport.ru/showthread.php?t=116370</a>
Reply With Quote
  #3  
Old 09-26-2007, 05:30 PM
Cars2007 Cars2007 is offline
 
Join Date: Jun 2007
Posts: 26
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Dismounted View Post
That is a good start, thanks. I am wondering how I might adapt that to store strings rather than bitfields. A lot of the code in there seems specific to bitfields.
Reply With Quote
  #4  
Old 09-27-2007, 08:02 AM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

To add a string setting to the forum options, you would basicly need to do the following:
- Add column to the "forum" table. (add in install code, remove in uninstall code of the product)
- Create plugins to: Add a default (when adding a new forum, this could be skipped), Add the field to the edit page & add the column to the validfields.
- Create the phrases to use when editing the page

For a basic example, see this modification: Direct External Links
You will find all you need in there, without much extra stuff that could confuse things.
Reply With Quote
  #5  
Old 09-27-2007, 11:43 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Also, make sure you prefix the fields you add to the database. (I don't know why Marco didn't mention this, as he's the one that taught me to do that )
Reply With Quote
  #6  
Old 09-27-2007, 01:11 PM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hehe,

Prefixing custom columns (or tables) is a way to make sure that you would not run into conflicts with any future vB version that might use a column with the same name.
Reply With Quote
  #7  
Old 09-28-2007, 12:07 AM
Cars2007 Cars2007 is offline
 
Join Date: Jun 2007
Posts: 26
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks for the help, guys. I was able to figure it out already, but I went ahead and prefixed the columns like you said. Good idea.

I added plugins for forumadmin_edit_form, forumadmin_update_save, forumdata_start, and forumdisplay_complete. Works like a charm. The plugin system in vBulletin is great!
Reply With Quote
Reply


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

Forum Jump


All times are GMT. The time now is 07:49 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.07546 seconds
  • Memory Usage 2,217KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_code
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (7)post_thanks_box
  • (7)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (7)post_thanks_postbit_info
  • (7)postbit
  • (7)postbit_onlinestatus
  • (7)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete