早上好。如何以相反的顺序显示由博主创建的博客评论:从最新到最旧。仅适用于部分帖子。谢谢
答案 0 :(得分:1)
您可以计算注释的长度并将其循环为0并将结果用于索引示例
<!-- Get the Post -->
<b:loop values='data:posts' var='post'>
<!-- It will loop from the length of comments to 0 to be used for index -->
<!-- comment.length to 0 -->
<b:loop values='data:post.comments.length " to 0"' var='i'>
<data:comments[i].author/>
<hr/>
</b:loop>
</b:loop>
答案 1 :(得分:0)
只有在使用非线程注释时才能实现。要将主题配置为使用非线程注释而不是线程注释,您必须在Blog小部件中的<b:includable id='comment_picker' var='post'>
块中进行更改。该块的代码将更改为 -
<b:includable id='comment_picker' var='post'>
<b:if cond='data:post.commentSource == 1'>
<b:include data='post' name='comments'/>
</b:if>
</b:includable>
之后,要反转评论的顺序,请找到以下b:loop
语句 -
<!-- In v2 themes, present inside <b:includable id='comments' var='post'> -->
<b:loop values='data:comments' var='comment' >
<!-- In v3 themes, present inside <b:includable id='commentList' var='comments'> -->
<b:loop values='data:post.comments' var='comment'>
将reverse
属性添加到b:loop
语句中,以便代码看起来像 -
<!-- In v2 themes-->
<b:loop values='data:comments' var='comment' reverse='1'>
<!-- In v3 themes-->
<b:loop values='data:post.comments' var='comment' reverse='1'>
要使其适用于某些帖子,您必须使用b:loop
语句(使用Post URL或PostID的条件)包装b:if
语句