• Welcome to Simple Machines Community Forum. Please login or sign up.

Topic Last Viewed Date

Started by Steve, April 20, 2015, 09:53:51 AM

Previous topic - Next topic

Steve

Is there a way to know the date a topic was last viewed?
Please do not PM me for support.

Kindred

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

margarett

Well, as Kindred uses to say: everything is possible, if you can code it :P

What you already have is smf_log_topics although it doesn't really give you the "when" (although it can give you the "who")

Best possibility (I think) is to stuff a new column in smf_topics (an UNSIGNED INT for some timestamp) and when the table is updated to add a new view
// Add 1 to the number of views of this topic.
if (empty($_SESSION['last_read_topic']) || $_SESSION['last_read_topic'] != $topic)
{
$smcFunc['db_query']('', '
UPDATE {db_prefix}topics
SET num_views = num_views + 1
WHERE id_topic = {int:current_topic}',
array(
'current_topic' => $topic,
)
);

in Display.php, update that new column with the current time ;)
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

Steve

Thanks for that. :)

I was looking more for some kind of query that I could run on a certain board to see when it's topics were last viewed, just for my own information with the objective being whether or not to get rid of certain threads.
Please do not PM me for support.

margarett

No, that I don't think you can...
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

Steve

Okay then ... will use what you gave me. Thanks again. :)

Marking solved.
Please do not PM me for support.

Night09

Can it not be set something like below to give a timestamp?


   // Add time of last view of this topic.
   if (empty($_SESSION['last_read_topic']) || $_SESSION['last_read_topic'] != $topic)
   {
      $smcFunc['db_query']('', '
         UPDATE {db_prefix}topics
         SET $time = new DateTime
         WHERE id_topic = {int:current_topic}',
         array(
            'current_topic' => $topic,
         )
      );



Shambles

Quote from: Steve
... run on a certain board to see when it's topics were last viewed ...

Wouldn't a spidered crawl skew your stats?

Kindred

Quote from: Shambles on April 21, 2015, 03:34:29 AM
Quote from: Steve
... run on a certain board to see when it's topics were last viewed ...

Wouldn't a spidered crawl skew your stats?

yup...
Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Steve

Good point Shambles. Hadn't thought of that. :)
Please do not PM me for support.

margarett

Nah, it's pretty easy to only update that column if the user is not a guest or even a spider, if recognized as such ;)
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

Pipke

There is this mod: Topic View Log , only works for logged in users.
"If something is wrong, fix it if you can. But train yourself not to worry: Worry never fixes anything."

Click here to view my mods for SMF

Hey 👋 Did i helped... you like what i do. You can now buy me a coffee! ☕

Steve

The 'Link to mod' link doesn't lead anywhere. :(
Please do not PM me for support.

Bigguy

That mod was removed from the mod site.

player.samp

Quote from: Steve on April 21, 2015, 06:00:22 PM
The 'Link to mod' link doesn't lead anywhere. :(


I have this package and I can send it to you if you need.

Kindred

you are not allowed to distribute that mod.. It is licensed by SMFSimple.
You can acquire it from the SMFSimple site
http://www.smfsimple.com/index.php?PHPSESSID=90ad698a71c3a090ea93c21e9955dec2&action=downloads
Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Steve

Thanks Kindred! And thanks again to everyone else. :)
Please do not PM me for support.

Advertisement: