In an effort to attempt to give back what little info I know (at least when it comes to drupal) I thought I would see if this might be a useful handbook page (note: I haven't a clue how to make a "new" handbook page). I was attempting to find info about how to display a users picture and a signature in a block on every blog entry and the blog home page for each user, and I couldn't for the life of me find any info about how to do this.

May be a little dirty but placing this in a block and only "showing" the block for */blog and */blog/*. (I use pathauto to create /user/username/blog and /user/username/blog/blog-entry rewritten URI's).

<?php
if ((arg(0) == 'node') && is_numeric(arg(1))) {
$args[0] = arg(1);
$node_id = $args[0];
$node = node_load($node_id);
$user_id = $node->uid;
} else if ((arg(0) == 'blog') && is_numeric(arg(1))) {
$args[0] = arg(1);
$user_id = $args[0];
}

$user_load = user_load($array = array('uid' => $user_id));
echo '<img src="/'.$user_load->picture.'" title="'.$user_load->name.'" /> <h3>'.$user_load->name;
echo "'s Blog</h3>";
echo '<div class="float_clear"></div>';
if($user_load->signature) {
echo '<div id="user_sig">'.$user_load->signature.'</div>';
}
?>

If anyone has a better method to do this, or thinks it's ready to tell people about and can point me in the direction to write a handbook page I would be welcome to doing a write up on this little snippet of PHP.

Comments

VM’s picture

to create a hanbook page use the create content link in your navigation block, then click on book page.

_____________________________________________________________________
My posts & comments are usually dripping with sarcasm.
If you ask nicely I'll give you a towel : )

dvessel’s picture

You can read this first. http://drupal.org/node/24572 thanks.

joon park

beekerstudios’s picture

I ended up putting it here:

http://drupal.org/node/213855

Under PHP Snippets.