[TYPO3-english] Send email to fe_users upon news creation

Jeppe Donslund jd at masters.dk
Thu Apr 14 11:14:02 CEST 2011


On creating a new news record I get this error: |<strong>ERROR:</strong> 
No class named: tx_newsnotify_tcemainprocdm|

The code from tx_newsnotify_tcemainprocdm.php:

class tx_newsnotify_tcemainprocdm {

	function processDatamap_postProcessFieldArray ($status, $table, $id, 
&$fieldArray, &$reference) {
	
		if ($table == 'tt_news') {
	  	switch ($status) {
	    	case 'new':
	      	/* Send email code */
	      	// The message
					$message = "Line 1\nLine 2\nLine 3";
					
					// In case any of our lines are larger than 70 characters, we 
should use wordwrap()
					$message = wordwrap($message, 70);
					
					// Send
					mail('jd at masters.dk', 'Fra seatrout.dk', $message);
				break;
			}
		}
	}
}

I have tried to register the class in ext_localconf.php with this:
$GLOBALS 
['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processDatamapClass'][] 
= 
'EXT:m_st_sendnewsnotification/class.tx_newsnotify_tcemainprocdm.php:tx_newsnotify_tcemainprocdm';

Should t3lib/class.t3lib_tcemain.php the change to a file in tt_news?


Regards
Jeppe




On 14-04-2011 10:35, Bernard Munslow wrote:
> Hi Jeppe,
>
> No need to tamper with the files in the tt_news module at all.
>
> Have a look into the link I send in the last mail.
>
> All you have to do is create a new extension with the kickstarter, and
> create the file with the hook.
>
> You'll probably want to instantiate a hook in TCEMAIN. Your class can be
> something like this:
>
> class tx_felo_tcemainprocdm {
>
> function processDatamap_postProcessFieldArray ($status, $table, $id,
> &$fieldArray, &$reference) {
>
> if ($table == 'tt_news') {
> switch ($status) {
> case 'new':
> /* Send email code */
> break;
> ...
> }
> }
> }
> }
>
> HTH.
>
> .- Bernard
>
> El 14/04/2011 10:09, Jeppe Donslund escribió:
>> Hi Bernard
>>
>> That seems to be what I need.
>> Could you guide me, where to look for the creation of tt_news records?
>> I think I should look for som mySQL insert lines somewhere.
>>
>> Jeppe
>>
>>
>> On 14-04-2011 09:45, Bernard Munslow wrote:
>>> Hi Jeppe,
>>>
>>> There probably are different approaches to do what you need.
>>>
>>> If you're ok with plain text emails, one possible way would be to
>>> implement a hook which detects creation of tt_news records and then
>>> simply send your notification using t3lib_div::plainMailEncoded or any
>>> other implementation to send an email.
>>>
>>> This is an excellent tutorial on hooks in case you need some extra
>>> information:
>>>
>>> http://typo3.org/development/articles/how-to-use-existing-hooks/
>>>
>>> Greetings,
>>>
>>> .- Bernard
>>>
>>> El 14/04/2011 9:37, Jeppe Donslund escribió:
>>>> Does anyone know a way to send out emails ( a small newsletter ) to
>>>> fe_users everytime there has been created a new news item?
>>>>
>>>> Bst regards
>>>> Jeppe Donslund
>>>
>>
>



More information about the TYPO3-english mailing list