Zikula: A Flexible Open Source Content Management System
home | forum | contact us

Dizkus

Bottom
pnModCallHooks Call
  • Posted: 06.04.2007, 07:24
     
    bmichel
    rank:
    Freshman Freshman
    registered:
     February 2007
    Status:
    offline
    last visit:
    07.04.07
    Posts:
    4
    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...
  • Posted: 07.04.2007, 04:56
     
    Simon
    rank:
    Steering Committee Steering Committee
    registered:
     December 2002
    Status:
    offline
    last visit:
    09.11.08
    Posts:
    13413
    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
  • Posted: 09.04.2007, 00:27
     
    Paustian
    rank:
    Helper Helper
    registered:
     May 2005
    Status:
    offline
    last visit:
    20.11.08
    Posts:
    129
    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

Main Menu

Extensions Database

Documentation

Development

Login

Donate to Zikula