function modalframe_theme_registry_alter in Modal Frame API 7
Same name and namespace in other branches
- 6 modalframe.module \modalframe_theme_registry_alter()
Implementation of hook_theme_registry_alter().
Prepend our module path to the theme registry entry for theme('page').
When we need to render a modal frame, modalframe_child_js() defines the variable $GLOBALS['modalframe_page_template']. Then, when theme('page') is executed, Drupal invokes all template preprocess functions related to the page template. When modalframe_preprocess_page() is invoked, it looks for this global variable, and if it exists, then the name of the template file 'page' is replaced by 'modalframe-page'.
This technique allows us to use a particular version of the template used to generate the output of theme('page') with a different layout (ie. no header, no left/right blocks, etc.), while still keeping all the features related to theme('page') implemented by core, themes and contrib modules such us jquery_update at no additional cost. Also, themers can provide their own custom versions of page.tpl.php and modalframe-page.tpl.php.
There is no additional performance impact during normal site operation, when using theme('page') without further alterations. No additional lookup will be made for page.tpl.php. This is it:
1) Active theme directory (it may or may not exist, often will). 2) Drupal's modules/system/page.tpl.php (default). 3) modalframe module directory (this lookup will be never reached).
On the other hand, when the file name for page template is altered, the lookups for file modalframe-page.tpl.php will proceed like this:
1) Active theme directory (it may or may not exist, often won't). 2) modules/system/modalframe-page.tpl.php (this lookup will always fail). 3) modalframe module directory (default).
See also
theme()
File
- ./
modalframe.module, line 51 - Provides an API to render an iframe within a modal dialog based on the jQuery UI Dialog plugin.
Code
function modalframe_theme_registry_alter(&$theme_registry) {
if (isset($theme_registry['page'])) {
$theme_registry['page']['theme paths'] = array();
$module_path = drupal_get_path('module', 'modalframe');
$theme = list_themes();
$theme_registry_copy = $theme_registry;
// munge on a copy
_theme_process_registry($theme_registry_copy, 'phptemplate', 'theme_engine', 'pow', $module_path);
$theme_registry += array_diff_key($theme_registry_copy, $theme_registry);
$hooks = array(
'page',
'html',
);
foreach ($hooks as $h) {
_modalframe_insert_after_first_element($theme_registry[$h]['theme paths'], $module_path);
}
// Add pre-preprocess function for page template.
array_unshift($theme_registry['page']['preprocess functions'], 'modalframe_pre_preprocess_page');
}
}