I have the view set up correctly, (following this tutorial http://drupal.org/node/215178) but I'm unable to get the user picture listed with user name. The tutorial doesn't include any advice on this. I tried hardcoding using the code below in my node-blog.tpl.php, but it doesn't seem to function properly.

	$accounts = module_invoke('views_bookmark', 'get_node_bookmarks', $nid);
	foreach ($accounts as $account_info) {
	$account = user_load($accounts_info->uid);
	print theme('user_picture', $account);
	}

How can I adjust the view concept from http://drupal.org/node/215178 to make it display user pictures as well?

Thanks in advance,

Marius

Comments

glob’s picture

I'm trying to do the same thing

My users pictures are stored in their node profile, so I guess that would be a bit more tricky! :)

mooffie’s picture

Component: Views integration » Miscellaneous

foreach ($accounts as $account_info) {

The 'views_bookmark_get_node_bookmarks' function, which you use, doesn't exactly return accounts. It returns some data which is keyed by the user IDs. So you should rewrite that section as:

if (isset($accounts)) {
  foreach ($accounts as $uid => $data) {
    $account = user_load(array('uid' => $uid));

I haven't actually tried to run this code, so expect typos.

My users pictures are stored in their node profile

Let's first see if Marius' new code works. If, and only if, it works, you could change it to something along of:

$node = nodeprofile_load('the_bio_nodetype', $uid);
if ($node) {
  $node = node_build_content($node, false, false);
  print $node->field_picture[0]['view'];
}

Sorry I can't give you two code that I actually tested and debugged. Let's leave that as an exercise for the reader.

mariusooms’s picture

Hi mooffie, thanks for the quick reply. The code works great and I actually prefer to code it in like this rather than using views. Thanks again!

quicksketch’s picture

Status: Active » Closed (fixed)
yeeloon’s picture

Component: Miscellaneous » Code
Status: Closed (fixed) » Postponed (maintainer needs more info)

Hi guys,

Where and what exactly should I implement this above code?

I don't use the node profile module, instead I use the standard User picture.. but somehow the dropdown in the Fields has no such field... Can someone point me what I need to do?

Thanks in advance!

quicksketch’s picture

Status: Postponed (maintainer needs more info) » Closed (fixed)

Hi yeeloon, could you open a new issue? The solution posted here is sort of specific to nodeprofile. It's not clear what you're trying to accomplish. Please be more specific in the new post.