MyBB Community Forums

Full Version: Proper Documentation
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Is there a proper documentation which explains all the global variables you can use in a plugin, how plugins work, maybe some sort of architecture description so you can decide where to run code etc and also some sort of list of what the hooks actually do. I have a list of what they are called and where they are, but not what they are for (like what is about to happen before/after the hook) etc.

Just some section that explains everything. I really want to start customising MyBB to do stuff like using a Login API instead of the traditional logging in. (like OpenID etc), turn the 5 star thread rating system into a thumbs up/down rating system... etc I really just want a page that will teach me everything I need to know to start thinking logically about how to do everything preferrably without having to read the entire source code.

I will read the entire source code if no such documentation exists, but I would like to know my options first Toungue

Please don't direct me to the documentation explaining features and admin cp etc, it's pointless to me as I want to develop not learn how to use the forum.


Thank you Smile
I am afraid we don't, all we got is located in the Wiki.
Have a look at the Hello World/Akismet plugin that comes with MyBB, there's documentation about all the core plugin functions in there (activate, deactivate, install, uninstall); activate and deactivate generally add/remove settings and templates/template edits, install/uninstall generally add/remove database columns and tables. You have access to all variables that are in MyBB, as long as you globalise $mybb, $db, $cache, $lang etc etc in your function. Hooks work like this:

$plugins->add_hook("global_start", "my_plugin_function");

This means when the global_start hook is run at the start of global.php, it'll run my_plugin_function() which would be in your file, and do whatever you want it to do at that stage in loading the page.
(2010-07-17, 10:32 AM)MattRogowski Wrote: [ -> ]Have a look at the Hello World/Akismet plugin that comes with MyBB, there's documentation about all the core plugin functions in there (activate, deactivate, install, uninstall); activate and deactivate generally add/remove settings and templates/template edits, install/uninstall generally add/remove database columns and tables. You have access to all variables that are in MyBB, as long as you globalise $mybb, $db, $cache, $lang etc etc in your function. Hooks work like this:

$plugins->add_hook("global_start", "my_plugin_function");

This means when the global_start hook is run at the start of global.php, it'll run my_plugin_function() which would be in your file, and do whatever you want it to do at that stage in loading the page.

Okay but why would I want to run code there? "global_start" doesn't give me any indication as to what is about to start etc. Also, how do you find out about all the variables such as $mybb, $db, $cache, $lang etc and the available function which can be used etc?
Well if you wanted something to run on every page you'd use that hook as that is run on every page at the start of global.php, it's just an example.

There isn't a list of every single variable and object in MyBB, it's whatever is in all the other files. Some function files are automatically included, but you can also just include other function files if you need the functions inside them.
(2010-07-17, 07:49 PM)MattRogowski Wrote: [ -> ]Well if you wanted something to run on every page you'd use that hook as that is run on every page at the start of global.php, it's just an example.

There isn't a list of every single variable and object in MyBB, it's whatever is in all the other files. Some function files are automatically included, but you can also just include other function files if you need the functions inside them.

But say for example I wanted to remove the original login system of MyBB and make it so that is used an external login. Like say I made a system where you pass login details to otherwebsite.com?u=test&p=test it would return "true" if it's a valid login. I want it to that if true is returned, it logs them in to the forum as normal... although I have no idea what needs to be created/set to be able to appear as logged in. Like what sessions or databases to set etc.

It's pretty much guesswork if you want to do anything without reading every single line in every single file of the MyBB system.
It's not guesswork, it's just a case of looking at some functions. I don't think anyone can develop plugins for software without already having a general idea of the structure of it and where things are. You'd need to hook into member.php, look at the code for logging in in member.php to see what it does to log you in.
Okay but what if I wanted to remove the default 5 star rating system and replace it with a thumbs up/thumbs down system? How would I find out what to disable and where to add/enable other things?
By looking at where and what the current code is. We couldn't possibly have documentation on every single aspect of every single feature and how to customise every single feature in every single way. As the stars are created via javascript when they're shown you'd need to remove the code that loads that from the templates, put in your own code, and then in your plugin work out whether to show a thumbs up or thumbs down or whatever you'd do and show that. You'd need to still store ratings in the normal way so it'd still show accurate ratings after you disabled the plugin.
Pages: 1 2