Hi,

I'm trying to theme privatemsg list. I'm attaching picture of what I want to achieve. Is it possible to do this, where should I start? Maybe someone have ready solution for this?

Thanks,
Pawel

CommentFileSizeAuthor
privatemsg_1.jpg40.05 KBrolkos

Comments

alexmoreno’s picture

im looking for a similar solution. I suppose that it will be necessary to theme, using the hooks. Is there any api for privatemsg available for this?

Thanks a lot.

drupalina’s picture

For my 6.x website I use this code that I put in template.php of my theme. Of course, you have to change the words "THEME-NAME" to the name of your theme:

/**
* Theme the participants field.
*
* @see theme_privatemsg_list_field()
*/
function THEME-NAME_privatemsg_list_field__participants($thread) {
  $participants = _privatemsg_generate_user_array($thread['participants'], -4);
  
  // Remove ourselves from the list of participants
  global $user;
  foreach($participants as $key => $participant) {
      if ($participant->uid == $user->uid) {
          unset($participants[$key]);
      }
  }
  
  $field = array();
  $field['data'] = _privatemsg_format_participants($participants, 3, TRUE);
  $field['class'] = 'privatemsg-list-participants';
// 	return $field;
//	  return theme('user_picture', $participant); 
    // select last author uid except the current user.
  $uid = db_query('SELECT pm.author FROM {pm_message} pm INNER JOIN {pm_index} pmi ON pmi.mid = pm.mid AND pmi.thread_id = %d WHERE pm.author <> %d ORDER BY pm.timestamp DESC LIMIT 1', $thread['thread_id'], $user->uid);
  // Only display something if we have an uid.
  $account = user_load($uid);
  if ($uid) {
    return theme('user_picture', $account) . theme('username', $account);
  }
}

/**
* Define the participants column.
*
* @see theme_privatemsg_list_header()
*/
function THEME-NAME_privatemsg_list_header__participants() {
  return array(
    'data'    => t('From / To'),    //<!----- NAME IT HERE
    'key'     => 'participants',
    'class'   => 'privatemsg-header-participants',
    '#weight' => -50,        //<!------ MOVE COLUMN TO LEFT
  );
}

/* expriment to display From as avatars */
function THEME-NAME_privatemsg_username($user) {
return theme('user_picture', $user);  
return theme('username', $user);
}

But this code won't work for 7.x. So I opened an issue here http://drupal.org/node/1549540

ptmkenny’s picture

Status: Active » Closed (fixed)