Skip to content

Commit

Permalink
UPDATED: 3.1 compatibility
Browse files Browse the repository at this point in the history
ADDED: Extension hook for updating email object prior to send
UPDATED: Documentation
  • Loading branch information
tractorcow committed Apr 22, 2013
1 parent 59fd941 commit 1685ee2
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 6 deletions.
15 changes: 15 additions & 0 deletions README.md
Expand Up @@ -37,6 +37,21 @@ CommentsNotifications:
recipient: 'Page'
```

## Extending

To hook into the outgoing email (in order to customise the template) you can
extend CommentingController with an extending class with a function updateEmail

```php
class EmailSenderExtension extends Extension {
public function updateEmail(Email &$email) {
$email->populateTemplate(array(
'SiteConfig' => SiteConfig::current_site_config()
));
}
}
```

## Need more help?

Message or email me at damian.mooyman@gmail.com or, well, read the code!
2 changes: 1 addition & 1 deletion code/CommentsNotifications.php
Expand Up @@ -31,4 +31,4 @@ public static function get_recipient($parent) {
default: return $recipient;
}
}
}
}
Expand Up @@ -38,7 +38,9 @@ public function onAfterPostComment(Comment $comment) {
$email->addCustomHeader('X-Sender', $sender);
$email->addCustomHeader('Sender', $sender);

$this->owner->extend('updateEmail', $email);

// Send
$email->send();
}
}
}
4 changes: 2 additions & 2 deletions code/extensions/CommentsNotificationsExtension.php
Expand Up @@ -4,7 +4,7 @@
* @author Damian Mooyman
*/
class CommentsNotificationsExtension extends DataExtension {
static $db = array(
private static $db = array(
'CommentNotificationEmail' => 'Varchar(255)'
);
}
}
2 changes: 1 addition & 1 deletion code/extensions/PageCommentsNotificationsExtension.php
Expand Up @@ -13,4 +13,4 @@ public function updateSettingsFields(FieldList $fields) {
);
}
}
}
}
Expand Up @@ -13,4 +13,4 @@ public function updateCMSFields(FieldList $fields) {
);
}
}
}
}

0 comments on commit 1685ee2

Please sign in to comment.