dph19153 2010-01-06 14:44
浏览 45
已采纳

Drupal 6:template.php重定向

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') && (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...?

  • 写回答

1条回答 默认 最新

  • drwjv28028 2010-01-06 19:38
    关注

    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' ));
        }
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?