Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create a view that displays node count?

Having trouble in views creating what seems like a very simple query. Display the number (count) of nodes of a given type. I'm not finding the option in any obvious place...

How to?

like image 896
Michael D Avatar asked Jan 30 '10 02:01

Michael D


2 Answers

You want the Views Group By module. Some more details about this module (from its project page):

This module enriches Views2 functionality with SQL Grouping and Aggregation capabilities.

Ever wanted to design a view that displays top terms for a specific node type and number of nodes for each top term? You could not build such query before, but now you can.

A new field group: SQL Aggregation is added, in Views, once you install the module. The field group has one available field: SQL Aggregation: Group By Fields. The field allows to configure many aspects of "group by" SQL clause and "count()" fields.

Currently only SQL COUNT() function is available due to a limitation in Views2 API. We are working on a Views2 patch to overcome the limitation. Patch will be submitted to Views2 project and, hopefully, applied shortly thereafter.

like image 159
Mike Crittenden Avatar answered Sep 28 '22 10:09

Mike Crittenden


Maybe instead of views it is better to use light custom SQL-query, something like this http://drupal.org/node/105375#comment-1095529

like image 44
Sorlag Avatar answered Sep 28 '22 12:09

Sorlag