• 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?

Marcus

Well-known member
#1
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:

Chris D

XenForo developer
Staff member
#2
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.
 

Jeremy

Well-known member
#3
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.