may I suggest adding this function
/**
* count number of times a node has been called a favorite
*/
function _favorite_nodes_count($nid) {
global $user;
$sql = "SELECT * FROM {favorite_nodes} WHERE nid = %d";
return db_num_rows(db_query($sql, $nid));
}
and perhaps adding the result to a node's header.
Comments
Comment #1
kitt commentedWhy the "global $user" line?
Comment #2
nwe_44 commentedfair point – it has no business here.
That was legacy from me playing with the code.
Comment #3
Dabitch commentedIt's still a good idea.
Comment #4
SpikeX commented*** NOTE: FOR DRUPAL 6.x ONLY *** (unless someone feels brave enough to test it on 5.x)
I did something similar on my website.
In the node links area (at the bottom), to show the number of favorites, perform this manual patch:
Add this function to the module file:
Find this function:
function favorite_nodes_link($type, $node = NULL, $teaser = FALSE)Near the bottom of the function you'll see a lot of }'s. Replace those with this code:
Don't forget the ");" at the top of that code (you don't want 2 of those in there).
Sorry I can't give a patch file, I've pretty heavily modified my favorite_nodes.module file and I'm not very good with patches anyway. :P Hope this helps! :)
Also, it would be cool if we could eventually have a page that would list all the users who favorited this node (and maybe even expose that to Views using a relationship).
Comment #5
kbahey commented