different background new topic
using 2.0.18.10 with VanillaBootstrap theme
For a new topic or a new post , i changed the background in the class "New" so that people can easily see that this is a new post. And ofcourse in both cases the line "1 New" is being displayed.
But now i want to make difference between posting a comment in an existing topic or posting comment in a new topic (so actually starting new topic).
Both text are being parsed in the New class.
I found in helper_functions.php this piece of code:
function WriteDiscussion($Discussion, &$Sender, &$Session, $Alt2) { static $Alt = FALSE; $CssClass = 'Item'; $CssClass .= $Discussion->Bookmarked == '1' ? ' Bookmarked' : ''; $CssClass .= $Alt ? ' Alt ' : ''; $Alt = !$Alt; $CssClass .= $Discussion->Announce == '1' ? ' Announcement' : ''; $CssClass .= $Discussion->Dismissed == '1' ? ' Dismissed' : ''; $CssClass .= $Discussion->InsertUserID == $Session->UserID ? ' Mine' : ''; $CssClass .= ($Discussion->CountUnreadComments > 0 && $Session->IsValid()) ? ' New' : ''; $DiscussionUrl = '/discussion/'.$Discussion->DiscussionID.'/'.Gdn_Format::Url($Discussion->Name).($Discussion->CountCommentWatch > 0 && C('Vanilla.Comments.AutoOffset') && $Session->UserID > 0 ? '/#Item_'.$Discussion->CountCommentWatch : ''); $Sender->EventArguments['DiscussionUrl'] = &$DiscussionUrl; $Sender->EventArguments['Discussion'] = &$Discussion; $Sender->EventArguments['CssClass'] = &$CssClass; $First = UserBuilder($Discussion, 'First'); $Last = UserBuilder($Discussion, 'Last'); $Sender->FireEvent('BeforeDiscussionName');
My question: how can i give a new topic a different class in which the content is being parsed?
Because i want to give that class a different background-color.
I think i have to do something with this line:
$CssClass .= ($Discussion->CountUnreadComments > 0 && $Session->IsValid()) ? ' New' : '';
Can someone help me with that how i can make difference between a new topic and a new post in an existing topic?
Comments
Hiya!
You can check the user discussion data and append a css class to discussions that haven't been viewed yet. I used the following as a quick test:
This hooks into the discussions controller right before the name is displayed and adds the class UnreadDiscussion if appropriate. Putting this snippet in your theme hooks file will give you 'access' to style unread discussions differently.
Search first
Check out the Documentation! We are always looking for new content and pull requests.
Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.
This works great @hgtonight. Thankyou. There is just one little thing: when clicking on All Viewed, the class UnreadDiscussion does not change to Item or Item Alt. But the "1 New" disappears. That's good! The background-color does disappear when you click on the topic itself. Is there any way i can make it work with the AllViewed to disappear?
That is a good question. The All Viewed plugin works by placing a datetime in the user table and hooking into the discussion model to change the comment counts reported.
This code should take the all viewed stamp into consideration and also not throw any errors in for installs not using the plugin.
Search first
Check out the Documentation! We are always looking for new content and pull requests.
Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.
Awesome @hgtonight. This works great. And when hitting the AllViewed button, the bg colors disappear both!
Thankyou very much for support.
See attachment: