User Relationships. How to create block with my friend list (avatar list)?

Comments

LxT’s picture

if you have the flag friend module, it comes with a view called 'friends'. edit it to see how it's done.

example.com/admin/build/views/edit/friends

rickyfriend4all’s picture

can we create a user relationship block using views. I mean.......

when we click on a users profile .. the users friend's should be shown ( not the logged in user's friends)

sagar ramgade’s picture

Hi,

You first need to add 3 relationships of user relationships.
ie User Relationships : Requestee user
User Relationships : Requester user
Then argument User Relationships : Requester user

Fields : (requestee) User : picture
(requestee) User : name

Sort criteria : (requestee) USer : Last access desc

Filter :
User Relationships : Relationship Status = 1

Hope this helps.

Acquia certified Developer, Back end and Front specialist
Need help? Please use my contact form

vol4ikman’s picture

Thank you for trying to help me, but it doesn't work properly.
The "view" showes me the list of my friends where I am also included as a friend of myself several times

sagar ramgade’s picture

I think there's something wrong with the relationship then, while adding the field u need tick the checkbox called require this relationship.
This may help because i had implemented using the same view, check
http://www.dealpals.com/users/johnsonennakalil

Acquia certified Developer, Back end and Front specialist
Need help? Please use my contact form

vol4ikman’s picture

I am trying to check the checkboxes but it doesn't help
I am still can see myself several times in this list....

sagar ramgade’s picture

Hi,
I have exported my views for your help. Import this and modify accordingly, On my clients site it working like a charm.

$view = new view; $view->name = 'user_relationships_browser'; $view->description = 'Shows someone\'s related users'; $view->tag = ''; $view->view_php = ''; $view->base_table = 'user_relationships'; $view->is_cacheable = FALSE; $view->api_version = 2; $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */ $handler = $view->new_display('default', 'Defaults', 'default'); $handler->override_option('relationships', array( 'requestee_id' => array( 'label' => 'requestee', 'required' => 0, 'id' => 'requestee_id', 'table' => 'user_relationships', 'field' => 'requestee_id', 'relationship' => 'none', ), 'requester_id' => array( 'label' => 'requester', 'required' => 0, 'id' => 'requester_id', 'table' => 'user_relationships', 'field' => 'requester_id', 'relationship' => 'none', ), 'rtid' => array( 'label' => 'rtid', 'required' => 0, 'id' => 'rtid', 'table' => 'user_relationships', 'field' => 'rtid', 'relationship' => 'none', ), )); $handler->override_option('fields', array( 'picture' => array( 'label' => '', 'alter' => array( 'alter_text' => 0, 'text' => '', 'make_link' => 0, 'path' => '', 'link_class' => '', 'alt' => '', 'prefix' => '', 'suffix' => '', 'target' => '', 'help' => '', 'trim' => 0, 'max_length' => '', 'word_boundary' => 1, 'ellipsis' => 1, 'strip_tags' => 0, 'html' => 0, ), 'empty' => '', 'hide_empty' => 0, 'empty_zero' => 0, 'exclude' => 0, 'id' => 'picture', 'table' => 'users', 'field' => 'picture', 'relationship' => 'requestee_id', 'override' => array( 'button' => 'Override', ), ), 'name' => array( 'label' => '', 'link_to_user' => 1, 'exclude' => 0, 'id' => 'name', 'table' => 'users', 'field' => 'name', 'relationship' => 'requestee_id', 'override' => array( 'button' => 'Override', ), ), 'status_link' => array( 'id' => 'status_link', 'table' => 'user_relationships', 'field' => 'status_link', ), )); $handler->override_option('sorts', array( 'access' => array( 'order' => 'DESC', 'granularity' => 'second', 'id' => 'access', 'table' => 'users', 'field' => 'access', 'relationship' => 'requestee_id', ), )); $handler->override_option('arguments', array( 'requester_id' => array( 'default_action' => 'default', 'style_plugin' => 'default_summary', 'style_options' => array(), 'wildcard' => 'all', 'wildcard_substitution' => 'All', 'title' => '%1\'s Friends', 'breadcrumb' => '', 'default_argument_type' => 'user', 'default_argument' => '', 'validate_type' => 'numeric', 'validate_fail' => 'ignore', 'break_phrase' => 0, 'not' => 0, 'id' => 'requester_id', 'table' => 'user_relationships', 'field' => 'requester_id', 'override' => array( 'button' => 'Override', ), 'relationship' => 'none', 'default_options_div_prefix' => '', 'default_argument_user' => 1, 'default_argument_fixed' => '', 'default_argument_php' => '', 'validate_argument_node_type' => array( 'blog' => 0, 'poll' => 0, 'answers' => 0, 'simpleanswer' => 0, 'image' => 0, 'deals' => 0, 'event' => 0, 'experience' => 0, 'page' => 0, 'profile' => 0, 'simplenews' => 0, 'story' => 0, 'wishlist' => 0, ), 'validate_argument_node_access' => 0, 'validate_argument_nid_type' => 'nid', 'validate_argument_vocabulary' => array( '1' => 0, '7' => 0, '8' => 0, '2' => 0, '6' => 0, '4' => 0, '5' => 0, '9' => 0, '3' => 0, ), 'validate_argument_type' => 'tid', 'validate_argument_php' => '', 'validate_user_argument_type' => 'uid', 'validate_user_roles' => array( '2' => 0, '5' => 0, '4' => 0, '6' => 0, '3' => 0, ), 'default_argument_image_size' => '_original', 'validate_argument_transform' => 0, 'validate_user_restrict_roles' => 0, 'image_size' => array( '_original' => '_original', 'thumbnail' => 'thumbnail', 'preview' => 'preview', 'small' => 'small', ), ), )); $handler->override_option('filters', array( 'approved' => array( 'operator' => '=', 'value' => '1', 'group' => '0', 'exposed' => FALSE, 'expose' => array( 'operator' => FALSE, 'label' => '', ), 'id' => 'approved', 'table' => 'user_relationships', 'field' => 'approved', 'relationship' => 'none', ), )); $handler->override_option('access', array( 'type' => 'none', )); $handler->override_option('cache', array( 'type' => 'time', 'results_lifespan' => '300', 'output_lifespan' => '300', )); $handler->override_option('title', 'Relationships'); $handler->override_option('items_per_page', 30); $handler->override_option('style_plugin', 'grid'); $handler->override_option('style_options', array( 'grouping' => '', 'columns' => '4', 'alignment' => 'horizontal', )); $handler->override_option('row_options', array( 'inline' => array( 'name_1' => 'name_1', ), 'separator' => ', ', )); $handler = $view->new_display('page', 'Page', 'page_1'); $handler->override_option('fields', array( 'picture' => array( 'label' => '', 'alter' => array( 'alter_text' => 0, 'text' => '', 'make_link' => 0, 'path' => '', 'link_class' => '', 'alt' => '', 'prefix' => '', 'suffix' => '', 'target' => '', 'help' => '', 'trim' => 0, 'max_length' => '', 'word_boundary' => 1, 'ellipsis' => 1, 'strip_tags' => 0, 'html' => 0, ), 'empty' => '', 'hide_empty' => 0, 'empty_zero' => 0, 'exclude' => 0, 'id' => 'picture', 'table' => 'users', 'field' => 'picture', 'relationship' => 'requestee_id', 'override' => array( 'button' => 'Override', ), ), 'name' => array( 'label' => '', 'link_to_user' => 1, 'exclude' => 0, 'id' => 'name', 'table' => 'users', 'field' => 'name', 'relationship' => 'requestee_id', 'override' => array( 'button' => 'Override', ), ), 'status_link' => array( 'label' => '', 'alter' => array( 'alter_text' => 0, 'text' => '', 'make_link' => 0, 'path' => '', 'link_class' => '', 'alt' => '', 'prefix' => '', 'suffix' => '', 'target' => '', 'help' => '', 'trim' => 0, 'max_length' => '', 'word_boundary' => 1, 'ellipsis' => 1, 'strip_tags' => 0, 'html' => 0, ), 'empty' => '', 'hide_empty' => 1, 'empty_zero' => 0, 'exclude' => 0, 'id' => 'status_link', 'table' => 'user_relationships', 'field' => 'status_link', 'override' => array( 'button' => 'Use default', ), 'relationship' => 'none', ), )); $handler->override_option('items_per_page', 24); $handler->override_option('use_pager', '1'); $handler->override_option('path', 'friends/%'); $handler->override_option('menu', array( 'type' => 'normal', 'title' => 'All Relationships', 'description' => '', 'weight' => '0', 'name' => 'navigation', )); $handler->override_option('tab_options', array( 'type' => 'none', 'title' => '', 'description' => '', 'weight' => 0, )); $handler = $view->new_display('block', 'Block by type', 'block_1'); $handler->override_option('use_ajax', TRUE); $handler->override_option('items_per_page', 10); $handler->override_option('use_pager', 'mini'); $handler->override_option('block_description', 'Display user\'s relationships grouped by relationship type'); $handler->override_option('block_caching', -1); $handler = $view->new_display('block', 'Block by user', 'block_2'); $handler->override_option('fields', array( 'picture' => array( 'label' => '', 'alter' => array( 'alter_text' => 0, 'text' => '', 'make_link' => 0, 'path' => '', 'link_class' => '', 'alt' => '', 'prefix' => '', 'suffix' => '', 'target' => '', 'help' => '', 'trim' => 0, 'max_length' => '', 'word_boundary' => 1, 'ellipsis' => 1, 'strip_tags' => 0, 'html' => 0, ), 'empty' => '', 'hide_empty' => 0, 'empty_zero' => 0, 'exclude' => 1, 'id' => 'picture', 'table' => 'users', 'field' => 'picture', 'relationship' => 'requestee_id', 'override' => array( 'button' => 'Use default', ), ), 'name' => array( 'label' => '', 'alter' => array( 'alter_text' => 1, 'text' => '[picture] [name] ', 'make_link' => 0, 'path' => '', 'link_class' => '', 'alt' => '', 'prefix' => '', 'suffix' => '', 'target' => '', 'help' => '', 'trim' => 0, 'max_length' => '', 'word_boundary' => 1, 'ellipsis' => 1, 'strip_tags' => 0, 'html' => 0, ), 'empty' => '', 'hide_empty' => 0, 'empty_zero' => 0, 'link_to_user' => 1, 'overwrite_anonymous' => 0, 'anonymous_text' => '', 'exclude' => 0, 'id' => 'name', 'table' => 'users', 'field' => 'name', 'relationship' => 'requestee_id', 'override' => array( 'button' => 'Use default', ), ), )); $handler->override_option('title', ''); $handler->override_option('items_per_page', 6); $handler->override_option('use_more', 1); $handler->override_option('use_more_always', 0); $handler->override_option('use_more_text', 'More'); $handler->override_option('style_options', array( 'grouping' => '', 'columns' => '2', 'alignment' => 'horizontal', )); $handler->override_option('row_options', array( 'inline' => array( 'picture' => 'picture', 'name' => 'name', ), 'separator' => '', 'hide_empty' => 0, )); $handler->override_option('block_description', 'Users Friend Block'); $handler->override_option('block_caching', -1);

Acquia certified Developer, Back end and Front specialist
Need help? Please use my contact form

vol4ikman’s picture

Look what I see after importing your view:
http://i012.radikal.ru/1003/ff/849198b44781.jpg

sagar ramgade’s picture

Are you using a development version of this module, I am using a recommended version 6.x-1.0-rc3 and views 6.x-2.8.
However if not able to achieve this, Create an issue in ur issue queue.

Regards
Sagar

Acquia certified Developer, Back end and Front specialist
Need help? Please use my contact form

vol4ikman’s picture

thank you for helping me =)

cledman’s picture

i´m getting this message:

* Field handler user_relationships.status_link is not available.
* Field handler user_relationships.status_link is not available.
* Field handler user_relationships.status_link is not available.
* Unable to import view.

Could you helpe me please?

miaoulafrite’s picture

thank you Sagar Ramgade,

i went to your page, and i would like to know how you get this "Online" status.
in views, i've seen only a filter to filter online users but nothing to actually DISPLAY the current satus (online/offline) of a user.

i'm specifically interested in listing users in a table, where one of the column would be "status : online or offline"

ice241985’s picture

I have created a views set up exactly like this one and the tab appears in my users profile, but I have no button or way of adding a user as a friend or deleting one.

hockey2112’s picture

I know your reply is very old, but this helped me immensely. Thank you!

zebadix’s picture

Advanced profile kit already does this

http://drupal.org/project/advanced_profile

z