1 system.api.php hook_init()

Perform setup tasks for non-cached page requests.

This hook is run at the beginning of the page request. It is typically used to set up global parameters that are needed later in the request. When this hook is called, the theme and all modules are already loaded in memory.

This hook is not run on cached pages.

To add CSS or JS files that should be present on all pages, modules should not implement this hook, but declare these files in their .info file.

See also

hook_boot()

Related topics

File

core/modules/system/system.api.php, line 1480
Hooks provided by Backdrop core and the System module.

Code

function hook_init() {
  // Since this file should only be loaded on the home page, it cannot be
  // declared in the info file.
  if (backdrop_is_front_page()) {
    backdrop_add_css(backdrop_get_path('module', 'foo') . '/foo.css');
  }
}