开发者

Drupal 6 - Custom page.tpl

I'm using Drupal 6. I have some css that I want to apply only for a spe开发者_如何学Ccific content-type. The content types machine readble name is "snap".

I copied the page.tpl.php and created another file called page-snap.tpl.php.

I have restarted apache and mysql and refresh the cache but when I look for the content type snap to use as the DIV I see nothing.

What am I doing wrong?

Thanks,


You can use $node->type to include some additional css...

if($node->type == 'snap') {
  //inlcude your css file
}


Take a look at Theming a page by content type

Instructions:

  • Rename page-snap.tpl.php to page-node-snap.tpl.php.
  • Create a file called template.php in your theme folder

In template.php, add this:

<?php
  function bluemarine_preprocess_page(&$variables) {
    if ($variables['node']->type == "snap") {
      $variables['template_files'][] = 'page-node-snap';
      drupal_add_css(PATH TO CSS FILE); // Enter path to custom css here
    }
  }
  • Save the file and clear the cache (admin/settings/performance)

More about drupal_add_css()


If you want different theme for different content type you can try themekey module. Using this module you can configure theme for different content types.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜