HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

count number of new discussions in category list

jackmaessenjackmaessen ✭✭✭
edited January 2015 in General Banter

i am trying to display the number of new discussions per category in the side panel under Category List.
In the discussionlist, this function creates the number of new comments or gives a "new" for a new discussion.

if (!function_exists('NewComments')):
function NewComments($Discussion) {
   if (!Gdn::Session()->IsValid())
      return '';

   //if ($Discussion->CountUnreadComments === TRUE) { // bug; for the author of discussion; it is not a new topic!!! see below
      if ($Discussion->CountUnreadComments === TRUE && $Discussion->InsertUserID != Gdn::Session()->UserID) {
      $Title = htmlspecialchars(T("You haven't read this yet."));

      return ' <strong class="HasNew JustNew NewCommentCount" title="'.$Title.'">'.T('new discussion', 'new').'</strong>';
   } elseif ($Discussion->CountUnreadComments > 0) {
      $Title = htmlspecialchars(Plural($Discussion->CountUnreadComments, "%s new comment since you last read this.", "%s new comments since you last read this."));

      return ' <strong class="HasNew NewCommentCount" title="'.$Title.'">'.Plural($Discussion->CountUnreadComments, '%s new', '%s new plural', BigPlural($Discussion->CountUnreadComments, '%s new', '%s new plural')).'</strong>';
   return '';

So my question: how can i modify this ( or make a new function like this) to make this possible: count the number of new discussions per Category (since last visit). Like image below:

cat.png 18.2K


Sign In or Register to comment.