Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Options

Show "new posts" indicator at category level?

LeeHLeeH
edited March 2012 in Vanilla 2.0 - 2.8

I'm deploying a test forum with Vanilla 2.1 (cloned from the github repo) and a modified version of the Bittersweet theme. I like how individual discussion threads in the Discussions view display "New" indicators (with class HasNew) with a count of new posts since last visit, but I want to extend that functionality and carry it up into the Category level, such that the top level category view shows an indicator when there are any posts in it with unread replies.

The functionality is in place in the Penny Arcade forums, but it's difficult to crib from it because the generated pages are too customized (categories with unread posts look like they are listed as list items with an "unread" class, but vanilla Vanilla doesn't do any such labeling).

I'm CSS smart and php stupid, but I can generally puzzle out what a given block of php code does based on context. Is there an easy, or semi-easy, way to retrofit some kind of unread reply indicator into the category view? It doesn't need a actual count or anything—just a visual indicator that a category contains unread replies would be perfect.

Best Answer

  • Options
    ToddTodd Chief Product Officer Vanilla Staff
    Answer ✓

    Your function doesn't work because the categories helper functions doesn't call that function because it's specialized for discussion lists.

    I can tell you that we will never have a specific count of new discussions at the category level because there's no decent way to optimize that functionality for large forums.

    We have some rudimentary strategies that allow a user to mark a category as read, but this is a feature that isn't quite ready for prime time right now.

Answers

  • Options

    I am definitely in over my head. I've located the set of lines in the Categories helper functions where I can insert TDs to account for an "Unread" marker, but the actual programmatic method for determining unread posts is too much for me to figure out.

    I can guess, for example, that the per-discussion "New" tag in the discussions view is generated by this bit of code in applications/vanilla/views/discussions/helper_functions.php:

    if (!function_exists('NewComments')):
    function NewComments($Discussion) {
    if (!Gdn::Session()->IsValid())
    return '';
    if ($Discussion->CountUnreadComments === TRUE)
    return ' '.T('new discussion', 'new').'';
    elseif ($Discussion->CountUnreadComments > 0)
    return ' '.Plural($Discussion->CountUnreadComments, '%s new', '%s new plural').'';
    return '';
    } endif;

    (Sorry about the formatting--trying code tags)

    However, that chunk of php obviously doesn't work if I just transplant it into an override file under theme/mine/views/categories/helper_functions.php; I'm guessing because it references functions(?) that don't exist....maybe? Not being a php coder or even a programmer in general, I'm not sure.

    The ability to determine whether or not a discussion contains unread replies obviously exists; I just don't know how to take advantage of it. Any help would be appreciated.

  • Options
    ToddTodd Chief Product Officer Vanilla Staff
    Answer ✓

    Your function doesn't work because the categories helper functions doesn't call that function because it's specialized for discussion lists.

    I can tell you that we will never have a specific count of new discussions at the category level because there's no decent way to optimize that functionality for large forums.

    We have some rudimentary strategies that allow a user to mark a category as read, but this is a feature that isn't quite ready for prime time right now.

  • Options

    That makes sense--it was a shot in the dark anyway, and I can see that having to walk the entire discussion tree of every category to accumulate a count of unread messages would be unworkable and would only get worse as the forum's user & post count increases.

    Still, the custom work you guys did for Penny Arcade does show that a category can be marked as containing unread posts, which is functionality that I definitely would like to see. The entire structure of how categories & discussions are displayed there is very different from release & prerelease vanilla (relying more on tables instead of stacked divs), but clearly there is some custom php code under there so that categories with unread replies are displayed with an additional "unread" class tacked on, which carries styling with it.

    I love Vanilla and am enjoying my experience with it—my forum is going live next week, in fact—and it would be great if at some point this bit of functionality made it into the release or prerelease versions :)

Sign In or Register to comment.