Conditional tags

A.Chakery

Active member
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
 
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 ;)
 
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
 
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.
 
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.
 
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
 
Top Bottom