我正在寻找一个在页面创建或更改页面后调用的钩子,如“ hide page in nav
”、“ deactivate page
”或“ move/delete page
”
有人知道吗?
谢谢!
这些 Hooks 位于t3lib/class.t3lib_tcemain.php
以下只是其中的一部分:
在您的情况下,我认为您可以使用“ processDatamap_postProcessFieldArray ”。
示例如何将其包含在ext_localconf.php中:
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processDatamapClass'][] = 'EXT:your_extension/hooks/class.tx_yourextension_tcemain.php:tx_yourextension_tcemain';
示例类:
<?php
class tx_yourextension_tcemain {
function processDatamap_postProcessFieldArray($status, $table, $id, &$fieldArray, &$pObj) {
if($table == 'pages' && $status =='new') {
// do some stuff
}
}
}
?>
使用$table,您可以检查修改了哪个表。$status允许您检索当前操作,例如“新建”、“更新”或“删除”。
TYPO3 > 6 的示例,命名空间位于另一个挂钩上:
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/tslib/class.tslib_menu.php']['filterMenuPages']['YourExtension\\Hook\\FilterMenuPages'] = 'EXT:your_extension/Classes/Hook/FilterMenuPages.php:YourExtension\Hook\FilterMenuPages';
对于TYPO3 7.6版本(也适用于 10.4.X)
在ext_localconf.php中写入以下内容
$GLOBALS ['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processDatamapClass']['extkey'] = 'Vendor\\Extension\\Hook\\TCEmainHook';
$GLOBALS ['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processCmdmapClass']['extkey'] = 'Vendor\\Extension\\Hook\\TCEmainHook';
创建钩子类/Classes/Hook/TCEmainHook.php,从下面的列表中选择适当的函数
<?php
namespace Vendor\Extension\Hook;
class TCEmainHook {
public function processCmdmap_preProcess($command, $table, $id, $value, \TYPO3\CMS\Core\DataHandling\DataHandler &$pObj) {}
public function processCmdmap_postProcess($command, $table, $id, $value, \TYPO3\CMS\Core\DataHandling\DataHandler &$pObj) {}
public function processDatamap_preProcessFieldArray(array &$fieldArray, $table, $id, \TYPO3\CMS\Core\DataHandling\DataHandler &$pObj) {}
public function processCmdmap_deleteAction($table, $id, $recordToDelete, $recordWasDeleted=NULL, \TYPO3\CMS\Core\DataHandling\DataHandler &$pObj) {}
public function processDatamap_afterAllOperations(\TYPO3\CMS\Core\DataHandling\DataHandler &$pObj) {}
public function processDatamap_postProcessFieldArray($status, $table, $id, array &$fieldArray, \TYPO3\CMS\Core\DataHandling\DataHandler &$pObj) {}
public function processDatamap_afterDatabaseOperations($status, $table, $id, array $fieldArray, \TYPO3\CMS\Core\DataHandling\DataHandler &$pObj) {}
}
有一个扩展dmc_hooklist列出了所有的钩子。(几年前用过)
或者看看 t3lib/class.t3lib_tcemain.php 有你需要的钩子。