The "Node: has new content" filter is not sufficient because it includes nodes that have been updated but have no new comments.

For example, we can't create a tracker view that only shows all forum posts with new comments since the user's last visit.

There is code here that works in the meantime if you add it to a module, but it would be nice if it was a core filter:
http://drupal.org/node/457408#comment-4235014

CommentFileSizeAuthor
#14 views_has_new_comments.zip2.3 KBmr.j
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

merlinofchaos’s picture

Patches considered, but active feature requests without any code or a developer with the time to champion it isn't likely to go anywhere.

dawehner’s picture

Version: 6.x-2.12 » 6.x-3.x-dev

There will probably no new features to 6.x-2.x

Michelle’s picture

This is what I was talking to you (merlinofchaos) about the other day in IRC. I'm still thinking of writing something, but it may be a while. Doing it in 3.x makes more sense, anyway, since I imagine 2.x is going to be deprecated once it's out. If someone else gets to it first, wonderful. Otherwise, there's a pretty good chance I'll do it sometime in the next few months.

Do you have any opinion on whether the code that was link to is a good starting point?

Michelle

fjen’s picture

+ subscribe

dawehner’s picture

@michelle
The code will probably look much different, but it can give you an idea how the sql should look like.

Michelle’s picture

@dereine No rush. I'm bogged down with stuff, now, for quite a while and wouldn't be able to make use of it any time soon. Don't want you wasting your time when I'm not in a position to follow through.

Michelle

aronnok’s picture

badly need this feature

Michelle’s picture

Version: 6.x-3.x-dev » 7.x-3.x-dev

I seriously doubt it will get into 6.x. Bumping the version because I still think this would be useful if anyone ever has time to do it.

Michelle

mr.j’s picture

I have actually finally worked this out on 6.x. It was a matter of copying the has new content filter and changing a few things.
Its currently part of a larger custom module I wrote full of generic stuff for a site. I'll try to clean it up and separate it into a separate module to add here, or would you prefer a patch against 6.x?

dawehner’s picture

A patch would be wonderful, though as 6.x-2.x is pretty much stable it will be added only to 6.x-3.x.

Rob230’s picture

For anyone interested I managed to simulate a "Content: Has new comments" field using the "Content: New comments" field.

  1. Add the Content: New comments field (which outputs the number of new comments)
  2. In Rewrite results enable "Rewrite the output of this field" and put the text as "new".
  3. In No results behaviour enable "Count the number 0 as empty" and "Hide rewriting if empty" (leave the no results text blank).
  4. In Style settings enable "Customize field HTML", choose a SPAN as the element, enable "Create a CSS class" and enter "marker" as the CSS class.

This should produce output similar to "Content: has new content" except for comments.

What would be nice is an aggregation of both (show "new" if the node is new OR if it has new comments and show "updated" if the node has been edited). That would complement the "Content: Updated/commented date" field.

janis_lv’s picture

I followed #11,

I wanted to achieve "(count) new" in a table view.

I found out that if I add just 1 "x new" with the span class=marker, the class was removed from the output.

I worked around this adding twice the "has new comments" field, one was re-written as "new" with the span, also the span wasn't working if the output was a link.

1 just from numbering, other for "new" with span class=marker.

JordanMagnuson’s picture

Component: comment data » node data
Issue summary: View changes

Has anyone done any further work on actually creating a proper filter for "Node: has new comments"?

mr.j’s picture

The attached works for me on views 6.x-3.x, using a custom module. What you have to do:

1. Start with your own custom module (referred to as "yourmodule" from now on).
2. Create a subdirectory called "views" inside yourmodule and unzip the attached file there.
3. Modify "yourmodule.views.inc" and replace the instances of "yourmodule" with the real name of your module.
4. Rename "yourmodule.views.inc" using the real name of your module.
5. Add the following function to yourmodule so that views knows where to find the new filter (again replace "yourmodule"):

function yourmodule_views_api() {
  return array(
    'api' => 2,
    'path' => drupal_get_path('module', 'yourmodule') . '/views',
  );  
}

6. Flush caches and alter your views to add the "Node: has new comments" filter.

By default it selects nodes that have new comments since the user last viewed the node, and new nodes with comments with a last comment timestamp within the last 30 days (same as the has new content filter). If you want to alter the 30 days time limit then you will have to alter the code (search for 2592000).

I don't think it will work at all for anonymous users as the history table doesn't track what they have read.

This really should be in views core.

johnkareoke’s picture

@ mr.j

I've tried your solution in #14 and I get "Broken/missing handler (= )" in my view when I add this filter.

This is the first module i've "created", but I'm pretty sure I've got the structure/locations and names correct.

Most important to solving this for me is that I'm using Drupal 7, not 6, so I think that is where the problem lies.

mr.j’s picture

Sorry I can't help you with D7. I have only used it on D6 I'm afraid.

Anonymous’s picture

hi...i'm looking for the same filter to only show nodes with new comment. Is there any progress about this?

regards

konsul

monstrfolk’s picture

Very simple way to do this....using module views php filter.

1. Add Content:Nid field to view
2. Add Views PHP filter to view.
3. Enter in the filter

return comment_num_new($data->nid) == 0;

That will return only rows with new comments.