In my theme, I would like to display the number of articles (nodes of a certain type) that are published on the site. Is there a code snippet for this?

Comments

zeitenflug’s picture

Depends. I have a code snippet for the phptemplate engine. What engine do you use?

jurriaanroelofs’s picture

phptemplate of course:)
what's the snippet?

-------------------------------
http://www.sooperthemes.com/#-Drupal-Themes

zeitenflug’s picture

This snippet displays the number of books in the database.


$result = db_query("SELECT nid FROM {node} WHERE type='book'");
$num_rows = db_num_rows($result);
if ($num_rows>0) {
        echo "<div id=\"books-results\">".$num_rows." book(s) available</div>";
        }

jurriaanroelofs’s picture

that looks pretty simple. I should learn the language some time, php I mean. Thanks.

-------------------------------
http://www.sooperthemes.com/#-Drupal-Themes