function context_theme_registry_alter in Context 6.3
Same name and namespace in other branches
- 6 context.core.inc \context_theme_registry_alter()
- 6.2 context.core.inc \context_theme_registry_alter()
- 7.3 context.core.inc \context_theme_registry_alter()
Implementation of hook_theme_registry_alter().
File
- ./
context.core.inc, line 83
Code
function context_theme_registry_alter(&$theme_registry) {
// Push theme_page() through a context_preprocess to provide
// context-sensitive menus and variables. Ensure that
// context_preprocess_page() comes immediately after
// template_preprocess_page().
$position = array_search('context_preprocess_page', $theme_registry['page']['preprocess functions']);
if ($position !== FALSE) {
unset($theme_registry['page']['preprocess functions'][$position]);
}
$position = array_search('template_preprocess_page', $theme_registry['page']['preprocess functions']);
$position = $position ? $position + 1 : 2;
array_splice($theme_registry['page']['preprocess functions'], $position, 0, 'context_preprocess_page');
// Add a page preprocess function to the very top of the theme_page()
// stack so that we can actually set contexts *before* the page theming
// is executed.
if (!in_array('context_page_alter', $theme_registry['page']['preprocess functions'])) {
array_unshift($theme_registry['page']['preprocess functions'], 'context_page_alter');
}
// Reroute theme_blocks() through context_blocks to determine block
// visibility by context. Only override theme_blocks() if a theme
// has not overridden it. It is the responsibility of any themes
// implementing theme_blocks() to take advantage of context block
// visibility on their own.
if (!isset($theme_registry['blocks']['type']) || !in_array($theme_registry['blocks']['type'], array(
'base_theme_engine',
'theme_engine',
)) && !isset($theme_registry['blocks']['file'])) {
unset($theme_registry['blocks']['preprocess functions']);
$theme_registry['blocks']['function'] = 'context_blocks';
}
}