简体   繁体   English

Drupal 6:template.php重定向

[英]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. 在Drupal安装中的template.php文件中,我没有做太多工作,但是这次我需要以节点表单为主题。 Following an excellent guide I found at http://drupal.org/node/601646 , I set up the following snippet. 遵循在http://drupal.org/node/601646上找到的出色指南,我设置了以下代码段。

function amity_island_theme($existing, $type, $theme, $path) {
  if ((arg(0) == 'node') && (arg(1) == 'add') && (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. 在添加if语句之前,该站点为每个请求提供了node-add_service_request.tpl.php服务。 After I added the IF statement, my screen just went completely white (I have PHP errors ON - no errors) 添加IF语句后,我的屏幕完全变成白色(我的PHP错误打开-没有错误)

Has this happened to anyone...? 这件事发生在任何人身上吗?

A little tinkering revealed that it didn't like calling the function, and then evaluating the if statement. 稍作修改后发现它不喜欢调用该函数,然后评估if语句。 When it evaluated to FALSE, it just returned a blank HTML skeleton. 当评估为FALSE时,它只是返回了一个空白的HTML框架。 With Drupal, once this happens, you have to go into the DB and manually wipe the cache table. 使用Drupal,一旦发生这种情况,就必须进入数据库并手动擦除缓存表。 Simply fixing the template.php file won't work - your screen will still come up white. 仅仅修复template.php文件是行不通的-屏幕仍然会变成白色。 The answer was to put the IF statement before the function... 答案是将IF语句放在函数之前...

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' ));
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM