View Full Version : add a field to the thread table
pyro.699
10-13-2005, 10:13 PM
i would like to know how to add a field to the thread table... lol, as the title says...
i would also like to know, how to inflict that on my postbit!
Andreas
10-13-2005, 10:15 PM
ALTER TABLE thread ADD foobar VARCHAR(20) NOT NULL DEFAULT ''
pyro.699
10-13-2005, 10:36 PM
what? lol
that makes the least of sence.. i know how 2 run the query.. ikd what its for, what files to edit...
(its for an rpg script, the user decideds what the requirements are for the rpg he wants to make, then based on his options, it adds them to the postbit...)
Andreas
10-13-2005, 10:46 PM
Your question was
i would like to know how to add a field to the thread table
I've answered it. But it seems like you wanted to know smth. else.
So please state exactly what ou want to know.
pyro.699
10-13-2005, 11:04 PM
Ok, (=D'')=D < Kirby with boxing gloves ^^
I would like to edit the appearance of forum id #26. Ifs goign to be made to fit a customized rpg script.
CURRENT OPTIONS:
look at my post ^^
Da Link (http://www.frozencreations.net/forum/showthread.php?t=39)
FEATURES:
User can choose what options he/she wants(in the thread posting area) (options are in link)
Depending on what the user has selected, thats what is displayed in the postbit
WHAT I HAVE DONE SO FAR:
added all current tables
added postbits
created the php file
made the querys
lme know if you need any more info
Guest190829
10-13-2005, 11:32 PM
Kirby's sql query is correct
ALTER TABLE thread ADD foobar VARCHAR(20) NOT NULL DEFAULT ''
foobar is the new field name.
If you need to get that info in a postbit then you have to use a select query to get the info.
But, why not just use custom profile fields?
pyro.699
10-13-2005, 11:49 PM
...
im more asking for a bit of help designing the script... not a request, like iming information i dont really like having people give me the scripts, id like to help build them.
I know that kirbys script is correct, im also asking, what else do i add?
Andreas
10-13-2005, 11:50 PM
If you need to get that info in a postbit then you have to use a select query to get the info.
$threadinfo['foobar'], no need for a query :)
Guest190829
10-13-2005, 11:55 PM
$threadinfo['foobar'], no need for a query :)
Learn something new everyday. :D
pyro.699
10-14-2005, 12:06 AM
ok, i need a bit mroe help... i need ot know how to tel the script to read what the user has selected...
-----
Help from AJ
-----
what i want is to be ale to specify a few things when i go to amke a post, then i want the postbit to be able to read those choices...
[22:01] Aj - It's That Time of Year Again!: just explain what you did to me
[22:01] Aj - It's That Time of Year Again!: when you make a thread you want to specify some things
[22:01] Aj - It's That Time of Year Again!: thast the main part because you have to add the fields to the datamanager, and learn how to use it
---------------
---NEW POST---
---------------
- Alter table thread to add your fields
- Adjust Template newthread
- Creae a Plugin for threadpfdata_start to add the fields to its validfields
- Create a Plugin for newthread_post_start to set the fields in $post to the cleaned form data
- Create a Plugin for newpost_process to set the values from $post to the Datamanager
This method does not cause additional queries
AJ helped me find this post, can you elaberate a bit more on this? more to my specifications?
like, do i add
if (thread id code == 26)
{
};
to every plugin? or what...
and how do i amke the postbit read what the user selected...
Thanks
pyro.699
10-16-2005, 12:19 AM
Ok, i really need help on this! im still desiging it, adn im stumped! please help me!
Adrian Schneider
10-19-2005, 12:01 AM
-Add field to database
See KirbyDE's post above (best done with install code though)
-Add the form element to newthread...
Edit the newthread template and add your field.
-Clean data, place into GPC array:
Hook: newthread_post_start
$vbulletin->input->clean_array_gpc('p', array(
'fieldname' => TYPE_UINT
));
$newpost['fieldname'] = $vbulletin->GPC['fieldname'];
-Set datamanager value:
Hook: newpost_process
if ($type == 'thread')
{
$dataman->setr('fieldname', $post['fieldname']);
}
-Validate the field for the datamanger (if you don't you get an error):
Hook: threadfpdata_start
$this->validfields['fieldname'] = array(TYPE_UINT, REQ_NO);
-Replace every occurance of "fieldname" with your form element name (preferably have it the same as the database field you make), and also replace every occurance of TYPE_UINT with how you want to clean your data.
pyro.699
10-19-2005, 12:07 AM
ok, thanks, that really explains some things!
i have one question, its for forum id #26 only! that one, and that one only, how do i rig it up do diaply the information for that forum only!
and, how do i get that border around the text like
---Text-------------
|..........................|
|..........................|
|..........................|
---------------------
pyro.699
10-20-2005, 06:24 PM
if ($type == 'thread')
{
$dataman->setr('fieldname', $post['fieldname']);
}
will that add this to the post? bgecause, i want it to add the crap to the postbit
AlexSFBay
11-01-2005, 06:34 AM
-Add field to database
See KirbyDE's post above (best done with install code though)
-Add the form element to newthread...
Edit the newthread template and add your field.
-Clean data, place into GPC array:
Hook: newthread_post_start
$vbulletin->input->clean_array_gpc('p', array(
'fieldname' => TYPE_UINT
));
$newpost['fieldname'] = $vbulletin->GPC['fieldname'];
-Set datamanager value:
Hook: newpost_process
if ($type == 'thread')
{
$dataman->setr('fieldname', $post['fieldname']);
}
-Validate the field for the datamanger (if you don't you get an error):
Hook: threadfpdata_start
$this->validfields['fieldname'] = array(TYPE_UINT, REQ_NO);
-Replace every occurance of "fieldname" with your form element name (preferably have it the same as the database field you make), and also replace every occurance of TYPE_UINT with how you want to clean your data.
Hi SirAdrian,
I did find the "newthread" template so I can add the new form field, but for the life of me I couldn't find:
newthread_post_start
newpost_process
threadfpdata_start
I'm currently running vB version 3.0.7. Could that be why? Anyone else successfully get this to work or know of any other helpful links?
Thanks in advance for your help!
krela
11-12-2005, 09:23 AM
Hihi!
Okay I got all the above working just fine, and it's great... however there's one problem with this... I can't edit any of the new fields once they're posted. Even if I add them to the editpost template it doesn't populate or update the fields.
I know I need to add the fields into one of the editpost hooks , but which hooks would I use and what would I update them with?
I guess I need a hook or two to add in the new fields to the edit post code, and a a hook to get the data to populate the edit form with the current data?
Any help would be massively appreciated!
Cheers,
Ben.
pyro.699
11-12-2005, 02:39 PM
Well, i could help you, i dont really like using the posting method, if u ahve a im program (or irc) id love to chat with ya
krela
11-12-2005, 03:03 PM
Check your private messages! :)
delaen1
02-23-2007, 04:28 PM
I've got this all working and I can use it just fine from the SHOWTHREAD template (with $threadinfo[myvar], but could anyone tell me how I'd go about using it in the threadbit template?
It doesn't seem to be available there.
Thanks.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2024, vBulletin Solutions Inc.