I have created a relationship Followers which can be reciprocated using the user relationship module. Now user A's relationship is something like: Followers(Them to you): User B, User C, User D Followers(You to them): User D
Now i want to create a view which only shows the number of followers and following:
I went about to create the view (Views 3, Drupal7) but was not able to do. Didnt get any filters or relationships regarding this. Also, tried using the Views Cal but am not clear. Would appreciate any help.
Apologies for not being clear.
I created a view of type Users. Then i added a relationship (this is the part where i am not sure if i am correct or not). I tried with all the available relationships pertaining to this such as User relationships:
User relationships: Requestee user User relationships: Requestee user is current user User relationships: Requester user User relationships: Requester user is current user User relationships: RTID
(i tried individually all of them and various combinations of them as well)
Then under Others i clicked yes for Use Aggregates and when asked for the grouping function ("Group type"), i selected "Count and unchecked the label in the configure field screen, so that it only shows the number.
I also added a filter that the user is logged in. However, it just shows me the number of relationships of different users who have requested the current one.
Found this thread: http://drupal.org/node/809476. However its for Drupal 6..., am trying to implement it for 7. lets see...if you have any pointers i would be grateful...will keep you posted
Based on the above thread i wrote the following code into a custom block.
<?php global $user; $user_id = $user->uid; $params = array("requestee_id" => $user_id, 'rtid' => 3); $count = user_relationships_load($params, array("count" => TRUE)); echo $user_id; echo $count; ?>
I just printed out the user id to check if correct user or not and it prints the correct user. However, count prints 0. Why is that?
I think i am on the right way using http://drupal.org/node/203396. However there are some fixes there. The correct code is:
<?php global $user; $requests = user_relationships_load($param = array("approved" => 1, "user" => $user->uid), $options = array(), $reset = FALSE); $requestcount = count($requests); echo $requestcount; ?>
This displays the total number of approved relationships. Now i want only the followers type relationship number. Looking into that. If anyone has any suggestions would appreciate them. Will keep you all posted
And now i am stuck. Whatever i try to do i am only getting the total number of relationships. I just want the number of followers(them to you) in one block and then using that, i hope, i will be able to get number of following(you to them). Would appreciate any help.