The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
[How-To] Walkthrough of hack development & Coding Tips: Thread Promotion System
I've wrote this tutorial @ other modding community i'm member on few days ago. I wanted to share it with this community as well, so members that don't visit there can benefit from it here as well. This tutorial will provide complete walk-through of the development made to create "Thread Promotion system" modification (can be found @ https://vborg.vbsupport.ru/showthread.php?p=1808040) So, lets get going: This guide assumes the following:
Development stages:
1. Modification Idea: This modification was as reply to request made. as request mentioned, he wanted a system that would allow him to set forum as being able to have "thread promotion" inside it. Which actually means once reply count passed XX it will automatically moved from forum A to B. The above description tells us 2 things:
Analyze & Process Information: (1) Mod appearance on admincp (& Hook Location): With above said, right now the coder should "see" the modification in his mind. Knowing you'll add some section under "Forum Manager" as you want it to be intergated in way every new forum add or edit will allow you to set it. & you need some code to perform the check. This will later on be "translated" to "forumadmin_edit_form" hook code. (2) Mod Core Code (& Hook Location): Since idea speaks of "if reply count > XXX" common sense suggest this should be implanted right after a person finished to post new reply. As right then we can "ask" what was the reply number & have we passed the mark we aimed for. And if we did - do your "magic". This will later on be "translated" to "newreply_post_complete" hook code. (3) Possible pitfalls & consideration points in code:
In general you should know the structure of your vbulletin (at least the common tables that construct it). In our case: we are most likely to need some info (either fetch or set) from 3 tables : "forum", "thread", "post". these tables have parent-child relationshionship structure similar to following: forum -> thread -> posts (thread has forum parent id, post has thread parent id)
As reminder, we came to conclusion we will need the following information "present" for us:
"Enable" filed that will act as BOOLEAN (true/falsE). "Reply Count" field of int type. "Forum ID" field of int type (says to us which is the target forum to be moved thereads onto. Lets get to business, logon on your phpmyadmin, go to table "forum" & add 3 new fields: And screen after fill these: Once made, you'll see this screen: Please "save" the (copy & paste to some place, will be used later) the ALTER query, as we will need it to the install code: The query should be like the following: Code:
ALTER TABLE `forum` ADD `enable_thread_promotion` TINYINT( 1 ) NOT NULL , ADD `reply_count_for_promotion` INT NOT NULL , ADD `target_forum_id` INT NOT NULL This can be done either from config.php or install some plugin for it. there are several debug mode hacks, just install one of them. 4. Create Product: Go to Admincp, from side nav select "Plugin & Products" -> "Manage Products" : Select "Add/Import Product": On the "Add New Product" screen fill the information as demonstrated in the following picture: When done, click "Save". Once product added you should see following screen: 5. Add Plugins: As discussed @ section 1, we will have in this modification 4 plugins/hooks.
So, lets start add them one by one: Admincp hook: From Admincp: "Plugins & Products" -> "Plugin Manager": Then select "Add new plugin": Then we fill the fields as shown in this picture: The code that was placed onto this hook is: PHP Code:
Data Manger Field Support hook: In the same way add another plugin, this time select "forumdata_start" as hook location. In there add code as shown in the next picture: Core Code hook: In the same way add another plugin, this time select "newreply_post_complete" as hook location. In there add code as shown in the next picture: I dont want to make this "monster post", You can get full source on the modification, i'll just put the following notes:
Core Code AJAX hook: This is exact copy & paste of previosu hook, just place it on "newreply_post_ajax" as hook location. At this point all plugins should be complete: 6. Testing Code: Check the code on your forum. Through it you'll find pitfall you didnt think about. In this case for example the reply count was zero-based, so i had to add -1 factor on code. These sort of things can only be found while you "hands on" code & test it, so dont be afraid ! Also general tip, if certain code not working, try to place php die("soem text"); on certain key points to tell if the code executed till that point. That can help to debug certain things. 7. Add Install/Uninstall Code: On Admincp go to "Plugin & Products" -> "Manage Products" & edit the current product we just did: Now we'll add the install/uninstall code, which is the db changes (add fields for install & drop fields for uninstall). Now it's time to use that ALTER query we wrote while back. Note the DROP query can be obtained from phpmyadmin as well. Then you will see this: When you have both MYSQL queries we can add it to product as shown here: All thats left now is to export & save 8. Export & save hack: From "Product Manger" choose export as seen here: Then save it on your directory: That's it !! Congratulations, if you followed all this (long) guide, you have now made your hack successfully Don't forget to share back with community your work I hope this guide has helped anyone out there that wanted to get into the modding & gets hands-on & start coding & was missing some pratical hand-on step-by-step tutorial.. If anyone has any further questions, post them here & i will help gladly. Enjoy |
#2
|
||||
|
||||
Very helpful! Thanks for sharing.
|
#3
|
|||
|
|||
Thanks for this!
|
#4
|
|||
|
|||
it looks wonderful
I didn't read it all but I know I need it so I'm going to come back again thanx a lot |
#5
|
|||
|
|||
Superb.
Thank you for this. Ive always wanted to learn how to code. Ive got an idea for several mods that I would love to create. I think ive got a lot more reading and learning to do before i start! |
#6
|
||||
|
||||
My aim (in both this tutorial & in my previous ones posted on other community i'm on) is to make any modification development, complex as it may seem, breaked-down to easy parts followed by step-by-step guides, providing users with knowledgebase of "craft tools" that one can use to code his ideas into fully working modification.
Be sure more guides/tutorials will be posted soon. Next guides will cover "hook system", "common variables" used (what var holding what info & at which hook is it accessiable from), Templates integrations, admincp advanced options (on new modificatiosn made) & more |
#7
|
|||
|
|||
This is exactly what I needed. Good job, and thank you for your time and effort.
|
#8
|
||||
|
||||
Nice,Thank you
|
#9
|
|||
|
|||
Nice hack, I'll definitely look more into this since I'm creating my own version of a promotion hack :-)
|
#10
|
||||
|
||||
please add : how to create option in the vbulletin ?
|
Thread Tools | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|