The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Insert custom thread field into the database
Hi there,
I have a good understanding of the vB templating system and PHP knowledge but I am having trouble working out how I could add a custom field on my thread pages to a new column in the "thread" table. I know how I could add info to the table using PHP prepared statements but apparently it is better to use vBulletins own database classes however I can't find information on it anywhere! I also don't know how I would get the generated thread ID to use as a reference when inserting this info or what my custom field would be called, I can't just use $POST['field']. These variables seem to be a mystery. Advanced vBulletin documentation seems to be pretty scarce am I supposed to guess these variables and class names :S. Thank you. |
#2
|
|||
|
|||
I don't know of any documentation, but I threw together a bare bones example of adding a field to the thread table, and I've attached the product xml (you'd only want to import this to a test forum). Two things this example doesn't do: create the database field and add the input field to the newthread template. I called my new field "test" and made it a string, so to use this example product you'd need to add a field to your thread table called "test", and add an input control to the form in the newthread template, and set name="test". Alternatively you could edit the code and change the field name and type to something else.
If you have any questions please ask, but if you don't already have the vb source code set up so you can search it, you should do that. If you search for the hook names you can see a little about what's going on at the point where each plugin in executed. |
Благодарность от: | ||
josh_krz |
#3
|
|||
|
|||
Thank you kh99, so all I need to do is create the database column and add the field within the template for this to work?
Looking at that XML these things seems pretty straight forward, if there were some definite way to know what classes and functions to use How do people learn how to code plugins, there must be some cache of resources somewhere outlining these things? Thanks once again! |
#4
|
||||
|
||||
No there is no tutorial, basically you have to know, php, html, css, and have a understanding of how vBulletin works. Then take it and put it all together.
PHP, basic guide: PHP 5 Tutorial HTML basic guide: HTML Tutorial - (HTML5 Compliant) CSS basic guide: CSS Tutorial vBulletin basic mod guide: Creating a Product |
Благодарность от: | ||
josh_krz |
#5
|
|||
|
|||
Quote:
BTW, another thing this example doesn't handle is editing the thread. Quote:
|
Благодарность от: | ||
josh_krz |
#6
|
|||
|
|||
Quote:
Quote:
Quote:
I will take a look at some of the internal code and see what I can make of it. Thank you very much! |
#7
|
|||
|
|||
This seems fairly straightforward but I guess I'm messing something up.
1. I've added 'expenditure' to the 'post' table. 2. I'd like to be able to to add/update this field when replies to a thread are made. newpost_process PHP Code:
PHP Code:
PHP Code:
PHP Code:
PHP Code:
|
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|