Active Users by Section

rated by 0 users
This post has 3 Replies | 2 Followers

Not Ranked
Posts 17
Points 265
Zshazlez Posted: Tue, Apr 15 2008 5:19 PM

I am looking at getting the online users who are active in the section the current user is viewing.  Basically, if I am in forum  "Forums » Community Server 2008 » Developers" I want to know who else is viewing it at the same time as me.  So, I was looking at using <CSControl:UserOnlineList> and within it using a <CSControl:UserOnlinePropertyValueComparison> in a <DisplayConditions> to control the location.  So, it would look something like (which I copied from the bottom of the old grouplist.aspx):

<CSControl:UserOnlineList runat="server" ShowHeaderFooterOnNone="false">
    <LeaderTemplate>
        <div class="CommonInlineMessageArea">
            <div class="CommonInlineMessageContent">
                <CSControl:UsersOnlineData ID="UsersOnlineData1" runat="server" Property="GuestCount" ResourceName="WhoIsOnlineView_GuestUsers" />
                <CSControl:UsersOnlineData ID="UsersOnlineData2" runat="server" Property="MemberCount" ResourceName="WhoIsOnlineView_UsersOnlineCount" />
    </LeaderTemplate>
    <QueryOverrides QueryType="AuthenticatedUsers" PageSize="999" />
 <HeaderTemplate>- </HeaderTemplate>
 <ItemTemplate>
     <CSControl:UserOnlineData ID="UserOnlineData1" runat="server" Property="DisplayName" LinkTo="Profile">
         <DisplayConditions>
             <CSControl:UserOnlinePropertyValueComparison runat="server"  ComparisonProperty="Location" ComparisonValue="SomeLocation" Operator="EqualTo" />
         </DisplayConditions>
     </CSControl:UserOnlineData>
 </ItemTemplate>
    <SeparatorTemplate>, </SeparatorTemplate>
    <NoneTemplate></NoneTemplate>
    <TrailerTemplate>
            </div>
        </div>
    </TrailerTemplate>
</CSControl:UserOnlineList>

My problem is, I don't know what to set the ComparisonProperty to.  I was hoping that just by including it in the grouplist control that it would know what it's data source was, but it doesn't seem to.  Has anyone done anything like this before?  Have any solutions?

Top 10 Contributor
Posts 3,424
Points 65,735
CS Developers
Ben Tiedt replied on Tue, Apr 15 2008 5:37 PM

What you want to compare to is the current page's URL (which, depending on the location of this markup, is dynamic).  I'd suggest using a <CSControl:CustomCondtion /> condition control, such as in the following:


<CSControl:UserOnlineList runat="server">
  <ItemTemplate>
    <CSControl:UserOnlineData runat="server" Property="DisplayName">
      <DisplayConditions><CSControl:CustomCondition runat="server" CustomResult='<%# Eval("Link").ToString() == CommunityServer.Components.CSContext.Current.RawUrl %>' /></DisplayConditions>
    </CSControl:UserOnlineData>
  </ItemTemplate>
</CSControl:UserOnlineList>

This will only render DisplayNames for online users that are viewing the same page as the current user.

Ben Tiedt's Blog

  • | Post Points: 20
Not Ranked
Posts 17
Points 265
Zshazlez replied on Wed, Apr 16 2008 11:15 AM

 Thanks Ben!

Is there a way to utilize this to tell me how many people are in a specific section?  Right now, if I have users looking at a thread in a specific forum, I'd like to know that they're in that forum, not just that thread.  If this is not directly possible, is there an object that I can use that will give a path of where the user is?  Kind of like the functionality in the bread crumbs object?

  • | Post Points: 20
Top 10 Contributor
Posts 3,424
Points 65,735
CS Developers
Ben Tiedt replied on Wed, Apr 16 2008 12:59 PM

Zshazlez:
Is there a way to utilize this to tell me how many people are in a specific section?
 

Not using the UserOnline object, no.  The UserOnline object stores the name and URL of the page the user last loaded -- to determine the section, not only would you need to know the section the current user is on, but also how to interpret every URL relating to a section into a section.

One *potential* option would be to add code to all pages within a section and call

CommunityServer.Components.Section section = CommunityServer.Controls.CSControlUtility.Instance().GetCurrentSection(this);
if (section != null)
   CommunityServer.Components.UsersOnline.SetLocation(section.Name, section.Url);

This will set the user's location to the section's home page (instead of the specific page within the section) if the user is within the context of a Section.  Then, the following <CSControl:UserOnlineList /> could be used to show other users looking at the same section:

<CSControl:UserOnlineList runat="server">
  <ItemTemplate>
    <CSControl:UserOnlineData runat="server" Property="DisplayName">
      <DisplayConditions><CSControl:CustomCondition runat="server" CustomResult='<%# Eval("Link").ToString() == (CommunityServer.Controls.CSControlUtility.Instance().GetCurrentSection(this) == null ? CommunityServer.Components.CSContext.Current.RawUrl : CommunityServer.Controls.CSControlUtility.Instance().GetCurrentSection(this).Url) %>' /></DisplayConditions>
    </CSControl:UserOnlineData>
  </ItemTemplate>
</CSControl:UserOnlineList>


Ben Tiedt's Blog

  • | Post Points: 5
Page 1 of 1 (4 items) | RSS
Powered by Community Server (Commercial Edition), by Telligent Systems

Copyright© 2008 Telligent Systems Inc. All rights reserved
CommunityServer.com  •  Telligent.com