How to display a view of contributors (all authors of a certain content-type)?
It's not so trivial like it seems.. I tried a user-based view and then a node-based view.
Almost got using the second way, but I am struggered with users with multiple contributions displayed several times.
I tried to group by user name and hide everything, but I got the view complaining of all field hidden.. any help??

Comments

sylvaticus’s picture

Status: Active » Fixed

Also searching on other forums I ended up with the idea it is not possible to get in with views.

So I wrote my own code and embedded it in a page (of course, PHP filter must be enabled!)

<ul>
<?php
// fetching the uid|authored nodes counter...
$result = db_query('SELECT n.uid, count(*) as counter FROM {node} n WHERE n.type="article" GROUP BY n.uid ');

// building and ordering the valid authors array...
$authors = array();
while ($row= db_fetch_object($result)) {
  if($row->counter > 0){
    $author = array();
    $user= user_load(array('uid' => $row->uid));
    $author['uid'] = $user->uid;
    $author['surname'] = $user->profile_surname;
    $author['name'] = $user->profile_name;
    $author['affiliation'] = $user->profile_affiliation;
    $authors[]=$author;
  }
}

// sorting the authors array by surname and name..
function compare_fullname($a, $b) {
    $retval = strnatcmp($a['surname'], $b['surname']);
    if(!$retval) return strnatcmp($a['name'], $b['name']);
    return $retval;
}
usort($authors, 'compare_fullname');

// printing the  authors..
foreach ($authors as $author) {
  echo '<li><a href="/user/'.$author['uid'].'">'.$author['surname'].', '.$author['name'].'</a> - <i>'.$author['affiliation']."</i></li>";
}

?>
</ul>

Status: Fixed » Closed (fixed)

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

wOOge’s picture

Issue summary: View changes

Here is code for D7 ( Drupal 7 ):

<ul>
<?php
//Machine name of content type we are interested in
$content_type = "article";
//Fetch the uid's who have posted a certain content type, count and order them from most posts to least, and assemble into an array
$result = db_query('SELECT uid, count(*) as counter FROM node WHERE type=:ctype GROUP BY uid ORDER BY counter DESC', array(':ctype' => $content_type))->fetchAll();


//Loop through each record and get usefull info for each user
foreach ($result as $row){
	$account = user_load($row->uid);
	print "<li>" . $account->name . " (" . $row->counter ." ". node_type_get_name($content_type) . ")</li>";
	
}
?>
</ul>