Currently the YAF read/unread behavior is not optimum compared to other systems like Invision, vBulletin, phpbb, simplemachine, etc. It's currently only implemented as a "changed topics since your last visit" and does not remember if you really read topics or not before leaving the forum.
This is a 1 million dollar question, and all systems seems to have different answers. 😛
See some discussions around the web :
here ,
here or
here Currently, YAF remembers only last visit, not real read/unread status.Example :
- You visit your forum, seeing that 10 topics are not read.
- You read only some topics, then close your browser
- You come back : all 10 topics are marked as read, and only new topic since your last visit are marked as "active"
The two killing features1) Ability to really track read/unread status, even between two sessions.
2) Ability to go directly to last unread message in a topic, and not last reply (in case you don't read it for a few days).
There are several ways to implement a real "read/unread status" feature. I'm only speaking about this feature a the case of registered users (anonymous users can stay with a last visit feature or less).
Cookie solution : The cookie-only solution seems not to be the most efficient because of the limitations of cookies (in size and quantity) and the fact that a user will not be able to track read/unread status from different computers will be a big drawback.
Db solution : Keeping read/unread status by topic for each user could become dangerous and not scalable. Depending the tracking system enabled (track all read status against track all unread status) a user which comes rarely will have a growing # of rows if you track unread topics, and a frequent user will have a huge # of rows if you track read topics.
A workaround seems to track unread status until a certain amount of days and/or a limit since your last visit, or combine both : in forum administration, an option will allow to set after how many days a topic will always be considered as read (using its last activity date).
My proposition / reflexionCreate a new table : topic_tracking
- userid int not null
- topicid int not null
- lastvisit datetime not null
- PK (userid, topicid)
- IX (topicid) to prune topics where activity limit has been reached
When a new topic is created, or a reply added
- Don't do anything, a topic will, by default, be flagged as "new" if created since your last visit
When you enter the forum (session start)
- Select all tracked topics for this user, joined with last topic activity to quickly detect which are the topics previously not read, consider them as "active" (new behavior)
- Check the user last visit and add all changed topic since then as "active" (current behavior)
- Store this list of active topics in session as "ActiveTopics"
When a user visit a topic
- If the topic is tracked in "ActiveTopics", update the lastvisit with the last displayed post date. If the user visit the first page, the remaining pages will still be "unread". If the read page is the last, then consider removing the entry. But keeping the entry could allow to still see the topic in the "active topics" page, but marked as read.
When a session end
- Update the topic_tracking table with session datas (we will only insert or update rows,
In a scheduled task
- Clear in DB all tracked topics where the topic last activity is older than the admin settings
I'll try to implement this feature "as-is" in the trunk, but before I must learn more from the source code to detect any gotcha. 😁
If you have comments, questions or anything else please post them.