Closed (duplicate)
Project:
Flag
Version:
6.x-2.0-beta3
Component:
Views integration
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
25 Nov 2010 at 20:57 UTC
Updated:
8 Dec 2010 at 05:16 UTC
Hello. First of all thanks for the awesome module.
I'm using Flag module to flag users. I have about 10 user flags (i.e. Editor, Admin, Critic, Commentator, Guru, etc.).
Tying to create a View to list all the flags user is flagged with and its count.
i.e. ->
Editor x3
Critic x5
Guru x1
Could someone please help!
Comments
Comment #1
mooffie commentedIf I understand correctly, all these flags are global flags. In other words, you want to count the number of editors, the number of gurus, etc.
This could be done very easily and elegantly once we have the #371432: Exposing the flaggings table: Alternative Views support feature.
But it's possible to do this even now (but not very elegantly):
This view isn't complicated, but the average person is likely to omit some detail(s). So here's a ready view you can "Import":
Note the following lines:
Change "editor"/"commentator"/"guru" to the machine-names of the flags on your own system. Do this before you import the view.
Make sure to turn on caching for the view (because it isn't efficient).
(Again: #371432: Exposing the flaggings table: Alternative Views support would make things much, much easier. Alternatively, if you know PHP you can use it instead of Views.)
Comment #2
ranavaibhavHello mooffie,
wow! thanks for your time and putting the sample view and information together. really appreciated.
However, it's my bad. I should have been clear and provided more information in my initial post.
RE: If I understand correctly, all these flags are global flags. In other words, you want to count the number of editors, the number of gurus, etc.
Actually, i wanted almost opposite of this. My user flags are not-Global flags. User can be flagged with Guru, Editor, etc flag multiple times. So one user could have 3 Guru flags, 2 Editor flags, etc.
And what i wanted is, on the user profile page, in a block, i wanted to list all the flags user has been flagged with and the total number of each flags.
After leaning from your sample view, it turns out that what i wanted is very very simple. below is the view i came-up with.
In this view, I'm passing User ID as an argument. Added "Flags: User flag counter" relationship for all the flags i wanted and "Flag Count" fields with hidden label and custom prefix.
Now the only problem is that currently I have only handful of user flags, but eventually it will grow to over 50 flags. So i will have to add relationship for each flag and field for each flag. Not sure if #371432: Exposing the flaggings table: Alternative Views support will solve this issue too.
By the way, I'm building Question-Answer site similar to StackOverflow and with flag system I'm trying to achieve badge system they have - http://stackoverflow.com/badges
Comment #3
mooffie commentedIt will.
I'll have good news soon.
Interesting. (It seems the only challenge will be to sort the flags by the titles. I'll have to think about this.)
Comment #4
mooffie commentedIt turns out there isn't a challenge here: I had the impression the titles were in a PHP serialized DB column (which makes them unavailable to Views), but they aren't: they are in a normal column. So all is well.
I'm marking this a dup of #371432: Exposing the flaggings table: Alternative Views support.