Topic-specific "Who is online" info

Looking for a MOD? Have a MOD request? Post here for help. (Note: This forum is community supported; phpBB does not have official MOD authors)
Ideas Centre
Veeno
Registered User
Posts: 7
Joined: Fri Jun 22, 2012 8:12 pm

Topic-specific "Who is online" info

Post by Veeno »

I have a very simple request. I want the "Who is online" info displayed in the bottom, when reading a certain topic (viewtopic.php), to only show users viewing that same topic (and, accordingly, the message being "Users reading this topic:" instead of "Users browsing this forum:").

I've searched here (and elsewhere) and all I found was this. That seems to have done exactly the thing I want, but it's way outdated and the download URL appears to not be working any more, so I can't download it to see how it was done.

Now, I'm a programmer myself and I'm proficient with PHP and I did figure out that what needs to be done (among other things probably) is change the way the variable $online_users is formed in includes/functions.php, but for the life of me I can't figure out what needs to be changed and how I could do it myself, so if someone could offer some help or make a mod it would be much appreciated.
User avatar
Jessica
Former Team Member
Posts: 4342
Joined: Sun Jul 18, 2010 2:53 pm
Location: Pennsylvania, USA
Name: Jessica

Re: Topic-specific "Who is online" info

Post by Jessica »

I don't have a download, but I did install this on my board and I managed to get it from the store/mods folder and change it to a zip file (fortunately there's no files that comes with the mod)

you can download it at my board -- http://chenschool.elementfx.com/phpBB3/ ... t.php?id=1

and take a look...maybe you can create a new mod?
Pro-choice, Atheist, Pro-LGBT rights
Everybody is a genius. But if you judge a fish by its ability to climb a tree, it will live its whole life believing that it is stupid. - Albert Einstein
Veeno
Registered User
Posts: 7
Joined: Fri Jun 22, 2012 8:12 pm

Re: Topic-specific "Who is online" info

Post by Veeno »

Thank you very much! However:
This MOD shows the number of other users browsing the same topic as the user.
Does it only show the number of users browsing the topic, or their usernames too?
User avatar
Jessica
Former Team Member
Posts: 4342
Joined: Sun Jul 18, 2010 2:53 pm
Location: Pennsylvania, USA
Name: Jessica

Re: Topic-specific "Who is online" info

Post by Jessica »

it shows the usernames too
Pro-choice, Atheist, Pro-LGBT rights
Everybody is a genius. But if you judge a fish by its ability to climb a tree, it will live its whole life believing that it is stupid. - Albert Einstein
Veeno
Registered User
Posts: 7
Joined: Fri Jun 22, 2012 8:12 pm

Re: Topic-specific "Who is online" info

Post by Veeno »

Jessica wrote:it shows the usernames too
Ok thanks a lot, I will make the modifications from the install_mod.xml now. If it works on 3.0.10 I will post what changes need to be done here just in case it ends up not being available on your board in the future.

It seems I was wrong though, it doesn't require modifying includes/functions.php at all.
Veeno
Registered User
Posts: 7
Joined: Fri Jun 22, 2012 8:12 pm

Re: Topic-specific "Who is online" info

Post by Veeno »

Yep, it works! Thanks once again! :D

Now as I promised, I will outline the changes that need to be done here, in case someone else in the future wants/needs to do the same:

  1. Modifying your SQL database.

    Execute the following SQL query on your board's database:

    Code: Select all

    ALTER TABLE phpbb_sessions ADD session_topic_id INTEGER NOT NULL DEFAULT 0;
  2. Modifying /viewtopic.php

    Find:

    Code: Select all

    page_header($user->lang['VIEW_TOPIC'] . ' - ' . $topic_data['topic_title'], true, $forum_id);
    Replace with:

    Code: Select all

    /* nanothree - users viewing topic mod */
    page_header($user->lang['VIEW_TOPIC'] . ' - ' . $topic_data['topic_title'], true, $topic_id, 'topic');
    /* nanothree - end users viewing topic mod */
  3. Modifying /includes/session.php
    1. Find:

      Code: Select all

      'forum'				=> (isset($_REQUEST['f']) && $_REQUEST['f'] > 0) ? (int) $_REQUEST['f'] : 0,
      On an empty new line after that add:

      Code: Select all

      /* nanothree - users viewing topic mod */
       'topic'				=> (isset($_REQUEST['t']) && $_REQUEST['t'] > 0) ? (int) $_REQUEST['t'] : 0,
       /* nanothree - end users viewing topic mod */
    2. Find:

      Code: Select all

      $sql_ary['session_forum_id'] = $this->page['forum'];
      On an empty new line after that add:

      Code: Select all

      /* nanothree - users viewing topic mod */
      $sql_ary['session_topic_id'] = $this->page['topic'];
      /* nanothree - end users viewing topic mod */
    3. Find:

      Code: Select all

      unset($sql_ary['session_forum_id']);
      On an empty new line after that add:

      Code: Select all

      /* nanothree - users viewing topic mod */
      unset($sql_ary['session_topic_id']);
      /* nanothree - end users viewing topic mod */
    4. Find:

      Code: Select all

      $sql_ary['session_forum_id'] = $this->page['forum'];
      On an empty new line after that add:

      Code: Select all

      /* nanothree - users viewing topic mod */
      $sql_ary['session_topic_id'] = $this->page['topic'];
      /* nanothree - end users viewing topic mod */
    5. Find:

      Code: Select all

      $sql_ary['session_forum_id'] = $this->page['forum'];
      On an empty new line after that add:

      Code: Select all

      /* nanothree - users viewing topic mod */
      $sql_ary['session_topic_id'] = $this->page['topic'];
      /* nanothree - end users viewing topic mod */
    6. Find:

      Code: Select all

      $sql_ary['session_forum_id'] = $this->page['forum'];
      On an empty new line after that add:

      Code: Select all

      /* nanothree - users viewing topic mod */
      $sql_ary['session_topic_id'] = $this->page['topic'];
      /* nanothree - end users viewing topic mod */
  4. Modifying /language/en/common.php (analogous changes need to be made to common.php for other languages used on your board as well)

    Find:

    Code: Select all

    'BROWSING_FORUM_GUESTS'	=> 'Users browsing this forum: %1$s and %2$d guests',
    On an empty new line after that add:

    Code: Select all

    	/* nanothree - users viewing topic mod */
    	'BROWSING_TOPIC'		=> 'Users reading this topic: %1$s',
    	'BROWSING_TOPIC_GUEST'	=> 'Users reading this topic: %1$s and %2$d guest',
    	'BROWSING_TOPIC_GUESTS'	=> 'Users reading this topic: %1$s and %2$d guests',
    	/* nanothree - end users viewing topic mod */
That's it. Purge the cache just in case and you're done.
Last edited by Oyabun1 on Fri Aug 29, 2014 11:15 pm, edited 1 time in total.
Reason: Files to edit corrected
Veeno
Registered User
Posts: 7
Joined: Fri Jun 22, 2012 8:12 pm

Re: Topic-specific "Who is online" info

Post by Veeno »

UPDATE: (excuse the triple-post)

You might also want to do this:

In includes/functions_display.php find the line which contains

Code: Select all

$last_post_url = append_sid(
and change that line to

Code: Select all

$last_post_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id_last_post'] . '&t=' . $row['topic_id'] . '&p=' . $row['forum_last_post_id']) . '#p' . $row['forum_last_post_id'];
The topic id is missing from the original last post URL on the board index and even though the link works without it, the user who follows the link won't get added to the list of people reading the topic because the script can't obtain the id of the topic without it being in the URL. This fixes that.
User avatar
Jessica
Former Team Member
Posts: 4342
Joined: Sun Jul 18, 2010 2:53 pm
Location: Pennsylvania, USA
Name: Jessica

Re: Topic-specific "Who is online" info

Post by Jessica »

Veeno wrote:U
PDATE: (excuse the triple-post)

You might also want to do this:

In includes/functions_display.php find the line which contains

Code: Select all

$last_post_url = append_sid(
and change that line to

Code: Select all

$last_post_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id_last_post'] . '&t=' . $row['topic_id'] . '&p=' . $row['forum_last_post_id']) . '#p' . $row['forum_last_post_id'];
The topic id is missing from the original last post URL on the board index and even though the link works without it, the user who follows the link won't get added to the list of people reading the topic because the script can't obtain the id of the topic without it being in the URL. This fixes that.
thanks for the fix!!
Pro-choice, Atheist, Pro-LGBT rights
Everybody is a genius. But if you judge a fish by its ability to climb a tree, it will live its whole life believing that it is stupid. - Albert Einstein
Veeno
Registered User
Posts: 7
Joined: Fri Jun 22, 2012 8:12 pm

Re: Topic-specific "Who is online" info

Post by Veeno »

Jessica wrote:thanks for the fix!!
No problem! ^_^

Well this topic certainly doesn't belong in this subforum any more, but I think it should stay here and I will update the mod and make a new thread for that in the proper section, whenever I stop being a lazy procrastinator that I am. :P
User avatar
Jessica
Former Team Member
Posts: 4342
Joined: Sun Jul 18, 2010 2:53 pm
Location: Pennsylvania, USA
Name: Jessica

Re: Topic-specific "Who is online" info

Post by Jessica »

idk, don't we need the original author's permission to take over or something? (nanothree)
Pro-choice, Atheist, Pro-LGBT rights
Everybody is a genius. But if you judge a fish by its ability to climb a tree, it will live its whole life believing that it is stupid. - Albert Einstein
Veeno
Registered User
Posts: 7
Joined: Fri Jun 22, 2012 8:12 pm

Re: Topic-specific "Who is online" info

Post by Veeno »

Jessica wrote:idk, don't we need the original author's permission to take over or something? (nanothree)
license.txt contains GNU GPL v2, so all I need to do is publish it under GPL v2 or v3, but I will credit him/her just because I think that's the polite thing to do.


edit: Dunno why I presumed nanothree is a guy there. -_-
Tarantino
Registered User
Posts: 876
Joined: Sat Feb 18, 2012 1:51 pm

Re: Topic-specific "Who is online" info

Post by Tarantino »

Just to warning that the "b. Find:" and all other finds are from includes/session.php and not viewtopic.php

Cheers

Return to “[3.0.x] MOD Requests”