大家制作主题,少不了这个node.tpl.php 主题模板文件,这个node.tpl.php文件主要是输出content,比如文字列表,还是就是正文部分。
上次我们说的page.tlp.php 就是负责排版的。我们看看node.tpl.php 里面具体有哪些变量。
这是从官方网站得到drupal 6最新模板变量,drupal 7可能有些变化。
整理笔记如下,方面以后查询使用。
主要是现实node。
可用的变量:
* $title:node的标题
* $content: node正文或者如果$teaser变量为真的话,就是列表格式了。先记者,等具体写的时候就明白了。
* $picture: 作者的头像,theme_user_picture().
* $date: 创建的日期 ( 可以用$created得到时间。 用 format_date()函数来格式化时间。比如我的一个实例
<?php
print t('发表: ') . format_date($node->created, 'custom', "y年m月d日") . t(' 作者: ') . theme('username', $node);
?>
).
* $links: 主题衔接,比如“更多”,“添加评论”,主要来源theme_links()。
* $name: node的作者: theme_user().
* $node_url: 当前节点url 例如:
<?php
if ($page == 0):
?>
<?php
endif;
?>
* $terms: 分类术语衔接。 theme_links().
* $submitted: theme_node_submitted().
其他变量:
* $node: 整个节点对象,包含日期,但是不一定安全(?)
* $type: node节点内容, 就是story, page, blog,等等。
* $comment_count:本节点的评论数量。.
* $uid: 节点作者的用户ID.
* $created: 节点发布时间.
* $zebra: Outputs either "even" or "odd". Useful for zebra striping in teaser listings.(?)
* $id: Position of the node. Increments each time it's output.
节点状态变量:
* $teaser: teaser 标志. 是真那就是列表格式输出,返回值假那就是正文输出就是整个节点输出。
* $page: 整个页面标志.是否是整个页面显示。
<?php
if ($page == 0):
?>
<?php
endif;
?>
* $promote: Flag for front page promotion state.
* $sticky: 发布是否设置置顶。.
* $status: 发布状态标志。是否发布了。.
* $comment: State of comment settings for the node.
* $readmore: Flags true if the teaser content of the node cannot hold the main body content.
* $is_front:当前节点是否是首页
* $logged_in: Flags true when the current user is a logged-in member.
* $is_admin: 标志为真,则表示是管理员。
笔记主要整理了node.tpl.php 模板主题的变量。有些变量还没有具体使用,等下一步在具体制作的时候再查询.
评论
发表新评论