ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Adding "Who's Online" to other pages beside the Forum Index

January 27, 2010 5:39pm

Subscribe [1]
  • #1 / Jan 27, 2010 5:39pm

    I’d like to add Who’s Online and Non-date-based stats to the right column of my forum so that when the user navigates away from the forum index page they can still see who is coming and going in the forum. However, I’m keeping all the other stuff in the visitor_stats function intact and on the forum index page.

    To go about this, I created a new function in mod.forum_core.php and c/p’d the Who’s Online and Non-date-based stats sections from function visitor_stats(). I did not delete these sections from the visitor_stats function as they are being used on the live side of the forum.

    Next, in my new forum theme I altered the theme_stats.php file to reflect this new function and inside it put the two sections I want in the right column.

    //-------------------------------------
    //  Right Column Stats
    //-------------------------------------
    function rightrail_stats()
    {
    return <<< EOF
    <div id="currentMembers" class="forum-rightrail">
        <h3>{lang:active_members}</h3><p> <br />
        {if member_names}<br />
        {member_names backspace='8'}<a href="http://{path:member_profile}">{name}</a>,  {/member_names}<br />
        {/if}<br />
    </div><!-- closes current members --></p>
    
    <p><div id="currentUserStats" class="forum-rightrail"><br />
        <ul><br />
            <li>{lang:total_logged_in} {total_logged_in}</li><br />
            <li>{lang:total_anonymous} {total_anon}</li><br />
            <li>{lang:total_guests} {total_guests}</li><br />
        </ul><br />
    </div><br />
    EOF;<br />
    }<br />
    // END

    This essentially split the data in Visitor Stats. Perfect. I altered top_bar to be my right column and placed my new {include} in its place after the login section. Then I move on to make the proper includes of {top_bar} in theme_global.php, theme_index.php, theme_topics.php and so on.

    On the forum index page, everything works great. I get the old Visitor Stats (newest members, forum totals, etc) below my main content like I wanted. And then in the right column—where my new function resides— Who’s Online, Total Logged-In Users, Total Anonymous Users and Total Guests show up correctly.

    But then I click into one of my topics. This should take me into the theme_topics.php page but all I get is:

    The following errors were encountered

    The page you requested was not found

    So I did some backtracking. I narrowed the problem down to {include:top_bar} being in the topic_page function of theme_topics.php. Get rid of that and the page works fine. Odd. Then I go over to theme_global.php and sift through the things in the top_bar function. Turns out that my new function is causing this error. If I take it out the page displays.

    But here’s the odd thing. I reverted theme_stats.php to it’s original Default incarnation where Who’s Online and what-not are located inside function visitor_stats(). I then placed {include:visitor_stats} in the same location where {include:rightrail_stats} was in the top_bar function from theme_global.php and it works! The topics page displays with no error. Furthermore, in the right column all of the visitor stats show up, including Who’s Online and the stuff I want to display there.

    It’s obvious that Who’s Online can show up in that spot on something other than the forum index page. But why does my new function break the page if I’m just copying code—not altering it?

    Some things I’ve tried to no avail:

    —Reference {include:rightrail_stats} in the topics_page section of theme_topics.php as opposed to top_bar

    —Cut out the code for Who’s Online and Non-date-based stats from function visitor_stats() in mod.forum_core.php and only have those instances reside in my new function.

    Does anyone know a way to do this properly? I don’t want to be poking around where I shouldn’t be, but I’m fine with making a new function in mod.forum_core.php if thats what needs to happen.

    Thanks in advance.

  • #2 / Feb 21, 2010 2:55pm

    anyone?

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases