I’ve been trying to figure out how to place a profile picture of the initial sender next to each thread in the inbox. Although it seems there has been some discussion of theming individual threads through modification of the privatemsg-view.tpl.php file, I can’t find many (if any) threads detailing how to create a new column in the Inbox view.

The module documentation is fairly good on the subject, and from that I’ve pieced together the following:

  1. I need to create a new SQL query to grab the author picture.
    function privatemsg_sql_picture(&$fragments, $uid) {
      // Set the primary table.
      $fragments['primary_table'] = '{users} users';
    
      // Add a field.
      $fragments['select'][] = 'users.picture';
      
      // Join another table.
      //$fragment['inner_join'][] = 'JOIN pm_message ON (users.uid = pm_message.author)';
    
      // And finally add a condition.
      $fragments['where'][] = 'users.uid = %d';
      $fragments['query_args']['where'][] = $uid;
    }
    
  2. I need to create a call in the format phptemplate_privatemsg_list_header__fieldname to generate the column headers
    function phptemplate_privatemsg_list_header__picture() {
      return array(
        'data'    => t('Author'),
        'key'     => 'picture',
        'class'   => 'privatemsg-header-author_picture',
        '#weight' => -45,
      );
    }
    
  3. I need to create a call in the format phptemplate_privatemsg_list_field__fieldname to generate the column content in each row
    function phptemplate_privatemsg_list_field__picture($thread) {
      $field = array();
      $field['data'] = $thread['picture'];
      $field['class'] = 'privatemsg-list-picture';
      return $field;
    }
    

Right now, I'm putting all the code into template.php.

I'm not quite sure where/how I'm supposed to call the privatemsg_sql_picture function. The docs give the following:

$query = _privatemsg_assemble_query('getsubject', 5);
$result = db_query($query['query']);

...but I'm unclear on where I'd call it (privatemsg seems to assemble queries when it is loading individual threads in the privatemsg_thread_load function).

Is this the correct approach, or am I pursuing a dead end? I'm not 100% clear if the documentation is referring to the creation of new columns in the Inbox view or in the individual thread view (it seems that the later case would be handled easily by creating a customized .tpl.php). I’d greatly appreciate it if someone could point me in the right direction on this. I’d love to do a tutorial on the process once I figure it out, I’m surprised I haven't found someone else asking about it.

CommentFileSizeAuthor
#8 1167362.patch5 KBberdir

Comments

theatereleven’s picture

I would LOVE to know how to do this....following.

AntiNSA’s picture

subscribe.

theatereleven’s picture

Anyone on this? Private messaging is really cryptic looking in my opinion. I really need our site's PM to look a little more like Facebook's. Not fancy, but just a little more friendly and clear.

areynolds’s picture

To be honest, I've dropped it for the moment. I settled for some styling that makes the format a bit simpler, but haven't found a solution for including sender pictures in the inbox view. It sounds like the project maintainers are trying for Views integration in the future, but that the queries Privatemsg has relied upon in the past are difficult to integrate.

berdir’s picture

Two problems...

a) You are following the 6.x-1.x documentation it seems, 6.x-2.x is now slightly different. See the updated documentation athttp://api.worldempire.ch/api/privatemsg/privatemsg.theme.inc/group/them.... You used 6.x-2.x in the version selection, so if you really use that version, you need to follow the updated documentation.

b) Second, there is no easy/fast way to know who is the first author of the thread as soon as there are multiple ones. You cant simply query it as you did in your code. Also, note that you have created a new query, but what you actually want is extending the existing privatemsg_sql_list query with this hook: http://api.worldempire.ch/api/privatemsg/privatemsg.api.php/function/hoo...

areynolds’s picture

Well, fiddlesticks. I am using 6.x-2.x-dev, so I was following the wrong documentation. I will post back when I make the updates.

(Danke Berdir vielmals. Ich hoffe daß ich richtig machen kann. Meine Deutsche Lehrer ist jetzt sehr traurig, weil ich alle Deutsch vergessen habe.)

berdir’s picture

Status: Active » Needs review
StatusFileSize
new5 KB

The patch adds a new "From" column which shows the last author that wrote in the thread (current user excluded). You can also configure if you want to show the user picture or not and if Imagecache Profiles is enabled, you can select which preset to use for the user picture.

Please test.

rolkos’s picture

Hi,

Did you get something? I have same problem.

rolkos’s picture

This patch works almost perfect. Thanks!

berdir’s picture

I have no idea what "almost perfect" is supposed to mean ;)

Please specify exactly what you have done, how you have configured it, how it looks now (screenshot would be awesome) and what you would expect differently.

To add this to this module, I need detailed feedback (This is the same for every issue with a patch. Don't just use them, provide feedback!)

broncomania’s picture

I try the patch and I see the profile pictures but my own are not now shown is that a normal behavior, missing or a bug?

drupalina’s picture

@ Berdir , Hi,

Would you be so kind as to provide this patch for Privatemsg 7x-1.2 ??? (or maybe a forked version of Privatemsg 7.x with user pictures. If forked, please mark your code with //Berdir begins and //Berdir ends )

I've searched and searched and there is no patch and no tutorial on how to do this in 7.x

Anonymous’s picture

I concur with Drupalina, a patch would be nice.. preferably with option for custom image field/style?

ptmkenny’s picture

Category: support » feature
ptmkenny’s picture

The thread for 7.x is here: https://drupal.org/node/1549540

oadaeh’s picture

Status: Needs review » Closed (won't fix)

This issue is being closed because it is against a branch for a version of Drupal that is no longer supported.
If you feel that this issue is still valid, feel free to re-open and update it (and any possible patch) to work with the 7.x-1.x branch (bug fixes only) or the 7.x-2.x branch.
Thank you.