Blog Author Image, Name, and Signature (one php snippet to brand all blogs)

This snippet, grabs a user's uploaded Profile Image, their account name, and their signature, and places it in a prescribed block (you decide where (i.e. left, right, menu, footer, header, etc.)). The idea here is you brand all blogs made by any user, with the authors info. This snippet intelligently figures out who the author of the blog is, and displays their respective info. You will need to place this in a block and only "show" the block for */blog and */blog/*. (I use pathauto to create /user/username/blog and /user/username/blog/blog-entry rewritten URI's). If anybody has any better methods by all means suggest away, I personally needed this to work, and this was simple enough to write.

Caveat: if you want more than 256 chars in the signature area, you will need to change the signature field type to something else (like mediumtext) in mysql in the users table. I only wanted mine a couple of chars longer than the allowed for varchar, and it kept chopping it, and I thought it was drupal, but it was just mysql.

So here goes:

<?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>";
if(
$user_load->signature) {
echo
'<div id="user_sig">'.$user_load->signature.'</div>';
}
?>

Using an imagecache preset

messenger - June 12, 2008 - 02:15

I am using imagecache to resize my user's pictures.
I've only made a change to the img src path, it is now the path to the resized imagecache pictures.

echo '<img src="/files/imagecache/userpicture_profile_block/'.$user_load->picture.'" title="'.$user_load->name.'" /> <h3>'.$user_load->name;

many thanks for posting this, i was just about to delve into it and came across this.

 
 

Drupal is a registered trademark of Dries Buytaert.