A hook is a predefined location in a zoglair source code file, where you can inject (~hook) your own code (stored in this table), so that it is evaluated and/or executed at runtime; just as if it was inside that file in the first place. In other words, instead of directly editing the original source code file, you keep your modifications separately. When that file is loaded and executed by zoglair core, your modifications are applied automagically, like a software patch.

A hook allows you to change and/or extend zoglair's functionality, without actually modifying its source. This way, not only you abide by its license (which does not permit source code modifications, in anyway), but also you keep your code safe from future upgrades. Even if the original hooked file is get overwritten by a newer version, your changes will be unaffected and continue to apply.

It is worth mentioning that the hook system is one of the two possible methods for extending zoglair. The other one is writing external plugins that augment its codebase. You may refer to our Developer Guide for details.

The hook form contains the following fields:

New Hook Form

  • Addon ID
    The ID of the Addon row, to which this hook belongs.
  • Title
    A descriptive title.
  • Location
    The location to which this hook applies.
  • Instance
    The hook's particular instance. In order to limit the list of available hooks, they are either grouped or made generic. For example, “zClip*::html” is a generic hook inside the “html()” method of all clips. This is what the asterisk stands for. By specifying a particular clip as the “Instance”, you create a hook for that clip alone. Instances are “Location” specific.
  • Code
    The code you want to be executed, depending on the context (~hook):
    • outputBuffer
      This hook is executed after page processing ends, before sending response headers. Instance is irrelevant. The code is free-form. See more info in Debugging.
    • zAuthBase::can_user
      This hook is executed just before can_user() returns its result, allowing you to fine-tune user privileges. Instance is supported (the action's name) but not required.
    • zClip*::html
      This hook is executed after a clip's HTML template is constructed, before it is evaluated. Instance must be the clip's class. The class of a clip is always the clip's name (1st letter uppercase) prefixed by “zClip”. For example, the class of “nodeList” is “zClipNodeList”. The code is supposed to alter the clip's template, stored in the associative array (~map) “$HTML”, under the key “main” for the container, and “loop” for the items (if applicable). Depending on the clip, there may be more keys and templates.
    • zClipCustom::html
      This hook is meant to be used for your own custom clips. Instance is an arbitrary node, you use when embedding this clip. The code is supposed to assign the clip's output to “$html”.
    • zDataBase::create
      This hook is executed after a table's model is constructed. It gives you the ability to change it. Instance is the table's name.
    • zSkinBase::get_style
      This hook is executed after the current style is constructed. Instance is the style's name. The code is supposed to alter the “$STYLE” array. See details in the personalized help page, shown when clicking on your toolbar, under the section “Style Variables”.
    • zSkinBase::render_unit_css
      This hook is executed after the current style's CSS is processed, just before it is saved. Instance is the style's name. The code is supposed to define additional rules in “$css”. See details in the personalized help page, shown when clicking on your toolbar, under the section “CSS”.

Needless to say, you should be extra cautious when coding hooks. It is strongly recommended to try them first on a local copy of your site. In the unlikely case that you lock yourself out, set disableHooks to TRUE, in zoglair.cfg.php. After you correct the offending code, reset this option to FALSE. If you do not have access to the server files, ask your webmaster.

« Growl Message »
(C) Nick B. Cassos - All Rights Reserved
powered by zoglair
page generated in 198ms (11 queries, 30ms)