K guyz,
I'm not sure if this has been asked before, but i ran a coupla searches and it turned up over 7000 results so that's a hell of a job going through..
I'm sure a mod/admin can help me on this one since the board is phpBB. I want something similar to the items since last visit. So if a user logs in new items will light up and read items will dissapear again..
How would one go about doing that. If a user reads an item only that item dissapears and is marked as read. I've done some looking in phpBB and saw that an array is created after loggin in. However i'm not an OOP guru yet so it's hard reading for me. LOL.
Anyways it's easy to get the new items from a last visit and print it on screen, however what do you need to do for the viewed part?
Slap me silly.. LOL
[solved]Items lit up since last visit.
Moderator: General Moderators
[solved]Items lit up since last visit.
Last edited by dreamline on Sun Aug 07, 2005 5:11 am, edited 1 time in total.
This would be my solution, but probably not the only way:
Store a timestamp for when each user was last seen, then store a timestamp for each thread (this timestamp will denote the time the thread was last posted to or edited)
Then when a user logs in you grab their timestamp and store it in the session, when you list threads simply use a comparison operator, and if a thread's timestamp is > when the user was last seen you output your icon accordingly to show the thread is new.
Note, on every page view you need to update the "user last seen" timestamp in the database, but upon them logging in or making a page view after a long period of inactivity (in the case of them using a 'remember me' function and being logged in consistently) you take that 'last seen' timestamp and store it in the session.
This is the "new items" part, but one more step is necessary for the desired effect:
As a user reads a thread you update an array in the session to keep track of threads he/she has already viewed, also when you list threads not only do you compare the timestamps but also check if this thread is in the "read threads" array you stored in the session. It may be more desirable to also store the time they read the thread, in case the thread has been read since they logged in but got posted into recently and should be flagged as "not read" again.
Store a timestamp for when each user was last seen, then store a timestamp for each thread (this timestamp will denote the time the thread was last posted to or edited)
Then when a user logs in you grab their timestamp and store it in the session, when you list threads simply use a comparison operator, and if a thread's timestamp is > when the user was last seen you output your icon accordingly to show the thread is new.
Note, on every page view you need to update the "user last seen" timestamp in the database, but upon them logging in or making a page view after a long period of inactivity (in the case of them using a 'remember me' function and being logged in consistently) you take that 'last seen' timestamp and store it in the session.
This is the "new items" part, but one more step is necessary for the desired effect:
As a user reads a thread you update an array in the session to keep track of threads he/she has already viewed, also when you list threads not only do you compare the timestamps but also check if this thread is in the "read threads" array you stored in the session. It may be more desirable to also store the time they read the thread, in case the thread has been read since they logged in but got posted into recently and should be flagged as "not read" again.
Last edited by josh on Sun Jul 24, 2005 9:25 pm, edited 1 time in total.
- shiznatix
- DevNet Master
- Posts: 2745
- Joined: Tue Dec 28, 2004 5:57 pm
- Location: Tallinn, Estonia
- Contact:
what i did when i made my forums was somthing that works but is a very bad way of doing it.
every user has a field for the threads with new posts. then when a new post is submited it updates the table for every member with that thread id (every thread has a specific id) so if the new thread has the id 34 then my field might look like this 3,21,67,34 where each number is the thread id of a thread with a new post in it.
then when a user views a thread it goes though and using explode() i check if that thread id is in my field, so if i viewed thread id 3 then it would see that i have that marked as a thread that has a new post, then i unset() that part of the array then i implode() it with a , and reupdate the table.
as you can tell this is a very bad way of doing it because if you have 1000 users, every time there is a new post you have to update 1000 fields...big problem to be doing very often. the idea is solid though and works perfect so you can find a better way of updating it then just use the idea and it will be good, or somthing.
good luck
every user has a field for the threads with new posts. then when a new post is submited it updates the table for every member with that thread id (every thread has a specific id) so if the new thread has the id 34 then my field might look like this 3,21,67,34 where each number is the thread id of a thread with a new post in it.
then when a user views a thread it goes though and using explode() i check if that thread id is in my field, so if i viewed thread id 3 then it would see that i have that marked as a thread that has a new post, then i unset() that part of the array then i implode() it with a , and reupdate the table.
as you can tell this is a very bad way of doing it because if you have 1000 users, every time there is a new post you have to update 1000 fields...big problem to be doing very often. the idea is solid though and works perfect so you can find a better way of updating it then just use the idea and it will be good, or somthing.
good luck
Yeah I thought about suggesting something like that but I was like wait no there's gotta be an easier way, right now I'm working on my forums (they're in beta right now) and I'm still polishing my BB code interpreter (still needs to be able to quote a quote, etc.. other bugs). When I get around to doing the "new posts" thing I'll let you know if I did anything impressive.
Your idea is solid in functionality but I can just imagine the overhead generated if that method was implemented on a forum with say, 70,000 users....
Hm i'm going to make a new post
/me posts topic
Message: Please wait while your topic is posted. (this generally takes about 2-3 hours)
heh just kidding around, in theory the thing with the timestamps *should* work, I have no idea how phpBB does it tho, hopefully some one will enlighten us.
Your idea is solid in functionality but I can just imagine the overhead generated if that method was implemented on a forum with say, 70,000 users....
Hm i'm going to make a new post
/me posts topic
Message: Please wait while your topic is posted. (this generally takes about 2-3 hours)
heh just kidding around, in theory the thing with the timestamps *should* work, I have no idea how phpBB does it tho, hopefully some one will enlighten us.
Thanks guyz, i'll have a look into it.. I did look at the phpBB code somewhat and saw that they create an array in the index file for all forums, however i can't seem to find what they do with that array if a user switches pages or if a user looked at a page.
But you've been helpfull so i'll fiddle some more with that..
But you've been helpfull so i'll fiddle some more with that..