PDA

View Full Version : [HOW TO] Add custom fields to new threads


jaybolt
27 Apr 2006, 21:07
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:

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 <if condition="$show['misc_options']"> and above that add:

<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 :

<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

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

newthread_post_start

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

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


threadfpdata_start

$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
09 Oct 2006, 11:04
can you give me a screen shot of your edit plugin screen

delaen1
20 Feb 2007, 16:18
How do you access it once it's in there?

dfe
01 Apr 2007, 13:16
Is it possible to do this, but then to only have it appear in a single forum, with subforums?

TMS_Hon
15 May 2007, 09:30
i used the hack, but the data is not getting inserted into the db... has anyone used this successfully... help
kamal

sonichero
21 May 2007, 06:55
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
21 Jun 2007, 07:01
Where can I see this in action?

Where can I see this in action?

patrickb
09 Aug 2007, 10:10
Could this also be used to add custom fields to forums?

Thanks

FatalBreeze
19 Aug 2007, 23:51
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
17 Oct 2007, 11:19
great article but its not inserting any data into the database using vb3.6.8 ? any ideas.

Lionel
26 Oct 2007, 23:43
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?

I'd like to know that also..

solution is in threadadmin_update ....

brandondrury
02 Nov 2007, 22:01
great article but its not inserting any data into the database using vb3.6.8 ? any ideas.

Same here.

Brandon

fly
04 Nov 2007, 15:34
Shouldn't you be using 'set' rather than 'setr'? I remember Andreas telling me not to use setr, as it bypasses some vB checks. I'm no genius at the stuff, so please excuse me if I'm wrong.

Jelmertjee
08 Nov 2007, 09:04
it's working fine for me (tested on clean 3.6.8 pl2 install) although you need to do more edits to actually show the $var in the thread, it does get inserted into the database for sure. If it's not working make sure you have used the right table name.. and the same $var everywhere.. Thanks for the article jaybolt.

so, how would you use it in a thread?

change a query in showthread.php and select the var, then put the $var into your showthread template wherever you want it.

Lionel
08 Nov 2007, 09:12
I did not have to do any additional edits on 3.68 patch level 2

Jelmertjee
12 Nov 2007, 19:05
so do you mean the "$var" was automatically added to the thread, without any edits, I guess you would need to change the template at least, and thought you would need to do more programming?!

So did anyone manage to implement this with the ability to edit threads as well? besides just creating them, like this is not very useful, often you just want to make some changes if you spot a mistake somewhere.. at least I do.

wolfe
17 Dec 2007, 17:47
how do i make it so i can edit the fields and update them because currently its updating blank fields

Lott
13 Feb 2008, 11:08
I'm also having difficulties inserting any data into the database using vb3.6.8.

Is there a specific "Hook_Location" that should be used for the plugins. I've tried "admin_index_main1", which was the default and "threaddata_postsave" - neither of which work.

Thanks for your help.

Opserty
13 Feb 2008, 13:46
Is there a specific "Hook_Location" that should be used for the plugins.Did you try the words given in bold above the piece of code?...

(in the original post.)

Lott
14 Feb 2008, 13:08
Did you try the words given in bold above the piece of code?...

(in the original post.)

Oops! - no I used these as the names of the plugin!
It seems obvious when you know how!

I used the bold words now and it works.

Thanks

sstalder
11 Mar 2008, 21:38
If I wanted to make my field editable via edit post do you know what changes need to be made?

sstalder
05 Apr 2008, 21:20
I figured out my question, if someone wants help pm me.

thebigman87
03 Jun 2008, 19:04
I trying to make this work on Vbulletin 3.7.0 and to a degree it's working.

It will Store the new field entry in MySQL, however I am having trouble in the process I need to perform in order to display it in either Threadbit or Postbit. I believe I need to edit forumdisplay and/or showthread in order to this. Can anyone help me on this? I just don't know where to start. Any Help what so ever will be very appreciated.

Medtech
04 Jan 2009, 23:18
would be nice to make a modification out of this that can be installed with chief post.;)

Twilkey
04 Feb 2009, 01:04
FYI, This works on 3.8

0lly
04 Mar 2012, 20:38
Great guide, I have it working fine :)

But, can anyone help me edit it so that the fields can be edited once they have been entered and submitted? Thanks.

Muhammad Rahman
02 Nov 2012, 04:44
VB4 please ...

m7sen
31 Oct 2014, 14:38
hello

how can i Add custom fields to new post
for
vb3.8.8

Lynne
31 Oct 2014, 18:42
hello

how can i Add custom fields to new post
for
vb3.8.8
http://www.vbulletin.org/forum/showthread.php?t=118896&highlight=profile+field
http://www.vbulletin.com/forum/forum/vbulletin-3-8/vbulletin-3-8-questions-problems-and-troubleshooting/vbulletin-quick-tips-and-customizations/219498-how-to-add-a-profile-field-to-the-postbit?214234-How-To-Add-A-Profile-Field-To-The-Postbit

m7sen
01 Nov 2014, 20:55
http://www.vbulletin.org/forum/showthread.php?t=118896&highlight=profile+field
http://www.vbulletin.com/forum/forum/vbulletin-3-8/vbulletin-3-8-questions-problems-and-troubleshooting/vbulletin-quick-tips-and-customizations/219498-how-to-add-a-profile-field-to-the-postbit?214234-How-To-Add-A-Profile-Field-To-The-Postbit

thanks
but what i want is
Add custom fields to new Post Reply in Thread
what i mean is
user what to add new post in whatever Thread
i want to disable message and user must
Writing in the fields that i have added
and show these fields in post

like http://www.vbulletin.org/forum/showthread.php?p=1796575
but what is problem in this mod
the mod add form not like post
i cannt use other mod like disable users to post twice for 24 hours
or this optoin in vbulletin

Subject to the rules and conditions of Management Forum
If not, posts will be always in the queue management approval


Because Easy Forms mod add form not like post

I want to manage the deployment of forms and control over :down: