Hi all,

I would like to add the picture of users on the Birthdays block.
Today, the block show user name, age and date.

I would like to add the user avatar !
(next to user name for example)

Could you please help me ?

Thanks in advance,

Jeremy

Comments

maartenvg’s picture

You have to override theme_birthdays_block() by copying the entire function to your template.php and renaming it to themename_birthdays_block(). Then add the appropriate PHP & HTML code for the user picture.
something like this.

Replace

$str .= '<tr><td>' . theme('username', $user) . '&nbsp;<small>' . $age . '</small></td><td>' . _birthdays_show_date($b['dob'],$user) .  '</td></tr>';

with

$str .= '<tr><td>'.theme('user_picture', $user).'</td><td>' . theme('username', $user) . '&nbsp;<small>' . $age . '</small></td><td>' . _birthdays_show_date($b['dob'],$user) .  '</td></tr>';

Which added a 'theme('user_picture', $user)'.

maartenvg’s picture

Status: Active » Fixed
Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.

alextronic’s picture

Hi Maarten,

I'm using Drupal 6.10, I'm using a Birthdays block and in my custom "birthdays-block.tpl.php" I have the following:

<?php foreach($birthdays as $birthday): ?>
    <tr>
      <td><?php print $birthday['username'] ?></td>
      <td><?php print $birthday['date'] ?></td>
      <td><?php print $birthday['picture'] ?></td>
    </tr>
    <?php endforeach; ?>

...but the picture does not display. I've read the posts above but I don't know if they apply for D6, or if there has been any advance and maybe there's an easy way to insert user's images in blocks.
(By the way, I never found the function theme_birthdays_block()!! ...I hope I don't have to deal with it)

Thanks in advance.

alextronic’s picture

OK, I did it. In the birthdays templates (page and/or block), create new column (<td>) in the table's header, Then add the corresponding <td> cell inside the foreach($birthdays as $birthday) loop that follows; something like this:

<td><?php if (!empty($birthday['account']->picture)) { print "<img src='".$birthday['account']->picture."'></div>"; } else { print "No image available"; } ?></td>

Hope it helps to others.