lee.marsh Posted July 20, 2009 Share Posted July 20, 2009 Hey guys, Ok. I took on the monster task of coding my own forums for a site of mine! (Ouchies. But, in all honesty.. they're not overly complicated. It was much easier to implement a forum into the current user system than convert the user system into a forum) So, the forum is just about finished. Just one little problem holding me back... You know when you view a forum? And there's the forum legend at the bottom (a 'key'..). Well, let's say we have 2.. New Posts No New posts So.. i figured the easiest way to do it would be to have a column in the users field.. with $user->last_loggedin.. and a collumn in the forums field $forum['last_updated'].. meaning i could simply.. <? if($user->last_loggedin > $forum['last_updated']){ // show the "New posts!" icon } else { // show the "Nooo new posts!" icon } Now, the problem arrises when the user is logged in.. everything is fine.. until someone else posts a new topic/post.. That then means, that the $user->last_loggedin < $forum['last_updated'].. meaning that the forum doesn't show as being updated.. doh! I could reverse the arguments of the original php code (above).. so that... <? if($user->last_loggedin < $forum['last_updated']){ // show the "New posts!" icon } else { // show the "Nooo new posts!" icon } But then that will throw out my "New posts" when the user first logs in.. It seems it's one or the other.. And damn, that seems like a really complicated way of saying that.. but i thought in detail would be the best way. It's driving me crazy. Is there any way to get both? Like.. i know vbulletin and other forum software manages it, but i don't really fancy trolling through vast amounts of code like that. Quote Link to comment Share on other sites More sharing options...
xtopolis Posted July 21, 2009 Share Posted July 21, 2009 this thread may be of some use Quote Link to comment Share on other sites More sharing options...
lee.marsh Posted July 21, 2009 Author Share Posted July 21, 2009 Hey xtopolis, thanks for that! Helped quite a bit.. and i've had a look at a few more topics on the same subject, and think i've come up with the simplest solution.. i'll put it here just incase anyone in the future has the same problem.. hopefully this should help Also, i've not tested this yet.. going to start implmenting it after i've finished this post.. here we go *// User registers //* We will update the $user->last_loggedin (field in the users table) to time() *// User logs in //* All of the posts/topics that are 'new' (Which are between time() and $user->last_loggedin) are added to a database... (Which consists of, user_id.. topic_id.. post_id) All posts/topics that are in the database.. appear as 'new' to the corrosponding user *// Someone else posts a topic/post //* When a new topic/post is added.. it is inserted into the database.. with all users that are online (within the last.. 20 minutes..).. again.. user_id.. topic_id.. post_id When a topic is viewed.. it's deleted from the database (again, with corrosponding user id) *// User logs out //* All entries in the database with their user ids on them.. are removed! Then the whole process starts again... The user logs in.. grabbing all of the posts from their last login.. to the current time.. This seems such a stupiiddd way to do this. And here's my reasoning.. Let's say 1000 users are logged in at the same time.. then someone posts a new POST... that's 1000 new rows in the database just for one single post.. Let's say a user doesn't login for a hell of a long time.. and like.. 50,000 new posts are added.. they login.. and 50,000 new entries are added to the database.. I guess i could limit the last one to the last 30 days or something.. even though major forum software doesn't seem to take that path :\ I'll let you know how it goes, anyhow. Quote Link to comment Share on other sites More sharing options...
xtopolis Posted July 22, 2009 Share Posted July 22, 2009 Granted, I don't have a lot of experience with this myself, but I'm not sure you entirely understood ALL the methods they were talking about in that thread. Play around with it and see if you find something that works/is efficient/manageable. Quote Link to comment 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.