| Topic: | pnModCallHooks Call |
|---|---|
|
bmichel
Freshman
Posts: 4 Posted: |
I'm writing a personalized user registration module and I've came across the pnModCallHooks function. But I can't figure out what it is for.Code// Let any hooks know that we have created a new item pnModCallHooks('item', 'create', $uid, 'uid'); If someone knows... |
|
Simon
online Steering Committee
Posts: 13427 Posted: |
Hook modules provide extra functionality related to existing content. For example, comments on news articles are provided by a comments hook. The pnModCallHooks function lets any modules hooked into the user registration process know that a new user object has been created. -- Regards, Simon itbegins.co.uk - Zikula Consulting Please read the Support Guide |
|
Paustian
Helper
Posts: 132 Posted: |
Hooks are very cool. This is something you should support in your module. What it does is send out a call to any Hook modules that are listening to your module. The example you gave above would notify any hooked in module that a new item, with the unique id $uid has been created. These lines of code are normally put into your code when you display, create, update or delete something in your module. The listening module can then take appropriate action when it gets these messages. If you are familiar with object programming and the broadcaster=>listener design pattern, hooks are listeners and modules that support hooks are broadcasters. This design pattern allows for some very neat functionality. Simon gave one example. Any module that supports hooks can have comments added to it just by including the EZComments module and making the connection between the broadcaster and listener. This is done in the modules admin panel, look for the hooks link. You get all the functionality of a comments module in your hookable module for free. I have also used it to add a quizzing capability to the Book module that I wrote. Any page in the book can have a quiz added to it. The quiz is created in the Exams module and then hooked up to a Book article. To see an example of this go to http://www.microbiol…ayarticle&art_id=23 and scroll to the bottom. By having them separate, it promotes code usability. Any other hookable module should be able to attach quizzes. edited by: Paustian, Apr 08, 2007 - 07:29 PM |