Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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.
Comment | File | Size | Author |
---|---|---|---|
flag-relationship-fix-na-1.patch | 870 bytes | skein | |
Comments
Comment #1
joachim CreditAttribution: joachim commentedI 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).
Comment #2
skein CreditAttribution: skein commentedWell the relationship that I defined in the patch is using only user flags, so that you get only the content of the flagged user.
Comment #3
joachim CreditAttribution: joachim commentedBut 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.
Comment #4
joachim CreditAttribution: joachim commentedComment #5
joachim CreditAttribution: joachim commentedFurthermore,
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.