This project is not covered by Drupal’s security advisory policy.

This module wants to end the situation of current D6, where hook_init() is a crowded battle place. Things like drupal_add_js(), drupal_add_css(), etc, can now be done in hook_pageapi(), instead of hook_init().

One major goal is to prevent premature theme initialization, premature menu_get_item(), and other things that we don't want to happen too early in a request.

Status / stability

The API of this module is still taking shape. See the discussion on

First release(s) of this module will be stable enough for use with DQX AdminMenu, which is going to have pageapi as a dependency.

Those aspects of the API that are not used in DQX AdminMenu are carved in chewing gum. Especially, method names and signature of the $api object. You only need to worry about this, if you use/develop other modules that use pageapi. In this case, you are welcome to join the discussion on

How it works

The module replaces template_preprocess_page() with its own function. From there it calls its own hook, hook_pageapi(). This hook runs later than anything in hook_init(), but before most or all of the preprocess page logic. And, it runs only on requests that actually render a page, not on things like ajax or imagecache.

How to use

In your own module, you can now write things like this:

function mymodule_pageapi($api) {
  // include stylesheet sites/all/modules/custom/mymodule/css/mymodule.css
  // yes, $api already knows the module dir of "mymodule".


As we already hijack the template_preprocess_page, there are plenty of possibilities:
- suppress core's js and css aggregation, breadcrumb building etc, if a contrib module is taking care of these things instead.
- additional helper functions on the $api object.

Project Information