0
我正在尝试将自定义主题应用于单个页面。该页面是我使用hook_menu设置的页面。 我已经impletemted hook_theme但是当我刷新网页,我收到以下错误:Drupal hook_theme错误
Fatal error: Unsupported operand types in /srv/bindings/baf029321aa248e5907866cc7de3a6d6/code/includes/form.inc on line 1044
以下是我的代码:
function mymodule_menu(){
$items['mymodule'] = array(
'title' => 'My-module',
'page callback' => 'drupal_get_form',
'page arguments' => array('mymodule_admin_page'),
'access arguments' => array('access content'),
);
return $items;
}
function mymodule_admin_page(){
drupal_set_message('My-module admin page responding');
return theme('mymodule_template');
}
function mymodule_theme($existing, $type, $theme, $path){
drupal_set_message('My-module theme hook responding');
return array(
'mymodule_template' => array(
#'render element' => 'elements',
'template' => 'mytemplate',
'path' => drupal_get_path('module', 'mymodule') . '/templates',
)
);
}
至于我可以告诉大家,出现错误时,我将正斜杠添加到'path' => drupal_get_path('module', 'mymodule') . '/templates',
。 如果我删除斜杠错误消失,但然后系统尝试并找不到mytemplate.tpl.php,因为它正在查看mymodule/templatemytemplate.tpl.php
。
移动'drupal_get_path( '模块', 'MyModule的')。 '/ templates'到另一个变量,然后在''path'=> $ myVariable'中使用它 –