TinyPortal

Development => Support => Older SMF versions => Topic started by: Assistance on August 02, 2006, 10:03:13 AM

Title: Online list: Viewing article
Post by: Assistance on August 02, 2006, 10:03:13 AM
When viewing the Online List ( action=who )

how to show that a member is viewing an article
as it only shows that they are viewing the index page

( used two login names on diff browsers to check )


Title: Re: Online list: Viewing article
Post by: anunlike on August 02, 2006, 03:34:56 PM
That hasn't been implemented, yet, AFAIK (correct me if I'm wrong).

But, it'll get in there, eventually.
Title: Re: Online list: Viewing article
Post by: Assistance on August 02, 2006, 03:54:29 PM
I cant add to the arrays?
Title: Re: Online list: Viewing article
Post by: Max on August 02, 2006, 05:05:02 PM
its not implemented yet to show the exact article or download file a person is viewing...
These are currently the whois actions for the portal,

//
$txt['whoall_page'] = 'Viewing An Article';
$txt['whoall_forum'] = 'Viewing The Forum Index';
$txt['whoall_cat'] = 'Viewing A Category Of Articles';
$txt['whoall_tpmod'] = 'Viewing A Module';
//
Title: Re: Online list: Viewing article
Post by: Assistance on August 03, 2006, 02:37:04 AM

'tpadmin' => array('TPortalAdmin.php', 'TPortalAdmin'),
'forum' => array('BoardIndex.php', 'BoardIndex'),
'tpmod' => array('TPmodules.php', 'TPmodules'),


These are currently the whois actions for the portal

unless I am missunderstand how the
$_REQUEST['action'] array - $_REQUEST['action'] => array($file, $function).
works
Title: Re: Online list: Viewing article
Post by: Techdomain on August 03, 2006, 11:29:58 AM
have you tested that?
Title: Re: Online list: Viewing article
Post by: Assistance on August 04, 2006, 01:16:48 PM

'.xml' => array('News.php', 'ShowXmlFeed'),
        'tpadmin' => array('TPortalAdmin.php', 'TPortalAdmin'),
                'forum' => array('BoardIndex.php', 'BoardIndex'),
                'tpmod' => array('TPmodules.php', 'TPmodules'),
'$txt['whoall_page'] = 'Viewing An Article';
        '$txt['whoall_forum'] = 'Viewing The Forum Index';
        '$txt['whoall_cat'] = 'Viewing A Category Of Articles';
        '$txt['whoall_tpmod'] = 'Viewing A Module';
);


QuoteParse error: syntax error, unexpected T_STRING, expecting ')' in..../discussion/index.php on line 309
Title: Re: Online list: Viewing article
Post by: Xarcell on August 04, 2006, 01:46:48 PM
Can you post a little more before and after code?
Title: Re: Online list: Viewing article
Post by: Assistance on August 05, 2006, 08:07:00 AM
its just the rest of the arrays ==>
what i copied from post 3 is when i got the error
Title: Re: Online list: Viewing article
Post by: Max on August 05, 2006, 03:08:15 PM
Quote from: Assistance on August 04, 2006, 01:16:48 PM

        '$txt['whoall_page'] = 'Viewing An Article';
        '$txt['whoall_forum'] = 'Viewing The Forum Index';
        '$txt['whoall_cat'] = 'Viewing A Category Of Articles';
        '$txt['whoall_tpmod'] = 'Viewing A Module';
);


QuoteParse error: syntax error, unexpected T_STRING, expecting ')' in..../discussion/index.php on line 309

this dosent go into the index.php file... it should allready be in TPortal.english.php file.
Title: Re: Online list: Viewing article
Post by: Assistance on August 06, 2006, 12:49:02 AM
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
Title: Re: Online list: Viewing article
Post by: Assistance on August 08, 2006, 07:58:59 AM
(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fwww.monica.com.br%2Fimages%2Fhelp.gif&hash=e5c850849661ddf41dff50771de3e27b391654dc)
         anyone?
Title: Re: Online list: Viewing article
Post by: than on December 12, 2006, 08:17:28 PM
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.
Title: Re: Online list: Viewing article
Post by: Elrond on November 09, 2007, 11:08:19 PM
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:

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
Title: Re: Online list: Viewing article
Post by: Assistance on November 12, 2007, 11:35:30 AM
QuoteAlthough this thread is almost exactly 11 months old

I'll still check my topics  ;)

and ty, works 100% :up:
Title: Re: Online list: Viewing article
Post by: Elrond on November 13, 2007, 11:06:03 PM
* Post updated here: http://www.tinyportal.net/index.php?topic=6908.msg162713#msg162713 *
Title: Re: Online list: Viewing article
Post by: Assistance on November 23, 2007, 05:56:53 AM
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?
Title: Re: Online list: Viewing article
Post by: bluedevil on November 23, 2007, 09:56:18 PM
This is a great idea.   Does this code really works?   or you still having issues?
Title: Re: Online list: Viewing article
Post by: Elrond on November 25, 2007, 07:33:46 AM
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).
Title: Re: Online list: Viewing article
Post by: Assistance on November 25, 2007, 08:05:33 AM
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..."
Title: Re: Online list: Viewing article
Post by: bluedevil on November 25, 2007, 07:16:12 PM
I made all changes per instructions above but i still see this:

Guest
(xx.xxx.xx.xx, Samsung)  01:13:55 PM Viewing the board index of .


Which that guest is me on my cell phone looking at an article.
Title: Re: Online list: Viewing article
Post by: Elrond on November 27, 2007, 03:21:27 AM
This could be the incorrect area for this modification as it deals with older versions of TP.

I'm using the current one, TP 0.9.8. I tested it on a clean install of SMF 1.1.4 + TP 0.9.8 (no other mods installed) and it works, either for article id or $story['id'] which is the query string id for an article if present.

What I see:

Elrond  (***.***.***.***)     10:08:47 pm     Viewing the article Visual options A.

Visual options A links to the article ID in any case, whether the url I'm at is page=5.0 or page=visual1, which is the article's canonical query name by default install of TP.

What the confusing part is is that I made some update posts about this and some of the updates could have confused the original post. If that's the case, it's possible to undo the changes by going into who.english.php in your theme and who.php in sources folder and just reverse the changes.

If you installed this on a default theme and either you are using a different theme other than default or the forum's default is set to something other than default, and your other themes have language files separate from those in the default theme, or the theme you made the modifications to, it won't display it correctly, which is another possibility.

If you are using separate themes and each of them uses different language files, including who.english.php, then the changes have to be made to those who.english.php files as well.

I'm certain you probably followed the instructions right because this is happening to two people posting here.

Only other thing I might think might be wrong is that you may have replaced

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

with...

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

...which would give some problems like that. Those two entries in who.english.php would be separate lines. The who_article_unk is only as a backup in case it can't read the article id on the who's online list for some reason.

Title: Re: Online list: Viewing article
Post by: Assistance on January 07, 2008, 08:32:28 AM
i'm using most update to date versions of SMF/TP........default variation theme

I'll go back over my edits, but its not about "what I see", its what I click
Title: Re: Online list: Viewing article
Post by: Elrond on January 19, 2008, 02:12:47 AM
Sorry that what I put up didn't help much. This was obviously more complicated than I made it out to be.