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.
Flags are usually used for marking content the user is interested in.
But sometimes the opposite is true: the user is flagging content she isn't interested in. For example, content she thinks is spam, offensive, or otherwise doesn't worth her time.
Another example: If the user is a moderator, she'd like to see content which isn't flagged, say, as "Reviewed", so she could review it.
For these cases we would like to show in our view only content which is not flagged. The "recipe" for doing this involves two steps:
- We start, as usual, by adding the flag relationship. The only difference is that now we uncheck the "Include only flagged content" checkbox. This will make our view list all content: whether flagged or not.
- We add the Flags: Flagged filter. We ask it to filter out flagged content. (In other words, in its settings form, under Status, we select Not flagged.)
Comments
List who has NOTflagged specific content
This seems to be a an issue right now within views possibly?
How can we display lists of users who have not yet flagged a piece of content that has been flagged by others?
This method seems to suffer
This method seems to suffer from a huge performance problem, when unticking the "Include only flagged content" checkbox the view starts to crawl with a Query execute time of 8712.13 ms. With the box checked this takes only around 2-5ms...
I need to show content unflagged by specific users.
Is something on my install causing this problem or is filtering by all unflagged content that expensive in the database?
EDIT: Updated to Flag dev and the same query dropped to a under 10ms.
Cool, thanks for the update.
Cool, thanks for the update. I am going through the same process at the minute on a localhost install and I did not experience that yet but always thought this might be an issue at some point.
T
^
Just look at the query.
Unticking the box didn't cause a performance problem according to query times. At least in my setup.
What's new and changing in PHP 8
Great stuff, I implemented
Great stuff, I implemented this on D7 and it worked out just fine. I wish I could display the flag link on a view listing comments though.
I think sometimes it is far
I think sometimes it is far easier to list all the flagged content by any user, and add a "Filter criteria" that looks for "Is empty (NULL)" User IDs (relationship: flag user is important).
Superb
Thanks for this steps its help me alot.
Not working with Drupal 9.1.2
Not working with Drupal 9.1.2 unfortunately.