最初是從Skyvee那裡看到的,一直都很希望可以在自己的blog加上留言的數字,除了可以更方便的回應留言外,亦可以令留言區更有質感。不過原本的做法只適用於普通的template上,好在Neo本身就有判斷comment數目的資料,所以要修改亦不是一件難事。
打開neo.js並找到function updateCommentsPage(page)之後加入。
if (oldestFirstOrder == 1) {
max = totalComments - 1 - (page * 10);
min = totalComments - 1 - ((page+1) * 10);
if (min < 0)
min = 0;
for (var i = max; i >= min; i--) {
disp = disp + "<span class='CommentIndex'>" + (totalComments - i) + "</span><dt class='comment-author'>" + "On " + dateString(commentDate[i], 0) + ", " + commentAuthor[i] + " said...</dt>";
if (commentAuthor[i] == blogAuthor) {
disp = disp + "<dd class='comment-body-author'>" + commentContent[i] + "</dd><br/>";
} else {
disp = disp + "<dd class='comment-body'>" + commentContent[i] + "</dd><br/>";
}
}
} else {
max = (page + 1) * 10;
if (max > totalComments)
max = totalComments;
for (var i = page * 10; i < max; i++) {
disp = disp + "<span class='CommentIndex'>" + (totalComments - i) + "</span><dt class='comment-author'>" + "On " + dateString(commentDate[i], 0) + ", " + commentAuthor[i] + " said...</dt>";
if (commentAuthor[i] == blogAuthor) {
disp = disp + "<dd class='comment-body-author'>" + commentContent[i] + "</dd><br/>";
} else {
disp = disp + "<dd class='comment-body'>" + commentContent[i] + "</dd><br/>";
}
}
}
之後再在]]></b:skin>之前加入以下CSS,請根據自己的template再自行修改。
.CommentIndex {
color:#F7ABAB;
display:block;
float:right;
font:italic bold 175%/1 'Century Gothic','Trebuchet MS';
margin:18px 0 0;
position:relative;
}
.CommentIndex:hover {
font-size:300%;
}
儲存後就可以看到每則留言都加上編號了。
發佈留言