I have found that you can add " Boomark Count" to the tables in Views. That works well.

Would you mind giving us the correct code to use in node.tpl.php to display how many users "bookmarked" a particular node? Thanks much!

Comments

quicksketch’s picture

Status: Active » Closed (duplicate)

Oops sorry I answered this in http://drupal.org/node/169334 with the new API function provided there. I'll re-iterate though that a view would probably be the more flexible option.

chadchandler’s picture

Status: Closed (duplicate) » Postponed (maintainer needs more info)

This is slightly different I think? If you are familiar with " De.licio.us" (social bookmarking), there is a count on the node that shows how many users have saved (or in this case bookmarked) a particular node.

http://del.icio.us/ Check out the number in Blue, as thats what I'm aiming for. Any ideas? Thanks Ske7ch!

quicksketch’s picture

Ah yes, this is a bit different. Here's a nice easy way.

  $counts = module_invoke('view_bookmark', 'get_counts', $nid);
  print $counts[vbid_here]['count'];
quicksketch’s picture

Status: Postponed (maintainer needs more info) » Active
chadchandler’s picture

Here is the code I inserted into my custom Node.(type).tpl.php file. Couldn't get it to work.

 <?php
  $counts = module_invoke('view_bookmark', 'get_counts', $nid);
  print $counts[1]['count'];
?>

All I changed was the Viewsbookmark ID I wanted to count. Am I also supposed to change $nid to the node id I want to count bookmarks for? I kind of wanted to to be automatic if it's possible.

quicksketch’s picture

Sorry I left off an 's':

      $counts = module_invoke('views_bookmark', 'get_counts', $nid);
      print $counts[1]['count'];
chadchandler’s picture

Status: Active » Fixed

Thanks Sketch!

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.

newbstah’s picture

Title: Code to display how many users bookmarked this node » Code to display how many users bookmarked this node
Status: Closed (fixed) » Active

Am a big fan of your module and I think I'm doing something fundamentally wrong with it. I used the above code - and put it into phptemplate_variables. You can read the discussion here:

http://drupal.org/node/212203

I'm a beginner and it's my first phptemplate variables call and that's why I put it there instead of here. Unfortunately, it doesn't seem that the problem is the phptemplate call. (or maybe what I'm trying to do is a fundamenally flawed idea) I'm thinking that it's something you could see that I'm doing wrong at a glance and I'd be grateful if you'd take a quick look. Wherever you reply I'll make sure the crosslinks work in case anyone else wants to try it later.

Meanwhile, here's the code as it stands now:

<?php
function  _phptemplate_variables($hook, $vars) {
   switch($hook) {
     case 'node' :
      //if we are about to load a node-XXX.tpl file
      $node = $vars['node'];   //grab the node in question
     
      if ($node->type=='image' || $node->type=='blog'){
        //if the node is of  type image or blog (add the rest of your types to the above
        if (module_exists('views_bookmark')) {
          $counts = module_invoke('views_bookmark', 'get_counts', $nid);
          $funny_count = $counts[3]['count'];
          $helpful_count = $counts[4]['count'];
          $vars['funny'] = $funny_count;
          $vars['helpful'] = $helpful_count;
        } 
      }
     break;
   }
   return $vars;
}
?>
newbstah’s picture

Have a conditional with sentence structure that matches number ('1 member' '2 members') over at this thread:
http://drupal.org/node/212203#comment-699095

Maybe it will save someone ten minutes sometime.

chadchandler’s picture

Status: Active » Fixed
Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.