Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/templates/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Templates drupal template.php不使用tpl文件_Templates_Drupal - Fatal编程技术网

Templates drupal template.php不使用tpl文件

Templates drupal template.php不使用tpl文件,templates,drupal,Templates,Drupal,我有一个代码可以在一台服务器上运行,但不能在另一台服务器上运行。基本上,我们已经写了一个模板文件,应该使用的URL是论坛讨论,但它显示的网页找不到 /* discussion forum templates */ $querystring=$_GET['q']; echo $querystring; // THIS PRINTS page-not-found $querystring=explode('&',$_GET['q']); if

我有一个代码可以在一台服务器上运行,但不能在另一台服务器上运行。基本上,我们已经写了一个模板文件,应该使用的URL是论坛讨论,但它显示的网页找不到

    /* discussion forum templates */
    $querystring=$_GET['q'];
        echo $querystring; // THIS PRINTS page-not-found
    $querystring=explode('&',$_GET['q']);    

if(!isset ($vars['node']) && $querystring[0]=='discussion-forum'){
    $vars['template_files'] = array(); 
    $vars['template_files'][] = 'page-discussion_forum'; 
}
if (!isset ($vars['node']) && $querystring[0]=='discussion_forum_answer') { 
    $_SESSION['question_id']=$querystring[1];
    $vars['template_files'] = array(); 
    $vars['template_files'][] = 'page-discussion_forum_answer'; 
    }

if(!isset ($vars['node']) && $querystring[0]=='discussion_forum_search'){
    $vars['template_files'] = array(); 
    $vars['template_files'][] = 'page-discussion_forum_search'; 
}

当我在
$querystring[0]=='discussion-forum'
中给出未在讨论论坛位置找到的页面时。它正确地显示了页面的内容。不知道这里发生了什么。它在其他服务器上工作正常。

要添加自定义tpl,我通常在预处理节点中添加主题建议

$vars['theme_hook_suggestions'][] = 'node____'.$vars['view_mode'];
所以你的应该是

function THEME_preprocess_node(&$vars, $hook) 
    $vars['theme_hook_suggestions'][] = 'page-discussion_forum_search';
 }

如果您确定您使用的是哪个版本的drupal,这会有所帮助,因为这些东西在不同版本之间会发生变化

你能在template.php中添加这个吗?是在preprocess_节点、preprocess_页面还是其他地方?提示一下,您可以使用arg()函数而不是获取q querystring。在_preprocess_页面(&$vars){…中使用它也可以尝试使用arg。即使这样也不起作用