Login / Status
developer.Resource
Home . Development . Articles . How to use existing hooks
Sponsors
hosted by punkt.deTYPO3 and Open Source Magazine

Conclusion

Using hooks is a quite simple but also powerful approach of extending the core or even other extensions. At least it helps you to get rid of the XCLASS dilemma in many situations 

Let's summarize the steps which are necessary to use a getUserObj hook:

  1. Locate a possible hook in the script you want to extend. If there is none, suggest a new hook to the source's author 

  2. Create a new class for each function you want to extend 

  3. Create a method for each hook you want to use. It is named after the method called in the hook itself. Use the same interface for your function which is defined in the hook. 

  4. Register your class by adding your extension name, filename and classname to the appropriate place in the global $TYPO3_CONF_VARS

  5. Study the source you want to extend and know what you are about to do! 

The main differences when using the a callUserFunction hook instead:

  1. make sure that your class containing the user function gets included (by require_once) 

  2. all parameters are passed in a single array, the second parameter contains a reference to the parent class. 

  3. You may collect all userfunctions in one big class, it's up to you. 

Notes about this paticular hook

At the time of this writing, the hook discussed in this article is only available in the latest CVS version of TYPO3's core (namely the HEAD branch for the upcoming version 3.7.0).  

If you would like to try the examples yourself, you'll have to checkout the CVS version or just wait for 3.7.0 being released ...