[TYPO3] Using a hook and rendering content in backend extension

Pascal Alich pascal.alich at ppi.de
Thu May 18 08:11:49 CEST 2006


Hey,
I am writing an extension for tt_news that allows the user to send the 
news as email, e.g. for urgent news. I'd like to realize it with a hook 
to "processDatamapClass" which is provided by tcemain.
Actually, I've two problems. The first one is that my method is not 
called by the Typo3 framework. That is my method:

   function processDatamap_postProcessFieldArray ($status, $table, $id, 
&$fieldArray, &$pObj) {
      mail('pascal.alich at ppi.de','test', $temp, 'test');
   }

That's my entry in ext_localconf.php:

TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class']['t3lib_tcemain']['php']['processDatamapClass'][] 
  = 'EXT:ppi_news_email/class.ppi_news_email_main.php:ppi_news_email_main';


In order to proceed I inserted my code directly in tt_news. But now a 
new challenge comes up. The news in the database might contain stuff like:

     <typolist>
      <link http://www.typo3.org _blank - "Typo3">Typo3 page</link>
    </typolist>

I'd like to render this to the appropriate html code. I've tried the 
following:

     if ($table == 'tt_news' ) {
       // checkbox "as email" checked?
       if ($fieldArray['tx_ppinewsemail_asemail']) {
         $to = $fieldArray['tx_ppinewsemail_email'];
         $from = 'news at ppinet.de';
         $title = $fieldArray['title'];
         $bodytext = $fieldArray['bodytext'];

         $cObj = t3lib_div::makeInstance("tslib_cObj");
         $conf = array(
	    'table' => 'tt_news',
	    'select.' => array('uidInList' => $id),
	  );
         $body = $cObj->CONTENT($conf);

         $mail = new XPertMailer;
         $mail->from($from);

         // send the e-mail
         $send = $mail->send('pascal.alich at ppi.de', "Intranet News : 
$title", $body);
...

This code result in a php error:
	Fatal error: Call to a member function on a non-object in 
/srv/www/intranet_test/htdocs/typo3_src-4.0/typo3/sysext/cms/tslib/class.tslib_content.php 
on line 6288

This might be due to the fact that the extension is in backend 
environment, hence frontend stuff is not initialized.

Does anybody have an idea how to solve the two problems?
Pascal Alich



More information about the TYPO3-english mailing list