I need to show users what parts of body is changed on Node update notifications, and at now I do this via Drupal Diff module and my custom hooks. Will be good to have this feature in Notify module core.
Here is example of my code:
function mymodule_node_presave($node) {
if($node->revision) {
$message['subject'] = "Node have new revision: $node->title";
$message['body'] = "<h1>".l($node->title,'node/'.$node->nid)."</a></h1>";
$message['body'] .= "<h1>Revision message:</h1><p>$node->log</p>";
$node_new=clone($node);
node_build_content($node_new);
$node_new_body=drupal_render($node_new->content['body']);
if($node->original) {
$node_old=clone($node->original);
node_build_content($node_old);
$node_old_body=drupal_render($node_old->content['body']);
$diff=diff_get_inline($node_old_body, $node_new_body);
$diff=str_replace("diff-deleted'","diff-deleted' style='background: #ccc; text-decoration: line-through;'",$diff);
$diff=str_replace("diff-added'","diff-added' style='background: #cfc;'",$diff);
$diff=str_replace("diff-changed'","diff-changed' style='background: #ffb;'",$diff);
$message['body'] .= "<h1>Diff of changes:</h1>".$diff;
}
$message['body'] .= "<h1>Current node body</h1>".$node_new_body;
}
$MimeMailSystem->mail($message);
}
Can you add something like this in Notify module, for sending to users not only updated content, but diff of current and previous revision?
Comments
Comment #1
gisleTo quote from the project page:
I don't see the general usefulness of this. The majority of users of Notify will not need this. For them, this will only bloat the module. The correct way to add this is in a sub-module that may be turned on to add this for those that really need it.
Comment #2
murzMaybe you can create hook or another way to intercept message generation process and replace it by other text in custom module? If this already here, can you provide some example how to use it? Thanks.
Comment #3
gisleNotify uses
hook_mailto generate its messages and you should be able to usehook_mail_alterin your sub-module to override the content in the messages sent.