显示用户未读的话题或帖子
我正在编写自己的基本论坛以插入到 code igntier 网站中。我对如何显示用户未读的线程/最新帖子有点困惑。
我正在考虑一个表来保存访问的每个 thread_id,但该表有可能变得相当大。
有哪些方法可以满足这一要求?
I am in the process of writing my own basic forum to plug into a code igntier site. I'm a little stuck on how to display threads/latest posts unread by a user.
I was thinking of a table that holds each thread_id visited, but this table has the potential to get rather large.
What's are some ways to approach this requirement?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
一个简单的想法:记录用户访问站点/论坛/子论坛的最后日期时间。根据您的喜好,这可以像线程或子论坛一样精细。也许在 cookie 中创建/更新这个
thread_id
和last_visit_date
键值对。也许将其存储在 cookie 中,而不是存储在 RDBMS 中。问:这是任务关键数据,还是能够/不能承受数据丢失的重要功能?当用户返回时,查找
create_date
大于论坛last_visit_date
的所有主题/帖子。我假设访问论坛(线程列表)的行为与“查看”相同。假设如果提供了信息,则您已“查看”了线程标题,无论您是否实际深入了解了该线程。
A simple idea: record the last datetime that a user visits the site/forum/subforum. This could be as granular as the thread or subforum, as you like. Perhaps create/update this key-value pair of
thread_id
andlast_visit_date
in a cookie. Perhaps store this in a cookie, rather than in your RDBMS. Ask: is this mission critical data, or an important feature that can/cannot withstand a loss of data?When the user returns, find all the threads/posts whose
create_date
is greater than thelast_visit_date
for the forum.I'm assuming that the act of visiting the forum (list of threads) is same as 'viewing'. Assuming that if the info was presented, that you'd 'viewed' the thread title, regardless of whether you actually drilled into the thread.
最简单的方法可能就是保留用户上次访问时间的 cookie 并查询此后发布/编辑的帖子。您无法完全获得所有已读线程,但大多数论坛似乎都是这样工作的,否则您必须将所有已读线程保存在某处。
The easiest way out would probably be just to keep a cookie of the time of user's last visit and query posts posted/edit after this. You don't get exactly all read threads but most forums seems to work this way, otherwise you have to save all read threads somewhere.
我认为您确实不需要像您想象的那样创建任何表来记录线程 ID,因为它会随着用户规模和创建的线程/帖子的数量而增长。您可以仅将用户上次访问后创建的话题或帖子显示为未读。我想这就是我要做的。
I don't think you really need to create any table to log thread ids as you have thought because its going to grow by the size of your users and by the numbers of threads/posts created. You can just show threads or posts that were created after the user's last visit as unread. I think thats what I am going to do.