Cache templates to avoid 1 additional query for each callback

Marcus

Well-known member
In Debug I see one additional query per each callback function returning a template:
PHP:
<xen:callback class="My_Callback_ForumList" method="getForumList" params="{$visitor}" />
PHP:
class My_Callback_ForumList {
  public static function getForumList($content, $params, \XenForo_Template_Abstract $template) {
       return $template->create('custom_template', $templateParams);
   }
}
How can I cache them all? With template caching? http://xenforo.com/community/threads/how-to-use-template-hooks.13167/ I thought xenForo caches most stuff on its own today :D
 
Side note, but you would be SO much better off storing templates as files so your opcode cache can pre-compile the templates. As a bonus, it doesn't need *any* queries to get templates.
 
Side note, but you would be SO much better off storing templates as files so your opcode cache can pre-compile the templates. As a bonus, it doesn't need *any* queries to get templates.
Forgot to activate this option again. Thanks ! The more you know the system, the easier it is to find the right solution :)
 
In your template_create event listener, for $templateName PAGE_CONTAINER (or something more specific if possible), call $template->preloadTemplate('your_template')
 
Thanks. Now I wonder if the addon on my "fetch templates as files" enabled forum would me minimal faster with or without adding the cache routine.
 
Top Bottom