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

Show avatars instead of names in online list

Discussion in 'XenForo Questions and Support' started by Trombones13, Dec 7, 2010.

  1. Trombones13

    Trombones13 Well-Known Member

    I've tried figuring this out from the Make Staff Online with no name or title mod without any luck. I would like the Members Online Now sidebar box to show a grid of the avatars of users who are online (like in the mod above for staff), instead of their name. Any ideas on how that's possible would be greatly appreciated. Thanks! :)

    Hopefully this is my last question to pester you all with before I open. hahaha
     
  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    The end result will look like this:

    Screen shot 2010-12-07 at 10.16.51 AM.png

    Edit this template:

    Admin CP -> Appearance -> Templates -> sidebar_online_users

    Find this code towards the bottom:

    Code:
    			<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>
    
    Use this avatar code in place of the username link:

    Code:
    <xen:avatar user="$user" size="s" img="true" />
    
    Like so:

    Code:
    			<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}">
    							<xen:avatar user="$user" size="s" img="true" />
    						<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>
    
    Done.
     
    Corey, luutruong, dieketzer and 3 others like this.
  3. Trombones13

    Trombones13 Well-Known Member

    Ah! I was looking at the correct place, apparently, but couldn't figure out how exactly to replace it. Thanks a lot, Jake!
     
  4. dieketzer

    dieketzer Well-Known Member

    i like the idea of using the avatars, but i had a couple of issues with this. i wanted smaller avs, such as the 'staff online' avs, i didnt want staff from 'staff online' to reappear in 'members online', and i wanted the username tooltip to appear on mouseover.

    i provide perhaps not the most elegant code, but it does the job :)
    replace the pertinent code with:
    PHP:
                    <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="$useri="$i">
                        <
    xen:if is="{$i} <= {$onlineUsers.limit}">

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

    <
    li title="{$user.username}class="Tooltip"><xen:avatar user="$usersize="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:foreach>
                    <
    xen:if is="{$onlineUsers.recordsUnseen}">
     
  5. Peggy

    Peggy Well-Known Member

    I don't like the idea of showing avatars rather than names. IMO that would negate the purpose of the "simplicity" of XenForo.
    Plus, for a very busy site, that would be alot of avatars showing in the sidebar. More graphics = slower load time.
     
  6. dieketzer

    dieketzer Well-Known Member

    a few things to consider:
    the avs are an average of 5KiB in size
    the avs are cached by your regulars
    the number of avs listed is configurable via the acp.
     
  7. Trombones13

    Trombones13 Well-Known Member

    How does the tooltip look when you do that? At a glance, my code looks the same, but the tooltip appears toward the middle of the avatar, which is annoying because it makes it harder to click on the avatar and go to the profile.
     
  8. dieketzer

    dieketzer Well-Known Member

    i overcame that issue.
    one thing i just noticed though, is that my code is listing people you follow in the online as well, which is annoying. i will fix that tomorrow.

    online.png
     
  9. Trombones13

    Trombones13 Well-Known Member

    Oh; I didn't realize that you were using the same size for those images--I have mine currently set to 48x48 (on the Members Online--Followed is still 32x32), so that may be the reason why. :/
     
  10. dieketzer

    dieketzer Well-Known Member

    no, thats not why. it actually took a lot of trial and error to fix that issue.
    im not entirely sure how i got it to finally float.
     
  11. dieketzer

    dieketzer Well-Known Member

Share This Page