Search code examples
templatesdrupaldrupal-7hook-menuhook-theme

Drupal 7 Custom Template Using hook_menu


I am trying to make custom page template using these hooks in Drupal 7 but it shows blank page when i open in browser. Here is my code

/*
    Implements hook_menu();
*/
function story_menu ()
{
    $items['story/filters'] = array(
        'title' => 'Search For stories',
        'page callback' => 'story_filter_page',
        'access arguments' => array('access content'),
    );
    return $items;
}     


// Implements Page Callback
function story_filter_page ()
{

    return theme('story_search_filter_page', array('title' => 'Testing'));
}


/*
    Implements hook_theme();
*/
function story_theme($existing, $type, $theme, $path)
{
    return array(
        'story_search_filter_page' => array(
            'variables' => array('title' => NULL),
            'template' => 'custom-page',
        ),
    );
} 

I have created the template file : custom-page.tpl.php in my module directory.


Solution

  • I have figured it out why page is showing blank. basically story is my content type to so in my theme there is a tpl file name : page--story.tpl.php and that file was empty .. so that is why my pages showing me blank screen.