Blocks

Taxonomy will be sorted as soon as possible. Dinner first.


Monday, November 9, 2009 - 20:40

The tutorial "Count all nodes" is a great tool if you need statistics displayed on you're site. If you want to specify by content types you can do it like this:

<?php
$mytype = array('you're content type name');
$in = implode("', '", $mytype);
$count = db_result(db_query("SELECT COUNT(DISTINCT(n.nid)) FROM {node} n WHERE n.type IN('$in') AND n.status=1"));
echo "$count";
?>

Wednesday, November 4, 2009 - 00:03

For a site that let users create advertisements I needed to display how many nodes that actually was published or available. Since I'm not a programmer I went into drupal support on irc and a helpful person handed me this code.

<?php
$result = db_query('SELECT COUNT(*) as nodes FROM node WHERE status = 1');
$arr = db_fetch_array($result);
print_r($arr['nodes']);
?>

To enable this, activate the Php Filter from Drupal core modules and create a block with the php-input-filter selected.