Skip to content

Instantly share code, notes, and snippets.

@davereid
Last active October 7, 2015 13:38
Show Gist options
  • Save davereid/3173153 to your computer and use it in GitHub Desktop.
Save davereid/3173153 to your computer and use it in GitHub Desktop.
drupal_deliver_minimal_html_page
<?php
function drupal_deliver_minimal_html_page($page_callback_result) {
if (is_int($page_callback_result)) {
return drupal_deliver_html_page($page_callback_result);
}
// Emit the correct charset HTTP header, but not if the page callback
// result is NULL, since that likely indicates that it printed something
// in which case, no further headers may be sent, and not if code running
// for this page request has already set the content type header.
if (isset($page_callback_result) && is_null(drupal_get_http_header('Content-Type'))) {
drupal_add_http_header('Content-Type', 'text/html; charset=utf-8');
}
// Send appropriate HTTP-Header for browsers and search engines.
global $language;
drupal_add_http_header('Content-Language', $language->language);
if (isset($page_callback_result)) {
$output = render($page_callback_result);
print '<html><head><title>' . drupal_get_title() . '</title>' . drupal_get_css() . drupal_get_js() . '</head>';
print '<body>' . $output . '</body></html>';
}
drupal_page_footer();
}
function drupal_deliver_raw_html_page($page_callback_result) {
if (is_int($page_callback_result)) {
return drupal_deliver_html_page($page_callback_result);
}
// Emit the correct charset HTTP header, but not if the page callback
// result is NULL, since that likely indicates that it printed something
// in which case, no further headers may be sent, and not if code running
// for this page request has already set the content type header.
if (isset($page_callback_result) && is_null(drupal_get_http_header('Content-Type'))) {
drupal_add_http_header('Content-Type', 'text/html; charset=utf-8');
}
// Send appropriate HTTP-Header for browsers and search engines.
global $language;
drupal_add_http_header('Content-Language', $language->language);
if (isset($page_callback_result)) {
print render($page_callback_result);
}
drupal_page_footer();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment