【转】CMS3

这篇文章介绍如果根据不同的内容类型(content types)进行页面布局(full page layout)。比如说你想让你的blog和books拥有不同的外观。

步骤:作为一个示例,下面一步一步演示一下如何为网站的blogs,books和首页(front page)拥有不同的页面布局。

首先:

1.复制page.tpl.php文件一份副本,将它重命名为page-default.tpl.php2.再做几次相同的工作,分别将其命名为”page-front.tpl.php”, “page-blog.tpl.php”和”page-book.tpl.php”等等3.使用编辑器,修改每一个tpl.php文件,按照你的要求进行修改页面布局4.将修改后的tpl-type.php文件(page-front.tpl.php , page-blog.tpl.php等等)上传到你正在使用的themem目录下

然后:

1.用下面这段代码替换page.tpl.php中的内容2.确保theme内有page-default.tpl.php文件3.上传page.tpl.php文件到你现在正在使用的theme目录内,新的页面而已就会自动生效了

Evance注:

1.下面的代码片断可以按照新增加/删减的内容类型进行添加/删除。2. page-default.tpl.php文件将会是未指定特定内容类型的布局文件所默认的布局,比如说,按照前期设计要求完成了theme设计。后来可 能根据新的需求又增加了新的内容类型,那么它将会使用page-default.tpl.php的布局进行页面组织。

<?php/*** This snippet loads up different page-type.tpl.php layout* files automatically. For use in a page.tpl.php file.** This works with Drupal 4.5, Drupal 4.6 and Drupal 4.7*/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;?>

源文:

description

This explains how to customise the entire page layout depending on the node type. An example application is if you wanted your entire blog pages to look different to your book pages.usage

As an illustrative example, the following step-by-step approach shows you how to setup different (full) page layouts for your blogs, books and the front page to your site.Step 1 of 2

1. make a copy of your page.tpl.php file and rename it to be page-default.tpl.php.2. make further copies your page.tpl.php file it and rename them to be page-front.tpl.php, page-blog.tpl.php and page-book.tpl.php etcetera..3. using a text editor like notepad.exe or equivalent, modify the layout of each tpl.php file to suit your desires4. upload your new page-type.tpl.php layout files to your active theme folder

Step 2 of 2

1. Using a text editor like notepad.exe or equivalent, replace the contents of your page.tpl.php file with the snippet below2. Ensure that you have a page-default.tpl.php file as part of your collection of layouts.3. Upload your new page.tpl.php file to your active theme folder and your new layouts will take effect automaticall

向上攀爬的。

【转】CMS3

相关文章:

你感兴趣的文章:

标签云: