Hello,

I have been using flags with my site and displaying flag related content via views.
But there is one thing I haven't been able to do. I can show a list of content from different flags, but I can't filter the list of content by the type of flag.

E.g.
There is a content type called "Books" that has two separate flags "Bought" and "Read".
I can create a view that shows a full list of books that have been flagged "Bought" or "Read" by a user. But I also want to allow the user to be able to filter the view using an exposed filter on the type of Flag.
So the user can:

  • show any book she has flagged
  • show all books she flagged as Bought
  • show all books she flagged as Read

Flagging seems to work by using relationships, but the flag type does not seem to be an option for making a filter.

I just wanted to see if there is a way around this or if there is an option I missed.

Thanks or your help.

Comments

joachim’s picture

Version: 7.x-3.3 » 7.x-3.x-dev
Category: Support request » Feature request

It's not doable, and it would be tricky to implement.

There are two ways.

Method a: make a view of nodes, and then you need a relationship that doesn't exist yet to join to the flagging table without limiting on the flag. You might then want to join to the flag table too, so you can get the flag names. At that point, you can filter on the flagging.fid column, and have an exposed filter for that.

One caveat would be that if node A is flagged with both flags X and Y, you'd get two rows for it.

Method b: make a view of flaggings. This isn't doable yet -- you'd need to declare the table as a base to Views. Then you need a relationship to nodes. You'd then have the exposed filter as in method a. And the same problem with duplicate rows.

It probably makes more sense to do method a, because people building a view will intuitively approach it from that side: you think 'I want a list of nodes, which I'll filter by how they're flagged', not 'I want a list of flaggings, that shows the nodes that are flagged'.

Also, doing it that way means that your list can also show nodes which are not flagged at all, by making the relationship non-required.

shi99’s picture

Hi joachim,

Thanks for your help. I will look into this further to see if I should go with the relationship approach or change the way I display the data.