PostNuke Help |
||
|---|---|---|
Previous |
Next |
|
Another way of accessing the functionality of other modules is by calling their functions directly with the pnModFunc() function. Doing this allows a number of advantages over hooks, but also a number of disadvantages. In general, calling functions directly is more flexible as the module developer understands exactly which functions they are calling and can also pass additional arguments to the function to customise its abilities. The disadvantages are that the module named in the function call needs to be installed and active on the system for the calls to work, and if this is replace by a different module providing similar functionality it will not work correctly.
Using direct function calls to other modules is fine within a module, but the developer should consider the implications of this on systems that might not have the modules that they are using installed. Also, even if direct function calls are used then the module developer should still call hooks at the appropriate places in the code to allow for other extended functionality to be added to the module.
An example of where direct function calls might be used within the Gallery module would be if the module developer wanted users to be able to rate various aspects of the picture displayed such as 'use of colour' and 'originality'. In this case a simple hook would not be able to accommodate this requirement, so the developer would instead make explicit calls to the 'Ratings' utility module to display a number of separate ratings, each with its own identifier. The hook call would still be made, which might also add a rating to the picture, but in this case the value could be considered as the overall rating for the picture rather than that just for a specific part.
Previous |
Next |