Hi,
I wanted to build a View listing all nodes a user (given by a user-id argument) has flagged. First I did this by having a flag-relationship to the node, and a user-relationship to the flag, and then having an argument on the user-id.
However, this seemed like a bit unnecessary, as I wasn't really interested in anything on the user-table, I just wanted to restrict the flags to those made by a specific user-id, which is already present in the flag_content table.
So, I've made a tiny addition to views_data, that allows arguments on flag_content.uid. I know that the functionality this offers is available already by means of a user-relationship, but sometimes it's nice to avoid too many relationships..
Regards
Morten
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | flag-1331614-views-uid-2.patch | 1.43 KB | q0rban |
| flag-Allow-arguments-on-flag-uid.patch | 436 bytes | fangel |
Comments
Comment #1
quicksketchThanks, this seems like a reasonable request. I've found a few places in Views where this inconsistency exists. I don't think there's a "User: UID" field for example, but there is a "Node: NID". I'll wait until I've had a chance to apply it and see how it "feels" before I know for sure if I'll be adding it to the project.
Comment #2
q0rban commentedI agree with this. This is how the node integration for Views module does it: http://drupalcode.org/project/views.git/blob/refs/heads/7.x-3.x:/modules...
You'll see there that node module doesn't just have the relationship, but also has filter, argument and field for the uid column. This allows you to operate on the uid without having to join to the user table.
Currently, for Flag module, if you want to get the uid into either a field, argument, or filter, you have to add two relationships, which amounts to two joins. This is unnecessary since the data exists right in the flag_content table itself—there is no need to do a join to retrieve it. The node module integration makes this clear in the description as well:
Attached patch follows this model, adding UID as a filter, argument, and field, and alters the title and help text to make this clear.
Comment #3
joachim commentedLooks good to me. Thanks for the patch!
Issue #1331614 by q0rban, fangel: Added uid on flag_content table as argument, field, and filter in Views.
Also backported to 6-2 and 6-1 branches.