rockinaway Posted October 6, 2007 Share Posted October 6, 2007 How would I go about detecting new posts and then storing them somewhere? Like a forum has it.. Quote Link to comment https://forums.phpfreaks.com/topic/72102-new-posts/ Share on other sites More sharing options...
BlueSkyIS Posted October 6, 2007 Share Posted October 6, 2007 posts should be stored in a database. when they are stored, there could be a timestamp field which tells you when they were inserted. sort on timestamp desc to get the latest at the top. Quote Link to comment https://forums.phpfreaks.com/topic/72102-new-posts/#findComment-363421 Share on other sites More sharing options...
rockinaway Posted October 6, 2007 Author Share Posted October 6, 2007 But then would it not require sessions if a user is loggin in and out? Like if there are certain amount, and then if they check the post then it is no longer new for THEM. ? Quote Link to comment https://forums.phpfreaks.com/topic/72102-new-posts/#findComment-363422 Share on other sites More sharing options...
BlueSkyIS Posted October 6, 2007 Share Posted October 6, 2007 you'll need sessions for any kind of decent forum. Quote Link to comment https://forums.phpfreaks.com/topic/72102-new-posts/#findComment-363425 Share on other sites More sharing options...
rockinaway Posted October 6, 2007 Author Share Posted October 6, 2007 So what if I had 10 new posts. I could pass their values in say $_SESSION['new_posts']. Then once the post is viewed I could remove it from the $_SESSION['new_posts'] array. Then when they log in I retrieve the latest posts since their last log in. HOWEVER this would mean posts they did not visit in the first log in, will not be retrieved in their second log in.. how would I make it possible so that they were... Quote Link to comment https://forums.phpfreaks.com/topic/72102-new-posts/#findComment-363428 Share on other sites More sharing options...
BlueSkyIS Posted October 6, 2007 Share Posted October 6, 2007 more complex forums keep track of the visitors views by updating the 'message_read' value for each message for each visitor. sessions are generally only used to make sure the visitor is logged in. everything else is done by updating and viewing data in the database. for instance, if a visitor logs in and reads a message, that message is marked as 'read' and is therefore no longer new. each time the visitor views another post, a timestamp is updated for that visitor record, basically saying "this visitor was still on the site at x time". i suggest that you download and install phpBB and take a look at how it does things, especially the database structure. Quote Link to comment https://forums.phpfreaks.com/topic/72102-new-posts/#findComment-363430 Share on other sites More sharing options...
rockinaway Posted October 6, 2007 Author Share Posted October 6, 2007 I have SMF installed.. but updating the database like that would not work for seperate users would it? Quote Link to comment https://forums.phpfreaks.com/topic/72102-new-posts/#findComment-363432 Share on other sites More sharing options...
BlueSkyIS Posted October 6, 2007 Share Posted October 6, 2007 I'm not familiar with SMF, but phpBB updates each user each time they click. Quote Link to comment https://forums.phpfreaks.com/topic/72102-new-posts/#findComment-363437 Share on other sites More sharing options...
rockinaway Posted October 6, 2007 Author Share Posted October 6, 2007 Can you tell me which table they update? I have an installation to check in.. thanks Quote Link to comment https://forums.phpfreaks.com/topic/72102-new-posts/#findComment-363441 Share on other sites More sharing options...
BlueSkyIS Posted October 6, 2007 Share Posted October 6, 2007 okay, i'm good at phpBB but i don't know it down to table names. Quote Link to comment https://forums.phpfreaks.com/topic/72102-new-posts/#findComment-363444 Share on other sites More sharing options...
rockinaway Posted October 6, 2007 Author Share Posted October 6, 2007 Damn.. but you are sure it is stored in the DB? Quote Link to comment https://forums.phpfreaks.com/topic/72102-new-posts/#findComment-363456 Share on other sites More sharing options...
BlueSkyIS Posted October 6, 2007 Share Posted October 6, 2007 sure what is stored in the DB? each time the user clicks? sure, where else would it be -->stored<--? look at phpBB's user table. and all the other tables that support the application. Quote Link to comment https://forums.phpfreaks.com/topic/72102-new-posts/#findComment-363460 Share on other sites More sharing options...
rockinaway Posted October 6, 2007 Author Share Posted October 6, 2007 So all I have to do is select all the posts when the user logs in, that are new since last visit. Then add them to a table in the database.. then remove them if they are viewed by another query. Then just keep updating when the log in.. right? Quote Link to comment https://forums.phpfreaks.com/topic/72102-new-posts/#findComment-363466 Share on other sites More sharing options...
BlueSkyIS Posted October 6, 2007 Share Posted October 6, 2007 yes. if you want to keep closer track, you'll need to update whenever the user reads a post, not just on login, etc. this is also the way some forums show you who is online. they check to see the last time the user clicked something. Quote Link to comment https://forums.phpfreaks.com/topic/72102-new-posts/#findComment-363470 Share on other sites More sharing options...
rockinaway Posted October 6, 2007 Author Share Posted October 6, 2007 Ok thanks Quote Link to comment https://forums.phpfreaks.com/topic/72102-new-posts/#findComment-363472 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.