Go Back   vb.org Archive > vBulletin Article Depository > Read An Article > vBulletin 3 Articles

Reply
 
Thread Tools
[HOW TO] Add custom fields to new threads
jaybolt
Join Date: Jun 2004
Posts: 20

 

UK
Show Printable Version Email this Page Subscription
jaybolt jaybolt is offline 04-26-2006, 10:00 PM

Ok - this is my first submitted 'how to' and is the result of me wanting to add a couple of new fields to my new threads. A quick search on here showed me a couple of people asking the same but no conclusive answers (there were a couple of threads with 'typos') so here is my code as is. It works for me anyway!

1. To add the fields to the thread table in the database:

Go into admincp and down to the bottom. Select Execute SQL Query and then add your fields as follows:

Code:
ALTER TABLE table ADD (
         var VARCHAR(10) not null default ''
)
Where table is the name of your vb thread table (eg vb_thread) and var is the name of the field you are adding.

2. Add the fields to the newthread template in admincp / style manager

Find
Code:
<if condition="$show['misc_options']">
and above that add:

Code:
<div style="padding:$stylevar[formspacer]px">
<div>
<input type="text" class="bginput" size="10" name="var" value="" id="var" tabindex="1" /> $vbphrase[var_name]</div>
Again, var is the name of the field and the same as in the previous SQL Query. You can smarten this up further using the fieldset tags and creating a custom vbphrase for the $vbphrase[your_phrase] part :

Code:
<fieldset class="fieldset">
<legend>$vbphrase[your_phrase]</legend>

above code in here

</fieldset>
3. Go to admincp / add new plug in and add the following three plugins (give them the same name so you recognise them later):

newpost_process

Code:
if ($type == 'thread')
{
    $dataman->setr('var', $post['var']);
}
newthread_post_start

Code:
$vbulletin->input->clean_array_gpc('p', array('var' => TYPE_STR));

$newpost['var'] =& $vbulletin->GPC['var'];
threadfpdata_start

Code:
$this->validfields['var'] = array(TYPE_STR, REQ_NO);
Once again, var is the name of the variable you have been using for your field name above.

I hope this helps - took me a while to get it sorted (and I did find help on here along the way) but this is the completed process.

[EDITED: corrected an inevitable type in the SQL query ]
Reply With Quote
  #2  
Old 10-09-2006, 10:04 AM
ibuddy ibuddy is offline
 
Join Date: Apr 2006
Posts: 46
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

can you give me a screen shot of your edit plugin screen
Reply With Quote
  #3  
Old 02-20-2007, 03:18 PM
delaen1 delaen1 is offline
 
Join Date: Nov 2006
Posts: 38
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

How do you access it once it's in there?
Reply With Quote
  #4  
Old 04-01-2007, 12:16 PM
dfe dfe is offline
 
Join Date: Oct 2006
Posts: 56
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Is it possible to do this, but then to only have it appear in a single forum, with subforums?
Reply With Quote
  #5  
Old 05-15-2007, 08:30 AM
TMS_Hon TMS_Hon is offline
 
Join Date: Apr 2007
Posts: 13
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

i used the hack, but the data is not getting inserted into the db... has anyone used this successfully... help
kamal
Reply With Quote
  #6  
Old 05-21-2007, 05:55 AM
sonichero sonichero is offline
 
Join Date: Jan 2007
Posts: 163
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by dfe View Post
Is it possible to do this, but then to only have it appear in a single forum, with subforums?
Per style only. So, copy your style, put as default for that forum and only make the template edits there.

Thanks BTW.
Reply With Quote
  #7  
Old 06-21-2007, 06:01 AM
SoftDux SoftDux is offline
 
Join Date: May 2007
Location: Johannesburg, South Afric
Posts: 137
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Where can I see this in action?

Where can I see this in action?
Reply With Quote
  #8  
Old 08-09-2007, 09:10 AM
patrickb patrickb is offline
 
Join Date: Jun 2007
Posts: 32
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Could this also be used to add custom fields to forums?

Thanks
Reply With Quote
  #9  
Old 08-19-2007, 10:51 PM
FatalBreeze FatalBreeze is offline
 
Join Date: Apr 2004
Location: Haifa - Israel
Posts: 163
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

that's a great article!
But if i want to edit my newthread? and then change the value of 'var', how do i do it?
Reply With Quote
  #10  
Old 10-17-2007, 10:19 AM
wolfe wolfe is offline
 
Join Date: Jan 2002
Posts: 900
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

great article but its not inserting any data into the database using vb3.6.8 ? any ideas.
Reply With Quote
Reply

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

Forum Jump


All times are GMT. The time now is 07:59 AM.


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.05141 seconds
  • Memory Usage 2,285KB
  • Queries Executed 23 (?)
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
  • (7)bbcode_code
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_article
  • (1)navbar
  • (4)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (10)post_thanks_box
  • (3)post_thanks_box_bit
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (10)post_thanks_postbit_info
  • (9)postbit
  • (10)postbit_onlinestatus
  • (10)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_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
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete