1. 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

Discussion in 'XenForo Development Discussions' started by Jake B., Aug 1, 2016.

  1. Jake B.

    Jake B. Well-Known Member

    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: Aug 1, 2016
  2. Jake B.

    Jake B. Well-Known Member

    Ended up just using a template hook for this. However, that is causing template hooks within that template not to fire :\
     
  3. Chris D

    Chris D XenForo Developer Staff Member

    Should just be a case of creating the appropriate template object and returning that:
    PHP:
    return new XenForo_Template_Public($templateName$params);
     
    Last edited: Aug 1, 2016
  4. Jake B.

    Jake B. Well-Known Member

    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

    [​IMG] Any way to make that happen?
     
  5. Chris D

    Chris D XenForo Developer Staff Member

    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
     
  6. Jake B.

    Jake B. Well-Known Member

    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!
     
  7. Jake B.

    Jake B. Well-Known Member

    Yep, that was the issue, got it working!
     

Share This Page