Hello.

Trying to achieve a list of Non-Friends in Views .Since I have a list of Friends already, I don't want them duplicated on a "Users" page.

I have tried various filters, relationships and arguments with no luck.

Here is what I am thinking should work :

Filters
User Relationship Type (RTID) : Empty

Relationships
Requester
Requestee

Arguments
Requester ID

Fields
(Requestee) User : Email

Help?

Comments

kvvnn’s picture

EDIT :

This actually lists a view of all users that have no relationships at all.

kvvnn’s picture

EDIT : I think the above Views config was kind of stupid. Heres what I think should work :

Filters

(Requestee) User : Current - No
(Requester) User : Current - No
User : Current - No


Relationships
Requester
Requestee


Arguments
none


Fields
User : Email

kvvnn’s picture

I believe what the above is doing is simply not listing friends of the current user.

However, it will not filter out friends of some other user who also happen to be friends with the current user.

kvvnn’s picture

I have resorted to this solution instead : http://drupal.org/node/409432#comment-1826252

Where I have a Users page with every user on the site, but differentiate between friends and non-friends of the user.

I do believe that UR should include a view for "Friends" and for "Non Friends".

Cheers!

alex.k’s picture

To help me understand, are you trying to list users who are not friends of you, or are you trying to list users who don't have any friends at all on the site?

kvvnn’s picture

Sorry for the confusion.

I am trying to list users who are not friends of the currently logged in user.

kvvnn’s picture

Update on the above:

Issue : There is no way (that I have found) to have a view with both Friends and Non-Friends listed, and then filter out Non-Friends through an exposed filter.

kvvnn’s picture

Title: List Non-Friends in Views » Can't list both Non-Friends and Friends, then filter out Non-Friends
alex.k’s picture

Status: Active » Closed (works as designed)

Yup, the only way would be to use two different views, or two displays within the same view.

kvvnn’s picture

The issue with having two displays within the same view is that we can't have combined sorting.

Are you planning on implementing this feature?

YK85’s picture

Any further development in User Relationships & Views integration?
If anyone has figured out a method can it please be shared with the community.

Thanks!

kvvnn’s picture

The only thing you can do is manipulate the fields once they come out. There is currently no way, using Views, to only list people who are not friends.

My suggestion is to use the Views_Customfield module (www.drupal.org/project/views_customfield) in a way that manipulates the user field based on whether the logged in user is friends with them.

Here is my example.

Filters

Node: Type = Profile
User: Current No
Content: First Name exposed
Content: Last Name exposed

Fields

User: Uid Uid
Content: Profile Image
Content: First Name Default
Content: Last Name Default
User: Name Name
Customfield: PHP code Data
Customfield: PHP code

Fields explained

Everything is excluded except Content: Profile Image and Customfield: PHP Code
Customfield: PHP code Data: This is Excluded in production. It is to see the field names according to Views Customfield. In order to do that you use

<?php
print var_export($data, TRUE);
?>

Customfield: PHP code: This contains code that determines what to print depending on whether the user is a friend or not.

<?php
global $relationships;
global $user;

//if users are friends and relationship has been approved
if ($relationships = user_relationships_load(array('between' => array($user->uid, $data->users_uid),'approved' => 1))) { 
print "<a class=friendName href=traveler/" . $data->users_uid . ">" . $data->users_name . "</a>";
}

//if a friend request has been made between the users, but hasn't been approved
else if ($relationships = user_relationships_load(array('between' => array($user->uid, $data->users_uid),'approved' => 0))) { 
print $data->users_name;
print "<br>...pending friend request";
}

else { 
//relationship/[uid]/request/[rid]?destination=user/[uid]
print $data->users_name;
print "<br><a class=user_relationships_popup_link href=relationship/" . $data->users_uid . "/request/1?destination=users>Send Friend Request</a>" ;
} 
?>
YK85’s picture

would this be helpful? http://drupal.org/project/viewsphpfilter
or could someone look into expanding UR-Views integration to allow for all the essential views?
many thanks!

aliyayasir’s picture

Please take a look at Suggest a Friend module
http://drupal.org/project/suggest-a-friend