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

Template Modifications Best Practises: When adding templates?

Discussion in 'XenForo Development Discussions' started by Marcus, Aug 26, 2013.

  1. Marcus

    Marcus Well-Known Member

    When do you add a whole template in the Template Modification Replace? Usually I use the system for
    • <xen:callback> or
    • <xen:include template>

    Within the Replace I have access to the variables, which is not true for <xen:include template> so I have to put the whole template in the Replace or use callbacks. Or could I pass a variable with <xen:include template>? Today I added advertisement banner tags directly in the replace.
     
    Last edited: Aug 26, 2013
  2. Chris D

    Chris D XenForo Developer Staff Member

    You should have access to the variables in xen include template as long as those variables are available to the current view. And that is no different to anything. Including a template doesn't magically bring across a load of view parameters.

    Don't forget you can wrap xen set and xen map variables inside xen include so if the included template makes use of $post but the view you're using contains $message then you can use xen:map to sort that.

    Including the contents of the included template in the replace field should be the same result.
     
  3. Jeremy

    Jeremy XenForo Moderator Staff Member

    Use include, you have access to the same variables as the including template. If you need more data, you should extend the appropriate controllers to add it.
     
    Chris D likes this.

Share This Page