You are here

节点摘要(teaser)的drupal主题化

g089h515r806 的头像
Submitted by g089h515r806 on 星期三, 2008-09-10 02:31

你可以在drupal主题的node.tpl.php模板文件中使用下面的条件语句,来为摘要创建一个独特的外观:

<?php
if ($teaser) {
//if node is being displayed as a teaser
//Anything here will show up when the teaser of the post is viewed in your taxonomies or front page
} else {
//all other cases
//Anything here will show up when viewing your post at any other time, e.g. previews
?>

 

或者,你想在条件语句中使用HTML,例如使用模板创建两个完全不同的布局:

  <?php if ($teaser): ?>
    <!-- teaser template HTML here -->
  <?php else: ?>
    <!-- regular node view template HTML here --> 
  <?php endif; ?>

 

注意$page变量用来判断节点是不是单独处在一个页面中,这与是否是作为摘要(teaser)显示的是有区别的:在节点的编辑预览页面, $page都为true的.

 

 相关链接:http://drupal.org/node/53464 , Think in Drupal