0

问题:现使用了移植的主题,评论每次都要提交两次才能提交成功,comments.php也修改了好几次,没成功,希望哪位大神指教一下
comments.php的代码如下:

<?php function threadedComments($comments, $options) {
    $commentClass = '';
    if ($comments->authorId) {
        if ($comments->authorId == $comments->ownerId) {
            $commentClass .= ' comment-by-author';
        } else {
            $commentClass .= ' comment-by-user';
        }
    } 
    $commentLevelClass = $comments->_levels > 0 ? ' comment-child' : ' comment-parent';
?>
                  <ul id="comments">
                    <li class="comment" id="<?php $comments->theId(); ?>">
                      <div class="c_content comment_body">
                        <div class="author">
                          <div class="avatar"><?php $comments->gravatar('80', ''); ?>
                          </div>
                          <div class="author-name"><b><?php $comments->author(); ?></b></a>
                          </div>
                          <div class="author-date"><small><?php $comments->date('Y-m-d H:i'); ?></small>
                          </div>
                        </div>
                        <?php if ('waiting' == $comments->status) : ?>
                        <p><small><strong>您的评论正在等待审核……</strong></small></p>
                        <?php endif; ?>
                        <div class="comment_content"><?php $comments->content(); ?></div>
                      </div>
                    </li>
                  </ul>
 
<?php } ?>

<?php if ($this->allow('comment')) : ?>
              <div id="comments_container">
                <div class="in-mark"><link href="<?php $this->options->themeUrl('static/comment-style.css'); ?>" type="text/css" rel="stylesheet"/>
                <div class="comment-title">发表评论</div>
                  <form method="post" action="<?php $this->commentUrl() ?>" id="comment-form" role="form">
                  
                    <div class="comment-traggle">
                      <div class="avatar"><img src="<?php $this->options->themeUrl('static/uface.png'); ?>"/></div>
                      <div class="traggle-title">撰写评论</div>
                    </div>
                    <div class="comment-form"><textarea name="text" rows="2" class="textarea_box"><?php $this->remember('text'); ?></textarea></div>
                    <div class="comment-traggled">
                      <div class="input_body clearfix">
                        <?php if (!$this->user->hasLogin()) : ?>
                        <ul class="ident">
                          <li>
                            <lable>昵称 *</lable>
                            <input type="text" name="author" value="<?php $this->remember('author'); ?>" />
                          </li>
                          <li>
                            <lable>邮箱 *</lable>
                            <input type="text" name="mail" value="<?php $this->remember('mail'); ?>" />
                          </li>
                          <li>
                            <lable>网址</lable>
                            <input type="text" name="url" value="<?php $this->remember('url'); ?>" />
                          </li>
                        </ul>
                        <?php endif; ?>
                        <?php $security = $this->widget('Widget_Security'); ?>
                          <input type="hidden" name="_" value="<?php echo $security->getToken($this->request->getReferer())?>">
                        <input id="c_submit" type="submit" value="提交评论"  class="c_button"/>
                      </div>
                    </div>
                  </form>
                  <?php $this->comments()->to($comments); ?>
                  <?php if ($comments->have()) : ?>
                  <?php $comments->listComments('before=<div>&after=</div>'); ?>
                  <?php if ($comments->pageNav()) : ?>
                  <div class="page-navigator clearfix">
                    <div class="in-mark">
                      <?php $comments->pageNav('&laquo; 前一页', '后一页 &raquo;',0 ,'', 'wrapTag=div&wrapClass='); ?>
                    </div>
                  </div>
                  <?php endif; ?>
                  <?php endif; ?>
                  <script>
                    $(document).ready(function(){
                      $(".comment-form").click(function(){
                        $(".comment-traggle").hide();
                        $(".comment-form textarea").css("height","auto");
                        $(".comment-traggled").fadeIn("slow");
                      });
                    });
                    $('textarea').keyup(function () {
                      $(this).height(this.scrollHeight);
                    });
                  </script>
                </div>
              </div>
<?php endif; ?>

2个回答

0

已采纳

有无可能因PJAX设置导致的冲突?若主题支持并开启了PJAX加速,则需要关闭评论上的反垃圾保护。(url重写冲突)
那么,关闭PJAX加速就好了。或关闭反垃圾(看个人喜好)

0

你的问题解决了吗?我和你一样遇到相同的问题,都是第一次提交失败,然后第二次提交就好了

1

暂时的解决办法是:Typecho中后台,设置——评论,将 开启反垃圾保护 勾去掉就可以了

sxgxhk · 4月1日

展开评论

撰写答案