Drupal 6: template.php redirections
I haven't worked to much within the template.php file in the Drupal installation, but this time I need to theme a node form. Following an excellent guide I found at http://drupal.org/node/601646, I set up the following snippet.
function amity_island_theme($existing, $type, $theme, $path) {
if ((arg(0) == 'node') && (arg(1) == 'add') &&开发者_Python百科amp; (arg(2) == 'service-request')){
return array(
'service_request_node_form' => array(
'arguments' => array('form' => NULL),
'template' => 'node-add_service_request' ));
}
}
prior to adding the if statement, the site served node-add_service_request.tpl.php for every request. After I added the IF statement, my screen just went completely white (I have PHP errors ON - no errors)
Has this happened to anyone...?
A little tinkering revealed that it didn't like calling the function, and then evaluating the if statement. When it evaluated to FALSE, it just returned a blank HTML skeleton. With Drupal, once this happens, you have to go into the DB and manually wipe the cache table. Simply fixing the template.php file won't work - your screen will still come up white. The answer was to put the IF statement before the function...
if ((arg(0) == 'node') && (arg(1) == 'add') && (arg(2) == 'service-request')){
function amity_island_theme($existing, $type, $theme, $path) {
return array(
'service_request_node_form' => array(
'arguments' => array('form' => NULL),
'template' => 'node-add_service_request' ));
}
}
精彩评论