This issue has cost me 3 years of my life by high bloodpressure... In Drupal 6, I was able to implement hook_theme in a template.php file, then calling the defined theme implementation in theme_preprocess_page(). I kept getting "ERR_EMPTY_RESPONSE" from my server, which was almost impossible to debug.

I defined the theme implementation like so:

function mytheme_theme() {
    return array(
        'theme_name' => array(
            'template' => 'tpl-filename',
            'variables' => array('variable_one' => NULL)
        )
    );
}

Then trying to execute it in theme_preprocess_page() as follows:

function theme_preprocess_page(&$vars) {
    $vars['themed_html'] = theme('theme_name', array('variable_one' => 'foobar')); 
}

This eventually resulted in the ERR_EMPTY_RESPONSE.

The funky thing is, removing the line: 'template' => 'tpl-filename', resolved the ERR_EMPTY_RESPONSE. But, ofcourse, this would not end up in what I wanted.

The workaround I eventually used was putting the theme('theme_name'... straight into page.tpl.php, which worked as expected.

The tpl file was there by the way, with clean HTML without PHP (to make sure that did not fire any errors).

I think this is a bug, since this worked a charm in D6.

Comments

bbinkovitz’s picture

Status: Active » Closed (duplicate)