Similar to another post aimed at using a different page.tpl.php for a certain content type, sometimes I've needed to call in the node via an iframe or similar, so I really need a different html.tpl.php for a certain content type...
I've laid the content out in a similar way to the other post...
- For starters, lets use some example names/variables, lets say:
- The theme I’m using is called ‘myTheme’
- The ‘content type’ I have set-up is called ‘News Article’
- The ‘machine name’ for my ‘content type’ is ‘news_article’
Solution
- After you have created your content type (i.e. ‘News Article’)…
- Copy your html.tpl.php page and rename it ‘html--’ + ‘machine name for your content type’ + ‘.tpl.php
- So if the ‘machine name’ for my ‘content type’ was ‘news_article’, my file would be ‘html--news-article.tpl.php’
- Note: the underscore has been changed for a hyphen.
- Open your template.php file and add the following code
function myTheme_preprocess_html(&$vars) { $node = menu_get_object(); if ($node && $node->nid) { $vars['theme_hook_suggestions'][] = 'html__' . $node->type; } }
Related Articles
Main Category
Secondary Categories