欢迎各位兄弟 发布技术文章

这里的技术是共享的

You are here

node 节点 及其它各种变量 字段

shiping1 的头像

定制drupal 7节点(node)

提交

drupal 7带来了许多变化,原先cck的功能融入核心模块里,标题和内容都成为一个字段,这样给我们定制节点的输出带来了方便。下面我们先看看node.tpl.php文件的一些参数。

 

$title: 节点的标题. $content: 输出节点的项目,也就是节点的字段. 使用 print render($content) 去输出他们, 如果要输出一个字段使用print render($content['field_example']). 使用 hide($content['field_example']) 去不输出某个字段.例如你想见回复分开输出  <?php
     
      hide($content['comments']);

      print render($content);
    ?>

 <?php print render($content['comments']); ?>

$user_picture: 作者的图片.

$date: 创建时间.

$name: 作者名通过 theme_username()处理输出.

$node_url:节点链接

$display_submitted: 是否显示提交信息.

$submitted:提交信息 $name 和 $date 在template_preprocess_node().

$classes:用于css,会显示下面的结果:

      node:当前模板类型,例如., "theming hook".

       node-[type]: 当前node类型

      node-teaser:node摘要

      node-preview: Nodes在预览模式.

      node-promoted: node发布在首页

      node-sticky: 顶置Nodes.

      node-unpublished:没发布的node.

$title_prefix (array): 模块控制的输出

$title_suffix (array):同上

$node:完整的node对象,不过包含的数据可能不安全.

$type:node类型

$comment_count: 评论数

$uid:作者id.

$created:node创建时间,格式为Unix timestamp.

$classes_array: Array of html class attribute values. It is flattened into a string within the variable $classes.

$zebra: Outputs either "even" or "odd". Useful for zebra striping in teaser listings.

$id: Position of the node. Increments each time it's output.

Node状态变量:

  • $view_mode: 查看模式, e.g. '全文', '摘要'...
  • $teaser:等同于 $view_mode == 'teaser'
  • $page:等同于 $view_mode == 'page'.
  • $promote: node发布在首页.
  • $sticky: node顶置.
  • $status: node发布状态.
  • $comment: node回复设置状态.
  • $readmore: Flags true if the teaser content of the node cannot hold the main body content.
  • $is_front: 判断为首页.
  • $logged_in:当用户登录时为真.
  • $is_admin: 为管理员账户时为真.
普通分类: