XF 1.2 Template Modifications and Comparison

Anyone who has developed add-ons for XenForo 1.1 knows that template hooks are a pain. They're a pain for us too, to say the least. Plenty of people have installed the Template Modification System add-on. We've been planning a TMS-like system for some time, before the XenForo add-on was ever actually released.

XenForo 1.2 will deprecate the template hook system and introduce it's own template modification system to make it easier for add-on developers to change templates. Note that I'm primarily focused on add-on developers here. It is possible to create your own custom template modifications if you're not an add-on developer, but unless you have multiple styles, I'd recommend just making the changes to the templates directly.

Let's look at what a template modification is:

ss-2013-04-12_11-35-58.webp


It's simply a "find this" and "replace with that" style replacement. You can do this to any template. If your find matches multiple times in a single template, it will replace each occurrence.

Applying a template modification does not actually modify the template, so it will not show up as customized and it will be automatically reapplied (if possible) when upgrading.

For those of you that want technical details, the modifications are applied before a template is parsed. If the modifications cause a template compilation error, they are automatically disabled.

Here's what the template modification overview looks like:

ss-2013-04-12_11-41-07.webp


All of the template modifications will be listed here, grouped by add-on and ordered by template. The checkbox enables/disables the modification. Note that if the modification is part of an add-on (and you're not in debug mode), you will not be able to edit the modification here but you can enable/disable it. More about this when editing a template.

The 3 numbers indicate the number of times the modification matched (green), the number of times the modification failed to match (grey) and the number of times the modification caused an error (red).

Editing a Template
There are a few new bits when editing a template as well.

ss-2013-04-12_11-43-10.webp


There are 3 new things here:
  • The "prevent" checkbox. If selected, modifications will be never be applied to this template. This can be used to quickly check a template without modifications or to adjust the modifications manually.
  • The "view template modifications" link. I'll discuss this below.
  • The "view custom changes" link. This will simply display a comparison of the parent version of the template (probably the master version) and the current version so you can identify the differences.
When you select view template modifications, you'll see an overlay like this:
ss-2013-04-12_11-43-25.webp

This shows you a comparison of how the template modifications will be applied to this template.
If you choose to manually apply modifications, the template modifications will be "materialized" into the template - they will actually be written into the template and automatic application of modifications will be disabled in this template. You can then manually edit the modifications if you wish. (Obviously if you upgrade an add-on and they've changed their modifications or you install a new add-on that changes this template, you won't be getting those new modifications so this should be used with care.)

Admin and Email Templates
These aren't left out. Add-on developers will have access to very similar systems that allow the admin and email templates to be manipulated in the same way.
We look forward to more dynamic add-ons with XenForo 1.2. :)
 
Last edited by a moderator:
Its a really nice system, but its geared towards developers to distribute required template changes. Editing the templates is still the recommended method.
 
I'm just a little confused. What I've seen in the screenshot seems identical to TMS so my question is if this system is integrated in XF or if do I need TMS as I'm doing now...
 
Others seem to find the TMS add-on adds other tid bits of functionality, but personally, I don't see the need for the add-on any more.
 
Surely I can add the mod into the template but the problem arise when I upgrade and I've to check all the modded templates. With TMS is easier don't you think?
 
Surely I can add the mod into the template but the problem arise when I upgrade and I've to check all the modded templates. With TMS is easier don't you think?
If you're using XenForo 1.1.x with TMS, backup your modifications or write them down somewhere. I was personally not able to automatically update my mods after upgrading to XenForo 1.2.

About XenForo 1.2, it has now some similar functions that had TMS. It works with public, admin & email templates (TMS was only working with public templates). About callbacks, I found that TMS was better designed, but it seems a few developers needed it. The advantage of TMS was that he could work by styles. The official functions only works with the master template and requires the debug mode to be activated then (unless you keep a direct link to your modifications). The new TMS addon compatible with XenForo 1.2 has been rewritten to allow customization by styles. Since it's now an addon to the official template modifications functions, it will also require the debug mode to see the menu.

So to answer your question directly, if you don't need template modifications by styles, you can only use the official system, otherwise install TMS. In anycase, write down your modifications somewhere to avoid to lost them (when converting your board from 1.1.x to 1.2.x).
 
You have an add-on installed called Template Modification System.

It appears to not be compatible with XenForo 1.2.

You should remove it. The feature is built into XenForo 1.2 and above without the need for an add-on.
 
so we still have xen:hook in xenforo templates system.
Wonder if there is a performance difference between xen:hooks and TM.

(I'm talking about a large form that has 701,207 members and 25,587,483 posts.)
 
There is, but its so minor that it doesn't count.

In compiled templates hooks are called like this:
Code:
$__compilerVar188 .= $this->callTemplateHook('header', $__compilerVar189, array());
but template modifications are directly applied, like its a part of final template.
 
Top Bottom