views:

26

answers:

3

What's the best way to display in a block the total amount of posts and comments of my entire drupal website?

thanks

A: 

One option is to use a View with the block display type. Views Calc can do the summing for you (http://drupal.org/project/views_calc).

Honestly, I think you will find it easier and possibly more performant to create a Statistics content type with CCK integer fields to store the initial values for the amount of each piece of information you need. Then configure the Rules module to increment/decrement the fields when you add or remove content/comments.

A third option I have not personally explored is the Statistics Pro module (http://drupal.org/project/statspro), which says it is Views-compatible.

Nicholai
so I actually need additional modules. Drupal has not global statistic s stored somewhere.. ? I will give a look. Thanks
Patrick
A: 

Use Views GroupBy module ( http://drupal.org/project/views_groupby ). You can specify the filters (e.g. you want to count nodes of particular type only) and so on. It will count the nodes for you.

If your view type is comment then in a similar count can be done on comments.

Sid NoParrots
+1  A: 

The quick and dirty way:

Ensure that you have PHP filter installed and available to you. Create a block with the php code

<?php

$ncount = db_query("SELECT COUNT(nid) FROM {node} WHERE status=%d", 1);
$ccount = db_query("SELECT COUNT(cid) FROM {comments} WHERE status=%d", 1);

print "Nodes: ".$ncount;
print "Comments: ".$ccount;

?>
Andrew Sledge
That will work. Using Views Group By will generate the same query but with possibly a little less pain though :-)
Sid NoParrots

related questions