List all blogs from users in same group I'm new to Drupal, and I'm using Organic Groups to make groups. The site is supposed to be a multi-blog platform where groups can have their own group and the group admin(only) should be able to get a list of all group members (linked to their blogs) in the side menu. How am I able to achieve this? Any help would be appreciated!

I found the following code from here:

&lt;?php
    $query = db_select('node', 'n');
    $query-&gt;join('users', 'u', 'n.uid = u.uid');
    $query-&gt;join('file_managed', 'f', 'f.fid = u.picture');
    $query-&gt;fields('u',array('name'));
    $query-&gt;fields('n',array('type'));
    $query-&gt;fields('f',array('filename'));
    $query-&gt;fields('u',array('uid'));
    $query-&gt;condition('u.status', 1);
    $query-&gt;condition('n.status', 1);
    $query-&gt;condition('n.type', 'blog', '=');
    $query-&gt;addExpression('COUNT(n.uid)');
    $query-&gt;groupBy('u.uid');
    $query-&gt;groupBy('n.type');
    $query-&gt;orderBy('COUNT(n.uid)', 'DESC');
    $result = $query-&gt;execute();
    $output = array();
    while($record = $result-&gt;fetchAssoc()) {
    // print $record ;
     $output = '&lt;div class="bloglist_row"&gt;';
     $output .= '&lt;div class="bloglist_userimage"&gt;&lt;img style="width:100%;" src="./sites/default/files/styles/thumbnail/public/pictures/'.$record['filename'].'"&gt;&lt;/div&gt;';
     $output .= '&lt;div class="bloglist_row_body"&gt;&lt;a href="blog/'.$record['uid']. '"&gt;'.$record['name']. 's Blog&lt;/a&gt;&lt;br /&gt;Posts: ('.$record['expression'].')&lt;/div&gt;';
     $output .= '&lt;/div&gt;';
     $output .= '&lt;img src="blog_spacer.jpg" width="220" height="25" /&gt;';
   //  $output .= '&lt;li /&gt;'.l($record['name']. ' ('.$record['expression'].')', 'blog/'.$record['uid']);
    }
    echo $output;
?&gt;


Unfortunately this gives me the following error:
Notice: Array to string conversion in include() on the last line (echo $output).

Any ideas on how I can achieve this with using Views?
Try setting $output = array(); to $output = ''; and see if that fixes the issue. Also, I would recommend using views instead of custom SQL query while dealing with Drupal.


Views