Hey,

I don't know if somebody else fixed this or not. I searched but did not find a solution.

I was trying to get a view of all the nodes that belonged to a user I flagged. Basically a 'Follow' function similar to Twitter.
The content view only allowed me to create a list of nodes that were flagged. So I added a few lines to the views file of the module and I got the wanted result.

So here's the patch, maybe it's something what others are searching for as well.

CommentFileSizeAuthor
flag-relationship-fix-na-1.patch870 bytesskein
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

joachim’s picture

Status: Needs review » Needs work

I suspect this needs work. It should skip user flags, as I'm not sure it would make sense then (at least, it hurts my brain thinking about it).

skein’s picture

Well the relationship that I defined in the patch is using only user flags, so that you get only the content of the flagged user.

joachim’s picture

+++ b/includes/flag.views.inc
@@ -207,6 +207,21 @@ function flag_views_data_alter(&$data) {
+      $data[$info['views table']]['flag_user_rel'] = array(

But this is inside a loop for each type of flag. So at some point, you're adding a user-user relationship by the look of it.

joachim’s picture

Version: 7.x-2.x-dev » 7.x-3.x-dev
joachim’s picture

Title: Create a view with nodes of flagged users » Documentation: Create a view with nodes authored by flagged users
Component: Views integration » Documentation
Category: feature » task
Status: Needs work » Active

Furthermore,

+++ b/includes/flag.views.inc
@@ -207,6 +207,21 @@ function flag_views_data_alter(&$data) {
+          'relationship field' => 'uid',

How do you know your entity table has a uid field? This will fail on most entities. We can't make this kind of assumption in flag.

What you need instead is:

- view of users
- relationship to the flag to limit users to those flagged
- add an argument on the flagging UID, to limit the result to users flagged by a particular UID
- add the User: Content authored relationship to go from the listed user(s) to the nodes

Converting this to a docs issue so this can be written up in the documentation cookbook.