Working with templates

Neil E.

Active member
Is there anything for templates in terms of a "master template"? I'm looking for something that can easily be used as a reference to compare changed templates to their original master. Similar idea to what I asked regarding styles (creating a new style with no parent becomes a copy of the master style).

Or alternately, is there a method to edit a template but leave the original text intact? This would be like having an ongoing record of changes.
Silly example: <ignore>original text is here</ignore>
 
Try WebDav to access your styles. It will give you access to templates as HTML files that you can download and/or edit with your favorite HTML editor. You can use it to compare different templates using any comparison tool.

Search this forum for "WebDav" and you'll come up with many threads explaining how to use it.
 
Silly example: <ignore>original text is here</ignore>

In templates, if you're removing code, it's always best to "comment it out" instead of deleting it.

You can do that with <xen:comment>original text is here</xen:comment>

As well as useful for leaving the original text intact, you could also use it to leave yourself notes, such as (example) <xen:comment>following changes were to remove user titles from posts</xen:comment>.

And as MagnusB says - yeah you can make the Master Style visible by putting your board into debug mode. This is only recommended on development sites, and certainly recommended either to restrict it to a certain IP address or turn it off on live sites.

It's also very important to be cautious while using the Master Style. If you inadvertently make an edit to the Master Style then that change will be permanent and you cannot revert the changes on a Master Style.

You can enable debug mode by following these instructions: http://xenforo.com/community/threads/frequently-asked-questions.5183/#post-248490
 
In templates, if you're removing code, it's always best to "comment it out" instead of deleting it.
You can do that with <xen:comment>original text is here</xen:comment>

Thank you, perfect for my limited skills.

It's good to know that debug mode exists, but I will stay clear of that one.

WebDav ........... maybe once I learn more.
 
More on working with templates based on Jake's reply on how to change NavBar text. Example:

Code:
<!-- account -->
    <li class="navTab account Popup PopupControl PopupClosed {xen:if $tabs.account.selected, 'selected'}">
 
        <a href="{xen:link account}" class="navLink accountPopup" rel="Menu"><strong>[COLOR=#ff0000]{$visitor.username}[/COLOR]</strong></a>
 
        <div class="Menu JsOnly" id="AccountMenu">
            <div class="primaryContent menuHeader">
                <xen:avatar user="$visitor" size="m" class="NoOverlay plainImage" title="{xen:phrase view_your_profile}" />
   
                <h3><a href="{xen:link members, $visitor}" class="concealed" title="{xen:phrase view_your_profile}">{$visitor.username}</a></h3>
   
                <xen:if hascontent="true"><div class="muted"><xen:contentcheck>{xen:helper usertitle, $visitor}</xen:contentcheck></div></xen:if>
   
                <ul class="links">
                    <li class="fl"><a href="{xen:link members, $visitor}">{xen:phrase your_profile_page}</a></li>
                </ul>
            </div>

Code:
<!-- account -->
<li class="navTab account Popup PopupControl PopupClosed {xen:if $tabs.account.selected, 'selected'}">
 
<a href="{xen:link account}" class="navLink accountPopup" rel="Menu"><strong>[COLOR=#ff0000]Profile[/COLOR]</strong></a>
 
<div class="Menu JsOnly" id="AccountMenu">
<div class="primaryContent menuHeader">
<xen:avatar user="$visitor" size="m" class="NoOverlay plainImage" title="{xen:phrase view_your_profile}" />
 
<h3><a href="{xen:link members, $visitor}" class="concealed" title="{xen:phrase view_your_profile}">{$visitor.username}</a></h3>
 
<xen:if hascontent="true"><div class="muted"><xen:contentcheck>{xen:helper usertitle, $visitor}</xen:contentcheck></div></xen:if>
 
<ul class="links">
<li class="fl"><a href="{xen:link members, $visitor}">{xen:phrase your_profile_page}</a></li>
</ul>
</div>

This is of course a direct template modification. I believe that all templates except EXTRA.css get molested during an upgrade. My conclusion is that the changes (in the example above) should be done in the EXTRA.css template only. The question is how best to do it? Do I leave the first block of code in the navigation_visitor_tab template without change and then add the second block to Extra.css? This assumes Extra.css is handled last and has priority over all other templates. Should I "comment out" the first block where it resides in navigation_visitor_tab?

EDIT: Not sure why the red highlight did not work. Block 1 "{$visitor.username}" [original] and Block 2 "Profile" [replacement]
 
Be careful to understand the distinction between templates and CSS.

Any "template" ending in ".css" such as EXTRA.css is for styling and only supports Cascading Style Sheet / CSS syntax.

All the other templates are HTML files and only support mostly HTML syntax.

The stuff you've mentioned above is all HTML code and cannot be used in CSS files.

Also, templates aren't "molested" during an upgrade but there needs to be a mechanism for handling changes made between versions by XenForo and customisations you've made yourself.

The compromise is that the updates from XenForo aren't applied and the template that contains your customisations are marked as "outdated".

When you log in to the Admin CP you are notified of Outdated Templates. You then have to go through a process of adding your customisations to the new templates.
 
Interesting. To review: Upgrading marks a modified template as "outdated". The forum operates with the new template and the modification no longer shows to forum users. The admin must then modify the current "new" template so the forum will return to the desired appearance.

This could require a lot of work after an upgrade.
 
Top Bottom