Count all nodes

warning: call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback, 'nodereference_autocomplete_access' was given in /home/mnnnecdq/public_html/drupalme/includes/menu.inc on line 452.
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.

Comments

Add comment

The content of this field is kept private and will not be shown publicly.