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

Conditional tags

A.Chakery

Active member
#1
Hello,

I need some conditional tags as below :

1- <If This is a Thread> SHOW THIS CODE</if>
2-<If This is a Forum> SHOW THIS CODE</if>

Any help is appreciated ...


thank you
 

Chris D

XenForo developer
Staff member
#2
Code:
<xen:if is="{$controllerName} == 'XenForo_ControllerPublic_Thread'">
Code to show in thread
</xen:if>
Code:
<xen:if is="{$controllerName} == 'XenForo_ControllerPublic_Forum'">
Code to show in forum
</xen:if>
Should do it ;)
 

A.Chakery

Active member
#3
Thank you very much .. but they didn't work ..

Actually I need them to use H1 codes in it like below :

Code:
                                <xen:if is="{$controllerName} == 'XenForo_ControllerPublic_Thread'">
                                <h1 class="itemLabel">{xen:helper threadPrefix, $thread}{$thread.title}</h1>
                                </xen:if>
                                <xen:if is="{$controllerName} == 'XenForo_ControllerPublic_Forum'">
                                <h1 class="itemLabel">{$forum.title}</h1>
                                </xen:if>
                                <xen:if is="{$controllerName} == 'XenForo_ControllerPublic_Page'">
                                <h1 class="itemLabel">{$page.title}</h1>
                                </xen:if>
do you have any idea how to do it ?


thank you
 

Jake Bunce

XenForo moderator
Staff member
#4
What template are you using the conditions in? Are you editing the PAGE_CONTAINER?

You probably need to use xen:container as the node / thread records aren't always made available to the container. For example:

Admin CP -> Appearance -> Templates -> forum_view

Add this line to the top of the template:

Code:
<xen:container var="$h1Title">{$forum.title}</xen:container>
Admin CP -> Appearance -> Templates -> thread_view

Add this line to the top of the template:

Code:
<xen:container var="$h1Title">{$thread.title}</xen:container>
That will pass the forum or thread title to the container as $h1Title such that you can use code like this in PAGE_CONTAINER:

Code:
<xen:if is="{$h1Title}">
<h1 class="itemLabel">{$h1Title}</h1>
</xen:if>
But having said that, there is already h1 code in the PAGE_CONTAINER, and values are already passed to it from the content templates (e.g. forum_view and thread_view) using a special xen:h1 tag:

Code:
<xen:h1>{$forum.title}</xen:h1>
So what you are trying to do might be redundant.
 

A.Chakery

Active member
#5
Thank you for the reply ... no I am trying to put it in the header ...

and then I wanna change the current H1 codes to H2 ....
 

A.Chakery

Active member
#7
actually I am editing the header_bar template


(its located at the top of the screen)...

so how should I edit it ?

Thank you
 

Jake Bunce

XenForo moderator
Staff member
#8
If that template is included by PAGE_CONTAINER or header then it is still in the container scope. Anything to do with the header is probably in the container scope, so the xen:container stuff still applies.
 

A.Chakery

Active member
#11
thank you very much .. it worked great ...

Another question : (sorry if I am asking too much :) )

Would you please tell me how can I change the default XF H1 tags into H2 ?

thanks