[themes] User info in blocks
Tony Yarusso
tonyyarusso at gmail.com
Thu Feb 7 20:24:15 UTC 2008
I'm trying to put together a block that will display additional information
on users' blog pages. The person I'm working with wants some of the more
"traditional" blog stuff, like a user picture, short bio, blogroll, and
archives links shown in the sidebar. All of the actual information is
supported by other modules, so I just need to be able to access it from
within my theme. Essentially, what I'm going for is to load this block
whenever the node type is 'blog post', and populate it with the content
matching the author of the node.
I am using a small snippet of code that someone else gave me already for
displaying a title. This is residing in node-blog.tpl.php right now and
works fine:
<?php $the_user = user_load(array('uid' => $node->uid)); ?>
<?php if ($the_user->profile_blog_title != ""): ?>
<h2><?php print $the_user->profile_blog_title ?></h2>
<?php else: ?>
<h2><?php print $node->name . "'s blog" ?></h2>
<?php endif; ?>
What I've been using so far in my module's implementation of hook_block
looks like this, which is just worrying about the picture for now:
case 'view':
$block['subject'] = t('Blog');
$the_user = user_load(array('uid' => $node->uid));
$user_pic = $the_user->picture;
$block['content'] = $user_pic;
return $block;
However, this does not return anything, and upon further investigation with
print_r(), it appears to be returning the anonymous user from 'uid', which
of course doesn't have a picture associated with it. Part of what I'm not
sure about is whether I can access the node information ($node->uid) from
within the block, since it's in the sidebar, not the main content area where
the node is loaded. Please excuse me as I'm very new to PHP and Drupal
development, but looking to learn.
--
Tony Yarusso
http://tonyyarusso.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/themes/attachments/20080207/f96589ad/attachment.htm
More information about the themes
mailing list