This article shows the basic usage of template.php to create the variables that are required for the accessibility module to work as expected. Other configurations of course can be made here, but this example show how to create the $dtd and $xmlns variables.
<?php
function _phptemplate_variables($hook, $vars) {
global $accessibility, $mime, $locale, $xml;
if (!@$accessibility) {
$content_type = 0;
} else {
$content_type = $accessibility['content_type'];
}
switch($hook) {
case 'page' :
if ( module_exists('accessibility') ) {
$output = '';
$xmlns = '';
if ( in_array($content_type, $mime['xml']) ){
$output .= $xml;
$xmlns .= 'xmlns="http://www.w3.org/1999/xhtml" xml:lang="'. $locale .'" ';
}
$output .= $mime['dtds'][$content_type];
$vars['dtd'] = $output;
$vars['xmlns'] = $xmlns;
} else {
$vars['dtd'] = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'."\n";
$vars['xmlns'] = '';
}
break;
}
return $vars;
}
The function checks to see that the accessibility module exists * and then renders the doc type accordingly and also sends the XML declaration too if the browser can handle it.
* Note: If you are using Drupal version 4.7x then you need to change module_exists to module_exist as this was a change moving to version 5.