Closed (works as designed)
Project:
Flag Friend
Version:
6.x-1.0
Component:
Views integration
Priority:
Minor
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
6 Sep 2010 at 15:11 UTC
Updated:
8 Oct 2013 at 10:35 UTC
Jump to comment: Most recent
Comments
Comment #1
miljats commentedThis works for me, try it.
Put this php code in a block header. Drupal´s core module PHP Filter must be enabled.
Set input format to PHP code. You can style php code with your own css classes.
Comment #2
kerberos commentedYeah, that gets the total number of a single user's friends on his friends page, but you can't do this for a list with multiple users or sort by the top 5.
I guess the only way the feature I am talking about would work with any decent performance is if Flag Friend also creates a table that stores each user's number of friends (the way Voting API stores the aggregate votes in addition to the single votes).
Comment #3
sirkitree commentedThere is a bit of a start on this, a function called flag_friend_get_friend_count() which does a select count query for a given user id. It does some basic static caching, but flag_friend does not have a dedicated statistics table.
I'd be open to adding this if someone was willing to work on it.
Comment #4
sirkitree commentedComment #5
mototribe commentedIf you install the views_PHP module you can execute PHP code in a views field.
Add a "global text" field and paste this PHP code to display the number of friends for the logged in user:
If you want to show the number of friends for a user with the user ID in the URL you'll have to add the "uid" field to the view ABOVE your php field and use this code:
Comment #6
nielsvoo commentedOke, this works fine, i put the code in a custom token so it can be used everywhere on my site.
Is there also a way to output the amount of pending and flagged friendships for a user using Drupal 7?
Thanks
Niels
Comment #7
nielsvoo commentedIs there a way to combine this code with this sql statement, otherwise blocked users won't ignored.
$sql = $this->query("SELECT * FROM `users` WHERE `status` != 0");
Thanks
Nielsvoo
Comment #8
socketwench commentedI'd probably just query the DB directly for both. It's not best practice, but the 6.x branch is pretty stable:
SELECT count(ff.friend_uid) FROM `flag_friend` as ff, `users` as u WHERE u.uid = ff.uid AND u.status != 0 AND u.uid = $current_user_id