The Staff Online Now Block

HTML:
<xen:if hascontent="true">
    <div class="section staffOnline avatarList">
        <div class="secondaryContent">
            <h3>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" />
                                <a href="{xen:link members, $user}" class="username">{$user.username}</a>
                                <div class="muted">{xen:helper userTitle, $user}</div>
                            </li>
                        </xen:if>
                    </xen:foreach>
                </xen:contentcheck>
            </ul>
        </div>
    </div>
</xen:if>
A first glimpse of XenForo template syntax for you...
Correct me if I'm wrong, but from the code it looks like it's looping through the entire online users table and checking if each user is a mod or admin.

Doesn't this seem like quite a lot of overhead to be running on each pageload? What happens when you get into the thousands of users (online)? :)

I should be clear that I do love the template syntax here, I'm just worried about the scalability of this particular piece. :)
 
Judging from the fact that you named your variables $onlineUsers, you guys have adopted some kind of coding standard like camelcase?

Which one is better

$isModerator();

or

$is_moderator();
 
We have 31 staff, of which maybe 10 are online at any one time. Just looking at the code that Kier posted, it seems it's possible to remove the avatars - that would enable the info to be displayed in more of a list format, which would work for us :)
 
Top Bottom