I'm creating a website and there is a problem that I have encountered. I need to create list of posts. And each posts have a like button and shows who's liked the post exactly as in Facebook. The likes are handled by the flag module. The list of posts is in a view. What I need to do is figuring out each nid every post has in the view and pull the latest likes and the number of likes each post have.
If this is already in a view -- you can do the flag/like counts by adding a relationship to the view (I'm assuming you're on Drupal 7). Add the 'Flags: Node flag counter' relationship and select the flag you want the counts for.
Then you can add, for each piece of content in your block or page, the 'Flags: flag counter' field. That'll appear only once you've added the relationship. Make sure to select for it to use the relationship.
Let me know if this doesn't make sense and I can elaborate a little more. :-)