Drupal 5 Views Module Breaks Block Administration

poor little kitten with big round eyes While working on a new Drupal 5.19 powered website that has the latest view module enabled, my coworker noticed a strange feature. Once you activated more than one template and tried to switch over to manage the blocks on an other template than garland you will see it switching to garland 50% of the time.

The problem here lies in the views module. This module makes a call to the t() function which calls a theme function which eventually has to call init_theme() to check which template it should use. Once the init_theme() funcion has been called, the global variable $theme will be set and any other calls to init_theme() will be . Being called so early in time, the init_theme() function has no idea it still has to switch to a custom theme defined by the blocks module.

The fix involves killing a kitten… also know as hacking drupal core. Fire up your favorite editor, open up includes/theme.inc.php and find the following lines of code.

function init_theme() {
  global $theme, $user, $custom_theme, $theme_engine, $theme_key;

  // If $theme is already set, assume the others are set, too, and do nothing
  if (isset($theme)) {
    return;
  }

and replace it with

function init_theme() {
  global $theme, $user, $custom_theme, $theme_engine, $theme_key;

  // If $theme is already set, assume the others are set, too, and do nothing
  // patchy patchy!
  if (isset($theme)) {
  	if(isset($custom_theme)) {
  		if($theme == $custom_theme) {
  			return;
  		}
  	} else {
    	return;
  	}
  }

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>