Tell me more ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

I'm currently building a module that has a popup page in it. The popup page is very simple and no real header/footer so I don't want to use the standard html.tpl.php page.tpl.php

How can I override the master templates with my own much simpler ones?

share|improve this question

1 Answer

If memory serves me well I think the easiest way is to simply print the output in your page callback function, and not return anything:

function MYMODULE_popup_page_callback() {
  // Your theme variables
  $vars = array('foo' => 'bar');
  $output = theme('MYMODULE_popup_page', $vars);

  print $output;

  // If there's nothing more to be had from this page request you might as well end it (gracefully).
  drupal_exit();
}

The other, more involved way, would be to override the default delivery callback for your menu item. The default is drupal_deliver_html_page(); if you want to go down this route I'd recommend reading and understanding that function to see what you'll need to do in your own function.

share|improve this answer
I've tried the method you suggested in code but that doesn't give me access to Drupal template vars such as $head $scripts. drupal_deliver_html_page() look like what I'm looking for, thanks. – Owen May 17 '12 at 17:25
Don't forget that if you're loading the page as an AJAX popup, it will inherit the CSS/JS already on the parent page :) – Clive May 17 '12 at 17:29
No it's not an Ajax page, just a html page with some text and links on it. – Owen May 17 '12 at 18:12
Ah ok, drupal_deliver_html_page() is probably the way to go then – Clive May 17 '12 at 18:13

Your Answer

 
discard

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.