-
-
Save Liongold/f0fcda4f39c9e8f33233 to your computer and use it in GitHub Desktop.
Website Change Notifications
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function onAfterPublish(&$original) { | |
$subSites = Subsite::currentSubsite(); | |
if($subSites->ContactEmail) { | |
$versioned = Versioned::get_version('SiteTree', $this->ID, $this->Version); | |
$member = Member::get()->byId($versioned->AuthorID); | |
// Check for changes in page controller | |
$mailer = new Email( | |
"no-reply@documentfoundation.org", | |
$subSites->ContactEmail, | |
"The site has just been updated. " | |
); | |
$mailer->setTemplate("RevisionEmail"); | |
$diffData = new DataDifferencer($original, $this); | |
$mailer->populateTemplate(new ArrayData(array( | |
'Name' => $member->FirstName, | |
'Surname' => $member->Surname, | |
'Title' => $this->getMenuTitle(), | |
'Link' => $this->AbsoluteLink(), | |
'Difference' => $diffData | |
))); | |
$mailer->sendPlain(); | |
} | |
return true; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Website Change Notification\n\n | |
Dear community,\n this email is being sent to inform you that $Name $Surname has just published a new version of $Title. \n\n | |
The following changes have been made to the page:\n | |
<% with $Difference %> | |
<% loop ChangedFields %> | |
$Title\n\n $Diff\n\n | |
<% end_loop %> | |
<% end_with %> | |
You can checkout the latest version of the page by visiting $Link. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
and using 'Difference' => $diffData
should fit our needs better (no Content field used in many pagetypes)