GoldPage1

logo

Tin đề xuất

Sự kiện tiêu biểu

Tạo Read more ... cho Blog

(Blogtamsu) - Để blog bạn chạy nhanh hơn thì cần phải phân chia bài viết của mình ra ,như vậy làm blog load nhanh hơn Bước 1 :Bạn chèn code 1 này vào trư....

https://nhipsong24vn.blogspot.com/ - Chuyên nhận rip, thiết kế, cung cấp: Template blogspot, template blogger chuẩn SEO, Tối ưu website, tích hợp tin tức, giỏ hàng cho blogger bán hàng...

Để blog bạn chạy nhanh hơn thì cần phải phân chia bài viết của mình ra ,như vậy làm blog load nhanh hơn
Bước 1:Bạn chèn code 1 này vào trước thẻ </head>

<script src='summary-posts.js' type='text/javascript'/>
<script type='text/javascript'>
var thumbnail_mode = "float" ;
summary_noimg = 250;
summary_img = 250;
img_thumb_height = 120;
img_thumb_width = 120;
</script>


Trong đó 'summary-posts.js' có nội dung như sau: (mở notepad lên copy code này vào và lưu lại với tên 'summary-posts.js' ,sau đó Upload lên host để lấy Link )
function removeHtmlTag(strx,chop){
if(strx.indexOf("<")!=-1)
{
var s = strx.split("<");
for(var i=0;i<s.length;i++){
if(s[i].indexOf(">")!=-1){
s[i] = s[i].substring(s[i].indexOf(">")+1,s[i].length);
}
}
strx = s.join("");
}
chop = (chop < strx.length-1) ? chop : strx.length-2;
while(strx.charAt(chop-1)!=' ' && strx.indexOf(' ',chop)!=-1) chop++;
strx = strx.substring(0,chop-1);
return strx+'...';
}
function createSummaryAndThumb(pID){
var div = document.getElementById(pID);
var imgtag = "";
var img = div.getElementsByTagName("img");
var summ = summary_noimg;
if(img.length>=1) {
if(thumbnail_mode == "float") {
imgtag = '<img src="'+img[0].src+'" class="post-thumbnail" width="'+img_thumb_width+'" height="'+img_thumb_height+'" alt=""/>';
summ = summary_img;
} else {
imgtag = '<img class="aligncenter" style="max-width:'+img_thumb_width+'px; max-height:'+img_thumb_height+'px;" src="'+img[0].src+'" alt=""/>';
summ = summary_img;
}
}
var summary = imgtag + '<div>' + removeHtmlTag(div.innerHTML,summ) + '</div>';
div.innerHTML = summary;
}


Hoặc code 2 này:
<script type='text/javascript'>
summary_noimg = 430;
summary_img = 340;
img_thumb_height = 100;
img_thumb_width = 120;
</script>
<script src='summary-post-v20-test.js' type='text/javascript'></script>

Và 'summary-post-v20-test.js' có nội dung: (mở notepad lên copy code này vào và lưu lại với tên 'summary-post-v20-test.js' ,sau đó Upload lên host để lấy Link )

/******************************************
Auto-readmore link script, version 2.0 (for blogspot)



********************************************/
function removeHtmlTag(strx,chop){
if(strx.indexOf("<")!=-1)
{
var s = strx.split("<");
for(var i=0;i<s.length;i++){
if(s[i].indexOf(">")!=-1){
s[i] = s[i].substring(s[i].indexOf(">")+1,s[i].length);
}
}
strx = s.join("");
}
chop = (chop < strx.length-1) ? chop : strx.length-2;
while(strx.charAt(chop-1)!=' ' && strx.indexOf(' ',chop)!=-1) chop++;
strx = strx.substring(0,chop-1);
return strx+'...';
}
function createSummaryAndThumb(pID){
var div = document.getElementById(pID);
var imgtag = "";
var img = div.getElementsByTagName("img");
var summ = summary_noimg;
if(img.length>=1) {
imgtag = '<span style="float:left; padding:0px 10px 5px 0px;"><img src="'+img[0].src+'" width="'+img_thumb_width+'px" height="'+img_thumb_height+'px"/></span>';
summ = summary_img;
}
var summary = imgtag + '<div>' + removeHtmlTag(div.innerHTML,summ) + '</div>';
div.innerHTML = summary;
}


Bạn phải lưu cái 'summary-posts.js' lên host rồi lấy link vd host google
Bước 2: theo bạn tìm đến thẻ <data:post.body/>
nhớ mở rộng tiện ích để xem đầy đủ
Sau khi tìm thấy bạn thay thế nó bằng code sau


<b:if cond='data:blog.pageType != "item"'>
<div expr:id='"summary-" + data:post.id'><data:post.body/></div>
<script type='text/javascript'>createSummaryAndThumb("summary-<data:post.id/>");</script>
<a class='readmore' expr:href='data:post.url'>Read more »</a>
</b:if>
<b:if cond='data:blog.pageType == "item"'><data:post.body/></b:if>

Lưu ý bạn chỉ được chọn 1 trong 2 code ở bước 1 thôi ,sau đó thực hiện tiếp bước2
Với cách làm này bạn Blog bạn sẽ trông rất chuyên nghiệp đấy
Chúc các bạn thành công !

Xem thêm>>

Xem thêm>>

Đóng liên hệ [x]
hotline0918