Hello,

I want to replicate the behavior of "My recent posts" in Drupal, where the posts I create and post comments to show up and get sorted by latest post date. If I enable the "User:name" filter, only the my nodes show up, if I enable the "Comment:author" filter, the nodes with no comments don't show up.

How can I make this happen?

Thanks,
Andrey.

Comments

michelle’s picture

Views comes with a "tracker" view that replicates this functionality. Why not clone that as a starting point for your view?

Michelle

mr.andrey’s picture

When I specify the user id, Views' tracker doesn't list nodes to which I posted comments, only nodes which I authored.

mr.andrey’s picture

Is there no way to replicate the "subscribe" by posting a comment to a post functionality of Drupal's recent posts?

merlinofchaos’s picture

Category: support » bug

Apparently I never wrote an argument to work properly for the tracker view. How surprising.

mr.andrey’s picture

Any progress on this?

Thanks,
Andrey.

dww’s picture

FYI: This will be necessary for the full views2 port of project_issue: #359129: Convert the "My issues" page to a view...

merlinofchaos’s picture

Actually I was wrong. I did write the argument, I just put the wrong one in the default.

I've modified the default tracker view in -dev. If you've overwritten your tracker view or just want to fix yours, change the argument to "Node: User posted or commented" (You'll have to delete the existing one and add a new one with the same options).

merlinofchaos’s picture

Status: Active » Fixed
dww’s picture

Category: bug » feature
Status: Fixed » Active

It'd be nice to have this as an filter, too (e.g. for the "Participant" exposed filter for the issue queue advanced search, http://drupal.org/project/issues/search/views).

dww’s picture

Issue tags: +drupal.org upgrade

Having this as an exposed filter would help the d.o upgrade -- tagging as such.

neclimdul’s picture

StatusFileSize
new2.26 KB

This seems to do it. Not sure if its the right way though.

mr.andrey’s picture

Hi Merlin,

I just downloaded the latest dev and tested the tracker. It seems to work very well.

I created a new node - it moves to the top of the list.
I posted a comment to an old node - it moves to the top of the list.

Thanks!
Andrey.

merlinofchaos’s picture

+    $args = array_values($this->value);
+    // @todo this could probably be done more efficiently.
+    foreach ($args as $value) {
+      $args[] = $value;
+    }

This looks like 2 routines that do the same thing (and the first one is faster). Is the loop doing something else I'm missing?

dww’s picture

It's adding the placeholder values again, since $condition is used twice.

I'm not sure why this isn't using db_placeholders()...

dww’s picture

Status: Active » Needs review
StatusFileSize
new2.65 KB

This was mostly working fine, but I re-rolled it for a few things:

A) This is a lot more clear about what's going on:

+    // We include the WHERE condition twice in the query, so we need two
+    // copies of these argument values.
+    $args = array_values($this->value);
+    $args = array_merge($args, $args);

B) "Display comments only if a user posted the node or commented on the node" is misleading. This is matching nodes, not comments.

Otherwise, this is exactly what I need for the "Participant" exposed filter on the advanced issue search.

merlinofchaos’s picture

Status: Needs review » Fixed

Committed!

Status: Fixed » Closed (fixed)
Issue tags: -drupal.org upgrade

Automatically closed -- issue fixed for 2 weeks with no activity.