counting

iraszl - October 11, 2007 - 12:25
Project:Favorite Nodes
Version:HEAD
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:active
Description

It would be great to have a feature to show the number of times a certain node have been favorited by people, like on YouTube.

#1

Sharique - April 15, 2008 - 11:30

I'm also looking for same feature.

#2

asund - April 15, 2008 - 21:01

You can get this by putting the following function in your themes template.php

function _favorite_nodes_count($nid) {
  $sql = "SELECT * FROM {favorite_nodes} WHERE nid = %d";
  return db_num_rows(db_query($sql, $nid));
}

And then you can call the function in your node template like this:
<?php print(_favorite_nodes_count($node->nid)); ?>

 
 

Drupal is a registered trademark of Dries Buytaert.