2010-12-14, 01:40 AM
Hey folks,
I have created a modification of myBB that I want to make a plugin-out of, and I have gone through the documentation, which is basically straightforward and well done but a little slim. So I am looking for some pointers and guidance on how to go forward moving my mod into a plugin.
I have 2 major questions:
1. first is about using the plugin hooks for my specific mod:
What I have currently is a set of custom templates ( or template set?) coupled with, as my system is now, modifications of 3 php files. I want to move my mods out of the php files and into a plugin.
Basically what my current mod does is to the 3 myBB php files involved in creating new posts:
newthread.php; newreply.php; and post.php.
The current mod is very simple: I have an extra field whose data needs to be written to the new post record in the mybb_posts table when it is created. So, for example, in newthread.php and newreply.php have appended my field to:
In newthread.php and newreply.php, this is then passed to post.php for the db insertion, where likewise post.php is modified by me to insert the data for my 'postType' field.
So, the question is now to write my field in a plugin, so that it won't be part of the normal newthread.php, newreply.php, and post.php distributions?
From the documentation I can see that I should create a function in my plugin file that fires on the:
hook. But that hook comes long after the new post record has been written, so my field won't be filled with my data as a part of the new post creation - the record will have already been written at the time the hook runs.
So, I am left to write to the table after the fact. But how will I know which record number needs to be updated? I need the pid of the newly created post, so I can update...
Knowing that would, I think, take care of my problem trying to create a plugin out of my php mods.
2. The second question has to do with the whole plugin / template system. Because my plugin will depend on these templates, how can I have the plugin install them? I don't see any documentation that really explains that. If I want to distribute my mod, once I get it all plugin-iffied. I want it to be some kind of package. How does that work?
Any links or pointers to other tutorials?
Thank you for any ideas about these questions,
Gordon
I have created a modification of myBB that I want to make a plugin-out of, and I have gone through the documentation, which is basically straightforward and well done but a little slim. So I am looking for some pointers and guidance on how to go forward moving my mod into a plugin.
I have 2 major questions:
1. first is about using the plugin hooks for my specific mod:
What I have currently is a set of custom templates ( or template set?) coupled with, as my system is now, modifications of 3 php files. I want to move my mods out of the php files and into a plugin.
Basically what my current mod does is to the 3 myBB php files involved in creating new posts:
newthread.php; newreply.php; and post.php.
The current mod is very simple: I have an extra field whose data needs to be written to the new post record in the mybb_posts table when it is created. So, for example, in newthread.php and newreply.php have appended my field to:
$this->post_insert_data = array(
"subject" => $db->escape_string($thread['subject']),
...
...
"postType" => $thread['postType'] //<< this is my fiield
);
In newthread.php and newreply.php, this is then passed to post.php for the db insertion, where likewise post.php is modified by me to insert the data for my 'postType' field.
So, the question is now to write my field in a plugin, so that it won't be part of the normal newthread.php, newreply.php, and post.php distributions?
From the documentation I can see that I should create a function in my plugin file that fires on the:
$plugins->run_hooks("newreply_do_newreply_end");
hook. But that hook comes long after the new post record has been written, so my field won't be filled with my data as a part of the new post creation - the record will have already been written at the time the hook runs.
So, I am left to write to the table after the fact. But how will I know which record number needs to be updated? I need the pid of the newly created post, so I can update...
Knowing that would, I think, take care of my problem trying to create a plugin out of my php mods.
2. The second question has to do with the whole plugin / template system. Because my plugin will depend on these templates, how can I have the plugin install them? I don't see any documentation that really explains that. If I want to distribute my mod, once I get it all plugin-iffied. I want it to be some kind of package. How does that work?
Any links or pointers to other tutorials?
Thank you for any ideas about these questions,
Gordon