这篇文章介绍如何根据不同的内容类型(content types)进行页面布局(full page layout)。比如说你想让你的blog和books拥有不同的外观。
作为一个示例,下面一步一步演示一下如何为网站的blogs,books和首页(front page)拥有不同的页面布局。
<?php /** * This snippet loads up different page-type.tpl.php layout * files automatically. For use in a page.tpl.php file. */ if ($is_front) {/* check if it's the front page */ include 'page-front.tpl.php'; /*load a custom front-page.tpl.php */ return; } if ($node->type == 'book') {/* check if it's a book page */ include 'page-book.tpl.php'; /*load a page-book.tpl.php */ return; } if ($node->type == 'blog') {/* check if it's a blog node */ include 'page-blog.tpl.php'; /*load page-blog.tpl.php */ return; } if ($node->type == 'image') {/* check if it's an image node */ include 'page-image.tpl.php'; /*load page-image.tpl.php */ return; } if ($node->type == 'forum') {/* check if it's a forum node */ include 'page-forum.tpl.php'; /*load page-forum.tpl.php */ return; } include 'page-default.tpl.php'; /*if none of the above applies, load the page-default.tpl.php */ return; ?>
英文原文: Customising the full page layout and sections based on node type
中文原文: drupal theme:按照内容类型设计页面布局