A little help to hide some categories in forum_list [Conditional inside]

rafass

Member
Hello Friends!
I need a little help to hide certain categories depends of the language selected using this nice conditional:
Code:
<xen:if is="{$visitor.language_id} == x">
Certain Categories / Forums
</xen:if>
In forum_list
Anyone can give me a hand / idea to do this? I've been trying several hours without success.
Appreciate some help. Even I'm willing to pay, if is a little difficult.
Many thanks!​
 
I think you want to do that in these templates..

node_category_level_1
node_category_level_2
node_category_level_n

And I do believe you'll need to add a condition for the node too...
Code:
<xen:if is="{$visitor.language_id} == x && {$category.node_id} == x">
 
Hello Snog! that sound good.
Code:
<xen:require css="node_list.css" />
<xen:require css="node_category.css" />

<li class="node category level_{$level} node_{$category.node_id}" id="{xen:helper linktitle, $category.node_id, $category.title, 1}">

    <div class="nodeInfo categoryNodeInfo categoryStrip">
   
        <div class="categoryText">
            <h3 class="nodeTitle"><a href="{xen:link categories, $category}">{$category.title}</a></h3>
            <xen:if is="{$category.description}"><blockquote class="nodeDescription baseHtml">{xen:raw $category.description}</blockquote></xen:if>
        </div>
       
    </div>
   
    <xen:if is="{$renderedChildren}">       
        <ol class="nodeList">
            <xen:foreach loop="$renderedChildren" value="$child">{xen:raw $child}</xen:foreach>
        </ol>
    </xen:if>
   
    <span class="tlc"></span>
    <span class="trc"></span>
    <span class="blc"></span>
    <span class="brc"></span>
</li>
Code:
<xen:require css="node_list.css" />
<xen:require css="node_category.css" />

<li class="node category_forum level_{$level} node_{$category.node_id}">

    <div class="nodeInfo categoryForumNodeInfo {xen:if $category.hasNew, 'unread'}">

        <span class="nodeIcon" title="{xen:if $category.hasNew, '{xen:phrase unread_messages}', ''}"></span>

        <div class="nodeText">
            <h3 class="nodeTitle"><a href="{xen:link categories, $category}" data-description="{xen:if @nodeListDescriptionTooltips, '#nodeDescription-{$category.node_id}'}">{$category.title}</a></h3>

            <xen:if is="{$category.description} AND @nodeListDescriptions">
                <blockquote class="nodeDescription {xen:if @nodeListDescriptionTooltips, nodeDescriptionTooltip} baseHtml" id="nodeDescription-{$category.node_id}">{xen:raw $category.description}</blockquote>
            </xen:if>

            <div class="nodeStats pairsInline">
                <dl><dt>{xen:phrase discussions}:</dt> <dd>{xen:if $category.privateInfo, '&ndash;', {xen:number $category.discussion_count}}</dd></dl>
                <dl><dt>{xen:phrase messages}:</dt> <dd>{xen:if $category.privateInfo, '&ndash;', {xen:number $category.message_count}}</dd></dl>
                <xen:if is="{$renderedChildren} AND @nodeListSubForumPopup">
                    <div class="Popup subForumsPopup">
                        <a href="{xen:link categories, $category}" rel="Menu" class="cloaked" data-closemenu="true"><span class="dt">{xen:phrase sub_forums}:</span> {xen:number $category.childCount}</a>
                       
                        <div class="Menu JsOnly subForumsMenu">
                            <div class="primaryContent menuHeader">
                                <h3>{$category.title}</h3>
                                <div class="muted">{xen:phrase sub_forums}</div>
                            </div>
                            <ol class="secondaryContent blockLinksList">
                            <xen:foreach loop="$renderedChildren" value="$child">
                                {xen:raw $child}
                            </xen:foreach>
                            </ol>
                        </div>
                    </div>
                </xen:if>
            </div>
           
            {xen:raw $nodeExtraHtml}
        </div>

        <xen:if is="{$renderedChildren} AND !@nodeListSubForumPopup">
            <ol class="subForumList">
            <xen:foreach loop="$renderedChildren" value="$child">
                {xen:raw $child}
            </xen:foreach>
            </ol>
        </xen:if>

        <div class="nodeLastPost secondaryContent">
            <xen:if is="{$category.privateInfo}">
                <span class="noMessages muted">({xen:phrase private})</span>
            <xen:elseif is="{$category.lastPost.date}" />
                <span class="lastThreadTitle"><span>{xen:phrase latest}:</span> <a href="{xen:link posts, $category.lastPost}" title="{$category.lastPost.title}">{$category.lastPost.title}</a></span>
                <span class="lastThreadMeta">
                    <span class="lastThreadUser"><xen:if is="{xen:helper isIgnored, $category.last_post_user_id}">{xen:phrase ignored_member}<xen:else /><xen:username user="$category.lastPost" /></xen:if>,</span>
                    <xen:datetime time="$category.lastPost.date" class="muted lastThreadDate" data-latest="{xen:phrase latest}: " />
                </span>
            <xen:else />
                <span class="noMessages muted">({xen:phrase contains_no_messages})</span>
            </xen:if>
        </div>

    </div>

</li>
Code:
<li class="node category level-n node_{$category.node_id}">
    <div {xen:if $category.hasNew, 'class="unread"'}>
        <h4 class="nodeTitle"><a href="{xen:link categories, $category}" class="menuRow">{$category.title}</a></h4>
    </div>
    <xen:if is="{$renderedChildren}">
        <ol>
            <xen:foreach loop="$renderedChildren" value="$child">
                {xen:raw $child}
            </xen:foreach>
        </ol>
    </xen:if>
</li>

You must validate your XenForo license to see quoted content
That conditional looks really cool! anyway I've working with this with easy and small elements / templates (and works like a charm)
But I'm lost with the templates above.
I have ready my ACP with the categories / languages. if you want to make tests there with this templates. (if you can give me a hand on it)
Appreciate so much your help Snog!
 
You would want to put the if statement before the <li ... and the /xen:if after the </li>

Code:
<xen:require css="node_list.css" />
<xen:require css="node_category.css" />
<xen:if is="{$visitor.language_id} == x && {$category.node_id} == x">
<li class="node category level_{$level} node_{$category.node_id}" id="{xen:helper linktitle, $category.node_id, $category.title, 1}">

   <div class="nodeInfo categoryNodeInfo categoryStrip">

     <div class="categoryText">
       <h3 class="nodeTitle"><a href="{xen:link categories, $category}">{$category.title}</a></h3>
       <xen:if is="{$category.description}"><blockquote class="nodeDescription baseHtml">{xen:raw $category.description}</blockquote></xen:if>
     </div>
  
   </div>

   <xen:if is="{$renderedChildren}">  
     <ol class="nodeList">
       <xen:foreach loop="$renderedChildren" value="$child">{xen:raw $child}</xen:foreach>
     </ol>
   </xen:if>

   <span class="tlc"></span>
   <span class="trc"></span>
   <span class="blc"></span>
   <span class="brc"></span>
</li>
</xen:if>

You can also change the category part to a list of categories by doing this..
Code:
<xen:if is="{$visitor.language_id} == x && in_array({$category.node_id} , array(1,2,3,4,5,etc))">

But I am at a loss as to why you would want to hide categories based on language. I think that's an unwise thing to do. What will unregistered users see? Nothing?
 
Why don't you just use the built in promotion system and add people to a different user group based on their language? Then set the permissions for the forums based on that.
 
Awesome! This is almost done!!
The language #1 (English) are showing only the category #1 (English Zone) that's perfect! :)
Now, how to add the other conditional to the language #2 (Spanish) to show only the category #2 (Spanish Zone) ?
I guess I have to use xen:elseif ? I have this now:
Code:
<xen:if is="{$visitor.language_id} == 1 && {$category.node_id} == 1">
TEMPLATE [Category 1]
</xen:if>
how to include the second conditional there?
Code:
<xen:if is="{$visitor.language_id} == 2 && {$category.node_id} == 2">
TEMPLATE [Category 2]
</xen:if>
--
Regarding the questions:
You must validate your XenForo license to see quoted content
Because each category will contain forums in a specific language.

English Zone [Category]
---English 1 [Forum]
---English 2 [Forum]
Spanish Zone [Category]
---Spanish 1 [Forum]
---Spanish 2 [Forum]

So, depending of the language selected you will see only the that specific language. if you know other languages and you want to take a look at these categories, just have to switch the language. :)

You must validate your XenForo license to see quoted content
The system of user promotions has been discarded for various reasons many days ago.

This new way is absolutely fantastic! I'll show you the result and you will see ;)
 
Don't use the else, I think an OR (||) will work.

Code:
<xen:if is="({$visitor.language_id} == 1 && {$category.node_id} == 1) || ({$visitor.language_id} == 2 && {$category.node_id} == 2)">
 
Snog, YOU ROCK!
It works absolutely perfect! clapclap.gif
Donation sent!
Screen Shot 2015-06-09 at 6.20.45 AM.png
Thank you sooooooo much for your help! clapclap.gif