Closed (fixed)
Project:
User Relationships
Version:
6.x-1.0-rc4
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
26 May 2010 at 03:47 UTC
Updated:
29 Jun 2011 at 17:22 UTC
Hi,
I'm trying to custom-write a seemingly simple block that will count the relationships that the user (whos profile is being viewed) has. Exactly like we see in on Twitter: (X)Followers, (X)Following. But I can't find the correct function in UR API.
I have only 1 type of one-way relationship called "Following", which is also reciprocal.
So the code in block should look something like:
<?php $account = user_load(arg(1)); ?>
<a href="/followers"><?php print UNKNOWN_USER_RELATIONSHIPS_API($account->uid); ?></a>
<br />
<a href="/followers">Followers</a>
...and a similar thing for the count of "Following" (you to them) kind of relationships
Could you possibly help? Much appreciate your help in advance
Comments
Comment #1
drupalina commentedI think I'm getting very close. I just need a little push. So far I have:
I just need a little help with loading the uid of the currently viewed user and/or the author of the currently viewed node, so that I can display the number of followers this user has inside the Author Pane.
Comment #2
alex.k commentedThe URL when looking at a user account is user/{uid}, so if you say
$user_id = arg(1);that will work.Comment #3
utsujp commented$count seems counts all including inactive users.
Can I limit the count for active user?
Comment #4
drupalina commented@alex.k -- Thanks!
But what if I want to display the relationship numbers for each user who are listed in a View using Custom_Field module???
So - I want to create a view that lists users
[Mary's Picture] - Username:Mary Smith - Follow/un-follow - Following 17 - Followers 26
[Jack's Picture] - Username:Jack Brown - Follow/un-follow - Following 36 - Followers 12
[Tim's Picture] - Username:Tim Clarck - Follow/un-follow - Following 23 - Followers 27
if we use
then it will load the currently logged in user.
If we use arg(1) then it will load the uid from url (and that definitely doesn't help)
The $user_id in this case must be derived from another place other than arg(1). But how?
any ideas?
Comment #5
ajayg commentedHow are you getting "Username:Mary Smith"? So some how need to pass that parameter/field to get userid .
Comment #6
robby.smith commentedIt be awesome if this could be possible using Views as well.
Subscribing
Comment #7
mrf commentedLooks like this question was answered previously.
Robby.smith, please open a separate feature request describing how you'd like to see this type of information included in views.