Closed (fixed)
Project:
404 Blocks
Version:
6.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
25 Mar 2010 at 06:02 UTC
Updated:
8 Apr 2010 at 23:20 UTC
You can simply toggle the $show_block variable if you do not want to recreate all functionality done in the various preprocessor hooks around the place:
<?php
/**
* Implementation of hook_theme_registry_alter().
*
* This adds the new preprocess function onto the theme stack, but at the start
* so it is called before the problematic template_preprocess_page() function.
*/
function HOOK_theme_registry_alter(&$theme_registry) {
$path = drupal_get_path('module', 'HOOK');
if (isset($theme_registry['page']) && isset($theme_registry['page']['theme paths'])) {
array_unshift($theme_registry['page']['theme paths'], $path);
array_unshift($theme_registry['page']['preprocess functions'], 'HOOK_pre_preprocess_page');
}
}
/**
* Toogle the block flag here :)
*/
function HOOK_pre_preprocess_page(&$variables) {
// Set additional conditions to change $show_blocks if you want here...
$is404 = $_GET['q'] == drupal_get_normal_path(variable_get('site_404', ''));
$is403 = $_GET['q'] == drupal_get_normal_path(variable_get('site_403', ''));
$variables['show_blocks'] = ($is404 || $is403) ? true : $variables['show_blocks'];
}
?>
And that would be enough to force blocks to show!
PS: I think that you can still use $_REQUEST['q'] to get the original path 'q' / The installation or update script should be used to set any variables so the init() would not need to be called.
Comments
Comment #1
johnalbinDang! Why didn't I think of that? I've re-arranged preprocess functions before, too! :-p
Excellent suggestion! This should also make the module compatible with all themes.
Comment #2
johnalbinWrote it, tested it, committed it!
Thanks again, Alan!
Comment #3
alan d. commentedNo worries. Glad to help