vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3 Articles (https://vborg.vbsupport.ru/forumdisplay.php?f=187)
-   -   [HOW TO] Add custom fields to new threads (https://vborg.vbsupport.ru/showthread.php?t=114249)

jaybolt 04-26-2006 10:00 PM

[HOW TO] Add custom fields to new threads
 
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 :) ]

ibuddy 10-09-2006 10:04 AM

can you give me a screen shot of your edit plugin screen

delaen1 02-20-2007 03:18 PM

How do you access it once it's in there?

dfe 04-01-2007 12:16 PM

Is it possible to do this, but then to only have it appear in a single forum, with subforums?

TMS_Hon 05-15-2007 08:30 AM

i used the hack, but the data is not getting inserted into the db... has anyone used this successfully... help
kamal

sonichero 05-21-2007 05:55 AM

Quote:

Originally Posted by dfe (Post 1217441)
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.

SoftDux 06-21-2007 06:01 AM

Where can I see this in action?

Where can I see this in action?

patrickb 08-09-2007 09:10 AM

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

Thanks

FatalBreeze 08-19-2007 10:51 PM

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?

wolfe 10-17-2007 10:19 AM

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


All times are GMT. The time now is 08:35 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.01155 seconds
  • Memory Usage 1,736KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (7)bbcode_code_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete