MyBB Community Forums

Full Version: Adding templates to the cache?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I've noticed in the debug information that any templates I add in a plugin are loaded up on page load rather than being in the cache like default templates - is there any way around this? It adds 2 queries to some pages in one of my plugins and Id rather remove those queries i possible.
You need to create a cache - I did it like this (is probably not optimal....)


$plugins->add_hook('global_start', 'champs_tcache');
function champs_tcache()
{
	if(isset($GLOBALS['templatelist']))
	{
		$GLOBALS['templatelist'] .= ',latestchamps_gallery,latestchamps_gallery_gallery';
	}
	
}

where the templatelist is the name of the templates you are creating. If you have an SQL query in your plugin it will still be a query though.
Ok, cheers leefish. The query simply selects the template from the database - that's what I want to remove Wink
Well it'll always have to select it from the database, the point of adding them to this list is so that your custom templates are loaded with the default $templates->cache() function, instead of having to be queried separately.
Yeah, that's what I'm meaning Wink I'm trying to remove the two extra un-necessary calls as (as stated), they're un-necessary when they could be called in a pre-existing one. Thanks.