Adding "view unread posts" plugin
For those of you familiar with phpbb forums, a very liked feature is the ability to show your unread posts, and also to skip to the last unread reply in that thread.
I have spoken to Pippin, from http://pippinsplugins.com, who estimates that to create a plugin to include these features on bbpress will cost between $350 and $600.
Now my website, which will have a forum migrated to it soon, will require these features, however it is only a hobby website
So I’m asking bbpress forum owners out there, do you want this plugin? And if yes, would you be willing to contribute to the cost?
Thanks! I really appreciate it. I’m really hoping to continue developing this out and make it into a really solid little add-on for bbPress.
Pippin wrote: I can definitely see how that can play a major role, but it’s definitely not going to make it in for now, at least not right away.
Keeping track of replies like that is a whole new ball game.
I’ve been talkin with JJJ (lead bbPress developer) about how we might work to integrate these features into the plugin core. Tracking replies will probably definitely be something we’ll look into then.
Hi Pippin, I don’t mean to be a pest, but would you have some sort of timeframe to integrate this? I think the forum members will be okay with the forum the way it is if they know that the feature will be added in the future.
I don’t think you have to wait for integration. The plugin Pippin wrote works perfectly. If, in future it’s fully integrated into the bbPress plugin for WordPress, then we can drop the extra plugin, but this works great! I wouldn’t wait for integration.
p.s. This plugin is worth supporting & I appreciate your work, Pippin. Hope many people have donated to your time spent on this. I wish I could give more. Thanks again!
Hi Pippin, great work on this plugin so far. Thank you. I read through the code and tested it out. The plugin works great, and I commend you for your hard work on this. I wanted to provide a bit of feedback in case you are planning any further revisions, just to weigh in with my 2c: 1) I realize you needed somewhere to hook the “mark as read/unread” link, and by default in bbp_theme_compat no action hook is provided in a topic header. Hooking it onto the subscribe link wedges it between subscribe/favorite and is overall a bit awkward for templating. I’m not sure what a better default solution would be, but personally I felt the need to unhook this and manually place the toggle button somewhere more appealing. 2) A standalone function to display a loop of unread topics would be great. show_unread_topics() is purpose built for the bbpress user profile, but under many circumstances users might want to call this list elsewhere (if we are using BuddyPress profiles for example). Personally I created a “View Unread Topics” page that functions similarly to the “Recent Topics” archive. Anyways, including a function for just the unread topics loop (with pagination) would be a nice addition for template flexibility purposes. 3) For a site with thousands of topics, is having that bulky a “_bbp_mar_read_ids” entry in meta a concern? 4) The plugin serves a nice function of allowing a user to track whether or not he/she has looked at topics which are posted. However, it seems to me that full “view unread posts” functionality would entail clearing resetting the “read” flag when the topic is updated with a new reply. What about saving each “read” ID to meta as: post_id?num_replies where num_replies is the number of replies to the topic when the user marked it as read. When a topic is called you can explode out how many replies it had when the user first marked it. If the topic now has more replies than when it was marked, you can override the “read” flag and reset it to unread. Probably not a very elegant solution, but I think what most users would be interested in is being able to generate a list of threads with unread content, not necessarily just unread topics. Anyways, thanks very much for your work on this. I’ll be keeping an eye on how this project develops. Andrew
1). I chose this hook because it was the only one that made sense to me, in terms of the final location. Since it is hooked, you are obviously free to move it wherever you wish.
2). Agreed, and this is on the list.
3). Yes this is a concern. JJJ and I spoke about this for a while for this exact reason. The plugin is persistent, meaning that every single topic ID is stored in the user meta, which will eventually run out of space. At some point I want to alter this, but have not yet come up with a better solution.
4). That very true but I have not yet figured out a way to really do that. The number of replies flag is an interesting though, and might work, but I can’t say for sure until I attempt to implement something.
Pippin, thanks for sharing your thoughts. Sorry the formatting of my original post was so hideous, I’m not sure what happened. I guess maybe line breaks got stripped after getting run through spam filter or something?
It’s definitely a tricky problem, I had thought about trying to write an “unread posts” function a while ago and decided against it because I was worried about scalability and database requirements. I wonder how some of the dedicated forum platforms handle this sort of feature.
aaclayton, speaking about “I wonder how some of the dedicated forum platforms handle this sort of feature.”
m running bbpress 1.0.2 forum with 400+ topics and 16000+ posts for 2+ years. Im using “Unread Posts” plugin written by ck and should say that its perfect. Have not faced any errors or performance problems with it. Maybe you should look at source of that? Not sure if that plugin can be still found on net, but in case its not I can share the code (actualy there is just one php file).
Pippin, is is possible to add a numeric indicator on the forum index page beside each topic to denote how many unread posts are inside of that topic? I imagine this being similar to iOS’s badges. This is a request from a current client, so I would be up for adding this myself if it’s not something you plan to integrate. I am, however, a bit of a novice at bbPress, so if there is anything that you could share to get me on the right path, I’d appreciate it! The plugin has been a lifesaver, thank you!
I anticipate that’s not going to be feasible, because it would require him to count whether individual replies have been read, instead of simply toggling if a topic is read or not.
The database implications of flagging read status at the reply level are a bit scary.
I’m not looking for it to count replies, I simply need it to count unread posts. I understand replies are another beast altogether. Simply put, If a topic listing page shows 5 posts are unread, I just want it to display a “5″ beside the topic name on the main forum index page…with a custom class of course…ha.
I’d like to be able to see unread replies in addition to unread topics. Can this be added easily to the plugin?
@Imabe10 It would be possible, but I do not plan to do it as it could potentially have some rather large impacts on performance.
@markramos83 This is not planned at this time, sorry.
Thanks, Pippin. I sent you a message through your site about custom development in case you hadn’t seen it.
I’ve got 32,000 members and 380k-ish posts, is it safe to use this plugin?
When I switched to bbPress that was the first thing my moderators asked me for, the ability to see unread, unanswered topcis.
*I am already having severe memory / performance issues with bbPress and don’t want to do anything to make it worse, but the moderators aren’t happy so mamas not happy
The only time this could cause memory issues is when clicking the “Mark All As Read”. Actually that could cause some seriously problems if you have that many posts.
As long as you do not try to mark every single post as read at once, it will not have any problems.
So I believe I’ve figured out a really simple solution to this all. My particular issue with the plugin in question in this thread is simply that it relies on users clicking a link to mark a post as read, which isn’t all that intuitive in my humblest of opinions.
Using a built in BBPress function `echo bbp_get_topic_last_reply_url( $topic_id );` and some CSS, we can easily style unread threads.
`echo bbp_get_topic_last_reply_url( $topic_id );` links to the latest reply in a given thread. So something like myforum.com/forum/topic/post-name/page/10/#postid-12345
When a new reply is created, that last bit there becomes #postid-12346 and is therefore a new URL, so browsers will treat it as an unvisited link. Therefor, doing something like this gets the job done:
For anyone who’d like more detail, I’ve written a complete post on exactly how to do this: http://clicknathan.com/web-design/bbpress-read-topic/
It only involves changing one BBPress template file in your theme & adding a single line of code to your style.css file.
I agree this is a reasonably clever approximation for displaying which threads have been viewed by the user however there is one primary feature that most forum-goers look for in a “unread posts” feature that this does not successfully proxy for, which is the ability to query a list of topics which are unread and/or have unread replies.
I played around with an alternative approximation of this feature by generating a list of topics with replies more recent than the user’s last recorded activity (from BuddyPress), but this also only simulates the functionality that posters are used to from a VBulletin style message board.
Pretty cool @clicknathan, I’ll be implementing this on my site.
Just noticed in your tutorial (it caught me out!) – your css step looks like this:
but should be like this
There’s a fairly substantial difference between “topics with no replies” and “topics with new (read UNREAD) replies”
Not to detract from the cleverness of your solution, but my point was that it can approximate “read topics” using browser side CSS, but it can’t generate a list of unread topics using PHP.
I’m currently working with/foisting my testing on @Clicknathan (Hi, Nathan!) on a plugin to address the goals of indicating unread topics, indicating topics that have unread replies, and providing a means to jump to the first unread reply for a given topic. (This is my first foray into the wild-n-wacky world of bbPress, PHP, and WordPress plugins…very educational thus far…)
My first cut is another solution using user metadata; I store a map of topic IDs to last-read-reply IDs. It looks like this `$TOPIC-ID:$LAST-REPLY-ID|$TOPIC-ID:$LAST-REPLY-ID|$TOPIC-ID:$LAST-REPLY-ID`.
When rendering topics in the loop, I check the topic’s metadata for last-reply ID, and compare it to the last-read-reply ID in the user’s map. If there is no matching topic in the map, I add a CSS class for “unread topic”; if there is a matching topic, and the last-read-reply ID is less than the last-reply ID, I add a CSS class for “unread replies”.
When handling replies, I update the map (only in memory!) as I loop through each reply, then commit the map back to user metadata after processing all replies. I also check each reply ID; if it is the first one I find greater than the last-read-reply ID from the map for the current topic, I throw in a “first-unread” anchor tag, so it can be easily jumped to on the client side.
Currently, I don’t limit the number of topic/last-read-reply pairs I store in the user metadata; I’m quite sure there will be a point where performance suffers.
I’m also unsure how best to handle pagination for the “jump to first unread reply” question; while dropping the anchor tag is easy enough, I’m not sure how to properly form the URL to which to append the anchor tag ref, without some fairly complex logic involving looking up the relative index of the first unread reply in the set of all replies for the topic.
Anyway, I’d love some feedback at the conceptual level now, and I’d even more appreciate some solid criticism when I get the plugin whipped into shape and submitted.
@danblumenfeld, seems like that would work fine for small sites with a limited number of users and topics, but what about when you get into the thousands of users with thousands of topics? At that point you are saving an extremely long meta key for every user. I would worry about scalability, although I think that’s true of any attempt at solving this problem.
As for pagination with jumping to the first unread reply, it might be more practical to simply give the user a “jump to last read reply” button using bbp_get_reply_permalink( $reply_id );
@aaclayton: I agree re: scalability. I was contemplating limiting the number of topics stored to the top N, basing “top” on freshness, and assuming anything not in the top was already read…that does leave the problem of older topics that are resurrected, appearing as new topics. I dunno…perhaps a simpler throttling mechanism would be just to discard topics off the back of the map as it grows beyond a certain size? Also less than ideal, but simple and doesn’t involve extra data lookups.
Thanks for the suggestion re: bbp_get_reply_permalink.
You must be logged in to reply to this topic.