PDA

View Full Version : read/unread tracking


mokakid
06-02-2008, 07:40 PM
I don't even have a clue on how to make a read/unread system on a forum made from scratch. I want to have icons next to each topic that shows the user if the topic has new posts or not.

hope you understand what i mean... i only need an idea
thanks

derzok
06-02-2008, 08:00 PM
You'd have to add a value to a table (or make an entirely new table) that would keep a list of threads you have viewed. Edit your display_thread function to update that table/column with thread ID and userid. Pull out the info from the table when you're displaying the forum so that you know what icon to use.

The problem with this is that if you have a lot of users with a lot of threads, your database can quickly fill up. I was writing a bbs for someone recently - they asked for a similar feature. I stuck with the database method because they would only have a few dozen threads and users. The vbulletin dev team has been having similar problems: http://www.vbulletin.com/forum/showthread.php?t=49868 - some good conversation there.

Edit: to minimize database usage, you could store a list of viewed threads in your database and read them out into a session variables or cookies - this would reduce some load.

CFMaBiSmAd
06-02-2008, 09:14 PM
Rather than keep a list of what each member has viewed, which would always require an increasing amount of data storage as the number of posts increases and as the number of members increase, do the reverse, keep a list of "new" unread posts.

See my post in this thread - http://www.codingforums.com/showthread.php?t=131004

Short version - keep a "book mark" date/time of each member's last visit. On each new visit, find all the posts newer than the last "book mark" date/time, add the id's of those posts to the unread table with that member's id, and update the "book mark" date/time to be that of the last post added to the unread table (this insures that any new posts made while reading existing posts will be seen as new the next time the member visits the site.) As each post is read by a member, remove his record for that post from the unread table (or if you have a "mark all posts as read" button, remove all that member's records from the unread table.)

mokakid
06-02-2008, 09:30 PM
i read your post and i understood how it works
i will give it a try as soon as i can :D

derzok
06-03-2008, 01:34 AM
Rather than keep a list of what each member has viewed, which would always require an increasing amount of data storage as the number of posts increases and as the number of members increase, do the reverse, keep a list of "new" unread posts.

See my post in this thread - http://www.codingforums.com/showthread.php?t=131004

Short version - keep a "book mark" date/time of each member's last visit. On each new visit, find all the posts newer than the last "book mark" date/time, add the id's of those posts to the unread table with that member's id, and update the "book mark" date/time to be that of the last post added to the unread table (this insures that any new posts made while reading existing posts will be seen as new the next time the member visits the site.) As each post is read by a member, remove his record for that post from the unread table (or if you have a "mark all posts as read" button, remove all that member's records from the unread table.)

+1, my friend! That's a clever solution - I might implement that if I ever have to do it again in the future. I think that's how vbulletin currently works. You also have the option of manually marking a forum or thread as "read" and then it'll shove it into a database (which won't fill up as fast since it's being manually filled).