8 February, 2023 seen 2,300
In Drupal 7, managing images can be quite challenging, especially when the default image is not provided. The platform…
Previous I wrote - How to display node count per taxonomy. Today I faced a problem displaying node count for a particular node reference field.
The scenario is like this: We have two content types: Destination, Hotel. Each hotel is referenced to a specific destination by using node reference. We need to display how many hotels there are in all destinations.
To achieve such a result, create a new View (content-based), for example, hotels
Relationships:
- Add node reference field, in our case - field_where
Other:
- Use aggregation: yes
Fields:
- (field_where) Content: Title | Aggregation settings
- (field_where) Field: Background | Aggregation settings (Optional)
- Content: Category | Aggregation settings(Optional)
- COUNT(DISTINCT Content: Nid) | Aggregation settings
- Global: View result counter | Aggregation settings (Optional)