XenForo Style changer

</clown>

Loyal Member
Template modification:

Template: PAGE_CONTAINER
Modification key: style_changer
Description: Style changer
Search type: simple replacement
Find:
HTML:
<div class="p-navgroup p-discovery{{ !$xf.visitor.canSearch() ? ' p-discovery--noSearch' : '' }}">
Replace:
HTML:
<xf:set var="$styleLight" value="3" /> <xf:comment>Light style. Specify the id of the style in the value.</xf:comment>
<xf:set var="$styleDark" value="2" /> <xf:comment>Dark style. Specify the id of the style in the value.</xf:comment>
<xf:set var="$styleTitle">
    <xf:if is="$xf.style.style_id == $styleLight">
        {{ {$xf.language.language_code} == 'ru-RU' ? 'Включить темный стиль' : 'Enable dark style' }}
    <xf:elseif is="$xf.style.style_id == $styleDark" />
        {{ {$xf.language.language_code} == 'ru-RU' ? 'Включить светлый стиль' : 'Enable light style' }}
    </xf:if>
</xf:set>

<xf:if is="$xf.visitor.canChangeStyle()">
    <div class="p-navgroup p-discovery">
        <a href="{{ link('misc/style', null, {
                'style_id': $xf.style.style_id == $styleLight ? $styleDark : $styleLight,
                '_xfRedirect': $redirect,
                't': csrf_token()
            }) }}"
            class="p-navgroup-link style-changer"
            data-xf-init="tooltip" title="{$styleTitle}">
            <span class="style{{ $xf.style.style_id == $styleLight ? '-light' : '-dark' }}"></span>
        </a>
    </div>
</xf:if>
$0

Two modification:

Template: extra.less
Modification key: style_changer_less
Description: Style changer
Search type: Regular expression
Find:
HTML:
#^.*$#su
Replace:

CSS:
$0
.p-navgroup-link.style-changer {
    span {
        &:before {
            .m-faBase();
        }
        &.style-light:before {
            .m-faContent(@fa-var-lightbulb-on);
        }
        &.style-dark:before {
            .m-faContent(@fa-var-lightbulb);
        }
    }
}

Result:
image.png
 
Last edited:
Back
Top Bottom