Most experience drupal builder knows that sometimes in the module folder the module author provides us with tpl (template) file that can be used with our themes to redesign / theme the layout for the particular module.

This is also the case for the private message module, you can use the privatemsg-view.tpl.php that you found the module directory and change the layout for the message threads view.

To do so you just need to copy the file to your theme directory and start editing the content of it.

// $Id: privatemsg-view.tpl.php,v 1.1.2.7 2009/11/19 15:59:55 berdir Exp $
// Each file loads it's own styles because we cant predict which file will be
// loaded.
drupal_add_css(drupal_get_path('module', 'privatemsg') . '/styles/privatemsg-view.css');

  
    
      
<?php
 
print $author_picture;
?>
<?php
 
print $author_name_link;
?>
<?php
 
print $message_timestamp;
?>
<?php
 
if (isset($new)) :
?>
<?php
 
print $new
?>
<?php
 
endif
?>
<?php
 
print $message_body;
?>
<?php
 
if ( isset($message_actions)) :
?>
<?php
 
print $message_actions
?>
<?php
 
endif
?>

But one thing that the module developer forgot to tell us. Beside the string found in the tpl file (example : $message_body) you can use $message array in the page.

So to determine what kind of array string available in your system, you just need to put :

<?php
drupal_set_message
('<pre>' . print_r($message, TRUE). '</pre>');
?>

somewhere in the tpl file and obviously must be inside a php tag.

To help you quick start theming the template, I provided supposedly generic $message that can be used by most system :


$message['author']->name // author raw name
$message['author']->uid // author raw uid
$message['subject'] // the subject of the message
$message['author']->mail // the author email address

Supposedly if you enable and install content profile for the user then it's very possible to load it in the message thread page.

Now you might ask, how about the private message list / send page?

Its possible to theme those pages also but a deeper understanding of how Drupal theme_table() api working method is a must.

/**
 * Theme to display the privatemsg list.
 *
 * This theme builds a table with paging based on the data which has been built
 * by the header and field theme patterns.
 */
function phptemplate_privatemsg_list($form) {

  $has_posts = !empty($form['#data']);
  drupal_add_css(drupal_get_path('module', 'wedding_tools_request_quote') .'/default.css');
  drupal_add_js(drupal_get_path('module', 'wedding_tools_request_quote') .'/jquery.tablesorter.min.js');
  drupal_add_js(drupal_get_path('module', 'wedding_tools_request_quote') .'/wedding_tools_request_quote.js');

  // Load the table columns.
  $columns = array('participants', 'subject', 'is_new', 'last_updated');

  // Load the themed list headers based on the available data.
    $headers = array( //'Category', 'Message', 'Status', 'Reply', 'Delete');
			array('data' => t('From:') , 'class' => 'category'),
			array('data' => t('Message:'), 'class' => 'subject'),
			array('data' =>  t('No:'), 'class' => 'status'),
			array('data' => t('Date:'), 'class' => 'reply'),
			array('data' => t('Delete:'), 'class' => 'toggle'),
			 );
  // sort the headers array based on the #weight property.
  //usort($headers, 'element_sort');

  $themed_rows = array();
  // Check if there is atleast a single thread.
  if ($has_posts) {
    foreach ($form['#data'] as $thread_id => $data) {
      // Theme the row.
	  $user_name = user_load($data['participants']);
	  $count_message = format_plural($data['is_new'], '1 msg' , '@count msgs');
	$row = array( 
		'data' => array(
			array('data' => l($user_name->name, 'user/' . $data['participants'])  , 'class' => 'category'),
			array('data' => l($data['subject'], 'messages/view/' .$thread_id) , 'class' => 'subject'),
			array('data' => $count_message , 'class' => 'status'),
			array('data' => wedding_tools_request_quote_ago($data['last_updated']), 'class' => 'reply'),
			array('data' => drupal_render($form['threads'][$thread_id]) , 'class' => 'toggle'),
			
			),
    	);


     // Store the #rows data in the same order as the header is, the key property of the header refers to the field that belongs to it.
  
      $themed_rows[] = $row;
    }
  }
  else {
    // Display a message if now messages are available.
    $themed_rows[] = array(array('data' => t('No messages available.'), 'colspan' => count($headers)));
  }

  // Remove any data in header that we don't need anymore.
  foreach ($headers as $id => $header) {
    unset($headers[$id]['key']);
    unset($headers[$id]['#weight']);
  }

  // Theme the table, pass all generated information to the table theme function.
  $form['list'] = array('#value' => theme('table', $headers, $themed_rows, array('class' => 'message-table no-sticky')));
  return drupal_render($form);
}

The snippet above is a modified theme function taken from the private message module. the code should be placed in the template.php of your theme.

If you want to use the original theme function, You should know that the original theme function utilizes multiple theme function to generate the header, the column and specific field. Those theme function then glued together in the theme_table function.

So if you want to use the original theme function then you need to look inside the "privatemsg.theme.inc" file in the private message module directory.