Display # of users in chat on forum home page

Last post 12-24-2007, 7:43 AM by cutechat. 9 replies.
Sort Posts: Previous Next
  •  11-25-2007, 7:20 PM 35357

    Display # of users in chat on forum home page

    Hi,
    I've just upgraded to V4 and was told in this version we could have the users online display on our forums (I'm using Snitz).
    I was wondering what code, or how I would go about doing this?

  •  11-25-2007, 7:29 PM 35359 in reply to 35357

    Re: Display # of users in chat on forum home page

    Sorry I had to edit my post.. but I do still need to know if this is possible and how
  •  11-26-2007, 12:01 PM 35374 in reply to 35357

    Re: Display # of users in chat on forum home page

    You can do this way :
     
    modify the inc_footer.asp # 70 :

    Response.Write "<script src='ChatterListScript.aspx'></script>"
     
    and then create a new file ChatterListScript.aspx , fill this code into it :
     

    <%@ Page Language="C#" %>
    <%@ Import Namespace="CuteChat" %>
    <script runat=server>
    static string Encode(string val)
    {
     if(val==null)return "";
     return val.Replace("\\","\\\\").Replace("\"","\\\\");
    }
    </script>

    var onlineusers=[];

    <%
    ChatPortal portal=ChatSystem.Instance.GetCurrentPortal();
    lock(portal)
    {

    foreach(ChatChannel channel in portal.GetStartedChannels())
    {
    foreach(ChatPlaceUser user in channel.GetAllUsers())
    {
     if(user.AppearOffline)continue;

    %>

    onlineusers.push({
    UserId:"<%=user.Identity.UniqueId%>"
    ,
    Name:"<%=Encode(user.DisplayName)%>"
    ,
    IsGuest:<%=user.Identity.IsAnonymous?"true":"false"%>
    });


    <%}%>

    <%}%>

    <%}%>


    for(var i=0;i<onlineusers.length;i++)
    {
     var user=onlineusersIdea;
     document.write("<span class='onlineuser'>");
     document.write(user.Name);
     document.write("</span>");
    }

     
     
     
     
     
    Hope this helps.
     
    Regards , Terry.
  •  11-26-2007, 5:52 PM 35397 in reply to 35374

    Re: Display # of users in chat on forum home page

    I'm trying to get it to work but it doesn't display anything. I'm not sure if an asp page can include a script that uses asp.net can it?
     

  •  11-27-2007, 6:07 AM 35409 in reply to 35374

    Re: Display # of users in chat on forum home page

    How would I call ChatterListScript.aspx from inside an asp.net page?
  •  11-27-2007, 6:11 AM 35410 in reply to 35397

    Re: Display # of users in chat on forum home page

    twentythree, just in case you just copied and pasted...it looks like the forum converted a piece of Terry's code into an emoticon.
     
    var user=onlineusersIdea;
     
     
    I'm guessing it should be [ i ] in place of the lightbulb (but it's all pushed together)
  •  11-27-2007, 8:38 AM 35413 in reply to 35410

    Re: Display # of users in chat on forum home page

    Yes.. the [ i ] change to an icon..
     
    Is that OK now ?
     
    Regards , Terry .
     
  •  11-27-2007, 9:15 PM 35450 in reply to 35413

    Re: Display # of users in chat on forum home page

    Ah yes! That was the problem... thanks :)
    I feel stupid for not noticing that :P

  •  12-23-2007, 3:09 PM 35996 in reply to 35413

    Re: Display # of users in chat on forum home page

    I would like to use the total number of chatters also but i am using Community Server 2007 and would like to place this in the right side content box. I tried to use the code above but i couldnt seem to get it to work.  This is what i have in one content box now.
     

    Site Stats

    There are 11 Members

    There are 6 Forum Posts

    There are 1 Blogs

    There are 1 Galleries

    There are 2 Files
     
    you can see where i would like to place it on this page. http://us322806.bizhostnet.com/
     
    Marry Xmas, Jay
  •  12-24-2007, 7:43 AM 36011 in reply to 35996

    Re: Display # of users in chat on forum home page

     
    Make sure you can open the script file properly.
    And make sure your page refer the script src properly .
     
    Because the folder of community server pages is not match the urls.
     
    Regards , Terry .
View as RSS news feed in XML