Drupal Answers is a question and answer site for Drupal developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I create a module and mymodule.module file like this:

function mymodule_menu(){
        'page callback'=>'mymodule_list_view',
    return $items;

function mymodule_list_view(){

function mymodule_theme($existing, $type, $theme, $path){
    return array(

then I create templates file: mymodule_list.tpl.php

And I create a theme and create templates file: page--mymodule.tpl.php. Now when I access /mymodule/list, it will use page--mymodule.tpl.php to render the page.

My question is: how should I write page--mymodule.tpl.php to display the content in mymodule_list.tpl.php?

share|improve this question
plz elaborate this – monymirza Nov 27 '12 at 11:04
page--mymodule.tpl.php should just be a copy of page.tpl.php – Alex Gill Nov 27 '12 at 11:45
I found that the content of mymodule_list.tpl.php was saved at the variable $page['content']['system_main']['main']['#markup'], so I think I should process this variable. – solomon_wzs Nov 28 '12 at 1:56
up vote 1 down vote accepted

You don't need a customized page template file because you are using a template file for your theme. What you need to do is to fix your code, which should be as the following one.

function mymodule_menu() {
  $items['mymodule/list'] = array(
    'type' => MENU_CALLBACK,
    'page callback' => 'mymodule_list_view',
    'access arguments' => array('access content'),

  return $items;

function mymodule_list_view() {
  return theme('list_view');

function mymodule_theme() {
  return array(
    'list_view' => array(
      'template' => 'list-view',

Notice that:

  • For the menu callback, you should define the access callback, and the access arguments, or the menu will not be visible to the users (except the user #1). By default, Drupal uses user_access() as access callback; in this case, you need to provide the permission string as access arguments.
  • The template filename must be equal to the theme name; the only acceptable difference is the underscores replaced by hyphens.
  • Your page callback needs to return its output, or print it. In the first case, the rendered page will contain all the output returned from Drupal, such as blocks; in the second case, the rendered page will just contain what your page callback prints.
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.