Results 1 to 22 of 22

Thread: New Posts?

  1. #1

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256

    Unhappy 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?
    My evil laugh has a squeak in it.

    kristopherwilson.com

  2. #2
    Fanatic Member cpradio's Avatar
    Join Date
    Apr 2002
    Posts
    616
    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.
    http://cpradio.net/
    Administrator @ WDForums and a Moderator @ WebXpertz City Forums

  3. #3

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    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?
    My evil laugh has a squeak in it.

    kristopherwilson.com

  4. #4
    Fanatic Member cpradio's Avatar
    Join Date
    Apr 2002
    Posts
    616
    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.
    http://cpradio.net/
    Administrator @ WDForums and a Moderator @ WebXpertz City Forums

  5. #5

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Okay. Say they come, look at one thread, and leave. when they come back, it'll show them as having read all threads.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  6. #6
    Fanatic Member cpradio's Avatar
    Join Date
    Apr 2002
    Posts
    616
    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
    http://cpradio.net/
    Administrator @ WDForums and a Moderator @ WebXpertz City Forums

  7. #7

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    If I had an idea of my own, I wouldn't be asking.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  8. #8
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    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

  9. #9

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    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...?
    My evil laugh has a squeak in it.

    kristopherwilson.com

  10. #10

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    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?
    My evil laugh has a squeak in it.

    kristopherwilson.com

  11. #11

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    The above is how I did it for now.

    I'll see how it works.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  12. #12
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    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.

  13. #13

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    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.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  14. #14

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    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.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  15. #15

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Where are you phpman? cpradio?

    I need some input here!
    My evil laugh has a squeak in it.

    kristopherwilson.com

  16. #16
    Fanatic Member cpradio's Avatar
    Join Date
    Apr 2002
    Posts
    616
    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.
    http://cpradio.net/
    Administrator @ WDForums and a Moderator @ WebXpertz City Forums

  17. #17
    New Member
    Join Date
    Jul 2002
    Posts
    2
    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

  18. #18
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    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.

  19. #19

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    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.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  20. #20
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    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.

  21. #21
    Fanatic Member Gimlin's Avatar
    Join Date
    Dec 2001
    Location
    Hell
    Posts
    734
    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.

  22. #22

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    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.
    My evil laugh has a squeak in it.

    kristopherwilson.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width