MyBB Community Forums

Full Version: How do plugins work?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
The question was kind of rhetorical.

After i explored the plugin system i found out that the only reason it works is because you guys have implemented the template system.

Without it, the current way to run the hooks would not work.

Or am i wrong?
nope. Hooks are run from the PHP files.
Yeah, but...since you eval variables from funtions you can control them.

Here is the sample from hello plugin.

$post['message'] = "<strong>Hello world!</strong><br /><br />{$post['message']}";
Could you have been able to control it, if templates didn't exist in mybb?
Well of course templates are required they are the site layout. But, what the plugins due is run in the php files. Only their outputs are inserted into templates.
Most plugins add features with which people have to interact with. Therefore, it edits templates.

Some plugins run mostly backstage. So, you won't notice them too much.
How do plugins work? Magic!

Not every plugin messes with the template system directly... in the end no matter which system used, in the end some variables make it into the output somehow, and if the plugin changes those variables in a hook, the output changes.

Doesn't matter if it's done through the template system, or with echo, as long as the hook runs before the echo is made. Otherwise you have to work with output buffers and replacing stuff in the html directly, which is ... ugly.