MyBB Community Forums

Full Version: Can only load template from Global Templates?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have this plugin where I add support for a page loader for my theme.
However, for some reason, it will not load the theme-specific template called "pageloader", it will only load it if it's inside the Global Templates?

Here is a snippet of my code loading out the template.

// Make sure we can't access this file directly from the browser.
if(!defined('IN_MYBB')) {
	die('This file cannot be accessed directly.');
}

if(defined('THIS_SCRIPT')) {
    global $templatelist;

    if(isset($templatelist)) {
        $templatelist .= ',';
    }

    $templatelist .= 'pageloader';
}

$plugins->add_hook('global_start', 'mytheme_load_globals');
function mytheme_load_globals() {
	global $templates, $pageloader;
        eval("\$pageloader = \"".$templates->get('pageloader')."\";");
}

Any idea what I am doing wrong?
Theme is defined after global_start has ran, thus you can't load the template correctly.

You need to hook at global_intermediate, at least.
(2020-06-14, 07:30 AM)Omar G. Wrote: [ -> ]Theme is defined after global_start has ran, thus you can't load the template correctly.

You need to hook at global_intermediate, at least.

Thank you Omar, that was the issue.
And now when looking into the MyBB core, this makes total sense.