1

I'm trying to build a new template for PPC landing pages. The template design is very different than the main template, therefore I'm trying to override html.tlp.php for a specific content type.

The content type machine name is "landing_page".

I've created the following:

html--landing_page.tpl.php (everything in the header and footer) page--landing_page.tpl.php (everything in the content area)

I got Drupal to read page--landing_page.tpl.php, but can't get it to read html--landing_page.tpl.php instead of the default html.tpl.php.

I've already tried the code at Override html.tpl.php per node type, but it doesn't work even after clearing the cache multiple times.

Here's what my preprocess_html function in template.php looks like:

  function bartik_preprocess_html(&$variables) {

  $node = menu_get_object();

  if ($node && $node->nid) {
    $vars['theme_hook_suggestions'][] = 'html__' . $node->type;
  }

 /* if ($vars['node']->type == 'landing_page'){
     $vars['theme_hook_suggestions'][] = 'html__landing_page';
  }
*/

  if (!empty($variables['page']['promo'])) {
    $variables['classes_array'][] = 'promo';
  }

  if (!empty($variables['page']['triptych_first'])
    || !empty($variables['page']['triptych_middle'])
    || !empty($variables['page']['triptych_last'])) {
    $variables['classes_array'][] = 'triptych';
  }

  if (!empty($variables['page']['footer_firstcolumn'])
    || !empty($variables['page']['footer_secondcolumn'])
    || !empty($variables['page']['footer_thirdcolumn'])
    || !empty($variables['page']['footer_fourthcolumn'])
    || !empty($variables['page']['footer_fivecolumn'])
    ) {
    $variables['classes_array'][] = 'footer-columns';
  }

  drupal_add_js(path_to_theme().'/js/jquery.actual.js');
  drupal_add_js(path_to_theme().'/js/custom.js');

  // Add conditional stylesheets for IE
  drupal_add_css(path_to_theme() . '/css/ie.css', array('group' => CSS_THEME, 'browsers' => array('IE' => 'lte IE 7', '!IE' => FALSE), 'preprocess' => FALSE));
  drupal_add_css(path_to_theme() . '/css/ie6.css', array('group' => CSS_THEME, 'browsers' => array('IE' => 'IE 6', '!IE' => FALSE), 'preprocess' => FALSE));
}
  • Why are you overriding the html template and not the page template? Just curious – chadpeppers Jan 29 '14 at 22:17
  • As I mentioned above, the page template doesn't include the <head> or footer sections only the content area. Since I want to use a different CSS file and the header and footer are different, I have to override html.tpl.php – depiction Jan 30 '14 at 16:00
2

replace

$vars['theme_hook_suggestions'][] = 'html__' . $node->type;

with

$variables['theme_hook_suggestions'][] = 'html__' . $node->type;
0

If you are specifically trying to load a different CSS file then you should use the hook_css_alter instead in a module file as it would be the preferred method. In this case simply use the same theme but just change the CSS file involved. If you need different regions overwrite the page.tpl.php file.

https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_css_alter/7

function hook_css_alter(&$css) {
  // Remove defaults.css file.
  unset($css[drupal_get_path('module', 'system') . '/defaults.css']);
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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