0

From a module, I want to output "hello world" simply as a string as efficiently as possible when i call /mymodule/helloworld.

ofcourse, using hook_preprocess_html and hook_preprocess_page i can assign nearly empty templates. the html template should contain <?php print $page; ?> and the page template <?php print render($page['content']); ?>, and the content could be the string 'hello world'.

however, drupal will still go through all the processes of generating $css in html or $page['sidebar_first'] in the page. Even if I override template_process_html it seems $variables['page']['page_top'] has already been populated.

How can I skip all the content processing and go straight for the output ?

[EDIT] had some usefull comments here, but still not what I want. I forgot to mention, I do want to use a template to print 'hello world'. So as I can override it in a theme, for example.

  1. Yes, I can change the delivery callback (either in hook_menu or in hook_page_delivery_callback_alter), but what the callback method receives is a render array. I do want to use a node template to render the content as html. I'd have to write my own delivery callback, I guess

  2. Yes, I can print out the html and call drupal_exit(), but then I wouldnt have the luxury of using a node template either

So, still looking.

*-pike

5

1 Answer 1

0

based on comments above and my own edits, i came up with this

function my_page_callback() {
    $output =  array(
        'template' => array(
            'data'      => array('dummy'=>true),
            '#theme'    => 'my_theme'
        )
    );
    print drupal_render($output);
    drupal_exit();
}

that goes straight for the beef: print the output. it does however use the templating system to create that output. it does not, i think, do all the preprocessing that would otherwise happen.

Your Answer

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

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