By Anonymous (not verified) on
Hello, I am having problems registering a theme_hook for my module, which is my first, so i am still very new and learning the ropes. Here is the code I have, I am wondering if anyone could tell me why the theme function is not getting called?
function onin_menu() {
$items = array();
$items['volunteers'] = array(
'title' => 'volunteers',
'page callback' => 'drupal_get_form',
'page arguments' => array('onin_volunteers_page_form'),
'access callback' => 'user_access',
'access arguments' => array('access content'),
'type' => MENU_CALLBACK,
);
return $items;
}
function onin_volunteers_page() {
return drupal_get_form('onin_volunteers_page_form');
}
/**
*Create the Volunteers Page Form
*/
function onin_volunteers_page_form(&$node, $form_state) {
$form['fullName'] = array(
'#type' => 'textfield',
'#title' => t('Enter your full name'),
'#required' => TRUE,
);
$form['email'] = array(
'#type' => 'textfield',
'#title' => t('Enter your email'),
'#required' => TRUE,
);
$form['phoneNumber'] = array(
'#type' => 'textfield',
'#title' => t('Enter your Phone Number'),
'#required' => TRUE,
);
$form['interests'] = array(
'#type' => 'textarea',
'#title' => t('Enter your interests'),
);
$form['skills'] = array(
'#type' => 'textarea',
'#title' => t('Enter your skills'),
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Save'),
);
return $form;
}
function onin_theme() {
return array(
'onin_volunteers_page_form' => array(
'arguments' => array('form' => NULL ),
)
);
}
function theme_onin_volunteers_page_form($form) {
$output = 'This should be added to the page but its not';
$output .= drupal_render($form);
return $output;
}
Thanks for your time. Also, I am open to other suggestions on how to improve my coding. Thanks
Comments
remove &$node from function
remove &$node from function onin_volunteers_page_form(&$node, $form_state) otherwise it will give an error called missing argument 1.
Another thing is the same code I tried in drupal 6.4 and its working fine for me.
Work Hard to understand what you have to do b4 U start, You may not be able to develop every detail but the more U know the less risk you take.
Thanks, the problem turned
Thanks, the problem turned out to be with my theme, I tried viewing it in Garland and it worked... Now to figure out why my theme breaks it...
try to save your theme might
try to build your theme configuration might be because of that it was not calling your theme.
You need to rebuild your theme whenever you register any theme.
here admin/build/themes
you can also go through http://drupal.org/node/207393
Work Hard to understand what you have to do b4 U start, You may not be able to develop every detail but the more U know the less risk you take.
Hmm, I've tried clearing the
Hmm, I've tried clearing the cache, reinstalling the module, disabling and re-enabling the theme, but nothing seems to make it work with my theme. It seems like my theme just totally ignore the hook_theme register in my module. It is strange... It works in garland though. Is there something else I am missing?
Try this
Register you theme using hook_theme();
Besides the fact that you are
Besides the fact that you are two years late with your response, he already had hook_theme in his code.
Contact me to contract me for D7 -> D10/11 migrations.
.tpl.php
and drupal theme expands file argument to
mvembed_formatter.inc.tpl.php
not
mvembed_formatter.inc
You are confusing 'file' with
You are confusing 'file' with 'template'. The value for 'template' has .tpl.php added to it. 'File' refers to the file that a theme function (not template) is contained within. This is so you can put theme functions in other files than the main .module file.
Contact me to contract me for D7 -> D10/11 migrations.