Template Question (Logic)

gwinans

Active member
Howdy.

I'm using this block for sidebar_online_users:
Code:
<xen:edithint template="sidebar.css" />

<xen:if hascontent="true">
    <!-- block: sidebar_online_staff -->
    <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>
<!-- 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="followedOnline">
                <xen:foreach loop="$onlineUsers.records" value="$user" i="$i">
                    <xen:if is="{$i} <= {$onlineUsers.limit}">
                  <xen:if is="!{$user.is_moderator} OR !{$user.is_admin}">
                  <xen:if is="!{$user.followed}">
                            <xen:if is="{$user.user_id}">
                  <li title="{$user.username}" class="Tooltip"><xen:avatar user="$user" size="s" img="true" class="_plainImage" /></li>
                <xen:else />
                                {xen:phrase guest}<xen:if is="{$i} < {$onlineUsers.limit}">,</xen:if>
                            </xen:if>
              </xen:if>
              </xen:if>
                    </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, 'total={xen:number $onlineUsers.total}', 'members={xen:number $onlineUsers.members}', 'guests={xen:number $onlineUsers.guests}'}
        </div>
    </div>
</div>
<!-- end block: sidebar_online_users -->

As far as I can tell, with this line of code - moderators should not display in the Members Online list:
Code:
 <xen:if is="!{$user.is_moderator} OR !{$user.is_admin}">

They, however, are.

All of the Staff members that show up in the member list are tagged as Super Moderators in the backend and are part of the Moderator ranked group (for css coloring of names).

Is 'is_moderator' appropriate for this or is there another ... check for superadmins?

I tried adding this to the above noted line:
Code:
!{$user.user_group_id} == 4

No bueno.
 
As far as I can tell, with this line of code - moderators should not display in the Members Online list:

Code:
<xen:if is="!{$user.is_moderator} OR !{$user.is_admin}">

Not quite. By that logic, a moderator who is not an admin will display.

I think you want this:

Code:
<xen:if is="!{$user.is_moderator} AND !{$user.is_admin}">
 
Even updating that line to:

Code:
<xen:if is="!{$user.is_moderator} AND !{$user.is_admin} AND !{$user.user_group_id} == 4">

.. I still see users in group 4 listed in the "Members online".

Is my logic wrong? I come from a decently extensive development background and this makes sense to me.
 
Well in the example above, my primary group is Registered (2) and my secondary groups are Administrative and Moderating.
I'm also an Adminstrator and a moderator.
 
Huh. Well, color me stumped. That same codeblock still shows a user that is a Moderator (group 4 and promoted as a Super Moderator) in the Members online list along with the Staff Online list.

The logic block looks sound. I did find that I was modifying the wrong sidebar file, but modifying the correct one still had no impact on the result.
 
Are you by any chance following the members in question?

I just did some quick tests and if you follow them they still show in the Members Online Now block in the People You Follow section.
 
I'm actually intentionally logged out to avoid that.

I may have had a cached template, it appears to be working now. Next goal is to change the bottom so it shows:

Online Now: ## (Staff: #, RankX #, RankZ #)

Shouldn't be too hard. Danke for the help gents.
 
Top Bottom