[TYPO3-dev] Trouble using hooks
Schani
usenet at schani.com
Sun Jun 15 12:48:37 CEST 2008
Hello all,
i have trouble using hooks in my extension.
I like to insert a record in the page table from my extension.
Now i insert in ext_localconf.php
$GLOBALS
['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processDatamapClass'][]
= 'EXT:xxx_kunden/class.tx_xxx_kunden.php:tx_xxx_kunden_hook';
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processDatamap_afterDatabaseOperations'][]
= 'EXT:xxx_kunden/class.tx_xxx_kunden.php:tx_xxx_kunden_hook';
In class.tx_xxx_kunden.php is:
<?php
class tx_xxx_kunden_hook extends t3lib_DB {
public function processDatamap_afterDatabaseOperations
($status,$table,$id,&$fieldArray,&$reference) {
$tce = t3lib_div::makeInstance('t3lib_TCEmain');
$tce->stripslashes_values = 0;
$hash = strtolower(md5(uniqid(rand(), true)));
$data['pages']['NEW' . substr($hash, 0, 8)]
= array(
'uid' => $page_uid,
'title' => $fieldArray['title'],
'hidden' => 0,
'pid' => 26,
'doktype' => 254,
// andere Datenfelder von pages
);
$tce->start($data, array());
$tce->process_datamap();
unset($data);
debug(func_get_args(),'TEST5');
}
}
?>
Now on save a new record in my xxx_kunden extension, the hooks create
not only one page record, but 1400 ?!?
What went wrong? Is it the right way to do this? Why is the hook create
many Records?
Thanks for help
Christian
More information about the TYPO3-dev
mailing list