1

I am embarking on a new project and have decided to use Omega as as my base theme. I have a few related questions to overriding html.tpl.php in my subtheme.

I normally use Modernizr for HTML5 feature detection and to provide the HTML5 Shiv functionality. Are there any problems with replacing the conditional HTML5 Shiv with always including Modernizr? Are any of the features incompatible with the Javascript that Omega provides (like the Media Queries extra)?

Second, I normally place Javascript at the bottom of the page. Will this interfere with any of the JS that Omega relies on?

2 Answers 2

2

I have now done a few Omega based sites, and I have some answers about these.

I have not run into any problem with moving the print $scripts to right before the closing </body> in html.tpl.php. That said, this question on Stack Overflow has a good discussion on why this may be an outdated advice.

I have also had good results replacing the HTML5 shiv in html.tpl.php with the following code.

<?php if ($modernizr): ?>
  <script src="<?php print $modernizr; ?>"></script>
<?php else: ?>
  <!--[if lt IE 9]><script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
<?php endif; ?>

I also added the following code in template_process_html().

if (theme_get_setting('mytheme_use_modernizr')) {
  $vars["modernizr"] = "/" . path_to_theme() . "/js/modernizr-2.0.6-min.js";
}

I then wire up a custom theme variable in theme-settings.php.

$form['mytheme'] = array(
  '#type' => 'fieldset',
  '#title' => t('mytheme settings'),
);

$form['mytheme']['mytheme_use_modernizr'] = array(
  '#type' => 'checkbox', 
  '#title' => t('Use Modernizer instead of HTML5 Shiv?'), 
  '#default_value' => theme_get_setting('mytheme_use_modernizr'), 
);
1

You could always use the Modernizr Drupal module and I'll do all the hard work for you ;)

One minor point of automation that still need to be completed is that the module's API needs to allow for NOT args, so that themes who supply their own copy of shiv can tell the Modernizr API to avoid including it. But we're working on it!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.