XF 2.0 Add style template comment to PAGE_CONTAINER

Snog

Well-known member
I'm not a style guru and I've forgotten what they are called. But, it would be nice if style designers could add a comment in the PAGE_CONTAINER template if they change the header section of the template.

Original XF default code:
Code:
<xf:if is="$headerHtml is not empty">
    <div class="p-body-header">
        {$headerHtml|raw}
    </div>
<xf:elseif contentcheck="true" />
    <div class="p-body-header">
    <xf:contentcheck>
        <xf:if contentcheck="true">
            <div class="p-title {{ $noH1 ? 'p-title--noH1' : '' }}">
            <xf:contentcheck>
                <xf:if is="!$noH1">
                    <h1 class="p-title-value">{$h1}</h1>
                </xf:if>
                <xf:if contentcheck="true">
                    <div class="p-title-pageAction"><xf:contentcheck><xf:pageaction /></xf:contentcheck></div>
                </xf:if>
            </xf:contentcheck>
            </div>
        </xf:if>

        <xf:if is="$description is not empty">
            <div class="p-description">{$description}</div>
        </xf:if>
    </xf:contentcheck>
    </div>
</xf:if>

With comment:
Code:
<!--[header]-->
<xf:if is="$headerHtml is not empty">
    <div class="p-body-header">
        {$headerHtml|raw}
    </div>
<xf:elseif contentcheck="true" />
    <div class="p-body-header">
    <xf:contentcheck>
        <xf:if contentcheck="true">
            <div class="p-title {{ $noH1 ? 'p-title--noH1' : '' }}">
            <xf:contentcheck>
                <xf:if is="!$noH1">
                    <h1 class="p-title-value">{$h1}</h1>
                </xf:if>
                <xf:if contentcheck="true">
                    <div class="p-title-pageAction"><xf:contentcheck><xf:pageaction /></xf:contentcheck></div>
                </xf:if>
            </xf:contentcheck>
            </div>
        </xf:if>

        <xf:if is="$description is not empty">
            <div class="p-description">{$description}</div>
        </xf:if>
    </xf:contentcheck>
    </div>
</xf:if>
<!--[/header]-->

Or if you want to take that into the two sections something like this:
Code:
<!--[header]-->
<xf:if is="$headerHtml is not empty">
    <!--[headerHtml]-->
    <div class="p-body-header">
        {$headerHtml|raw}
    </div>
    <!--[/headerHtml]-->
<xf:elseif contentcheck="true" />
    <!--[headerContent]-->
    <div class="p-body-header">
    <xf:contentcheck>
        <xf:if contentcheck="true">
            <div class="p-title {{ $noH1 ? 'p-title--noH1' : '' }}">
            <xf:contentcheck>
                <xf:if is="!$noH1">
                    <h1 class="p-title-value">{$h1}</h1>
                </xf:if>
                <xf:if contentcheck="true">
                    <div class="p-title-pageAction"><xf:contentcheck><xf:pageaction /></xf:contentcheck></div>
                </xf:if>
            </xf:contentcheck>
            </div>
        </xf:if>

        <xf:if is="$description is not empty">
            <div class="p-description">{$description}</div>
        </xf:if>
    </xf:contentcheck>
    </div>
    <!--[/headerContent]-->
</xf:if>
<!--[/header]-->

Adding those would greatly improve compatibility between styles and add-ons if everyone did it. It could be accounted for in template modifications much easier that way.

There are probably more places they could be added, but that one is the biggest thorn right now. ;)
 
If you're wanting to use these for template modifications they won't work if these tags don't exist in the master style
 
If you're wanting to use these for template modifications they won't work if these tags don't exist in the master style
But they will work in styles that have them. ;)

And not work in the ones that don't. (XF itself)

So 2 modifications with execution order set would handle everything.
 
My thinking is (and is generally how I account for Ui.X changes)...

The first modification looks for the header and /header tags. If it finds them, then my modication takes place, the second one would not find what it's looking for and nothing happens with the second one.

If the first one isn't found the second one looks for the default template contents and my modification takes place.
 
Ideally markers like that in XF itself and custom styles in all of the major sections would be terrific.

But that's probably too much to ask. :whistle:
 
But they will work in styles that have them. ;)

Last time I tried doing something like this (in XF1) template modifications would fail completely if the code didn't exist in the master style, even if the code did exist in a child style, so something must've changed since then
 
Last time I tried doing something like this (in XF1) template modifications would fail completely if the code didn't exist in the master style, even if the code did exist in a child style, so something must've changed since then
I do it in XF 1 in some cases too. It's all in the execution order and what it's being replaced with (the replacement can't contain what the second modification is looking for).

Ui.X modification check of PAGE_CONTAINER executes first:
uix.webp

Default code for PAGE_CONTAINER executes second:
xf.webp

The modifications don't apply if what they're looking for doesn't exist.
 
Last edited:
Top Bottom