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

Category Conditional Problem

pjfry

Active member
#1
Hi

I have a little Problem with an conditional. I hab a look at Brogans FAQ (Thanks for that!) and found this one:

Code:
How can I show content in a specific category?
<xen:if is="{$category.node_id} == x">
This content will show in category x
</xen:if>
Note that in order for this to work, you must have categories set as pages in the ACP -> Options -> Node & Forum List: Create Pages for Categories.
This is exactly what I need. So I tried this for my Logo to change depending in which category the visitors are. This is my code in the logo_block template:

HTML:
<xen:if is="{$category.node_id} == 54">
<div id="logo"><a href="/categories/world-of-warcraft.54/">
                <span><xen:comment>This span fixes IE vertical positioning</xen:comment></span>
                <img src="/styles/onlinegilde/wow_logo.png" alt="{$xenOptions.boardTitle}" />
            </a></div>
<xen:elseif is="{$category.node_id} == 39" />
<div id="logo"><a href="/categories/world-of-warcraft.54/">
                <span><xen:comment>This span fixes IE vertical positioning</xen:comment></span>
                <img src="/styles/onlinegilde/d3_logo.png" alt="{$xenOptions.boardTitle}" />
            </a></div>
<xen:else />
<div id="logo"><a href="{$logoLink}">
                <span><xen:comment>This span fixes IE vertical positioning</xen:comment></span>
                <img src="@headerLogoPath" alt="{$xenOptions.boardTitle}" />
            </a></div>
But it do not work. I tried to change the logo for a specific forum with this code:

HTML:
<xen:if is="{$forum.node_id} == 26">
<div id="logo"><a href="/categories/world-of-warcraft.54/">
                <span><xen:comment>This span fixes IE vertical positioning</xen:comment></span>
                <img src="/styles/onlinegilde/wow_logo.png" alt="{$xenOptions.boardTitle}" />
            </a></div>
<xen:else />
<div id="logo"><a href="{$logoLink}">
                <span><xen:comment>This span fixes IE vertical positioning</xen:comment></span>
                <img src="@headerLogoPath" alt="{$xenOptions.boardTitle}" />
            </a></div>
And that worked. So is there a XenForo Problem with the category conditional or do I miss something?

Thanks for help!

Benny
 
F

Floris

Guest
#2
The string might not be available in the header template, you can always set a var for it in the template where it works, and use that in the header template.

But the difference between forum id and category id, I will always use forum id.
Categories will probably only work when you have the option set to make a page for categories rather than an anchor link.
 

pjfry

Active member
#3
Hi Floris,

thanks for your help! The hint with the variable and container was great. Now all works fine!

Thanks! Benny