Created
March 30, 2012 21:36
-
-
Save jrast/2255310 to your computer and use it in GitHub Desktop.
Silverstripe Tasks with templated email
This file contains hidden or 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
<!-- This is located at /paht/project/themes/jotoedi/Email/Anmeldungen.ss --> | |
<h1>Anmeldungen für die nächsten Touren</h1> | |
<% control Touren %> | |
<h2>$TourName</h2> | |
<% end_control %> |
This file contains hidden or 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
// .... | |
function process() { | |
$dateInWords = '+ 3 week 2 days'; | |
$dateInOneWeek = date('Y-m-d', strtotime($dateInWords)); | |
echo 'Touren zwischen Heute ('.date('d.m.Y').') und dem ' . date('d.m.Y', strtotime($dateInWords)) . ":\n"; | |
$touren = DataObject::get( | |
'Tour', | |
"StartDatum < '" . $dateInOneWeek . "' AND StartDatum > NOW()", | |
'StartDatum ASC' | |
); | |
$data = array( | |
'Touren' => $touren | |
); | |
$email = new Email('[email protected]', '[email protected]', 'JO-Tödi: Tourenanmeldungen', ''); | |
$email->setTemplate('Anmeldungen'); | |
$email->populateTemplate($data); | |
if($email->send()) | |
echo "E-Mail versendet!\n"; | |
else | |
echo "E-Mail konnte nicht gesendet werden!\n"; | |
} | |
// ... |
Problem Solved!
The Problem is caused by the different manifest files CLI and WEB use!
So you have to run this:
php /path/project/sapphire/cli-script.php AnmeldungenTask flush=1
to generate the new manifest files for the cli script!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If i run this task from command line, i get this error: