[TYPO3-dev] Powermail hooks - fetch id of powermail mail record just created?
Florian Schaeffer
florian.schaeffer at mercoline.de
Mon Dec 7 07:47:08 CET 2009
Hello Brain,
> I'm playing around with powermail and its hooks. I need to output the id
> of the powermail mail record that has just been created after the user
> submits the form. So far I have not succeeded.
As the docs to powermail state there is no real hook for it available
ATM but in the forums on forge there is an entry which proposes to use a
userFunction for it.
One should simply get the last entry of the powermail_mails-table and
use it as uid of the mail. But it has to be said, this can only be used
on mid-traffic sites. If you have a LOT! of entries happening at the
same time the function may return a false id....
This is how we do it:
Make a userFunc-PHP-File:
<?php
class user_userFuncPowermail {
function user_getUidOfMail() {
// get latest entry from db
$result = $GLOBALS['TYPO3_DB']->exec_SELECTquery( 'max(uid) as
uid', 'tx_powermail_mails', '');
$row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result);
return $row['uid']+1;
}
}
?>
and then on the page where the powermail-form is add an additional
template and out something like this in the setup-field
includeLibs.user_userFuncPowermail =
fileadmin/templates/Erweiterungen/userFunc.powermail.php
plugin.tx_powermail_pi1 {
dynamicTyposcript {
lastMailId = USER
lastMailId.userFunc = user_userFuncPowermail->user_getUidOfMail
}
}
this f.e. will make the UID-field accessible for the mail
processing-functions. In our case we just send the generated ID to the
user so he has an unique identifier for his ticket (the marker can be
accessed like "Ticket-ID: ###POWERMAIL_TYPOSCRIPT_LASTMAILID###")
HTH
Florian
More information about the TYPO3-dev
mailing list