Theming messages with template files

Public

By default, message module (http://drupal.org/project/message) doesn't support theming messages via files by default. But it is really easy to fix this problem.

Put this into your template.php:

Get raw version
php
  1. function THEMENAME_preprocess_entity(&$variables) {
  2. foreach($variables['theme_hook_suggestions'] as &$suggestion) {
  3. $suggestion = 'entity__' . $suggestion;
  4. }
  5. }

Now create a template file named entity--message.tpl.php and enjoy theming:

Get raw version
php
  1. <div id="message-<?php print $entity->id; ?>" class="message-item clearfix">
  2. <div class="message-content">
  3. <?php print render($content); ?>
  4. </div>
  5. </div>