It would be nice to have an API function that can be used to view a list of all users who bookmarked a given node. views_bookmark_get_user_bookmarks() takes a $nid as an argument, but limits it to the current user.

Comments

webchick’s picture

Patch.

webchick’s picture

This is the same patch, but orders the results by timestamp. This way, when displaying results in a block or so, the list will be dynamic where it always shows the person who bookmarked it most recently at the top. I'm trying to think of a situation where this is not desirable, and can't really come up with one. Hopefully committers agree. :)

webchick’s picture

New patch, now with static caching and the return results organized a bit better so they make sense.

chadchandler’s picture

Very nice! Was just posting a support request regarding this. What exactly needs to go in node.tpl.php to get this to work? Thanks again! Much needed addition!

quicksketch’s picture

Status: Needs review » Fixed

Thanks webchick! Committed.

@CChandler, you'll be best off creating a view for your needs. But if you just want the raw output in an efficient manner you could use something like this:

  $accounts = module_invoke('view_bookmark', 'get_node_bookmarks', $nid);
  foreach ($accounts as $account_info) {
    $account = user_load($accounts_info->uid);
    print theme('user_picture', $account);
  }
Anonymous’s picture

Status: Fixed » Closed (fixed)