• 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

Trombones13

Well-known member
#1
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
 

Jake Bunce

XenForo moderator
Staff member
#2
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.
 

dieketzer

Well-known member
#4
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="$user" i="$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="$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:foreach>
                <xen:if is="{$onlineUsers.recordsUnseen}">
 

Peggy

Well-known member
#5
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.
 

dieketzer

Well-known member
#6
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.
 

Trombones13

Well-known member
#7
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:
code
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.
 

dieketzer

Well-known member
#8
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
 

Trombones13

Well-known member
#9
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. :/