#FF6600
16715
0
1
Dec 3, 2024 19:00:57 GMT -8
Patrick [ASE]
Ancient Geek
46,300
November 2003
allseeingeyes2
|
Post by Patrick [ASE] on Nov 16, 2009 7:17:21 GMT -8
Is there aan easy way to get a 'New' icon for topics on a website ? I'm collaborating with Captain Niobe on a forum and site, and when a new topic is added to the website, it would be good to have the New icon to display with the title/link if the reader hasn't read it, similar to how Proboards does it. If this means server coding, can you explain how to do it and what codes need to be used. Thanks
|
|
inherit
16846
0
Nov 19, 2012 15:20:20 GMT -8
Chris
3,036
December 2003
cddude
|
Post by Chris on Nov 16, 2009 9:16:18 GMT -8
You'd need server coding if you also want it to be "marked as read." There's a few different ways to do it, but that all depends on your setup. The main thing you need is some way to identify the user. I have three easy ways to do this: 1) If you have a login system, their username. 2) Set a unique cookie on their computer and use this to identify them. (Issue if they clear cookies.) 3) Use their IP address. (Issue if their IP changes, which happens.) Either way, we just want some system to track the user. Then we need a unique ID for each article/thread. If you're using a database already, this is really easy. Now we just need a system like this: 1) When loading the list of threads, also load the data concerning whether or not the user has read that specific thread. Try not to abuse MySQL queries in this case. 2) If the user has read the thread, don't show the icon. 3) If the user hasn't read the thread, show the icon. 4) When viewing a thread by clicking the link, if the relationship between user and thread doesn't exist, create it. This way it just got "marked as read." Hopefully that makes sense. It's not actually that hard of a system to implement. The only issue is implementing it efficiently.
|
|
inherit
54640
0
Jul 2, 2019 10:52:15 GMT -8
Phrate
It's been 9 years!
1,297
August 2005
ghotherkill
|
Post by Phrate on Nov 18, 2009 14:47:57 GMT -8
An effective method, Chris. What I used for the forum I'm making is this: - Grab all threads on board (paged, of course)
- If the thread starter isn't the user themselves, then check if the new people to post on that thread isn't them as well.
- From those new posts, check if the cookie with the identifer significant to that thread exists. An example might be "post_1234_view" or something similar.
- If no cookie is present, then show the "new" image. Once the user views the thread, a cookie will be made with that indentifer.
Now, my forum only accepts people who's browsers accepts cookies, so this is only one option.
|
|
#FF6600
16715
0
1
Dec 3, 2024 19:00:57 GMT -8
Patrick [ASE]
Ancient Geek
46,300
November 2003
allseeingeyes2
|
Post by Patrick [ASE] on Nov 18, 2009 18:05:45 GMT -8
Remembering this is for a website page. I don't think Niobe wants the bother of logins, she may confirm here. Sounds like a cookie needs to be set if the reader has visited the link so it 'hides' the icon.
|
|
inherit
54640
0
Jul 2, 2019 10:52:15 GMT -8
Phrate
It's been 9 years!
1,297
August 2005
ghotherkill
|
Post by Phrate on Nov 19, 2009 8:38:49 GMT -8
Yes, as in, it checks if the cookie is not present (a.k.a. if there are unread posts)
Then, once you read those "unread" posts, it sets their cookie equivilant to say, their post ID or something similar.
|
|
inherit
16846
0
Nov 19, 2012 15:20:20 GMT -8
Chris
3,036
December 2003
cddude
|
Post by Chris on Nov 19, 2009 9:18:35 GMT -8
Yes, as in, it checks if the cookie is not present (a.k.a. if there are unread posts) Then, once you read those "unread" posts, it sets their cookie equivilant to say, their post ID or something similar. However, there is a limit on cookie size. I believe it's 3kb, but I might be wrong. Either way, a lot of articles start to pose a problem then. That's why I recommended the database strategy.
|
|
inherit
54640
0
Jul 2, 2019 10:52:15 GMT -8
Phrate
It's been 9 years!
1,297
August 2005
ghotherkill
|
Post by Phrate on Nov 19, 2009 9:27:47 GMT -8
I'm sure a simple cookie named "post_4324454355_view" wouldn't be over 3kb, even with the ID number in the millions.
But, if I'm wrong, then may you explain exactly how you would go through with this database strategy? I read your post but failed to get a solution. Would you possibly, have a seperate table?
|
|
inherit
100824
0
May 13, 2012 5:37:49 GMT -8
Michael
14,585
March 2007
wrighty
|
Post by Michael on Nov 19, 2009 16:50:24 GMT -8
I'm sure a simple cookie named "post_4324454355_view" wouldn't be over 3kb, even with the ID number in the millions.
But, if I'm wrong, then may you explain exactly how you would go through with this database strategy? I read your post but failed to get a solution. Would you possibly, have a seperate table? Problem comes when there are loads of articles! The database method isn't that hard. You'd have a table with perhaps 3 rows. Article_ID User_ID TimeStampor something like that...
|
|
inherit
54640
0
Jul 2, 2019 10:52:15 GMT -8
Phrate
It's been 9 years!
1,297
August 2005
ghotherkill
|
Post by Phrate on Nov 19, 2009 17:14:47 GMT -8
Problem comes when there are loads of articles! The database method isn't that hard. You'd have a table with perhaps 3 rows. Article_ID User_ID TimeStampor something like that... I don't think you quite understand it. The cookie would only be created after you view the page that contains the unread post. Not created every time a thread/post is made. The number I said is in the trillions, and it still wouldn't be a problem. PB isn't even in the trillions for posts.
So, with that table, you're saying for every new post read, it inserts a table for that post I just read? That's terribly space-consuming.
|
|
inherit
130228
0
Jul 11, 2024 19:19:59 GMT -8
Charles Stover
1,731
August 2008
gamechief
|
Post by Charles Stover on Nov 19, 2009 19:56:57 GMT -8
It would be for every topic, not post. Neither are right or wrong. It depends on whether you're willing to trade reliability for for space. The upside to the database method is more control. You could easily just remove all rows where the date is over a week/month/year old, since it's unlikely that they'll be reading that article/topic again. The upside to the cookie method is that it requires no space, but it's extremely unreliable. It won't work for browsers with cookies disabled, and it's up to the browser and/or OS to honor the site's wishes of how long the cookie should exist, often with them being erased as soon as the browser closes. I dig the DB method. Wrighty's table would take up hardly any space at all, especially when combined with a Cron job to clear it out of entries older than a month.
|
|
inherit
54640
0
Jul 2, 2019 10:52:15 GMT -8
Phrate
It's been 9 years!
1,297
August 2005
ghotherkill
|
Post by Phrate on Nov 20, 2009 7:54:58 GMT -8
Hmm, well I hadn't thought of the cookies-disabled option, as I would assume it'd be a requirement.
But, I guess I'll have to try out this method. My question is, how would you detect whether a specific user has read the article or not? Just insert one of those tables for every user? Sorry for the lack, I just don't quite catch it.
|
|
inherit
100824
0
May 13, 2012 5:37:49 GMT -8
Michael
14,585
March 2007
wrighty
|
Post by Michael on Nov 20, 2009 10:25:27 GMT -8
Hmm, well I hadn't thought of the cookies-disabled option, as I would assume it'd be a requirement.
But, I guess I'll have to try out this method. My question is, how would you detect whether a specific user has read the article or not? Just insert one of those tables for every user? Sorry for the lack, I just don't quite catch it. When the user loads the page you insert something into the table. saying the article ID, user (or IP), and timestamp. Don't get what there isn't to get...
|
|
inherit
54640
0
Jul 2, 2019 10:52:15 GMT -8
Phrate
It's been 9 years!
1,297
August 2005
ghotherkill
|
Post by Phrate on Nov 20, 2009 13:49:54 GMT -8
Ahh, alright. Well I'll stick with my method for now.
|
|
inherit
130228
0
Jul 11, 2024 19:19:59 GMT -8
Charles Stover
1,731
August 2008
gamechief
|
Post by Charles Stover on Nov 20, 2009 22:48:11 GMT -8
Hmm, well I hadn't thought of the cookies-disabled option, as I would assume it'd be a requirement.
But, I guess I'll have to try out this method. My question is, how would you detect whether a specific user has read the article or not? Just insert one of those tables for every user? Sorry for the lack, I just don't quite catch it. When the user loads the page you insert something into the table. saying the article ID, user (or IP), and timestamp. Don't get what there isn't to get... He's prolly not used to MySQL. It was hard for me to understand table optimization when I first started. Took quite a while before it clicked and I understood how a database functions. article ID, user ID, date read $read_receipt = mysql_query('SELECT `date` FROM `read_receipts` WHERE `article` = ' . $article_id . ' AND `user` = ' . $user_id) or die(mysql_error()); $read_receipt = mysql_fetch_assoc($read_receipt); if (!$read_receipt['date']) echo 'NEW!'; There would be ways to optimize it (by returning an Array), but it'd prolly be too complicated for someone without prior MySQL training and the sort. Optimization's a betch.
|
|
inherit
54640
0
Jul 2, 2019 10:52:15 GMT -8
Phrate
It's been 9 years!
1,297
August 2005
ghotherkill
|
Post by Phrate on Nov 21, 2009 10:39:07 GMT -8
Charles, I am quite the expert at MySQL, I was just new to his idea is all.
|
|