Drupal 7: hook_menu not working correctly I've created a custom module (called page_arg) simply for the purpose of registering a path and having it use a certain template file. I had this working with Drupal 6, but can't get it to work in Drupal 7. Basically, if I leave the page_arg_callback() function in the module, I get a 500 Server Error on every page in the site. If I remove it, I'm able to visit the path I'm trying to register, but it isn't using the template file I want it to use.

function page_arg_menu() {
  $items = array();

  $items['flashcards'] = array(
    'title' =&gt; 'Flashcards',
    'page callback' =&gt; 'page_arg_callback',
    'page arguments' =&gt; array(1),
    'access arguments' =&gt; array('access content'),
    'type' =&gt; MENU_CALLBACK
  );
  return $items;
}

function page_arg_preprocess_page(&amp;$vars) {
    $url = urlSplit(); //custom function. trust me, this isn't the problem :)
    if($url[0] == 'flashcards'){
        $vars['template_files'][] = 'flashcards';
    }
}

function page_arg_callback($arg){
  return 'howdy';
}


As a secondary question, is this the best way to go about simply registering a path and pointing it to a template file? Seems a bit elaborate. Could I implement hook_menu() in my theme instead?
Try this:

function page_arg_menu() {
  $items = array();

  $items['flashcards'] = array(
    'title' =&gt; 'Flashcards',
    'page callback' =&gt; 'page_arg_callback',
    'access arguments' =&gt; array('access content'),
    'type' =&gt; MENU_CALLBACK,
  );

  return $items;
}

function page_arg_callback() {
  // Do stuff
  return theme('page_arg');
}

function page_arg_theme($existing, $type, $theme, $path) {
  return array(
    'page_arg' =&gt; array(
      'template' =&gt; 'page-arg',
      'path' =&gt; drupal_get_path('module', 'page_arg') . '/theme/templates',
    ),
  );
}


Create a file page-arg.tpl.php and put it in /theme/templates in your module (page_arg) directory.