I have tried to get this question answered in the past, but I was never given a satisfactory response.

I am building a custom module. I do not want the module to inherit the current theme being used by Drupal core; it should have its own themes/templates. This is the code I have written.


// $Id$
require_once ('myApp.theme.inc');
function myApp_menu() 
 $result = array();
 $result['myApp'] = array(
    'title' => "My App",
    'page callback' => "myApp_home",
    'access callback' => true,
    'type' => MENU_NORMAL_ITEM,
    'weight' => 1,

 return $result;

function myApp_home(){   
    $output = theme('myApp_home', array('data'=> '')); 
    return $output;


function myApp_theme() {
    $path_to_theme = drupal_get_path('module', 'myApp')."/theme/";      

    $themes = array(); 
    $themes['myApp_home'] = array(
    'template' => 'myApp_home',
    'path' => $path_to_theme , 
    return $themes;


<body>Hello World</body>

The problem is that the module still resides within the Drupal core. I want to have it be a full page web application.

I am new to this, so if anyone could provide an explanation of the best practice, and example code, I would really appreciate it.

  • The simplest method is to simply print the HTML from the callback function rather than return it. That will stop the theme wrappers being invoked and just render your template
    – Clive
    Commented Sep 1, 2017 at 16:21
  • Yes, but then how do you pass in data and use templates?
    – jason
    Commented Sep 1, 2017 at 16:21
  • Exactly the same way you would if you were going through the normal page template. All you're doing differently is making the entire response the HTML that would normally be inside the main content region, instead of the same HTML wrapped in page.tpl.php
    – Clive
    Commented Sep 1, 2017 at 16:34
  • Would you mind providing an example of this method?
    – jason
    Commented Sep 1, 2017 at 17:53

1 Answer 1


As Clive said, you can simply return HTML instead of the render array, e.g.

function myApp_theme() {
    $html = "<html><head></head><body>Hello World</body></html>;      
    return $html;

A more general way is to modify the page.tpl.php in your theme and add a wrapper around the normal styling. E.g.

<?php if ( $plain_page ) { ?>
  <?php print render($page['content']); ?>
<?php } else { ?>
Normal stuff
<?php } ?>

Then in your module, use the template_preprocess_page hook to set the $plain page variable. E.g.

my_module_preprocess_page( &$vars ) {
  [ check if it's a page you want as plain ]
    $vars['plain'] = TRUE;

You will only need the content for the tags as the html.tpl.php template handles that.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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