TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

May 01, 2024, 07:33:27 AM

Login with username, password and session length
Members
  • Total Members: 3,885
  • Latest: Growner
Stats
  • Total Posts: 195,174
  • Total Topics: 21,220
  • Online today: 167
  • Online ever: 3,540 (September 03, 2022, 01:38:54 AM)
Users Online
  • Users: 0
  • Guests: 140
  • Total: 140

Online list: Viewing article

Started by Assistance, August 02, 2006, 10:03:13 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Assistance

ok correct it is there in TPortal.
but not working

when someone is viewing an article (page=38)
it shows they are reading the board index

Assistance


than

Hi,

In the new version TP 0.9.7 it still does not work. Could you exlpain us which modifications should we do to make it works?

Sorry for my english and thanks in advance.

Elrond

#13
Although this thread is almost exactly 11 months old, I figured I'd pop in to provide some assistance.

Firstly, you must follow these instructions closely, as with all manual additions. You may also want to backup the below-listed files and/or backup your database in case you enter something terribly wrong. This is to be on the safe side. Be conservative with changes you make always (that is almost a contradiction).

Secondly, you will require the following files:

  • (your root folder)/Themes/default (or your theme)/languages/Who.english.php
  • (your root folder)/Sources/Who.php

Open them in a text editor (please God not notepad oy vey).

Thirdly, have Who.english.php open, you will be modifying that first:

The first modification is an obvious one: the text line.
Find:
$txt['who_board'] = 'Viewing the board <a href="' . $scripturl . '?board=%d.0">%s</a>.';

Add BEFORE the above:
$txt['who_article'] = 'Viewing the article <a href="' . $scripturl . '?page=%d.0">%s</a>.';

Add this if it's not already present:
$txt['who_article_unk'] = 'Viewing an article';

Thus, the article text is nearly identical to that for the board, except with who_article for the txt array, article for the text instead of board, and ?page instead of ?board.

Fourthly, have Who.php open, and this will be the final set of modifications:

Find:
// These are done to later query these in large chunks. (instead of one by one.)
$topic_ids = array();
$profile_ids = array();
$board_ids = array();

Add AFTER the above:

$article_ids = array();


Find:
// It's a board!
elseif (isset($actions['board']))
{
// Hide first, show later.
$data[$k] = $txt['who_hidden'];
$board_ids[$actions['board']][$k] = $txt['who_board'];
}

Add AFTER the above:
// It is an article!
elseif (isset($actions['page']))
{
$data[$k] = $txt['who_hidden'];
$article_ids[$actions['page']][$k] = $txt['who_article'];
}


Almost done...now we need the Database Query for this - it will be similar to the one it does for board queries.

Find:
// Load board names.
if (!empty($board_ids))
{
$result = db_query("
SELECT b.ID_BOARD, b.name
FROM {$db_prefix}boards AS b
WHERE $user_info[query_see_board]
AND b.ID_BOARD IN (" . implode(', ', array_keys($board_ids)) . ")
LIMIT " . count($board_ids), __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($result))
{
// Put the board name into the string for each member...
foreach ($board_ids[$row['ID_BOARD']] as $k => $session_text)
$data[$k] = sprintf($session_text, $row['ID_BOARD'], $row['name']);
}
mysql_free_result($result);
}

Add AFTER the above:

// Load article names.
if (!empty($article_ids))
{
$result = mysql_query("
SELECT a.id, a.subject, a.shortname
FROM {$db_prefix}tp_articles AS a
WHERE a.id IN (" . implode(', ', array_keys($article_ids)) . ")
LIMIT " . count($article_ids));
if($result)
{
while ($row = mysql_fetch_assoc($result))
{
// Put the board name into the string for each member...
foreach ($article_ids[$row['id']] as $k => $session_text)
$data[$k] = sprintf($session_text, $row['id'], $row['subject']);
}
mysql_free_result($result);
}
else if(!$result && count($article_ids) > 0)
{
$result = mysql_query("
SELECT a.id, a.subject, a.shortname
FROM {$db_prefix}tp_articles AS a
WHERE a.shortname='" . implode(', ', array_keys($article_ids)) . "'
LIMIT " . count($article_ids));
if($result)
{
while ($row = mysql_fetch_assoc($result))
{
// Put the board name into the string for each member...
foreach ($article_ids[$row['shortname']] as $k => $session_text)
$data[$k] = sprintf($session_text, $row['id'], $row['subject']);
}
mysql_free_result($result);
}
else
{
$data[$k] = $txt['who_article_unk'];
}
}
else
{
$data[$k] = '';
}
}


Last but not least, SAVE your files. If you don't have any online users at the time except yourself with which to test this, go to an article page, validate it with the w3c validator, and presto! You have a guest that will be viewing that article, and you'll be able to see if it works if it says something like "Guest  (128.30.52.49)     *time*    Viewing the article Some Article Name".

If you didn't follow the instructions, you could see anything from a parse error to a database error.

***** THIS POST HAS BEEN UPDATED, PLEASE REFER TO THIS AS THE FULL VERSION OF THIS MODIFICATION AS IT IS UP TO DATE *****

Sorry for all caps, that was necessary. :P

Assistance

QuoteAlthough this thread is almost exactly 11 months old

I'll still check my topics  ;)

and ty, works 100% :up:

Elrond


Assistance

#16
all i get with the above edits is ....

Nothing, or nothing you can see... < is what the online list shows now >

maybe I am not reading the posts right, as I have done....

$txt['who_article_unk'] = 'Viewing an article';

and "total fix for the who.php code in the sources folder..."
[ code ]


edit

was is this moved to Older SMF versions?

bluedevil

This is a great idea.   Does this code really works?   or you still having issues?

Elrond

#18
Assistance, it seems to work the way it is now. I'll edit my original post and put it altogether there, and edit my last post just to put "updated as seen in previous post" so that there's less confusion about it.

I'll also throw this on a test install on my network's server so that I can see that this works. I'm going to also put this in an attachment/mod thing so that I can use package manager to install it as well, so that I can definitely see if it works and doesn't blow up anything else.

Quote from: bluedevil on November 23, 2007, 09:56:18 PM
This is a great idea.   Does this code really works?   or you still having issues?

No issues of any kind now on my install. In the current revision of the code it will look for an article id if the user is browsing by that, and if the article id is not a number and is instead the query string text for the article, it will still give a reading on that so that all bases are covered. This can be done with any number of pages like custom actions and such. There are a number of things, like galleries and such I've put together and on the online list it will tell you who's looking at what album, or image, or what they're doing in the gallery, but the gallery's only a WIP feature and I don't make it public till it's done (in this case I just went ahead and put up code that I knew may not be 100% but it is working alright now).

Assistance

ok all seems to work well...............

but only 1 issue is that when viewing the online list

it shows the link to the article by page #
and not the query text name

so this is what it looks like....


member 1: is viewing an article
member 2: views the online list....and clicks that article
member 1: now views the online list and see member 2 as
"Nothing, or nothing you can see..."