aneuryzm
aneuryzm

Reputation: 64844

How to display the total amount of posts?

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

thanks

Upvotes: 1

Views: 359

Answers (3)

Andrew Sledge
Andrew Sledge

Reputation: 10351

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;

?>

Upvotes: 2

Sid Kshatriya
Sid Kshatriya

Reputation: 5015

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.

Upvotes: 0

Nicholai
Nicholai

Reputation: 818

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.

Upvotes: 0

Related Questions