Contao Developer Documentation

Developer documentation for the Contao Open Source CMS Download Latest version from GitHub


Contao hooks

Hooks work similar to the callback functions of the Data Container Array. You can register one or more functions for a certain event and when the event is triggered, the callback functions are executed. Hooks allow you to add custom functionality to the core.

How about a code example:
// config.php
$GLOBALS['TL_HOOKS']['getImage'][] = array('MyClass', 'myGetImage');

// MyClass.php
public function myGetImage($image, $width, $height, $mode, $strCacheName, $objFile, $target)
{
    return MyImage::generateThumbnail($image, $widht, $height, $mode);
}