The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Where in the code are new threads created?
Hello VBulletin forum,
I am trying to have VBulletin make an additional database entry when creating a new thread. But I just can't seem to find the section where this happens. Could anyone give me some directions? |
#2
|
||||
|
||||
All the posts go through the API -- vB_Api_Content_{Text, Photo, Link, Poll}
From there, it's handed off to the library (vB_Library_Content_}, and then it gets handed down to the db classes (vB_dB_MySQL_*). IIRC, all a "new thread" is is a post whose parent is the containing channel. |
#3
|
|||
|
|||
Alright, that helped a lot. Thanks for the quick reply!
|
#4
|
|||
|
|||
I think I'll need some more help.
I want to make the database entry with this line of code (maybe this is already where I'm doing a mistake?): Code:
$vbulletin->db->query_write("INSERT INTO " . TABLE_PREFIX . "my_table (field1, field2, field3) VALUES (1, 2, 3)"); Now I want this line to be executed upon creating a new thread. So I went and inserted it in the vb_api_content_text add() function, and after it not working I also tried vb_library_content_text add() and a whole lot of other possible functions elsewhere. However, not once did it actually do a database entry and I would always get this error message from VB in my browser: Error while saving content: SyntaxError: Unexpected token F Maybe noteworthy is that while it gave that error message and didn't redirect me to the newly created topic, it did create it nonetheless. Can you (or someone else) tell what I'm doing wrong? :\ |
#5
|
||||
|
||||
Could it be an error with your SQL? Without seeing actual code and/or data, it's tough to debug.
Additionally, the db->query_write stuff is depreciated. Not sure if it'll actually be removed from the source code or not...but might be a good idea to look at the DB Assertor classes. If, for no better reason than it's the vb5 way. |
#6
|
|||
|
|||
So I finally had the opportunity to actually continue working on this and first of all, thanks for your reply.
As you suggested, I took a look at the DB Assertor classes and used the insert() function instead of query_write() and changed my code accordingly: Code:
vB_dB_Assertor::insert("my_table", array("field1" => 1, "field2" => 1, "field3" => 1)); Anyway, on to my problem. I put this in the add() function of vb_api_content (also tried other functions of other classes), but still to no avail. I don't get any error messages anymore, but at the same time nothing happens. So either I'm in the wrong spot or my code is wrong. Any ideas? :\ |
#7
|
||||
|
||||
I think you need to have an entry in the DB Assertor class for your table. You should be able to create your own DB Assertor class and do the entire thing without file edits, though.
|
Благодарность от: | ||
Randomguyy |
#8
|
|||
|
|||
Works like a charm now. Thanks a lot for your help!
|
#9
|
|||
|
|||
So making db entries when creating a new topic works for me. Now, though, I have a new problem.
What I want to do is make it possible to basically reply to a topic with another topic. To do this, I created a button in a PHP module in the first topic, which also adds the topic's ID in the URL. I want to save the IDs of the first and second topic in the db so that I can connect both via a link in f.e. a PHP module. Now I want this to happen right as you click the 'Post' button for creating a new topic. However, for the life of me, I can't find where exactly in the code I would have to add my own code to execute the db insert. help pls? |
Thread Tools | |
Display Modes | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|