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.

Lionel 10-26-2007 10:43 PM

Quote:

Originally Posted by FatalBreeze (Post 1321264)
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 11-02-2007 09:01 PM

Quote:

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

Brandon

fly 11-04-2007 02:34 PM

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 11-08-2007 08:04 AM

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 11-08-2007 08:12 AM

I did not have to do any additional edits on 3.68 patch level 2

Jelmertjee 11-12-2007 06:05 PM

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 12-17-2007 04:47 PM

how do i make it so i can edit the fields and update them because currently its updating blank fields

Lott 02-13-2008 10:08 AM

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 02-13-2008 12:46 PM

Quote:

Originally Posted by Lott (Post 1442064)
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 02-14-2008 12:08 PM

Quote:

Originally Posted by Opserty (Post 1442144)
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 03-11-2008 08:38 PM

If I wanted to make my field editable via edit post do you know what changes need to be made?

sstalder 04-05-2008 08:20 PM

I figured out my question, if someone wants help pm me.

thebigman87 06-03-2008 06:04 PM

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 01-04-2009 10:18 PM

would be nice to make a modification out of this that can be installed with chief post.;)

Twilkey 02-04-2009 12:04 AM

FYI, This works on 3.8

0lly 03-04-2012 08:38 PM

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 11-02-2012 04:44 AM

VB4 please ...

m7sen 10-31-2014 01:38 PM

hello

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

Lynne 10-31-2014 05:42 PM

Quote:

Originally Posted by m7sen (Post 2520760)
hello

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

https://vborg.vbsupport.ru/showthrea...=profile+field
http://www.vbulletin.com/forum/forum...To-The-Postbit

m7sen 11-01-2014 07:55 PM

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 https://vborg.vbsupport.ru/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
PHP Code:

Subject to the rules and conditions of Management Forum 
If notposts 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:


All times are GMT. The time now is 02:05 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.01423 seconds
  • Memory Usage 1,782KB
  • 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_php_printable
  • (7)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (30)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
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete