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' => 'Flashcards',
'page callback' => 'page_arg_callback',
'page arguments' => array(1),
'access arguments' => array('access content'),
'type' => MENU_CALLBACK
);
return $items;
}
function page_arg_preprocess_page(&$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?