TYPO3挂钩页面/内容

时间:2016-07-04 19:05:19

标签: typo3 hook typoscript extbase typo3-7.6.x

我找到了this Answer here on stackoverflow

我需要一个Hook,它在创建,删除,移动或更新页面和内容时执行。 我只找到了这个钩子processDatamap_postProcessFieldArray,但是如果创建,删除,移动或更新了内容,它将不会被执行。仅在创建或删除页面时执行。

我在TYPO3版本7.6.9。

是否有所有可用挂钩的列表?

问候。

1 个答案:

答案 0 :(得分:2)

结帐this answer。它详细解释了如何设置一个在删除记录时执行的钩子,并且肯定会帮助你。

总结一下,你需要在ext_tables.php

中注册你的钩子
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['YourHook'][] = 'YourVendor\\YourExt\\Hooks\\YourHook';

并将钩子本身声明为:

/ext/your_ext/Classes/Hooks/yourHook.php

Here is a partial list of available hooks from the official Docs

修改

您正在寻找正确的Member Function

说实话,我不确定你是否需要勾选多个或者使用processCmdmap_afterFinish来做你需要的事情:

<?php
namespace YourVendor\YourExt\Hooks;

class ProcessCmdmap {
   /**
    * hook that is called when an element shall get deleted
    *
    * @param string $table the table of the record
    * @param integer $id the ID of the record
    * @param array $record The accordant database record
    * @param boolean $recordWasDeleted can be set so that other hooks or
    * @param DataHandler $tcemainObj reference to the main tcemain object
    * @return   void
    */
    function processCmdmap_postProcess($command, $table, $id, $value, $dataHandler) {
        /* Does this trigger at all for the actions you need? */
        \TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump($command);
        die();
        if ($command == 'delete' ||
            $command == 'update' || 
            $command == 'move' || 
            $table == 'tx_yourext_domain_model_something') {

        }
    }
} 

此代码的大部分内容来自this answer