• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

XF 1.3 $contentTemplate conditional?

Floren

Well-known member
#1
Hi,

I changed how the title displays in PAGE_CONTAINER with this conditional:
Code:
    <title><xen:if is="{$title}">
        {xen:raw $title} | {$xenOptions.boardTitle}
    <xen:else />
        <xen:if is="{$contentTemplate} == 'forum_list'">
            {$xenOptions.boardTitle} {xen:phrase forums}
        <xen:elseif is="{$contentTemplate} == 'resource_index'" />
            {$xenOptions.boardTitle} {xen:phrase resources}
        <xen:else />
            {$xenOptions.boardTitle}
        </xen:if>
    </xen:if></title>
For some reason, is not working. Can you please let me know what is the proper format?
 

Chris D

XenForo developer
Staff member
#2
The problem is, the first condition will always be true. {$title} is usually available on every page. I'm guessing the title is always:
Code:
{xen:raw $title} | {$xenOptions.boardTitle}
?

You probably need to change the entire conditional to:

HTML:
<title>
    <xen:if is="{$contentTemplate} == 'forum_list'">
        {$xenOptions.boardTitle} {xen:phrase forums}
    <xen:elseif is="{$contentTemplate} == 'resource_index'" />
        {$xenOptions.boardTitle} {xen:phrase resources}
    <xen:elseif is="{$title}" />
        {xen:raw $title} | {$xenOptions.boardTitle}
    <xen:else />
        {$xenOptions.boardTitle}
    </xen:if>
</title>
 

Floren

Well-known member
#3
The problem is, the first condition will always be true. {$title} is usually available on every page. I'm guessing the title is always:
Code:
{xen:raw $title} | {$xenOptions.boardTitle}
?[/html]
Ya it does, sorry I was not paying attention.
However, on live site (1.3.0) the title is displayed properly with the above mentioned conditional?
https://www.axivo.com/

On my vanilla test forum running on 1.3.1 it does not.
 
Last edited:

Chris D

XenForo developer
Staff member
#4
That's pretty much impossible unless you have changed something else.

{$title} comes from the value set in the <xen:title /> tags you see in pretty much every template. That's what I mean by that condition will always be true because pretty much every single template includes <xen:title> and that's what feeds the {$title} conditional in the template.
 

Floren

Well-known member
#5
Ya, I understand your logic. :)
I'll change it as you suggested, thanks Chris. Honestly I don't remember editing anything related to code and on templates nothing is changed.