How can I work out this view?

前端 未结 3 583
终归单人心
终归单人心 2021-01-22 11:26
  • List -> l_user I have a List node that has a user-reference field (l_user).
  • Story -> s-user I then have
3条回答
  •  北海茫月
    2021-01-22 12:12

    I'd suggest getting all of the user references from the list node and passing those into a views argument. So your code would look something like this (untested):

    $user_ids = array();
    foreach ($list_node->l_user as $user_reference) {
      $user_ids[] = $user_reference['uid'];
    }
    $view = views_get_view('list_view');
    return $view->preview('block_1', array(implode(',', $user_ids));
    

    That assumes you have a view named 'list_view' with a display named 'block_1' (you can see the machine name when you hover over the display). That display needs to be a node view with a filter of node type 'story' and an argument of content user_l set to take multiple values. There's almost certainly a bug in that code, but I know the general concept works, as I've done it several times before.

提交回复
热议问题