I'm working on a bulletin board system and I have a general question.
I'm trying to think of how to do "read" and "unread" for the thread.
How would you store this information/set it up?
How does vBulletin do it?
Printable View
I'm working on a bulletin board system and I have a general question.
I'm trying to think of how to do "read" and "unread" for the thread.
How would you store this information/set it up?
How does vBulletin do it?
They use a cookie and place a timestamp on when you last was here, and if your timestamp is older than some of the posts made than it recognizes those as new posts.
When do you refresh the timestamp, though? When the user looks at a thread? Then what about the other threads that they haven't seen yet? :confused:
Do this:
Read the cookie for their last visit and store that info into a session variable, then reset the cookie with the recent information
Any Post made after that session variable should be shown as new.
Okay. Say they come, look at one thread, and leave. when they come back, it'll show them as having read all threads. :(
that is true. Unless you automatically subtract 5 minutes from their last active time so it has a 5 minute span for error.
If you dont like the idea just make one of your own up :p
If I had an idea of my own, I wouldn't be asking. ;)
you would have to keep the users timestamp in the DB seperate from the post timestamp. that way you can compare them to the specific user and specific posts/threads
I'm not sure I'm catching on...?Quote:
Originally posted by phpman
you would have to keep the users timestamp in the DB seperate from the post timestamp. that way you can compare them to the specific user and specific posts/threads
How about this?:
First I create a table like so:
vbsRecent
--------------
id int 7 primary, blah, blah
threadID blah, blah
user blah, blah
viewed datetime
Everytime a person views a thread, it checks for the existance of an entry for them and the thread in this table. If it is found, it updates the viewed. It then, in forum view, compares the viewed to the last post, if viewed is older, then it's been seen. If not, it hasn't.
Each time this is called, it also deletes entries in the table where viewed is 2 or more days old, so don't have too many entries in the table.
That way it ensures the user has seen the thread and isn't based on their last visit?
How does this sound? Can you think of any drawbacks or improvements?
The above is how I did it for now.
I'll see how it works.
well yeah you could do it that way, but then if you get a lot of users would that add up fast while you are keeping a table for users too?
see this is what I imagined.
you have a table for users where it keeps there info. on that table you have a field called tmstamp or something like that. this is the time where they logged back on the forum.
now, when a user makes a thread the timestamp of that thread is in that table where the thread id is kept (your posts table).
now when the user is logged on those 2 fields are compared.
so actually you compare the new post's timestamp to the users timestamp and see how far they are of from each other then do what you want.
everytime a user replies to the thread the timestamp changes and so does the time between the users timestamp and the posts time.
something like that anyway. no need to have a table that you don't need. :)
Yeah, but this seems like the same thing I discussed with cpradio.
Will this work for every thread? Ie: they view one thread, only that thread shows up as being looked at.
What if the user comes, doesn't look at any threads, and leaves? Will that timestamp be replaced, thus showing the user as having looked at those threads?
I'm still confused by what you mean. Sorry I'm not understanding it easily. :(
It would be a lot of records, but I don't think it would take up that much space. Each record isn't really holding that much data. And since it only stores 2 days worth of data...Quote:
Originally posted by phpman
well yeah you could do it that way, but then if you get a lot of users would that add up fast
Say I have 100 regularly active members that look at 200 posts a day...that's 40,000 posts for 2 days. Yeah, that does seem like a lot.
But I'm willing to hear any other idea that does what I want. You might be on to something, but I just don't understand it. :(
Where are you phpman? cpradio?
I need some input here! :(
I have been at Colorado all weekend so that is why I have not replied until now.
Right now I cannot think of a decent method to do this. I still say it should be via cookies and cookies only but who knows.
Hey,
How about a unique ID for every post you have, and then on one record in a table, just store each post id for each post the user has looked at..that should work! Might be a bit intensive though, I'm not sure? Just seperate by commas..
Record
username - toto
viewedthreads - 1,2,3,4,5,6,7,8,9,10
-toto
well, apart from what I said I don't know of any other way. I will think about it.
why even worry about if the user has seen the thread or not? looking at them is a lot different than replying to them. if the user logs in and does nothing and then leaves the only thing that would change is the users timestamp. it shouldn't change the posts timestamp. the only time that changes is when somebody replies to it.
I'm not going to go through a great trail to explain it. I gave up on the project for awhile anyways.
Just look at how vbforums does it. That's what I want. So you don't have to click on a thread to see if you've read it or not.
How about this:
table users:
ID, Name, EMail, settings....
table threads:
ID, Name, LastPosted, Content.....
table lastviewed:
UserID, ThreadID, LastSeen, WasNotified,....
Then when displaying the threads you search lastviewed for all entries which have the current user ID as UserID, then pick out the entries with the ThreadIDs you want and compare threads.LastPosted to LastSeen of those entries.
Like:
SELECT * FROM lastviewed WHERE UserID=$user_id;
SELECT * FROM threads WHERE ForumID=$current_forum;
The wasnotified field stores if a notification mail was already sent to the user (like vBulletin every good forum should only send one notification message per thread).Code:// get the results into arrays indexed by ID (the threads query result)
// and ThreadID (the lastviewed query result).
for($row = each($threads_result))
{
if($row[1][lastposted] islaterthan $lastviewed_result[$row[0]][lastseen])
// has new posts
}
You could have a similar table for subscriptions and all that stuff.
I'm pretty sure that's the way vBulletin does it btw.
Why did you quit, it looked very promising.Quote:
Originally posted by The Hobo
I'm not going to go through a great trail to explain it. I gave up on the project for awhile anyways.
Just look at how vbforums does it. That's what I want. So you don't have to click on a thread to see if you've read it or not.
Because I didn't know why I was doing it. It started to feel like I was wasting my life for nothing.Quote:
Originally posted by Gimlin
Why did you quit, it looked very promising.
And I didn't quit. I'm just taking a vacation from it for awhile.