2

How can I theme the output of Privatemsg? I took look at http://api.worldempire.ch/api/privatemsg/privatemsg.theme.inc/group/theming/1, but I didn't understood how to use that. I want to totally change the HTML output for the message list.

How do I use my custom date format in the messages? I guess the format_date() function would help me, but how do I use it correctly?

print format_date($messages_timestamp, 'custom', 'd=m=Y') returns "01.01.1970." What is that?

3
  • Which of these theme function are you looking at ? Does $messages_timestamp displays a timestamp ? – tostinni Jun 7 '11 at 16:59
  • 1
    Please specify what exactly you want to do. The generic answer to your generic question is "use theme overrides". And the format_date() question is completely unrelated to this so I suggest you make that a separate question. Note that Privatemsg for Drupal 7 allows you to configure the used date format, but that feature will probably not be backported to 6.x-2.x as it depends on a new core feature. – Berdir Jun 7 '11 at 17:00
  • It seems strange that you get "01.01.1970" when the format passed to the function is "d=m=Y;" I would expect the result to eventually be "01=01=1970." – kiamlaluno Jun 7 '11 at 19:07
2

Ok, here is some information.

  • That list shows threads, not single messages. You can't change that, at least not with theming. The only thing you easily can do is enable the privatemsg_limits module and set the number of messages per thread to 1. That basically disables threading and each message will be sent as a new thread. Then they will be shown separetly on the list, but they will also be shown separately on the thread view page. Privatemsg views is currently only compatible with 6.x-1.x and looks rather unmaintained at this point.

  • You can configure the displayed columns and their order in the Privatemsg settings.

  • The theming functions are used to customize the content of single columns. For example, to show a different date format, you can override phptemplate_privatemsg_list_field__last_updated():

    function phptemplate_privatemsg_list_field__thread_started($thread) {
      $field = array();
      $field['data'] = format_date($thread['thread_started'], 'custom', 'd.m.Y H:i');
      $field['class'] = 'privatemsg-list-date-started';
      return $field;
    }
    

    In 7.x, Privatemsg shows a different date format depending on the age of the message, that is done in privatemsg_format_date() if you want to backport that.

  • To change how the table looks, you should be able to that with just CSS. Privatemsg adds tons of classes to that table, including a seperate class for every column and classes for rows with new messages and soon for unreplied messages too.

6
  • What if i want to make message list (Not inside thread) tabeless? – Alexander Kim Jun 10 '11 at 8:39
  • I want to make message list without a table headers and table at all. Gonna use DIV's instead of table – Alexander Kim Jun 10 '11 at 8:43
  • You can either override api.worldempire.ch/api/privatemsg/privatemsg.theme.inc/function/… or use the API directly as outlined in drupal.org/node/624528. It will however require quite a bit of code to make the table a list or something. I'm not sure why you'd want to do that. Even the messages list on facebok is a table, it's just the CSS that makes it look nice. – Berdir Jun 10 '11 at 8:49
  • And how to display only 1st author of the message not all recipients. – Alexander Kim Jun 10 '11 at 8:51
  • well, do u know a social networking site - vk.com my chief wants my messages list tabeless, without table header and content profile field_photo. – Alexander Kim Jun 10 '11 at 9:02
0

format_date() requires a UNIX timestamp, which is an integer containing the number of seconds passed from January 1, 1970; when you pass a value that is 0, NULL, or a string that doesn't start with a number, then the result of the function is January 1, 1970.

In your case, it could also be that $messages_timestamp is not a defined variable, a variable that has been unset, or a variable that has been set to NULL.

8
  • Sorry for being not exactly. Berdir, i've already asked you on drupal.org about theming and you gave me a link on your API. I don't know how to use those theme functions to change the html output of messages-list. Can you throw me an examples? – Alexander Kim Jun 8 '11 at 2:29
  • @Heihachi: Again, provide an example of what exactly you want to change and I can probably give you the code you need for that. Making up a random example won't help you much I think. – Berdir Jun 8 '11 at 23:07
  • @Berdir: I want to theme - when you press on link My Messages. Attaching screenshot - pics.kz/s1/ae/e3/dd/aee3dde7d4037de9d79f3f5c0c52708f.jpg It's a my messages page. – Alexander Kim Jun 9 '11 at 4:09
  • @Berdir: also as you can see in the data column it displays only d.m.Y without a time. In a clean drupal install i had no problems with displaying time near d.m.Y. – Alexander Kim Jun 9 '11 at 4:11
  • @Heihachi: Yes, I know that already. What there? Do you want to change the content of a single column, the order of comments, look and feel of the whole table...? – Berdir Jun 9 '11 at 6:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.