I'm stumped by something that seems like the absolute most obvious thing anyone would want to do with this module.

I have a one-way relationship called "follow." I let me users follow eachother, Twitter-style.

I want to create a view that shows the latest nodes created by people the currently logged in user is following.

However I see no obvious way to do that in Views 2. Surely it's possible, right? It's the most obvious use for a module like this.

How do I do it? I don't see any filters in Views 2 for filtering based on whether the node author is related to the currently logged in user. Thanks!

CommentFileSizeAuthor
#2 ur-view-content.png22.72 KBmtsanford

Comments

mtsanford’s picture

Did you take a look at that user_relationships_content view that you can enable? It has something similar.

In Live Preview select page for the display, then 1/1 for the arguments, and some node type. That will show the content created by users that are in a relationship of type 1 with user 1. (user/relationship_type is the argument).

mtsanford’s picture

StatusFileSize
new22.72 KB

Actually, starting w/ user_relationships_content may not be the way to go. Views can definitely be confusing, especially when working with complex relationships, where the implementation of the module may not be clear.

Try importing the view below. I have 1 two-way relationship, called 'friend'. If your relationship #1 is not 'friend' this view may not work, or may need editing. I also attached a screenshot.

Not sure, but in your case you may need to use UR_implications module to automatically create a 'followee' relationship to correspond to your 'follower' relationship, so that you can use the 'Requestee user' relationship. I could not get it to work using 'requester user' relationship because the 'user: current' filter would not seem to act on that.

$view = new view;
$view->name = 'user_relationships_content_2';
$view->description = '';
$view->tag = '';
$view->view_php = '';
$view->base_table = 'node';
$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' => 1,
    'id' => 'requestee_id',
    'table' => 'user_relationships',
    'field' => 'requestee_id',
    'override' => array(
      'button' => 'Override',
    ),
    'relationship' => 'none',
  ),
));
$handler->override_option('fields', array(
  'title' => array(
    'label' => 'Title',
    'link_to_node' => 1,
    'exclude' => 0,
    'id' => 'title',
    'table' => 'node',
    'field' => 'title',
    'relationship' => 'none',
  ),
  'name' => array(
    'label' => 'author',
    '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,
    'link_to_user' => 1,
    'overwrite_anonymous' => 0,
    'anonymous_text' => '',
    'exclude' => 0,
    'id' => 'name',
    'table' => 'users',
    'field' => 'name',
    'relationship' => 'none',
  ),
));
$handler->override_option('sorts', array(
  'created' => array(
    'order' => 'DESC',
    'granularity' => 'second',
    'id' => 'created',
    'table' => 'node',
    'field' => 'created',
    'override' => array(
      'button' => 'Override',
    ),
    'relationship' => 'none',
  ),
));
$handler->override_option('filters', array(
  'uid_current' => array(
    'operator' => '=',
    'value' => '1',
    'group' => '0',
    'exposed' => FALSE,
    'expose' => array(
      'operator' => FALSE,
      'label' => '',
    ),
    'id' => 'uid_current',
    'table' => 'users',
    'field' => 'uid_current',
    'relationship' => 'requestee_id',
  ),
  'approved' => array(
    'operator' => '=',
    'value' => '1',
    'group' => '0',
    'exposed' => FALSE,
    'expose' => array(
      'operator' => FALSE,
      'label' => '',
    ),
    'id' => 'approved',
    'table' => 'user_relationships',
    'field' => 'approved',
    'relationship' => 'none',
    'override' => array(
      'button' => 'Override',
    ),
  ),
  'rtype' => array(
    'operator' => 'in',
    'value' => array(
      '0' => '1',
    ),
    'group' => '0',
    'exposed' => FALSE,
    'expose' => array(
      'operator' => FALSE,
      'label' => '',
    ),
    'id' => 'rtype',
    'table' => 'user_relationships',
    'field' => 'rtype',
    'override' => array(
      'button' => 'Override',
    ),
    'relationship' => 'none',
  ),
));
$handler->override_option('access', array(
  'type' => 'none',
));
$handler->override_option('cache', array(
  'type' => 'none',
));
$handler->override_option('items_per_page', 30);
$handler->override_option('distinct', 0);
$handler->override_option('style_plugin', 'table');
$handler->override_option('style_options', array(
  'grouping' => '',
  'override' => 1,
  'sticky' => 0,
  'order' => 'asc',
  'columns' => array(
    'title' => 'title',
    'rtype' => 'rtype',
    'updated_at' => 'updated_at',
  ),
  'info' => array(
    'title' => array(
      'sortable' => 0,
      'separator' => '',
    ),
    'rtype' => array(
      'sortable' => 0,
      'separator' => '',
    ),
    'updated_at' => array(
      'sortable' => 0,
      'separator' => '',
    ),
  ),
  'default' => '-1',
));
$handler = $view->new_display('page', 'Page', 'page_1');
$handler->override_option('title', 'Recent Content By My Friends');
$handler->override_option('path', 'my-friends-recent-content');
$handler->override_option('menu', array(
  'type' => 'normal',
  'title' => 'My Friends Recent Content',
  'description' => 'Friends Content',
  'weight' => '0',
  'name' => 'navigation',
));
$handler->override_option('tab_options', array(
  'type' => 'none',
  'title' => '',
  'description' => '',
  'weight' => 0,
));
Jj-1’s picture

I have fixed the problem for 1 way relationships for people, this view shows the users nodes that they are 'following' It needs a few tweaks to add your post type, or published content but it works.

A working version of this view can be fond at www.heyworld.co.uk/ff

$view = new view;
$view->name = 'user_relationships_content_2';
$view->description = '';
$view->tag = '';
$view->view_php = '';
$view->base_table = 'node';
$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' => 1,
    'id' => 'requestee_id',
    'table' => 'user_relationships',
    'field' => 'requestee_id',
    'override' => array(
      'button' => 'Override',
    ),
    'relationship' => 'none',
  ),
));
$handler->override_option('fields', array(
  'picture' => array(
    'label' => 'Picture',
    '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',
    'override' => array(
      'button' => 'Override',
    ),
    'relationship' => 'none',
  ),
  'widget' => array(
    'label' => '',
    'alter' => array(
      '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' => 'widget',
    'table' => 'vote_up_down',
    'field' => 'widget',
    'override' => array(
      'button' => 'Override',
    ),
    'relationship' => 'none',
  ),
  'name' => 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,
    'link_to_user' => 1,
    'overwrite_anonymous' => 0,
    'anonymous_text' => '',
    'exclude' => 0,
    'id' => 'name',
    'table' => 'users',
    'field' => 'name',
    'relationship' => 'none',
    'override' => array(
      'button' => 'Override',
    ),
  ),
  'title' => 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,
    'link_to_node' => 1,
    'exclude' => 0,
    'id' => 'title',
    'table' => 'node',
    'field' => 'title',
    'relationship' => 'none',
    'override' => array(
      'button' => 'Override',
    ),
  ),
  'created' => 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,
    'date_format' => 'time ago',
    'custom_date_format' => '',
    'exclude' => 0,
    'id' => 'created',
    'table' => 'node',
    'field' => 'created',
    'override' => array(
      'button' => 'Override',
    ),
    'relationship' => 'none',
  ),
  'comment_count' => 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,
    'set_precision' => FALSE,
    'precision' => 0,
    'decimal' => '.',
    'separator' => ',',
    'prefix' => '',
    'suffix' => '',
    'exclude' => 0,
    'id' => 'comment_count',
    'table' => 'node_comment_statistics',
    'field' => 'comment_count',
    'override' => array(
      'button' => 'Override',
    ),
    'relationship' => 'none',
  ),
));
$handler->override_option('sorts', array(
  'created' => array(
    'order' => 'DESC',
    'granularity' => 'second',
    'id' => 'created',
    'table' => 'node',
    'field' => 'created',
    'override' => array(
      'button' => 'Override',
    ),
    'relationship' => 'none',
  ),
));
$handler->override_option('filters', array(
  'uid_current' => array(
    'operator' => '=',
    'value' => '0',
    'group' => '0',
    'exposed' => FALSE,
    'expose' => array(
      'operator' => FALSE,
      'label' => '',
    ),
    'id' => 'uid_current',
    'table' => 'users',
    'field' => 'uid_current',
    'relationship' => 'requestee_id',
  ),
  'approved' => array(
    'operator' => '=',
    'value' => '1',
    'group' => '0',
    'exposed' => FALSE,
    'expose' => array(
      'operator' => FALSE,
      'label' => '',
    ),
    'id' => 'approved',
    'table' => 'user_relationships',
    'field' => 'approved',
    'relationship' => 'none',
    'override' => array(
      'button' => 'Override',
    ),
  ),
  'rtype' => array(
    'operator' => 'in',
    'value' => array(
      '0' => '8',
    ),
    'group' => '0',
    'exposed' => FALSE,
    'expose' => array(
      'operator' => FALSE,
      'label' => '',
    ),
    'id' => 'rtype',
    'table' => 'user_relationships',
    'field' => 'rtype',
    'override' => array(
      'button' => 'Override',
    ),
    'relationship' => 'none',
  ),
));
$handler->override_option('access', array(
  'type' => 'none',
));
$handler->override_option('cache', array(
  'type' => 'none',
));
$handler->override_option('items_per_page', 30);
$handler->override_option('use_more', 1);
$handler->override_option('use_more_always', 1);
$handler->override_option('use_more_text', 'More...');
$handler->override_option('distinct', 1);
$handler->override_option('style_plugin', 'grid');
$handler->override_option('style_options', array(
  'grouping' => '',
  'columns' => '1',
  'alignment' => 'horizontal',
));
$handler->override_option('row_options', array(
  'inline' => array(
    'title' => 'title',
    'created' => 'created',
  ),
  'separator' => '',
  'hide_empty' => 0,
));
$handler = $view->new_display('page', 'Page', 'page_1');
$handler->override_option('title', 'Following Feed');
$handler->override_option('path', 'ff');
$handler->override_option('menu', array(
  'type' => 'none',
  'title' => 'My Friends Recent Content',
  'description' => 'Friends Content',
  'weight' => '0',
  'name' => 'navigation',
));
$handler->override_option('tab_options', array(
  'type' => 'none',
  'title' => '',
  'description' => '',
  'weight' => 0,
));
Sinan Erdem’s picture

Comment #2 works great! Thanks...

alex.k’s picture

Status: Active » Fixed

Sounds like this is resolved.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

martin.l’s picture

Status: Closed (fixed) » Active

Hello,

I have two problems, applying #4:
- error message (translated from german ;-):
# The field-routine vote_up_down.widget is not available.
# The view could not be imported.
- the link www.heyworld.co.uk/ff does not work.

alex.k’s picture

Try removing the bit that refers to vote_up_down from the export:

  'widget' => array(
    'label' => '',
    'alter' => array(
      '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' => 'widget',
    'table' => 'vote_up_down',
    'field' => 'widget',
    'override' => array(
      'button' => 'Override',
    ),
    'relationship' => 'none',
  ),
Jj-1’s picture

"the link www.heyworld.co.uk/ff does not work."

The site has been updated since then and now features a new format.

and alex k has shown the correct thing to change on the code, but if that doesnt work just install the vote up down module and then remove it once you have inported the view.

mrf’s picture

Status: Active » Closed (duplicate)

Closing this as a duplicate of #455792: default "user_relationships_content" View doesn't work for one-way relationships but it looks like we have a possible solution here for that issue?

eL’s picture

#2 works fine for me.

But I need in one View nodes from friends and from logged in user. I can do this with Attachment in Views, but I need it in one default View, because I use this View for referencing nodes, that can be users own or his friends.

eL’s picture

"Views OR" module solved my problem.