Book Image

TYPO3 Extension Development

Book Image

TYPO3 Extension Development

Overview of this book

Table of Contents (13 chapters)

Implementing a Frontend Hook


The Frontend hook class file goes into the extension's directory. The file is named class.tx_feuserstat_hooks.php. According to coding conventions, the class name becomes tx_feuserstat_hooks. There will be only one hook inside but we name the file (and the class) in plural to enable adding more hooks if necessary in future versions.

When adding this class, GPL and XCLASS declarations should be added manually. Make sure you do this first thing after creating a new class for TYPO3.

Now, we create a dummy function for the hook. The function name has to be checkDataSubmission because it is hard-coded like this in the TSFE.

The TSFE provides a reference to itself as a parameter to the hook function. The same reference is available as $GLOBALS['TSFE']. For better clarity, we will use the global variable and will skip the function parameter completely.

Next, we need to register the hook. We do it by adding the following code to ext_localconf.php:

$GLOBALS['TYPO3_CONF_VARS...