Take messages generated by module and print them inside the node teaser? I have a Pay2Publish module, which gets no support these days, so I have to turn to the community for the help.  I guess this is a simple PHP question:

I want to take the messages generated by Pay2Publish module and display them bellow each node teaser.

Here's the code from the module:

/**
 * Implements hook_node_view()
 * 
 * Displays the Message for the author of a node
 */
function ms_paypublish_node_view($node, $view_mode, $langcode) {
  $plans = variable_get('ms_paypublish_plan_' . $node-&gt;type, array());
  $pp_node = ms_paypublish_load_node_nid($node-&gt;nid);

  if ($pp_node AND !empty($plans)) {
    if ($view_mode == 'full' AND user_access('renew own pay to publish nodes')) {
      global $user;
      if ($node-&gt;uid == $user-&gt;uid) {
        switch ($pp_node-&gt;status) {
          case 0: // Not Published
            drupal_set_message(
              str_replace(
                '!link', 
                l(t('Publish'), 'ms_paypublish/publish/' . $node-&gt;nid), 
                variable_get('ms_paypublish_not_published_text', 'This content is not published. To publish, please click here: !link')
              )
            );
            break;

          case 1: // Published
            if ($pp_node-&gt;expiration_date) {
              drupal_set_message(
                str_replace(
                  array('!days','!link'), 
                  array(
                    ms_paypublish_get_expiration_string(ms_paypublish_get_expiration($node-&gt;nid)),
                    l(t('Promote / Extend'), 'ms_paypublish/publish/' . $node-&gt;nid)
                  ), 
                  variable_get('ms_paypublish_published_text', 'This content will expire in !days days. To Promote / Extend, please click here: !link')
                )
              );
            }
            break;

          case 2: // Awaiting Admin Approval
          case 5:
            drupal_set_message(variable_get('ms_paypublish_approval_text', 'This content is Awaiting Admin Approval. It will be published shortly.'));
            break;

          case 3: // Not yet published
            drupal_set_message(str_replace('!link', l(t('Publish'), 'ms_paypublish/publish/' . $node-&gt;nid), variable_get('ms_paypublish_publish_text', 'This content has not been published yet. To publish, please click here: !link')));
            break;
        }
      }
    }
  }
} 


What do I need to put inside my custom node--content-type.tpl.php so that these messages are displayed below each teaser?
My suggestion is:


Change this line in hook_node_view()
if ($view_mode == 'full' AND user_access('renew own pay to publish nodes')) {
and add $view_mode == 'teaser' to it. Then you can create a patch and submit to community, if you think that this feature may be needed by other users.
You can create a template file for this content type, store the messages in a theme variable and display them in template file, just use &lt;?php print $VARIBALE_NAME ?&gt; You also have to write a template preprocess function where you will write code to get message body.


I think second option is the best. The requirement is not generic and changing the module is not right in this case. However, you can search the module's issue queue for this.

References


function template_preprocess_node
Drupal 7 Template (Theme Hook) Suggestions