扒了个模板,遇到点麻烦求大佬解答

模板开发以及发布测试

版主: seita

回复
Sakura
帖子: 13
注册时间: 2017年 3月 3日 04:14
联系:

扒了个模板,遇到点麻烦求大佬解答

帖子 Sakura »

这两天看中一个te模板,于是自己扒下来了,但是遇到一个问题,这个模板的评论的class要自定义,于是我从网上找了一段代码粘进去,也的确可以按预期显示出来了,但是回复楼层提交后,不会自己退回上一层,官方的模板,还有几个大佬的模板,回复楼层提交后,会自己退回上一层,然而我这模板回复后还要自己点一次"取消回复"才能退回上一层,是我弄少了什么吗?以前我只用

代码: 全选

<?php $comments->listComments(); ?>
的时候好像是可以自己退回去的?很少扒站所以并不知道是什么情况,求大佬解答



还没有整理过所以代码非常乱...

代码: 全选

<?php if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>


<?php function threadedComments($comments, $singleCommentOptions) {


$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'; 
    $depth = $comments->levels +1;
?> 


<li id="li-<?php $comments->theId(); ?>" class="comment-body<?php
if ( $depth > 1 && $depth < 3 ) {
echo ' comment-child';
$comments->levelsAlt(' comment-level-odd', ' comment-level-even');
}
elseif ( $depth > 2 ) {
echo ' comment-child2';
$comments->levelsAlt(' comment-level-odd', ' comment-level-even');
}
else {
echo ' comment-parent';
}
$comments->alt(' comment-odd', ' comment-even');
echo $commentClass;  ?>">


<div class="comment-author">
<div class="gravatar">
<?php $comments->gravatar($singleCommentOptions->avatarSize, $singleCommentOptions->defaultAvatar);    ?>
</div>

<cite class="fn"><?php $singleCommentOptions->beforeAuthor();
$comments->author();$singleCommentOptions->afterAuthor();  ?>
</cite>


<div class="comment-meta">
<a href="<?php $comments->permalink(); ?>"><?php $singleCommentOptions->beforeDate();
$comments->date($singleCommentOptions->dateFormat);

$singleCommentOptions->afterDate();  ?></a>
</div>


<div class="comment-reply">
<?php $comments->reply($singleCommentOptions->replyWord); ?>
</div>
 
<div class="comment-content">
<?php $comments->content();  ?>
</div>


<?php if ($comments->children) { ?>

<div class="comment-children">
<?php $comments->threadedComments($singleCommentOptions); ?>
</div>
<?php } ?>
 
</li>
<?php
}
?>


<div id="comments">
    <?php $this->comments()->to($comments); ?>

    <?php if ($comments->have()): ?>
   <h3><?php $this->commentsNum(_t('暂无评论'), _t('仅有一条评论'), _t('已有 %d 条评论')); ?></h3>

<?php $comments->pageNav('«', '»', 10, '', array('wrapTag' => 'ol', 'wrapClass' => 'page-navigator','itemTag' => 'li', 'textTag' => 'span', 'currentClass' => 'current', 'prevClass' => 'prev', 'nextClass' => 'next')); ?>

    <?php endif; ?>


    <?php $comments->listComments(); ?>

    <?php if($this->allow('comment')): ?>
    <div id="<?php $this->respondId(); ?>" class="respond">
        <div class="cancel-comment-reply">
        <?php $comments->cancelReply(); ?>
        </div>


       <form method="post" action="<?php $this->commentUrl() ?>" id="comment_form" role="form">
            <?php if($this->user->hasLogin()): ?>
          <p><?php _e('登录身份: '); ?><a href="<?php $this->options->profileUrl(); ?>"><?php $this->user->screenName(); ?></a>. <a href="<?php $this->options->logoutUrl(); ?>" title="Logout"><?php _e('退出'); ?> &raquo;</a></p>
            <?php else: ?>


                                <div class="comment_input">
                <label for="author"><?php _e('称呼'); ?> *</label>
               <input type="text" name="author" id="author" placeholder="" class="text" size="15" value="<?php $this->remember('author'); ?>" required >
               </div>
               <div class="comment_input">
               <label for="mail"><?php _e('邮箱'); ?> *</label>
               <input type="text" name="mail" id="mail" class="text" size="15" value="<?php $this->remember('mail'); ?>"><?php if ($this->options->commentsRequireMail): ?> <?php endif; ?>
               </div>
               <div class="comment_input">
               <label for="url">链接</label>
               <input type="text" name="url" id="url" class="text" size="15" value="<?php $this->remember('url'); ?>"<?php if ($this->options->commentsRequireURL): ?> <?php endif; ?> />
               </div>

<?php endif; ?>
                            <textarea rows="8" cols="50" name="text" id="textarea" class="textarea" required placeholder="<?php _e('评论内容'); ?> *"><?php $this->remember('text'); ?></textarea>

            <div> <button type="submit" class="submit"><?php _e('提交评论'); ?></button></div>

         </form>
            </div>



</div>
    <?php else: ?>
    <h3><?php _e('评论已关闭'); ?> :(</h3>
    <?php endif; ?>
</div>



screencapture-beta-frostedglass-win-1527235403716.png
screencapture-beta-frostedglass-win-1527235403716.png (513.05 KiB) 查看 2561 次
回复