Community

What is the better way to change doctype

Hi all,

I want to use HTML 5 Doctype in my theme. I know that we can change it in html.tpl.php. But I wnat to change it through preprocess. I have search a lot and find a bit of code for it.

Which is following:-

template.php

<?php
function ies_preprocess_html(&$variables) {
   if (
module_exists('rdf')) {
    
$variables['doctype'] = '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML+RDFa 1.1//EN">' . "\n";
    
$variables['rdf']->version = ' version="HTML+RDFa 1.1"';
    
$variables['rdf']->namespaces = $variables['rdf_namespaces'];
    
$variables['rdf']->profile = ' profile="' . $variables['grddl_profile'] . '"';
} else {
    
$variables['doctype'] = '<!DOCTYPE html>' . "\n";
    
$variables['rdf']->version = '';
    
$variables['rdf']->namespaces = '';
    
$variables['rdf']->profile = '';
}
}

<
strong>html.tpl.php</strong>

<?
php print $doctype;
?>

<?php
print $head;
?>

<?php
print $head_title;
?>

<?php
print $styles;
?>

<?php
print $scripts;
?>

<?php
print $page_top;
?>

<?php
print $page;
?>

<?php
print $page_bottom;
?>

But drupal showing following error:-

Strict warning: Creating default object from empty value in ies_preprocess_html() (line 44 of C:\xampp\htdocs\rajnish\ecm\sites\all\themes\ies\process\theme.php).

Please help me. I am newbay.

Any help would be highly appreciated.

Thanks,
Rajnish Rao.

Comments

I would suggest to change the

I would suggest to change the Doctype in html.tpl.php page of your theme.
It would be separate from logic.

-Imran

nobody click here