Skip to content

Instantly share code, notes, and snippets.

@zachharkey
Forked from pascalduez/html.tpl.php
Created February 29, 2012 02:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zachharkey/1937162 to your computer and use it in GitHub Desktop.
Save zachharkey/1937162 to your computer and use it in GitHub Desktop.
Drupal 7 — HTML5 html.tpl.php
<!DOCTYPE html>
<html<?php print $html_attributes; ?>>
<head>
<?php print $head; ?>
<title><?php print $head_title; ?></title>
<?php print $styles; ?>
<?php print $scripts; ?>
</head>
<body<?php print $body_attributes;?>>
<?php print $page_top; ?>
<?php print $page; ?>
<?php print $page_bottom; ?>
</body>
</html>
<?php
/**
* Implements hook_preprocess_html().
*/
function THEMENAME_preprocess_html(&$vars) {
$vars['html_attributes_array'] = array();
$vars['body_attributes_array'] = array();
// HTML element attributes.
$vars['html_attributes_array']['lang'] = $vars['language']->language;
$vars['html_attributes_array']['dir'] = $vars['language']->dir;
// Adds RDF namespace prefix bindings in the form of an RDFa 1.1 prefix
// attribute inside the html element.
if (function_exists('rdf_get_namespaces')) {
$vars['rdf'] = new stdClass;
foreach (rdf_get_namespaces() as $prefix => $uri) {
$vars['rdf']->prefix .= $prefix . ': ' . $uri . "\n";
}
$vars['html_attributes_array']['prefix'] = $vars['rdf']->prefix;
}
// BODY element attributes.
$vars['body_attributes_array']['class'] = $vars['classes_array'];
$vars['body_attributes_array'] += $vars['attributes_array'];
$vars['attributes_array'] = '';
}
/**
* Implements hook_process_html().
*/
function THEMENAME_process_html(&$vars) {
// Flatten out html_attributes and body_attributes.
$vars['html_attributes'] = drupal_attributes($vars['html_attributes_array']);
$vars['body_attributes'] = drupal_attributes($vars['body_attributes_array']);
}
/**
* Implements hook_html_head_alter().
*/
function THEMENAME_html_head_alter(&$head_elements) {
// Simplify the meta charset declaration.
$head_elements['system_meta_content_type']['#attributes'] = array(
'charset' => 'utf-8',
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment