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

  1. Install Standard with 'media entity image' module
  2. Create a content type 'photo gallery' with an entityreference field 'photos' which reference 'media image'.
  3. Create an 'photo gallery' node with more than 2 'media image'.
  4. Add a comment on one 'media image'.
  5. 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'.
  6. Visit the view. 'media image' with no comment disapear.

Comments

Thib created an issue. See original summary.

Thib’s picture

Issue summary: View changes
Thib’s picture

Issue summary: View changes
Thib’s picture

larowlan’s picture

So 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.

larowlan’s picture

comment_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.

Thib’s picture

Thanks 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.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

andypost’s picture

Status: Active » Closed (duplicate)
Related issues: +#2801929: View loses records after adding comment count field