Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
236 lines (132 sloc) 11.4 KB
<!doctype html>
<!--[if lt IE 9]> <html class="no-js oldie" lang="en"> <![endif]-->
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Creating HTML 5 theme for Drupal 6 | Divya Manian</title>
<meta name="author" content="Divya Manian">
<meta name="description" content="Since I write and tweet about HTML5 Koolaid, it is only appropriate that my website also incorporates the new and improved semantic elements of HTML5 &hellip;">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="canonical" href="">
<link href="/stylesheets/screen.css" rel="stylesheet">
<link href="" rel="alternate" title="Subscribe" type="application/atom+xml">
<link href="" rel="alternate" title="Subscribe to Web Development updates" type="application/atom+xml">
<body >
<div class="container">
<div class="content">
<header role="banner"> <h1><a href="/">Divya Manian</a></h1>
<h2><a class="twitter" href="">twitter</a> <a class="rss" href="">RSS Feed</a> <a class="youtube" href="">Youtube Channel</a> <a class="github" href="">Github</a></h2>
<nav class="sitenav"><a href="/">Home</a>
<a href="/archives">Archives</a>
<a href="/about.html">About</a>
<nav class="article">
<a class="previous" href="/css-references-for-mainstream-browsers.html" title="CSS References for Mainstream Browsers">❬</a>
<a class="next" href="/presenting-your-self-online.html" title="Presenting Your Self Online">❭</a>
<time datetime="2009-12-16T00:00:00-08:00" pubdate><span class='month'>Dec</span> <span class='day'>16</span> <span class='year'>2009</span></time>
<h1 class="entry-title"><a href="/creating-html-5-theme-for-drupal-6.html">Creating HTML 5 theme for Drupal 6</a></h1>
<div class="entry-content"><p>Since I <a href="/web-design.html">write</a> and <a href="">tweet</a> about HTML5 Koolaid, it is only appropriate that my website also incorporates the new and improved semantic elements of HTML5. I also figured it would be the right time to upgrade to Drupal 6. </p>
<p>Here is how you can create a theme which uses some of the new elements of HTML5. This is not the <em>only</em> way to do it, but simply my attempt at creating one. Please comment if you know of better ways to do it.</p>
<ul><li>The new elements of HTML5 will not render correctly in Firefox 2 and below (you can see how this website renders in Firefox 2 to see the true extent of devastation). Your best bet is to output a class to body element — use that to style the page — if Firefox 2 makes a request, <a href="" title="Browser.php &#8211; Detecting a user&#8217;s browser from PHP | Chris Schuld's Blog">using PHP Browser Detection</a> (this script will cause crazy results on all browsers, if you enable caching).</li>
<li>You need <a href="" title="HTML5 enabling script">Remy Sharp’s HTML 5 enabling script</a> so that IE can recognize new HTML5 elements and apply the CSS correctly.</li></ul>
<p>Before you start creating a HTML5 Drupal theme, <a href="" title="Designing a blog with html5 | HTML5 Doctor">read this post on creating a blog with HTML 5 markup</a>. That should give you all information you need on the markup. Then, start with an existing Drupal 6 theme that you want to convert to HTML5.</p>
<p>These are the template files I modifed: </p>
<li><code>page.tpl.php</code> - I divided the content into <code>header</code>, <code>footer</code>, <code>section</code> elements. I also used <code>nav</code> to be the container for the <code>primary links</code></li>
<li><p><code>node.tpl.php</code> - Each node is an <code>article</code>. This is also where you can use the <code>time</code> element to mention the published date of a node: </p>
<code>&lt;time pubdate=&quot;pubdate&quot; datetime =&quot;&lt;?php echo format_date($created,&#x27;custom&#x27;, &#x27;Y-m-d&#x27;); ?&gt;&quot;&gt;
&lt;?php echo format_date($created,&#x27;small&#x27;) ?&gt;
&lt;/time&gt; </code>
<li><code>search-result.tpl.php</code> - I am not sure if this is correct, but I have marked up each search result as an <code>article</code>. </li>
<li><code>search-results.tpl.php</code> - If you need a <a href="">sectioning element</a> around the search results, this is where you should add it.</li>
<li><code>comment.tpl.php</code> - I used <code>article</code> to markup each comment. I also used <code>time</code> to render the publication date of a comment:
<pre><code>&lt;time pubdate=&quot;pubdate&quot; datetime =&quot;&lt;?php
echo format_date($comment-&gt;timestamp, &#x27;custom&#x27;, &#x27;Y-m-d\TH:i:s&#x27;);
$tzone = variable_get(&#x27;date_default_timezone&#x27;);
printf(&#x27;%s%02d:%02d&#x27;, ($tzone &lt; 0 ? &#x27;-&#x27; : &#x27;+&#x27;), abs($tzone / 3600), abs($tzone % 3600) / 60);
&lt;?php echo format_date($comment-&gt;timestamp, &#x27;small&#x27;)?&gt;
<li><code>comment-wrapper.tpl.php</code> - In my theme, all comments are contained within a <code>section</code> which can be specified in this file.</li>
<li><code>box.tpl.php</code> - I used <code>article</code> as a container for the comment form. This template renders the container for that form.</li>
<li>Own Module — I had to create a module to use <code>article</code> to wrap the Advanced Search Form. Here is the code I used in the module:
<pre><code>//nimbupani is the name of the module
function nimbupani_form_alter(&amp;$form, $form_state, $form_id) {
if($form_id == &#x27;search_form&#x27;) {
<p>The has a <a href="" title="Search for .tpl.php | Drupal API">full list of all themable template files available to you in Drupal 6</a> if your theme requires more customization. </p>
<p>You can use <a href="" title=" (X)HTML5 Validator"></a> to test your pages. But be warned, the validator is known to lag behind the specification. So, you might get false negatives, if so, ignore them if you know you are confirming to the latest specification.</p>
<h3>Further Work</h3>
<p>This is just scratching the surface, you can also make all form elements to use HTML5 attributes, and also add <a href="">ARIA landmarks</a>. These are my focus areas for the next update to my theme.</p>
<p>Meanwhile, if there is any element that is incorrectly used on this site, or if you have any suggestions on how to make the site better, do comment!</p>
<p class="meta">This post was posted by
<a href="/about.html">Divya Manian</a>
<time datetime="2009-12-16T00:00:00-08:00" pubdate><span class='month'>Dec</span> <span class='day'>16</span> <span class='year'>2009</span></time> in
<span class="categories">
<a class='category' href='/categories/web-development/'>Web Development</a>
. If you would like to update this post, <a href="">please send a pull request</a>.
<div id="disqus_thread" aria-live="polite"><noscript>Please enable JavaScript to view the <a href="">comments powered by Disqus.</a></noscript>
<aside id="articles">
<p><img class="avatar" src="/assets/divya.png" height=50> <a href="">Divya Manian</a> is a Web Developer in Seattle. <a href="/about.html">More about me ❭</a></p>
<h2>Posts on Web Development</h2>
<ul><li><a href="/html5please.html">html5please</a></li><li><a href="/mustache.html">mustache, hogan, handlebars</a></li><li><a href="/redesign-notes.html">Redesign Notes</a></li><li><a href="/summary-of-various-exciting-css-drafts-and-proposals.html">Summary of various exciting CSS drafts and proposals</a></li><li><a href="/this-revolution-needs-new-revolutionaries.html">This revolution needs new revolutionaries</a></li><li><a href="/some-css-transition-hacks.html">Some CSS Transition hacks</a></li><li><a href="/safe-css-defaults.html">Safe CSS Defaults</a></li><li><a href="/unplugged-2011.html">Unplugged 2011</a></li><li><a href="/bokeh-with-css3-gradients.html">Bokeh with CSS3 Gradients</a></li><li><a href="/making-pure-css3-demos-better.html">Making "Pure CSS3" demos better</a></li><li><a href="/web-opener-at-opera.html">Web Opener at Opera</a></li><li><a href="/current-color-in-css.html">Current Color in CSS</a></li><li><a href="/css-vocabulary.html">CSS Vocabulary</a></li><li><a href="/active-web-development.html">Active Web Development</a></li><li><a href="/sexy-css3-buttons.html">Sexy CSS3 Buttons</a></li><li><a href="/accessible-css-barcharts.html">Accessible CSS Barcharts</a></li><li><a href="/svg-is-coming.html">SVG is coming!</a></li><li><a href="/wee-marquee.html">Wee! Marquee</a></li><li><a href="/vignettes-with-css3-box-shadows.html">Vignettes with CSS3 Box Shadows</a></li><li><a href="/drop-shadows-with-css3.html">Drop Shadows with CSS3</a></li><li><a class="btn" href="/categories/web-development/">More</a></li></ul>
<footer role="contentinfo"><p>
Copy to your heart’s content 2012 - Divya Manian -
<span class="credit">Powered by <a href="">Octopress</a></span>
<script type="text/javascript">
var disqus_shortname = 'nimbublog';
var disqus_developer = 1;
var disqus_url = '';
var disqus_identifier = '';
(function () {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'http://' + disqus_shortname + '';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
<script src="/javascripts/octopress.js"></script>
var _gaq=[['_setAccount','UA-97188-1'],['_trackPageview']];
(function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];