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

rightchoice2c_me’s picture

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.

Anonymous’s picture

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...

rightchoice2c_me’s picture

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.

Anonymous’s picture

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?

flunardelli’s picture

Register you theme using hook_theme();

function mvembed_theme() {
  return array(
    // mvembed formatter theme functions.
    'mvembed_formatter_audio_player' => array(
      'arguments' => array('element' => NULL),
      'file' => 'mvembed_formatter.inc',
    ),
    'mvembed_file' => array(
      'arguments' => array('file' => NULL),
      'file' => 'mvembed_formatter.inc',
    ),
  );
}

jaypan’s picture

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.

i-sultan’s picture

and drupal theme expands file argument to
mvembed_formatter.inc.tpl.php
not
mvembed_formatter.inc

jaypan’s picture

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.