By Robert Lemke
One way for extensions to take over control of certain parts of TYPO3's core is using hooks. This article gives an example of how to register your own userfunction at an existing hook and shows the best practice for using hooks in general.
This tutorial is intended for all kinds of TYPO3 extension programmers who want to override or take influence on certain behaviour of TYPO3's core or some extension, by taking advantage of the concept of hooks.
A basic knowledge of extension programming and some general idea about using objects in PHP is assumed. You should read the section about hooks in the document TYPO3 Core APIs, available at typo3.org
A hook is some easy way to extend or replace a certain part of the source by your own methods. They are often used for providing pre- and post-processing userfunctions in the core as well as giving control totally to a method provided by some extension author.
The big advantage of using a hook instead of the older X-Class mechanism is the ability to enable more than one extension to extend the same class or method. This has been discussed in the developer mailinglist for some time and is also explained in the TYPO3 Core APIs document.
The drawback is, that a hook has to exist before you can use it. So if you are in a situation in which you would like to extend a core or extension's functionality, just ask the source's author to provide a hook for you in the next release.