Conditional Statements

Conditional Statements

Is there a conditional statement to check if the user has an active user upgrade with a specific id? For example:

Code:
<xen:if is="{$purchased.user_upgrade_id} == 5">
Show this to users with user upgrade id 5
</xen:if>
 
Does the user upgrade add them to a user group?

If so, it's probably best to just check for that.
 
Yes, but they are all added to the same group, that's why I want to check for the user upgrade id.
 
I don't believe that is something which is available, but you can use this to dump the variable in the template to see if there is something you can use:
Code:
{xen:helper dump, $user}

{xen:helper dump, $visitor}

Depending on what you are trying to do, you may need to use $user or $visitor.
 
Code:
<xen:if is="{$visitor.user_id}"><xen:if is="!{xen:helper ismemberof, $visitor, 12}">content here</xen:if></xen:if>

The above code works fine. "content here" is only shown to logged-in members who don't belong to user group id 12.

But is that the most effective way to achieve that? Two xen if is one after another?

Can I somehow combine those xen if's into one? How? Is it worth it?
 
You can combine statements using AND and OR.
There are examples in the resource.

It won't really make much difference though.
 
I made 2 banners (with the help of @Russ ) and using conditionals set one that members see and the other is for guests... It is in the "ad_top_content" template, but I would like to make it where the banner for members is ONLY on the forum_list.

I tried adding AND "{$contentTemplate} == 'forum_list'" but it returns an error.. Im guessing you cannot use AND along with elseif ?
Code:
<xen:if is="!{$visitor.user_id}">
<div class="xbNoticeWrapper2">
   <div class="xbNoticeInner">
     <div class="xbNoticeContent">
       <h2>Welcome to Next Chapter Gaming</h2>
       <h6>A community by ADULT gamers, for ADULT gamers!</h6>         
       <a class="button" href="{xen:link 'register'}">Register Now</a>
     </div>
   </div>
</div>
<xen:else />
<div class="xbNoticeWrapper">
   <div class="xbNoticeInner">
     <div class="xbNoticeContent">
       <h2>Ready for Beer 30?</h2>
       <h6>Be sure to check out who's hosting and what time!</h6>         
       <a class="button" href="http://nextchaptergaming.com/forums/beer-30-night-info.54/">Beer 30 Mega-Thread</a>
     </div>
   </div>
</div>
</xen:if>

Any Ideas?
 
You use them in the appropriate template, depending on what you are trying to achieve.
 
How can I do an if statement or check to see if it's the forum homepage index, forum display, but not display the actual thread

I was thinking !=thread along those lines....however I'm a little bit lost there at the moment.
 
If I write a conditional to see if the thread is in a certain forum can I check the parent forum or would I need to check it against all of the child forums?
 
I need the conditional to *hide* content from a new member who is not yet manually approved. Thanks!! :D
 
Hello,
I've tried and tried but cannot hide staff online, to guests?
I managed to hide members online over a year ago, but using the same conditional statement I can't hide staff.. Is there a different way to do this?
Here's my code, I hope someone can help as I have tried but can't crack it for some reason;
Code:
<xen:if is="{$visitor.user_id}">
<xen:edithint template="sidebar.css" />

<!-- block: sidebar_online_staff -->
<xen:if is="{$visitor.user_id}">
<xen:if hascontent="true">
    <div class="section staffOnline avatarList">
        <div class="secondaryContent">
            <h3>{xen:phrase staff_online_now}</h3>
            <ul>
                <xen:contentcheck>
                    <xen:foreach loop="$onlineUsers.records" value="$user">
                        <xen:if is="{$user.is_moderator} OR {$user.is_admin}">
                            <li>
                                <xen:avatar user="$user" size="s" img="true" />
                                <xen:username user="$user" rich="true" />
                                <div class="userTitle">{xen:helper userTitle, $user}</div>
                            </li>
                        </xen:if>
                    </xen:foreach>
                </xen:contentcheck>
            </ul>
        </div>
    </div>
</xen:if>
</xen:if>
<!-- end block: sidebar_online_staff -->

<!-- block: sidebar_online_users -->
<div class="section membersOnline userList">      
    <div class="secondaryContent">
        <h3><a href="{xen:link online}" title="{xen:phrase see_all_online_users}">{xen:phrase members_online_now}</a></h3>
      
        <xen:if is="{$onlineUsers.records}">
      
            <xen:if is="{$visitor.user_id}">
                <xen:if hascontent="true">
                <h4 class="minorHeading"><a href="{xen:link account/following}">{xen:phrase people_you_follow}:</a></h4>
                <ul class="followedOnline">
                    <xen:contentcheck>
                        <xen:foreach loop="$onlineUsers.records" value="$user">
                            <xen:if is="{$user.followed}">
                                <li title="{$user.username}" class="Tooltip"><xen:avatar user="$user" size="s" img="true" class="_plainImage" /></li>
                            </xen:if>
                        </xen:foreach>
                    </xen:contentcheck>
                </ul>
                <h4 class="minorHeading"><a href="{xen:link members}">{xen:phrase members}:</a></h4>
                </xen:if>
            </xen:if>
          
            <ol class="listInline">
                <xen:foreach loop="$onlineUsers.records" value="$user" i="$i">
                    <xen:if is="{$i} <= {$onlineUsers.limit}">
                        <li>
                        <xen:if is="{$user.user_id}">
                            <a href="{xen:link members, $user}"
                                class="username{xen:if '!{$user.visible}', ' invisible'}{xen:if {$user.followed}, ' followed'}">{$user.username}</a><xen:if is="{$i} < {$onlineUsers.limit}">,</xen:if>
                        <xen:else />
                            {xen:phrase guest}<xen:if is="{$i} < {$onlineUsers.limit}">,</xen:if>
                        </xen:if>
                        </li>
                    </xen:if>
                </xen:foreach>
                <xen:if is="{$onlineUsers.recordsUnseen}">
                    <li class="moreLink">... <a href="{xen:link online}" title="{xen:phrase see_all_visitors}">{xen:phrase and_x_more, 'count={xen:number $onlineUsers.recordsUnseen}'}</a></li>
                </xen:if>
            </ol>
        </xen:if>
      
        <div class="footnote">
            {xen:phrase online_now_x_members_y_guests_z_robots_a, 'total={xen:number $onlineUsers.total}', 'members={xen:number $onlineUsers.members}', 'guests={xen:number $onlineUsers.guests}', 'robots={xen:number $onlineUsers.robots}'}
        </div>
    </div>
</div>
<!-- end block: sidebar_online_users -->
</xen:if>

I even followed this but meh, can't get it going. Just wondering if I have missed something. :confused:
https://xenforo.com/community/threads/remove-admin-user-from-staff-online-now-sidebar.36040/
 
Hello,
I've tried and tried but cannot hide staff online, to guests?
I managed to hide members online over a year ago, but using the same conditional statement I can't hide staff.. Is there a different way to do this?
Here's my code, I hope someone can help as I have tried but can't crack it for some reason;
Code:
<xen:if is="{$visitor.user_id}">
<xen:edithint template="sidebar.css" />

<!-- block: sidebar_online_staff -->
<xen:if is="{$visitor.user_id}">
<xen:if hascontent="true">
    <div class="section staffOnline avatarList">
        <div class="secondaryContent">
            <h3>{xen:phrase staff_online_now}</h3>
            <ul>
                <xen:contentcheck>
                    <xen:foreach loop="$onlineUsers.records" value="$user">
                        <xen:if is="{$user.is_moderator} OR {$user.is_admin}">
                            <li>
                                <xen:avatar user="$user" size="s" img="true" />
                                <xen:username user="$user" rich="true" />
                                <div class="userTitle">{xen:helper userTitle, $user}</div>
                            </li>
                        </xen:if>
                    </xen:foreach>
                </xen:contentcheck>
            </ul>
        </div>
    </div>
</xen:if>
</xen:if>
<!-- end block: sidebar_online_staff -->

<!-- block: sidebar_online_users -->
<div class="section membersOnline userList">     
    <div class="secondaryContent">
        <h3><a href="{xen:link online}" title="{xen:phrase see_all_online_users}">{xen:phrase members_online_now}</a></h3>
     
        <xen:if is="{$onlineUsers.records}">
     
            <xen:if is="{$visitor.user_id}">
                <xen:if hascontent="true">
                <h4 class="minorHeading"><a href="{xen:link account/following}">{xen:phrase people_you_follow}:</a></h4>
                <ul class="followedOnline">
                    <xen:contentcheck>
                        <xen:foreach loop="$onlineUsers.records" value="$user">
                            <xen:if is="{$user.followed}">
                                <li title="{$user.username}" class="Tooltip"><xen:avatar user="$user" size="s" img="true" class="_plainImage" /></li>
                            </xen:if>
                        </xen:foreach>
                    </xen:contentcheck>
                </ul>
                <h4 class="minorHeading"><a href="{xen:link members}">{xen:phrase members}:</a></h4>
                </xen:if>
            </xen:if>
         
            <ol class="listInline">
                <xen:foreach loop="$onlineUsers.records" value="$user" i="$i">
                    <xen:if is="{$i} <= {$onlineUsers.limit}">
                        <li>
                        <xen:if is="{$user.user_id}">
                            <a href="{xen:link members, $user}"
                                class="username{xen:if '!{$user.visible}', ' invisible'}{xen:if {$user.followed}, ' followed'}">{$user.username}</a><xen:if is="{$i} < {$onlineUsers.limit}">,</xen:if>
                        <xen:else />
                            {xen:phrase guest}<xen:if is="{$i} < {$onlineUsers.limit}">,</xen:if>
                        </xen:if>
                        </li>
                    </xen:if>
                </xen:foreach>
                <xen:if is="{$onlineUsers.recordsUnseen}">
                    <li class="moreLink">... <a href="{xen:link online}" title="{xen:phrase see_all_visitors}">{xen:phrase and_x_more, 'count={xen:number $onlineUsers.recordsUnseen}'}</a></li>
                </xen:if>
            </ol>
        </xen:if>
     
        <div class="footnote">
            {xen:phrase online_now_x_members_y_guests_z_robots_a, 'total={xen:number $onlineUsers.total}', 'members={xen:number $onlineUsers.members}', 'guests={xen:number $onlineUsers.guests}', 'robots={xen:number $onlineUsers.robots}'}
        </div>
    </div>
</div>
<!-- end block: sidebar_online_users -->
</xen:if>

I even followed this but meh, can't get it going. Just wondering if I have missed something. :confused:
https://xenforo.com/community/threads/remove-admin-user-from-staff-online-now-sidebar.36040/
and you didn't use BD Widget?
 
Top Bottom