Hi folks,

I want the email notification for an inserted node to include a specific view mode of the node itself (i.e. the "notifications" view mode).
I've looked at making a module that hooks into notifications_notifications($op) and extends Notifications_Node_Insert_Template. However, all I can do is edit the text & tokens which are returned by the "default_text" function. Even the $events and $subscriptions variables are inaccessible as they are protected. So is there any way of returning a full node? I've been banging my head about this and would love to get any ideas on how to do this.

Thanks!
JP

Comments

pereljon’s picture

Getting close using the get_objects to get access to the node, node_view to get the view mode, and drupal_render to render. Just need to figure out how to make the notification be html instead of plain text!

 function default_text($type, $options) {
    switch ($type) {
      case 'subject':
        return array(
          '#tokens' => TRUE,
          '#markup' => t('[node:type-name]: [node:title]', array(), $options),
        );
      case 'content':
      $theObjects=$this->get_objects();
      $theNode=$theObjects['node'];
      $theView=node_view ($theNode,"notifications");
      $theRender=drupal_render($theView);
        return array(
          '#type' => 'messaging_template_text', '#tokens' => TRUE,
          'teaser' => $theRender,
          'more' => array(
            '#type' => 'messaging_link',
            '#text' => t('Online version of this post:', array(), $options),
            '#url' => '[node:url]',
          ),
        );
      case 'header':
        return array(
          '#markup' => '',
        );
      default:
        return parent::default_text($type, $options);
    }
  }
}