I am using the Message module to tell people when nodes are created, deleted or edited. Is there a way to combine the messages module with my nodes in views.

What I want to do is show a message of a node being deleted or edited, and then show some fields of this node. I tried using tokens inside the message module, but that does not seem to do the trick.

  • 1
    For messages in general you add an entity reference to the node for manage fields on the message type and then use tokens inside the message text. But if the node is deleted there will be nothing to reference. – J. Reynolds Mar 25 '15 at 5:16
  • Yup, I created my entity reference. But I have got different node types. Empty tokens then gets printed as [normal text], and some of the fields which have values, also gets printed like that. – jae.phoenix Mar 25 '15 at 5:24
  • It should work for create and edit. Not for delete. – J. Reynolds Mar 25 '15 at 5:29


Use Drupal hooks on create/edit/delete of node, then create a custom message type that just takes text field (no entity reference).

Then in your hooks create the new message type and add for its field value the message text constructed from the node fields. Embed links to node if node is still available.

$message = message_create('general_alert');
$wrapper = entity_metadata_wrapper('message', $message); // populate with node data

// Set necessary fields to use with tokens.
$wrapper->field_message_text->set(array('value' => $text));

Or even better, include both an entity reference field for your message and a text field. Add the entity reference when creating/updating the node, and populate the text field when deleting the node.

| improve this answer | |

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.