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.
A content type 'Photo gallery' has an entityrefrerence field to reference some medias images to create a photo gallery.
A view displays these Photo galleries as a grid.
I would like to display on each referenced medias image the number of comment but only the referenced media image with more than 1 comments are displayed
Steps to reproduce
- Install Standard with 'media entity image' module
- Create a content type 'photo gallery' with an entityreference field 'photos' which reference 'media image'.
- Create an 'photo gallery' node with more than 2 'media image'.
- Add a comment on one 'media image'.
- Create a view -FORMAT grid, field -FIELDS 'photos', 'comment count' with relation content use 'photos' -FILTER CRITERIA content: type 'photo gallery' -RELATIONSHIPS content use 'photos'.
- Visit the view. 'media image' with no comment disapear.
Comments
Comment #2
ThibComment #3
ThibComment #4
ThibComment #5
larowlanSo in D7 there was code to ensure each node had a record in comment statistics table.
That was modified when we made it possible to comment on any entity.
What you need is an entry in the table for every node that can be commented, or we need to modify the relationship to be a left join.
Comment #6
larowlancomment_entity_insert()
is responsible for creating a record for each entity, so did you a) enable comment module after the content was created or b) migrate content.There is no consideration of either of those scenarios.
Comment #7
ThibThanks for your feedback.
Comment module was enable before content was created but comment field on this entity was created after the content was created.
There was no migrate content.
Comment #10
andypostClosing as duplicate of #2801929: View loses records after adding comment count field
there's patch