I have a form that I'd like to put in an iframe. I'd like to change the base template to a very minimal page.tpl.php and strip out everything but the headers and the content (basically).

in drupal 5 there was _phptemplate_variables($hook, $vars = array()), but that seems to be deprecated in 6, in 6 I'm trying hook_theme, but with no luck. I was hoping there might be a "drupal_base_theme('my_theme.tpl.php);" function, but I haven't found it yet.

Can anyone give me any pointers in the right direction as to how I might accomplish this?

Thanks in advance, m...

Comments

Bagz’s picture

Hi, if your form is in your own module then you can override the theme to be used by the module.

In your .module file add a "custom_theme" hook, for example:

<?php
function your_module_name_custom_theme() {
	if (arg(0) == 'your_module_name') {
	  return 'mayo';
	}
}
?>

This will make Drupal use the Mayo theme for your module. You can of course use any installed (and enabled) theme.

vasi1186’s picture

Hi,

in your custom module, put this code:

function your_module_name_preprocess_page(&$variables){
  if (menu_path_is_returning_your_form){ //here you can check the arg() function to see if you are on the path
    $vars['template_files'][] = 'page-iframe';
  }
}

Then, in your site theme folder, create a new file named page-iframe.tpl.php and put there only the variables that you need from page.tpl.php.

Don't forget to clear the cache after you implement the preprocess hook!

Vasi.

Bagz’s picture

Hi Vasi, not sure if you know, but when commenting you can put the normal php opening and closing tags inside the code and /code tags and it will show up nicely coloured..

Bagz’s picture

Neat solution from Vasi, and you could also use that approach for other conditions such as specific templates for certain nodes, i.e. use

<?php
if ($node->type == 'blog') {
 $vars['template_files'][] = 'special_template';
}
?>

I tried this approach once as well, but found I was still stuck with the default theme's CSS, so couldn't change the column layout.