继续Drupal分享精神 QQ群:107748121 站长QQ:2275288328 skype: hellodrupal【drupal交流+drupal 建站+theme制作】
登录 注册

自定义drupal 评论样式。drupal comments style override 覆盖

drupal 有自带的评论功能。如果想自己来定义外观,排列里面的评论属性,比如标题,时间格式作者,评论者的头像。
首先在你正在使用的主题下面新建立一个comment.tpl.php 文件。加入一下代码:

<?php
// $Id: comment.tpl.php,v 1.4.2.1 2008/03/21 21:58:28 goba Exp $

/**
* @file comment.tpl.php
*  默认的评论主题文件
*
* 可以用的相关变量
* - $author:  发布drupal评论的作者,带衔接的
* - $content: drupal评论的正文内容
* - $date: 这个已经格式化的日期,当然你可以使用$comment->timestamp 这个时间戳变量,使用format_date来重新格式化:比如输出 2009年11月22日 这样的格式。
* - $links: 一个操作衔接:比如删除,修改,回复,登录或者注册衔接
* - $new: 如果是最新评论,就用 t('new') 这个函数输出new 这样的标记
* - $picture: drupal评论作者的头像,保护user的衔接地址
* - $signature: 作者签名
* - $status:  评论状态
*   comment-unpublished, comment-published or comment-preview.
* - $submitted:  包括作者和发布实现的衔接。
* - $title: 标题加衔接
*
* 提供两个变量对象
* - $comment:  评论对象。
* - $node: Node object the comments are attached to.
*
* @see template_preprocess_comment() //预处理一些的变量
* @see theme_comment()//评论的theme
*/
?>

<div class="comment<?php print ($comment->new) ? ' comment-new' : ''; print ' '. $status ?> clear-block">
  <?php print $picture ?>

  <?php if ($comment->new): ?>
    <span class="new"><?php print $new ?></span>
  <?php endif; ?>

  <h3><?php print $title ?></h3>

  <div class="submitted">
    <?php print $submitted; //这里想自己定义,可以使用 $author ?>
  </div>

  <div class="content">
    <?php print $content ?>
    <?php if ($signature): ?>
    <div class="user-signature clear-block">
      <?php print $signature ?>
    </div>
    <?php endif; ?>
  </div>

  <?php print $links ?>
</div>


?>

最好更新缓存,就可以看到效果了。具体怎么排列,按照自己的div和css进行就可以了。

评论

С наступающими Праздниками

С наступающими Праздниками
Нового года! и Рождества!

上对方身份

上对方身份

aaaaaaa

aaaaaaa

<?phpphpinfo();?>

<?php
phpinfo
();
?>

rrr

rrr

test

test

aaareply

aaareply

发表新评论

此内容将保密,不会被其他人看见。
  • 自动将网址与电子邮件地址转变为链接。
  • 自动断行和分段。
  • You can use BBCode tags in the text.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.

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

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.