Quantcast
Channel: Recent posts across whole site
Viewing all articles
Browse latest Browse all 49203

Setting a view relationship around the content author

$
0
0

For my d6 site, I was wanting to display two different types of nodes both of which are created by users. Not wanting to show my stupidity I searched and searched but couldn't find anything and had previously writter a dynamic filter code for d5 which struck me as messy. Finally, I wrote something for myself that can enable it as a relationship in my code. Thought I'd share it in case other people needed the same code. If there is a simpler way, I'd love to know it but to me this is incredibly simple and shows the power of views2.

function user_relation_views_data(){
    $data=array();
      $data['node']['uid']['relationship'] = array(
        'base' => 'node',
        'base field' => 'uid',
        'field' => 'uid',
        'group' => 'node',
        'title' => 'Author Relationship',
        'help' => 'Relate nodes by the author',
        'handler' => 'views_handler_relationship',
        'label' => t('UserID'),
      );
 
    return $data;
  }

Viewing all articles
Browse latest Browse all 49203

Trending Articles