News Ticker

Menu

Video Of Day

Bài viết phổ biến

Tạo số đếm thứ tự cho các comment

Giới thiệu: Tạo số đếm thứ tự cho các comment trên blog. Comment đầu tiên sẽ mang số 1, kế đến là số 2, và cứ thế đếm tiếp tục. Việc này sẽ giúp dễ theo dõi và tìm lại comment cũ hơn, vì chỉ cần nhớ số là dễ dàng tìm được.

Dùng thủ thuật này sẽ không hiển thị được tốt thủ thuật 
Tạo màu nền riêng biệt cho các comment – Nghĩa là sẽ không hiển thị được nhiều hình nền xen kẽ nhau, mà chỉ hiển thị được một màu nền đầu tiên.

CÁCH THỰC HIỆN 

1. Đăng nhập 
Blogger
2. Chọn: Mẫu > Chỉnh sữa HTML 

3. Chèn script.

Bước 1: Tìm dòng 
<b:loop values='data:post.comments' var='comment'>

- Thay thế nó bằng đoạn code sau:
<!-- Tạo số đếm thứ tự cho các comment (1)-->
<script type='text/javascript'>var CommentsCounter=0;</script>
<b:loop values='data:post.comments' var='comment'>
<div class='' expr:id='data:comment.id'>

Bước 2: Tiếp tục tìm dòng 
<data:commentPostedByMsg/>

- Thêm vào sau nó đoạn code sau:
<!-- Tạo số đếm thứ tự cho các comment (2)-->
<span class='comment-number'>
<a expr:href='"#comment-" + data:comment.id' title='Comment Link'>
<script type='text/javascript'>
CommentsCounter=CommentsCounter+1;
document.write(CommentsCounter)
</script>
</a>
</span>


Bước 3: Kế đến kéo xuống dưới một chút sẽ thấy đoạn code:
<dd class='comment-footer'>
<span class='comment-timestamp'>
<a expr:href='data:comment.url' title='comment permalink'>
<data:comment.timestamp/>
</a>
<b:include data='comment' name='commentDeleteIcon'/>
</span>
</dd>

- Thêm vào sau đoạn code trên thẻ đóng 
</div> 


Bước 4: Tìm dòng 
]]></b:skin>

- Thêm vào trước nó đoạn code CSS sau:
/*Tạo số đếm thứ tự cho các comment (3)*/
.comment-number {
float: right;
background: url(LINK_HÌNH) no-repeat; /*Hình trang trí cho số đếm comment. Không dùng hình thì bỏ qua*/
margin-right: 4px; /*Vị trí số đếm comment*/
margin-top: 0px; /*Vị trí số đếm comment*/
text-align: center;
font-family: Verdana;
font-size: 12px;
font-weight: bold;
}
 
.comment-number a:link, .comment-number a:visited {
color: #ADADAD !important; /*Màu số đếm comment*/
text-decoration: none !important;
}
.comment-number a:hover, .comment-number a:active {
color: #FF9933 !important;
text-decoration: none !important;
}


Bước 5: Save template. (Lưu mẫu)

Share This:

Jillur Rahman

I'm Jillur Rahman. A full time web designer. I enjoy to make modern template. I love create blogger template and write about web design, blogger. Now I'm working with Themeforest. You can buy our templates from Themeforest.

No Comment to " Tạo số đếm thứ tự cho các comment "

  • To add an Emoticons Show Icons
  • To add code Use [pre]code here[/pre]
  • To add an Image Use [img]IMAGE-URL-HERE[/img]
  • To add Youtube video just paste a video link like http://www.youtube.com/watch?v=0x_gnfpL3RM