dongxibo2095 2010-11-17 20:27
浏览 105
已采纳

将论坛帖子标记为已读?

I'm working on a custom forum and was wondering what people would consider as the best approach to marking a thread as read.

I want to display a post icon for the threads and if the thread hasn't been read it has an unread icon and the topic title is bold. If its been read then the topic title is normal font weight and the post icon changes to the read icon.

Would the best way be to store in the users session which threads they have viewed and set it up to mark all threads older than 48 hours or so as read?

Thanks!

  • 写回答

3条回答 默认 最新

  • dsjfrkvn818747 2010-11-17 20:43
    关注

    Create a second table such as:

    thread_member: thread_id, member_id, read_flag, posted_flag, bookmarked_flag
    

    Basically anything specific to that member and a thread could go in there. When pulling the list of threads, LEFT JOIN against that table. If read_flag is 0 or NULL, then it's new.

    SELECT * FROM thread t
    LEFT JOIN thread_member tm ON t.id=tm.thread_id AND tm.member_id=$member_id
    WHERE t.id=$thread_id
    

    Anytime somebody posts a message in the thread, just run this query:

    UPDATE thread_member SET read_flag=0 WHERE thread_id=$thread_Id
    

    posted_flag could be used to determine if the person wrote a message in the thread.

    bookmarked_flag could be used to determine if the person bookmarked the thread.

    To keep the table trim, you could truncate all old records that didn't have any important flags set. In this example, you could delete all records older than X days/weeks/months that don't have bookmark_flag set.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度