|
-
Oct 4th, 2002, 03:41 PM
#1
Thread Starter
Stuck in the 80s
New Posts?
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?
-
Oct 4th, 2002, 05:34 PM
#2
Fanatic Member
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.
-
Oct 4th, 2002, 05:38 PM
#3
Thread Starter
Stuck in the 80s
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?
-
Oct 4th, 2002, 05:40 PM
#4
Fanatic Member
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.
-
Oct 4th, 2002, 05:56 PM
#5
Thread Starter
Stuck in the 80s
Okay. Say they come, look at one thread, and leave. when they come back, it'll show them as having read all threads.
-
Oct 4th, 2002, 05:57 PM
#6
Fanatic Member
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
-
Oct 4th, 2002, 06:09 PM
#7
Thread Starter
Stuck in the 80s
If I had an idea of my own, I wouldn't be asking.
-
Oct 8th, 2002, 09:08 AM
#8
Frenzied Member
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
-
Oct 8th, 2002, 12:26 PM
#9
Thread Starter
Stuck in the 80s
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
I'm not sure I'm catching on...?
-
Oct 8th, 2002, 01:55 PM
#10
Thread Starter
Stuck in the 80s
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?
-
Oct 8th, 2002, 03:07 PM
#11
Thread Starter
Stuck in the 80s
The above is how I did it for now.
I'll see how it works.
-
Oct 8th, 2002, 03:38 PM
#12
Frenzied Member
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.
-
Oct 8th, 2002, 03:43 PM
#13
Thread Starter
Stuck in the 80s
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.
-
Oct 8th, 2002, 03:57 PM
#14
Thread Starter
Stuck in the 80s
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
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...
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.
-
Oct 10th, 2002, 10:14 PM
#15
Thread Starter
Stuck in the 80s
Where are you phpman? cpradio?
I need some input here!
-
Oct 14th, 2002, 12:49 PM
#16
Fanatic Member
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.
-
Oct 14th, 2002, 10:40 PM
#17
New Member
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
-
Oct 15th, 2002, 04:42 PM
#18
Frenzied Member
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.
-
Oct 15th, 2002, 06:33 PM
#19
Thread Starter
Stuck in the 80s
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.
-
Oct 16th, 2002, 11:53 AM
#20
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;
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
}
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).
You could have a similar table for subscriptions and all that stuff.
I'm pretty sure that's the way vBulletin does it btw.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Oct 17th, 2002, 03:13 PM
#21
Fanatic Member
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.
Why did you quit, it looked very promising.
-
Oct 17th, 2002, 09:07 PM
#22
Thread Starter
Stuck in the 80s
Originally posted by Gimlin
Why did you quit, it looked very promising.
Because I didn't know why I was doing it. It started to feel like I was wasting my life for nothing.
And I didn't quit. I'm just taking a vacation from it for awhile.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|