0

A node has a uid field. In a node view I would like to add a field to show the author name with his pictures. I now added a field and using entity referencing to a view with all users where I can select the user of the node, and displaying the entity as a useraccount has the desired result. But now I need to select the author so that's very bad, i could update the field using node_update hook but this is so ugly I'm out looking for a way how this should be done. So basically I need to display fields form the node owner on the node as a field.

Came up with a different approach created code fields with display suite and used this for the userimage for example, works fine and no extra modules needed using this method.

<?php
if ($node = menu_get_object()) {
  $user = user_load($node->uid);
  print theme('user_picture', array('account' =>$user));
}
0

2 Answers 2

1

In view go to Relationship Tab under Advanced and add relationship called Content: Author. Now you can able to add a field of your author name and picture.

If you need to get particular node author details means you can just add Content: Nid under contextual Filter.

In Nid Relationship settings select ** Provide default value** in that select a type as Content ID from URL, now have the author details..

1
  • Hello, was not using views, just displaying a node.
    – byenary
    Commented Jul 17, 2015 at 20:55
0

What if you create an Entity Views Attachment. Checkout some quick instructions on setting this up: http://megadrupal.com/blog/show-author-profile-block-in-drupal-node.

1
  • Thx, I'll look into that, thx.
    – byenary
    Commented Jul 17, 2015 at 20:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.