• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Render template from xen:helper

Jake B.

Well-known member
#1
Basically, I'm wanting to create a helper that will render a template, is this possible? I can't seem to find the best way to do this or do I just need to use a template hook? Also, no a template modification is not an option :p
 
Last edited:

Jake B.

Well-known member
#2
Ended up just using a template hook for this. However, that is causing template hooks within that template not to fire :\
 

Chris D

XenForo developer
Staff member
#3
Should just be a case of creating the appropriate template object and returning that:
PHP:
return new XenForo_Template_Public($templateName, $params);
 
Last edited:

Jake B.

Well-known member
#4
Should just be a case of creating the appropriate template object and returning that:
PHP:
return new XenForo_Template_Public($templateName, $params);
I'm trying to do this with navigation, and it appears at least that included templates aren't included and the template name is just rendered instead

Any way to make that happen?
 

Chris D

XenForo developer
Staff member
#5
Template includes should just work:
PHP:
public static function helperTemplateTest()
{
   return new XenForo_Template_Public('test1');
}
test1:
HTML:
This is template 1

<xen:include template="test2" />
test2:
HTML:
This is template 2
Output when the template helper is called:

upload_2016-8-1_15-54-32.png
 

Jake B.

Well-known member
#6
Ah, nevermind the subnavigation links aren't using an include, it just has the template name so I'll need to do the include manually. I'll dig into this a bit more, thanks!