A guide to XenForo 1.2 and templates

A guide to XenForo 1.2 and templates

You don't have to go through all of the templates on every update because not every template is modified in the core in every update.

In most scenarios you won't even need to do anything on those updated templates other than go to the merge screen, scroll down it and review areas highlighted in blue (auto merges) or yellow areas indicating conflicts.

Most times I've done this it takes no more than 10 seconds to skim down the template and action what needs actioning.

I'm not going to knock anyone who wants to use TMs.

But be careful not to pre-judge the other methods.
 
  • Like
Reactions: Bob
With a template modification system I only have to go find and fix what breaks on updates. With template merge I have to go through all the templates and make choices on every update. The latter seems to be much more work and I also can't just turn an edit off if I wish to.

So while I may yet embrace this NEW thinking I am not sold on it yet. More work = Bad
As Chris has said, for the most part, you can auto-merge most changes and it'll take a lot less time than you think.
 
If Template Modifications work for you, great. Knock yourself out.

But the point of this guide was to explain the options available to people. And to ensure people have an understanding of how direct template edits are no longer a thing to avoid.

Maybe that didn't come across in the guide.

Primarily the TM system is a development tool. If you have specific things that you find easier to achieve in the TM system, no one is going to stop you :)

On the flip side, the main reason people used any sort of TM style system in the first place was because of a (understandable) reluctance to make direct template edits.

The reason for that reluctance was because of an inability to easily compare the changes between an upgraded template and a directly edited template. The only choice was to revert and manually reapply.

That reluctance and reasoning is now entirely void. Direct template edits should no longer by default be avoided. If you can do them, do them.

At the same time, if you prefer to use the TM system -- no one is going to stop you.

It's all about options. There's now many more.

I've already utilised the TM (I'm no developer) but the changes and edits I made into it have saved me multiple template edits across many styles, more than a few times I can say. So this guide is definitely good reading.
 
I still see people shuddering with fear at the thought of template edits. They're not the bane of all evil any more.

About time this was highlighted.

Good tutorial Chris!
 
Here is an example of doing a template edit directly vs. via TMs:

Lets say you want to add a notice to all xenforo pages above the h1 title.

Direct Template Edit:

- Go to AppearanceTemplates
- Open the PAGE_CONTAINER template
- Scroll down until you find "<!-- h1 title, description -->" and copy&paste the following code above it so that it will look like this:

Code:
<xen:comment>This is a simple hello world notice above the title of every page</xen:comment>
<div class="notice" style="color:red; border: 1px solid red; border-radius: 5px; background-color:yellow;padding:5px;text-align:center">Hello World</div>
<!-- h1 title, description -->

- Save

Result:

View attachment 52209


Now we are doing the same but with the Template Modifications method:

Template Modification:

- Go to AppearanceTemplate Modifications
- Click Create Template Modification
- Enter the following values in the specified fields:

Template: PAGE_CONTAINER
Modification Key: pc1
Description: This is a simple hello world notice above the title of every page
Search Type: Simple Replacement
Find: <!-- h1 title, description -->
Replace:
Code:
<div class="notice" style="color:red; border: 1px solid red; border-radius: 5px; background-color:yellow;padding:5px;text-align:center">Hello World</div>
<!-- h1 title, description -->

- Click Save Template Modification

The result is the same. The difference is how you can manage this template edit. With the TM method, if you want to remove this notice, you need just to uncheck the checkbox of the appropriate TM:

View attachment 52211

And in case you want to enable it again, all you need to do is to check the checkbox. Also you can see instantly the name of the template a modification is applied to and what the modification actually does. Easy and convenient.


With the direct template edit method you actually need to search for the template that contains your edit because unlike the TM method your edits aren't listed. But you don't know what edit you made because it has been some time since you did it so you need to open a template and find the edit you are looking for via the View Custom Changes function. And once you found it, you need to remove your edits directly from the template if you wish to remove the notice we added above the h1 title of every xenforo page. And in case you want to add it back, you need to paste the code again directly in the template.

Compared to the TM features, direct template edits are still a pain, really. And even these TM features are limited for style developers as you pointed out in your guide.

Thanks for this guide to non speaker english like me (the images and example help a lot), very clear and well explicated.
Great job @Luxus
 
You don't have to go through all of the templates on every update because not every template is modified in the core in every update.

Is there an overview/list page of all edits/conflicts or do you only see them when you go into a template?

If there was an analogous page to "you have outdated templates" then that'd make the checking much easier.
 
Is there an overview/list page of all edits/conflicts or do you only see them when you go into a template?

If there was an analogous page to "you have outdated templates" then that'd make the checking much easier.

/admin.php?templates/outdated
Outdated Templates

/admin.php?styles/customized-components
Customized Components
 
Thank you for this guide Chris. I'm slowly understanding the intent of the core TM. I've absolutely loved the convenience of guiltar's TMS. The real advantage was the list format with description and the quick on/off function. So let's say I'm going to rework everything now to be actual direct template edits (no core TM). Is there any way to see a list of modified templates that would include some description of the modification? I hate the idea of having to enter each template to look for my comments to figure out what the edit was for.
 
You can use:

admin.php?styles/customized-components

To see any customised components for each style. This includes template edits and style properties that have been changed.

There's no on/off switch and there's no indication in there as to what has changed.

I have seen this argument for TMS elsewhere. Although to a certain extent I can appreciate an at a glance, ordered view with convenient on/off switches is useful, I have to wonder to myself -- how often will you need to switch a single edit on/off? If you look at the template name surely you have a vague idea what the edit does as the template name perfectly describes the page/location the template is used.
 
Actually as a total newbie to forum software, I found the on/off switch to be priceless. Instant confirmation that the edit "took" (applied 1 time). To me the switch was just as useful as the list. I can document the edit changes elsewhere but the ability to see that the edit was successful saved a lot of time. I can see why popular thinking has shifted to using direct template edits.
 
You will instantly know whether an edit is successful or not, because it is checked before the changes are saved.

If the template saves successfully, the edit "took".

If you get an error, it didn't. And then it tells you exactly what line causes the problem, and often specifically what the problem is.
 
Well I've worked on direct editing. I'm not sold yet, but I can probably make it do what I need.

I have a template with multiple TMS edits within that same template. Using separate descriptions as per the TMS summary list, it was super easy to keep track of them.

With direct editing, I've been adding comments at each spot which works to a limited degree. There is one situation that I'd like to improve. I have edits that require deleting a block of code. It would be nice to see the deleted code still exist in the template without having to "view changes" to see it.

One thing I tried was to wrap the "to be deleted" section of code in a xen:comment. In theory this prevents execution, but during "view changes", it shows only the exact literal differences, so it's hard to identify the entire code block.

Is there any method of commenting that would stop execution of a code block AND have "view changes" highlight the complete code block?
 
A further point: Why is the change history NOT cleared when a template is reverted? Since I've been experimenting, I've got a long history list that I don't want. How do I clear the history list?
 
Thanks for the nice overview. I was always hesitant about making direct template edits even though it was sometimes difficult using the extra.css with "!important" since it rarely did break something else. I guess I'll get to editing templates directly!
 
I think I'll continue to use TM or TMS for holidays/events temporary mods, and direct edits for minor and "definitive" edits.

@Chris D
With direct templates edits what do you think is the best way to go from a style to a new one? For example when we have to do a massive restyle of the forum.
Note edits down during the original edits, updating the notes if modified, and when needed for the restyle re-apply them reading from those external notes?
 
Kintaro are you on 1.3.0? The latest 1.3 TMS from Guiltar adds a dropdown for style choice that should allow modifications per style. I have not seen any method to do modifications per style with the new TM system (core). I looked for posts that would indicate a way to do this.
 
This thread is specifically about editing templates directly. There is no way to do template modifications per style because the TM system in XenForo is recommended solely for add-on developers.

To modify styles it is recommended to just edit the templates directly. The system for merging custom changes into an updated template is incredibly simple.
 
Top Bottom