I am attempting to apply a custom theme to a single page. The page is one I have setup using hook_menu. I have impletemted hook_theme but when I refresh the website, I get the following error:
Fatal error: Unsupported operand types in /srv/bindings/baf029321aa248e5907866cc7de3a6d6/code/includes/form.inc on line 1044
The following is my code:
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',
)
);
}
As far as I can tell, the error occurs when I add the forward slash to 'path' => drupal_get_path('module', 'mymodule') . '/templates',
.
If I remove the slash the error goes away but then, the system tries and fails to find mytemplate.tpl.php because it's looking at mymodule/templatemytemplate.tpl.php
.
Try this ... this menu alwaya call a form function not call a theme function