Hey all!
I'm in the process of creating a site, combining a forum. However, I'm unsure on how to go about adding this feature: Marking new posts since last visit
I know I can do it by creating a database table and set the values individually.. but that is a heck of a load on the database!
So what I'm trying to do, is just doing it on a session basis, like most forums work. Creating an array (I assume) and marking the values of that to having "new posts since last view", or not.
I currently have it, so it marks all threads as unread.. until you view them, and it marks them read. But I don't want it to mark ALL threads unread, only those that have posts since the last view.
The problem I have is when trying to determine those.. as when you open the page for the first time, it won't know which have already been viewd..
How can I go about it?
The data I have available is as follows:
The session_last_activity for the user (currently used for a "user has timed out" script)
Timestamp of the last post within a topic
I can't quite work out how to do it..
This is what I'm trying to put it in..
if( $auth->getUserID() != -1 ) {
if( !array_key_exists($thread['id'], $_SESSION['new_topics']) ) {
/*
if( $thread_lastpost_timestamp > $_SESSION['session_start'] ) {
$value = 1;
}
else {
$value = 0;
}
*/
$_SESSION['new_topics'][$thread['id']] = 1;
}
}
any help or guidance would be greatly appreciated! 😃 I tried searching no the net for it, but kept coming up with things related to current forums and this feature.. not to implement it in your own script.