jaread83
10 years agoChampion
Online users component query
Hello,
I found a good example of an 'online users' component here and it works exactly how I needed it to. Unfortunately a few users have pointed out that you can't identify between a standard user and mods/admins in the list of avatars that appear. The API in the linked version does not show any data to identify the roles of each online member.
How can I convert the above code sample to bring out the users roles (admin/mod) and apply a class to the user container? Here is the component code I am using:
<#assign users = rest("/users/online/registered?page_size=100").users />
<#if users.user?has_content>
<div class="lia-panel lia-panel-standard users-online-wrapper">
<div class="lia-decoration-border">
<div class="lia-decoration-border-top">
<div> </div>
</div>
<div class="lia-decoration-border-content">
<div>
<div class="lia-panel-heading-bar-wrapper">
<div class="lia-panel-heading-bar">
<span class="lia-panel-heading-bar-title">${text.format("module.users-online.title")}</span>
</div>
</div>
<div class="lia-panel-content-wrapper">
<div class="lia-panel-content">
<div id="customUsersOnline" class="customUsersOnline">
<#list users.user as onlineUser>
<#assign avatar = rest(onlineUser.@href+"/profiles/avatar/size/message").image />
<a href="${onlineUser.@view_href}"><img src="${avatar.url}" title="${onlineUser.login}"></a>
</#list>
</div>
</div>
</div>
</div>
</div>
<div class="lia-view-all">
<a class="lia-link-navigation view-all-link" href="/t5/forums/usersonlinepage">view all</a>
</div>
<div class="lia-decoration-border-bottom">
<div> </div>
</div>
</div>
</div>
</#if>Any help on this would be greatly appreciated!