Vote up!
Vote down!

How can I add a snipet to the HTML head?

We developed a commerce site and some of our users that use IE9 have their PC's set to " Browser: IE9, Document mode: IE 7 Standards". This will render our custom navigation useless as the drop downs hide behind the content. They also do not read the z-index.

We created a snippet that forces the browser to read the page in IE 9 Standards or IE 8 Standards if they are available. This snippet should be place in the HTML head.

I can not however find a way to place this in the Commerce Kickstart head.

I am using Kickstart 2 and have only replaced the menu.

Asked by: dlz2157
on June 28, 2013

2 Answers

Vote up!
Vote down!

You could create a new theme using "commerce_kickstart_theme" as the base theme, just make sure you read most everything here: https://drupal.org/node/225125 (logo, favicon, and regions are not inherited for example).

This is how your theme.info could look: https://gist.github.com/favrik/5893080/raw/b7e8a27c4887e48ede1e671f2aa74...

Then, when the new theme is setup, override the "html.tpl.php" omega template by creating that file inside your new theme "templates" directory. This is how the file structure of my "testor" theme looks like: https://gist.github.com/favrik/5893078/raw/4c2bdcec2f55de88d6f591832c78d...

Alternatively, you could use "template_preprocess_html" to add custom tags to the head like http://kahthong.com/2011/12/add-creator-meta-tag-drupal-html-head-section (you still need a child theme for that).

Answer by: Favio Manriquez
Posted: Jun 29, 2013
Vote up!
Vote down!

I probably should have been a bit more specific on what I needed it for. For a change as small as I needed which was to force IE to the latest rendering engine I created a small module. There is probably one already out there that does something similar, but here is what I did in case anyone is wondering.

* Implements hook_html_head_alter hook = module/theme
function ie_doctype_html_head_alter(&$head_elements) {
// Force IE9, IE8, or the latest IE rendering engine and Google Chrome Frame.
$head_elements['chrome_frame'] = array(
'#type' => 'html_tag',
'#tag' => 'meta',
'#attributes' => array('http-equiv' => 'X-UA-Compatible', 'content' => 'IE=9,IE=8,IE=edge,chrome=1'),

Answer by: dlz2157
Posted: Jul 12, 2013