Typecho评论调用变量

  <?php $comments->gravatar('40', ''); ?> //头像,有两个参数,大小、默认头像?
  <?php $comments->author(); ?> //评论作者
  <?php $comments->permalink(); ?> //当前评论的连接地址
  <?php $comments->date('Y-m-d H:i'); ?>//评论时间,可在括号里设置格式
  <?php $comments->reply(); ?> //回复按钮,可在括号里自定义评论按钮的文字
  <?php $comments->content(); ?> //评论内容
  <?php $comments->theId(); ?>     //每个评论的唯一ID
  <?php $comments->sequence(); ?>     //评论所在楼层
  <?php $comments->responseUrl(); ?>     //回复地址
  <?php $comments->responseId(); ?>     //回复框ID
  <?php $comments->trackbackUrl(); ?>     //trackback地址

comments.php
评论列表

<h4><?php $this->commentsNum('No Response', 'One Response to"' . $this->title . '"', '%d Responses to "' . $this->title . '"'); ?></h4>
<ol id="comment_list">
    <?php $this->comments()->to($comments); ?>
        <?php while($comments->next()): ?>
    <li id="<?php $comments->theId(); ?>">
        <div class="comment_data">
                <?php echo $comments->sequence(); ?>. 
                <strong><?php $comments->author(); ?></strong>
                on <?php $comments->date('F jS, Y'); ?> at <?php $comments->date('h:i a'); ?>
            </div>
        <div class="comment_body"><?php $comments->content(); ?></div>
    </li>
    <?php endwhile; ?>
</ol>

结束循环。我们用有序列表\<ol>,因为评论的发表是有先后顺序的。

评论输入表单

<!-- 判断设置是否允许对当前文章进行评论 -->
<?php if($this->allow('comment')): ?>
 
    <h4 id="response">Leave a Reply</h4>
 
    <!-- 输入表单开始 -->
    <form method="post" action="<?php $this->commentUrl() ?>" id="comment_form">
 
        <!-- 如果当前用户已经登录 -->
        <?php if($this->user->hasLogin()): ?>
            <!-- 显示当前登录用户的用户名以及登出连接 -->
            <p>Logged in as <a href="<?php $this->options->adminUrl(); ?>"><?php $this->user->screenName(); ?></a>. 
            <a href="<?php $this->options->index('Logout.do'); ?>" title="Logout">Logout &raquo;</a></p>
 
        <!-- 若当前用户未登录 -->
        <?php else: ?>
            <!-- 要求输入名字、邮箱、网址 -->
        <p><input type="text" name="author" class="text" size="35" value="<?php $this->remember('author'); ?>" /><label>Name (Required)</label></p>
        <p><input type="text" name="mail" class="text" size="35" value="<?php $this->remember('mail'); ?>" /><label>E-mail (Required *will not be published)</label></p>
        <p><input type="text" name="url" class="text" size="35" value="<?php $this->remember('url'); ?>" /><label>Website</label></p>
        <?php endif; ?>
 
        <!-- 输入要回复的内容 -->
     <p><textarea rows="10" cols="50" name="text"><?php $this->remember('text'); ?></textarea></p>
     <p><input type="submit" value="Submit Comment" class="submit" /></p>
    </form>
<?php endif; ?>

很多情况下并不对评论文件进行修改,可以直接拿来使用写入相应的css。


扫描二维码,在手机上阅读!