Prev |  | Next

#### 1.4.4.8. HOOK

Function

  The HOOK statement can be used to run a module hook from a template. By using hooks in the templates, you have an easy way for modules to add data to a page, without having to change the templates too much. Because these hooks need an activated module that acts upon them, creating HOOK statements is certainly for advanced users only.

Syntax

  `{HOOK <HOOK NAME> [<ARG1> <ARG2> .. <ARGn>]}`

  Both the `<HOOK NAME>` and the arguments that are used in the HOOK statement can be any of the data types that are supported by the template language (see Section 1.4.3, “Data types”).

How hook functions are called

  Depending on the number or arguments that are used in the HOOK statement, different type of calls are made to the hook function for the given `<HOOK NAME>`.

  - No arguments:
    the hook function is called without any arguments at all:
    `hook_function()`
  - One argument:
    The single argument is used directly for calling the hook function:
    `hook_function($ARG1)`
  - Multiple arguments:
    The arguments are wrapped in an array, which is then used for calling the hook function:
    `hook_function(array($ARG1,$ARG2,..$ARGn))`

Example code

  Example 1.20. HOOK statement usage

      {HOOK "template_hook"}

      {LOOP MESSAGES}
        {HOOK "show_message" MESSAGES}
      {/LOOP}

      {VAR HOOKNAME "my_magic_hook"}
      {HOOK HOOKNAME "my argument"}

Prev | Up | Next
| Home |