Re-Theme Private Message Function I would like to rewrite the original function code for the Private messages block module. The original code displays a text message for no messages or messages in the inbox. I would like to change it to an image but am no where near on the right track.  Here is the coded that I am trying to change

 /**
 * Theme a block which displays the number of new messages a user has.
 */
function theme_privatemsg_new_block($count) {
  $count = $count['count'];
  if ($count == 0) {
    $text = t('0 Messages');
  }
  else {
    $text = format_plural($count, 'You have a new message!',
                        'You have @count new messages!');
  }

  return l($text, 'messages', array('attributes' =&gt; array('id' =&gt; 'privatemsg-new-link')));
}


I was trying the following replacement:

/**
 * Theme a block which displays the number of new messages a user has.
 */
function theme_privatemsg_new_block($count) {
  $count = $count['count'];
  if ($count == 0) {
    /*$text = t('0 Messages');*/
    $text = l('&lt;img src="messages.png" height="40"/&gt;);
  }
  else {
    /*$text = format_plural($count, 'You have a new message!',
                        'You have @count new messages!');*/
    $text = l('&lt;img src="messages.png" height="40"/&gt;');                   
  }

  return l($text, 'messages', array('attributes' =&gt; array('id' =&gt; 'privatemsg-new-link')));
}


I suspect there are issues with the fact that it is designated as a text string instead of code that should be rendered.  What do you think?

Using PHP I am trying:

/**
 * Theme a block which displays the number of new messages a user has.
 */
function theme_privatemsg_new_block($count) {
  $count = $count['count'];
  if ($count == 0) {
    /*$text = t('0 Messages');*/
    $theme_path = drupal_get_path('theme', 'eternal'));
    $text = '&lt;img src="' . $base_path . '/' . $theme_path . '/images/messages.png" width="50"/&gt;';
  }
  else {
    /*$text = format_plural($count, 'You have a new message!',
                        'You have @count new messages!');*/
    $theme_path = drupal_get_path('theme', 'eternal'));                    
    $text = '&lt;img src="' . $base_path . '/' . $theme_path . '/images/messages.png" width="50"/&gt;';                   
  }

  return l($text, 'messages', array('attributes' =&gt; array('id' =&gt; 'privatemsg-new-link'), 'html' =&gt; TRUE));
}
$text = l('&lt;img src="messages.png" height="40"/&gt;); looks wrong. "l" is function to create links, i guess thats what is failing here. Try to remove it and leave just $text = '&lt;img src="messages.png" height="40"/&gt;';.

For reference on "l" see drupal api page - please note that there is also 'HTML' parametr in "l" function that you should set to true, since you are passing HTLM code in $text to that returning "l".


  'html' (default FALSE): Whether $text is HTML or just plain-text. For example, to make an image tag into a link, this must be set to TRUE, or you will see the escaped HTML image tag. $text is not sanitized if 'html' is TRUE. The calling function must ensure that $text is already safe.