PostNuke Help |
||
|---|---|---|
Previous |
Next |
|
If you are developing a utility module then you probably want to allow your module to be called as a hook. This requires the module functions to be able to be called as hooks, and the module to register and unregister its hooks as required.
Hook functions are very similar to standard module functions, but they have a number of extra restrictions placed on them to be able to work as hooks:
Hook functions must be able to operate correctly given only two arguments in their arguments array - obid and returnurl, as these are the only parameters that are passed to the function if it is called as a hook. Other parameters can be allowed by the function but they must be optional, and default to suitable values if not present such that the function will work appropriately.
Hook functions must not rely on other hooks to exist, or to have been called already or in future. The order of calling a list of hooks is undefined, and depending on the site administrator's preferences particular hooks might never be called.
Hook functions must not call the pnModCallHooks() function, or functions that might themselves call pnModCallHooks(). If a hook does this it risks getting the code into an infinite loop.
The Ratings module that comes with the core PostNuke distribution has an example hook function that shows how to fit within these guidelines whilst still producing a general-purpose function.
Previous |
Next |