preloadTemplate, what it do?

Jake Bunce

Well-known member
I am trying to understand the low level function of preloadTemplate. I found code examples, such as Kier's post here:

http://xenforo.com/community/threads/suggestion-list-of-xenforo-com-custom-edits.17157/#post-224952

But I don't understand exactly how it works and when it is appropriate.

In my specific situation I have a navigation_tabs listener that renders a template:

Code:
				$template = new XenForo_Template_Public('nat_childlinks', array(
					'firstChildNodes' => $firstChildNodes,
					'selected' => $selectedTabId == 'nodetab' . $nodeTab['node_id']
				));
				$childLinks = $template->render();

I am wondering if I should be preloading this template.
 
When dealing with navigation I find that preloading is not necessary. When using template hooks preloading is optimal hence creating a savvy looking file and making the loading of the template faster considering the preload from what I understand cache's the template.
 
I've found that if you're using template hooks, look at the query count. If it increases by one it should be preloaded and if there's no change in the count you could leave it as-is.

Now whether or not you should preload in all instances is something I'm unsure of. I don't think it's necessary as it's already called/cached (the extra query to fetch that particular template not being needed).
 
I've found that if you're using template hooks, look at the query count. If it increases by one it should be preloaded and if there's no change in the count you could leave it as-is.

Now whether or not you should preload in all instances is something I'm unsure of. I don't think it's necessary as it's already called/cached (the extra query to fetch that particular template not being needed).


Thank you...this topic of this thread makes sense to me now...and the first line is worded in a way that if I need to remember this sometime down the road ....I will recall this thread.
 
Top Bottom