0

I'm looking to allow users to create a "blacklist" of certain tags on a site. My plan was to do this through adding a "Blacklisted Tags" field on the user entity, but I'm open to other solutions. If an item is tagged with a tag they've blacklisted, it won't appear in a view. Is there a way to do this using default views functionality? If not, what's the simplest way to achieve this?

1

I guess using the ER field on user profiles is the easiest way, it all depends on your requirements.

If you need users to interactively "mark" tags on tags pages or through some other places you could use Flag modules and let them flag tags to blacklist them by simply clicking on the "Blacklist" flag link.

Either way you can build Views that show only content that hasn't been tagged with those.

Add the Contextual filter for the Blacklisted ER field (Default value...) then under More check the Exclude. This way your list will not show any content that has blacklisted tags.

Of course, your Contextual needs to be configured properly but there are many answers here you can find with all the options listed.

Flags views take some more steps to configure but the logic is the same.

  • The problem with this approach is that I first have to add a relationship to the taxonomy tags in order to filter by taxonomy term id. As soon as I do that, I get a bunch of duplicate results (one for each taxonomy term on a content type). Checking "distinct" doesn't seem to solve this problem. – Matt Apr 25 at 17:34
  • Relationships can do that, duplicate the results, but you can use Aggregation to make them show only once, if the Distinct doesn't work in this case. When adding multi-valued Fields to views there is the setting to show them all on the same row, so it may be relevant in some cases. – prkos Apr 26 at 4:06
  • How do you use aggregation to get rid of those duplicate results? I've tried several different ways and don't understand how to use it to remove those duplicates. I also tried moving to flags, and I have the same result where it creates two images, one that's flagged and one that's not, and then filters the one that's not flagged. – Matt Apr 26 at 18:06
  • It's difficult to give exact steps flying blind. Remove any Sort criteria, it can interfere with Aggregation. Basically, you keep the Group results together option everywhere, maybe adjust some Fields "Group column" to be "Entity ID" and not "Value", and Taxonomy usually "Target ID" instead of "Entity ID" if on Content Views. But the whole configuration needs to make sense. It can be thrown off by Fields that use Relationships, if you add "Group by field" under Format etc. Build the simplest Views, Aggregate and adjust so it works, then add in other stuff one by one checking it works. – prkos Apr 27 at 7:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.