[development] hook_theme

Earl Miles merlin at logrus.com
Wed Mar 16 16:52:07 UTC 2011


You're on the wrong path.

Normal page output, i.e, doing this:

function my_page() {
  $output = 'blah'
  return $output;
}

...will be wrapped in theme('page').

You have two options:

1) Implement theme_preprocess_page, detect (somehow, you have to figure
out how to detect this) that you need to be in a stripped down page, and
set $variables['template_file'] = 'page-my-stripped-page.tpl.php'

In Drupal 6, this is the best choice, because there are elements of a
page you MUST have. i.e, the <head> tags which you probably want.

2) Print your output directly and return NULL. If you return NULL (or 0,
I think), the system assumes that you don't need to wrap in
theme('page') because you already printed the output. This is commonly
used for feeds and other things that aren't actually HTML pages. So:

function my_page() {
  $output = 'blah'
  print $output;
}


On 3/16/2011 7:13 AM, Damian Adriel Perez Valdes wrote:
> hello:
> 
> i have a question. I need to make a page in my module with out a garland
> theme, to show with a ligthbox module.
> 
> I use:
> 
>         'title' => 'Show',
>         'page callback' => 'theme',
>         'page arguments' => array('view_user'),
>         'access callback' => TRUE,
>         'type' => MENU_CALLBACK,
> 
> /**
>  * Implementation of hook_theme().
>  */
> function show_theme() {
>   return array(
>     'view_user' => array(
>       'arguments' => array('view_user' => NULL, 'type' => 'html', 'node'
> => NULL),
>       'template' => 'page-user-view',
>     ),
>   );
> }
> 
> it's work fine, but load with a garland theme. and i need white page,
> without theme, because i load this page with lightbox2 module.
> 
> what can i do ?
> 
> thanks.



More information about the development mailing list