28 January, 2022 seen 660This is an article back from 2014, when I had the vision to launch a web agency in Tbilisi, Georgia. In the end, I didn…
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
- Add node reference field, in our case - field_where
- Use aggregation: yes
- (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)