1

I would like to add a block into the side bar of all article nodes that contains a mini profile of the user who authored the article. I was wondering if there is an easy way to do this. Thanks

3

Checkout the Author Pane module as well.

Author Pane is a block of information about a given user, like those typically found on a forum post, but can be used in other places as well. From core, it collects the user picture, name, join date, online status, contact link, and profile information. In addition, any module or theme can feed it more information via the preprocess system. All of this information is then gathered and displayed using a template file.

| improve this answer | |
  • 1
    Exactly what I was looking for! – Mike Jan 1 '12 at 23:04
3

You should investigate the Views Module. Watch the series at Nodeone.se regarding using the views module called "Taming the Beast" to learn how.

| improve this answer | |
  • Two questions; can I make a view that can show the specific author of a node? I've watched parts of that tutorial. Would you happen to know a part off that top of your head that might help(if not nbd)? – Mike Dec 31 '11 at 2:42
  • As you can tell by the size of the tutorial views is an important module. Your answers are spread over many of the videos in the series. Its worth the time understanding how the parts in each video are linked together. – Ashlar Dec 31 '11 at 3:39
  • after watching it, you're totally right. Thank you for the help. – Mike Dec 31 '11 at 19:51
2

Implement a custom Block or use PHP filter. Find the current node via drupal_get_destination. Once you have the node fetch the uid of the creator/editor and do a user_load to get the full user record.

In a similar way you could also implement an author pane plug-in.

| improve this answer | |
  • could you tell me a little more about the author pane plug-in? or possible post a link? – Mike Dec 31 '11 at 19:50
1

If you really must use a block, you might want to try the eva module. However, if you are open to other solutions, there are a couple of other things to consider.

For sophisticated relationships between different elements on the page, I would recommend trying out panels. Panels seem a little intimidating at first, but it is easy to put, say, the article content in one panel, and user information in another. Try it out; a little experimentation can go a long way.

Finally, if you just want something really quick and easy, make a node-article.tpl.php in your theme, and drop in some code similar to the following:

<?php if ($submitted): ?>
<span class="user-info">
  <?php $account = user_load($uid); print theme('user_picture', $account); ?>
  <span class="blog-author"><?php print l($account->name, "users/" . $account->name); ?></span>
  <!-- See also: http://highrockmedia.com/blog/how-create-custom-date-format-better-theming-drupal-views -->
  <?php if (!$teaser) { print format_date($created, 'custom', '<\d\iv \c\l\a\s\s="\d\a\t\e\b\l\o\c\k"><\d\iv \c\l\a\s\s="\m">M</\d\iv><\d\iv \c\l\a\s\s="\d">d</\d\iv><\d\iv \c\l\a\s\s="\y">Y</\d\iv></\d\i\v>'); } ?>
</span>
<?php endif; ?>

The snippet above shows the user profile picture, the user's account name, and a fancy calendar date that the article was posted on; just add css and stir.

| improve this answer | |
  • Oh, I missed the "Author Pane" module in the answer above -- that really looks like the easiest solution! – greg_1_anderson Jan 1 '12 at 6:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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