MyBB Community Forums

Full Version: Plugin hook after each template
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Adding something like
$template = $plugins->run_hooks("template_".$title, $template);
in the templates class so when an template is loaded it runs an hook with everything in it, so plugins can change things "on-the-run".
I was planning on implementing a template plugin hook so that you would add a template listener.

Maybe something like

$plugins->add_hook("template_get", "my_template");
...
function my_template($name, $content){
switch($name){
case 'index':
$content = str_replace(...);
return $content;
}
}

Was planning on implementing one for the database too but told not to implement new features for 1.2 just yet. Fix bugs being the main priority since we don't really want to introduce new ones do we Wink
Well I still thinks my solution would be the best though. since you don't need to run an hook to see what template it is.. and it would be easier to make plug-ins with it, instead of changing the templates. That's my opinion anyways.
for example:
$plugins->add_hook("template_index", "my_template");
...
function my_template($content) {
     return str_replace(" ", "", $content);
}
Yea an plug-in hook for the database as well would be cool.
Okey, well hopefully it will come in an version after 1.2 Smile
Bugs are more important, indeed.