In this example I'll show how you can display certain pages with an alternate theme layout. In a real world example, I added some jQuery to my module to allow the user to open a new window and allow them to add a node. The newly opened window had to bypass my regular theming to function properly.
I wanted my custom theme layout to start right after my closing </head> tag and before my opening <body> tag, so I inserted this line of PHP code in my page.tpl.php file:
<?php
theme('check_no_theme', $variables);
?>
Next, I added a function to my theme template.php file. This function checks to see if the query string matches an entry in a defined array and then uses the _phptemplate_callback function to load a theme file called "notheme-page.tpl.php".
<?php
function MYTHEME_check_no_theme(&$variables) {
// create a list of q values that will have no theming
$noThemeQs = array('MYPAGE_1', 'MYPAGE_2', 'MYPAGE_3');
if (in_array($_REQUEST['q'], $noThemeQs)) {
_phptemplate_callback('notheme-page', $variables);
}
}
?>
Last, I create a file called notheme.page.tpl.php. This file contains the alternate page.tpl.php html. NOTE: the PHP "die" statement is important from keeping the original theme from being displayed.
<body>
INSERT YOUR ALTERNATE THEME LAYOUT HERE
</body>
<?php print $closure; ?>
</html>
<?php die; ?>