建立节点类型node-type模板

在默认安装的drupal后,安装程序会创建2个内容类型:page和story。所有的节点内容输出都是通过node.tpl.php完成,无论是在摘要(teaser)页还是内容页(page)。

如果需要我们可以每个内容类型或单个内容类型建立节点(node)模板,例如:
node-story.tpl.php

推荐方法是:复制主题模板目录中的node.tpl.php另保存为:node-story.tpl.php
注意:node.tpl.php必须在你的主题目录中,不要将node.tpl.php重命名为node-story.tpl.php

如果你还有其他内容类型需要定制,规则是:node-[node-$type].tpl.php
什么是node-$type?你可以URL到admin/content/types 查看。
加入你启用了forum和book模块,可以建立:node-forum.tpl.php 、node-book.tpl.php

建立node-[node-$type].tpl.php不是必须的,根据需要定制,如果大同小异就没有必要了。

另外在drupal 6.x中,当建立了新的模板文件需要注册,方法是在"管理--> 站点设置-->性能" URL:admin/settings/performance 点击"清除缓存数据"按钮

本文的介绍内容你可以访问:http://drupal.org/node/17565

关于Node.tpl.php可以参考drupal.org的文章http://drupal.org/node/11816

由于blogger被无期限“和谐”,故将此文转了过来。
原文:http://playts.blogspot.com/2009/02/node-type.html

评论

发表新评论

此内容将保密,不会被其他人看见。
  • 自动将网址与电子邮件地址转变为链接。
  • 允许HTML标签:<a> <img> <em> <del> <strong> <cite> <code> <pre> <ul> <ol> <li> <dl> <dt> <dd> <h3> <h4> <h5> <h6>
  • 自动断行和分段。
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>. The supported tag styles are: <foo>, [foo]. PHP source code can also be enclosed in <?php ... ?> or <% ... %>.

更多关於格式化选项的信息

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image.