Prev |  | Next

### 3.3.3. css_register

Modules can provide extra CSS data for CSS code that is retrieved through the css.php script. Extra CSS definitions can be added to the start and to the end of the base CSS code. Modules that make use of this facility should register the additional CSS code using this hook.

Call time:

At the start of the css.php script.

Hook input:

An array, containing the following fields:

- css
  The name of the css file that was requested for the css.php script. Phorum requests either "css" or "css_print". The module can use this parameter to decide whether CSS code has to be registered or not.
- register
  An array of registrations, filled by the modules. Modules can register their CSS code for inclusion in the base CSS file by adding a registration to this array. A registration is an array, containing the following fields:
  - module
    The name of the module that adds the registration.
  - where
    This field determines whether the CSS data is added before or after the base CSS code. The value for this field is either "before" or "after".
  - source
    Specifies the source of the CSS data. This can be one of:
    - file(<path to filename>)
      For including a static CSS file. The path should be absolute or relative to the Phorum install directory, e.g. "`file(mods/foobar/baz.css)`". Because this file is loaded using a PHP include() call, it is possible to include PHP code in this file. Mind that this code is stored interpreted in the cache.
    - template(<template name>)
      For including a Phorum template, e.g. "`template(foobar::baz)`"
    - function(<function name>)
      For calling a function to retrieve the CSS code, e.g. "`function(mod_foobar_get_css)`"
  - cache_key
    To make caching of the generated CSS data possible, the module should provide the css.php script a cache key using this field. This cache key needs to change if the module will provide different CSS data.
    Note: in case "file" or "template" is used as the source, you are allowed to omit the cache_key. In that case, the modification time of the involved file(s) will be used as the cache key.
    It is okay for the module to provide multiple cache keys for different situations (e.g. if the CSS code depends on a group or so). Keep in mind though that for each different cache key, a separate cache file is generated. If you are generating different CSS code per user or so, then it might be better to add the CSS code differently (e.g. through a custom CSS generating script or by adding the CSS code to the $PHORUM['DATA']['HEAD_DATA'] variable. Also, do not use this to only add CSS code to certain phorum pages. Since the resulting CSS data is cached, it is no problem if you add the CSS data for your module to the CSS code for every page.

Hook output:

The same array as the one that was used for the hook call arguments, possibly with the "register" field updated. A module can add multiple registrations to the register array.

Prev | Up | Next
| Home |