0

I have a flag called Collect. (Flag is individual, and enabled on multiple content types.) The flag has an entity reference field to a content type called Bucket. When users flag nodes, they go to a form and select the bucket for the flagging in the entity reference field (field_bucket_select).

Users can view their Bucket list in a view that filters on 'current logged in user' (as well as the content type) so they see only the Buckets they created--so the view has a content author relationship.

The problem: I want this view to include a count of flaggings or flagged nodes, whichever works. There's no 'count' field for that available without a relationship, so I add the relationship for field_bucket_select.

Immediately, Buckets are listed multiple times in the view--exactly the number of times as there are flaggings related to each.

I go into the view advance settings and turn on distinct. No change.

Also, if I add the count field, the counts are odd.

I'm thinking this is not an usual need, so I'm just doing it wrong. Guidance appreciated.

(Drupal 9)

5
  • What type of entity is the Bucket list view showing? For basic info on how to set up flag count see here: drupal.org/project/flag/issues/3178501#comment-13881585 Nov 24 at 0:32
  • The Bucket list view lists nodes of the Bucket content type.
    – aharown07
    Nov 25 at 2:38
  • I checked out the discussion at the link, but as it notes the flag count module doesn't actually provide an example view. It doesn't seem to address the situation where one needs to count flagged nodes or flaggings by way of an entity reference between a parent node (a Bucket) and each flagging.
    – aharown07
    Nov 25 at 2:44
  • Yes, you are in unknown territory. Flag for Drupal 8/9 is not yet complete and some things, particularly related to Views support, are poorly documented and have not yet been implemented. My guess is you will probably have to code this yourself; I have been using flaggings with fields on my site, and I had to add a fair amount of custom code to get it to work. Nov 25 at 3:46
  • Thanks. I don't know how to code that, so we'll have to see if the project will be accepted without that for now... or hire a bit of custom dev.
    – aharown07
    Nov 27 at 19:32

Your Answer

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

Browse other questions tagged or ask your own question.