Blog DX

Phân trang cho Blogger - Page Navigation for Blogger

15 tháng 11, 2014
Phân trang (Page Navigation) là một tiện ích được nhiều blog áp dụng nhằm tăng tính chuyên nghiệp cho trang blog của họ. Dưới đây mình sẽ hướng dẫn các bạn cách phân trang cho Blogger và một số style phân trang đẹp.

Bước 1: Thêm code JavaScript phân trang
Đăng nhập Blog ~> Vào Mẫu ~> Chỉnh sửa HTML. Thêm đoạn code sau vào trước thẻ </body>
<b:if cond='data:blog.pageType != &quot;static_page&quot;'>
<b:if cond='data:blog.pageType != &quot;item&quot;'>
<script type='text/javascript'>
    var postperpage=10;
    var numshowpage=4;
    var upPageWord ="&#171; Trước";
    var downPageWord ="Tiếp &#187;";
    var urlactivepage=location.href;
    var home_page="/";
  </script>
<script type='text/javascript'>
//<![CDATA[
eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('6 K;6 i;6 h;6 u;1x();D 1s(15){6 5=\'\';M=L(Y/2);4(M==Y-M){Y=M*2+1}A=h-M;4(A<1)A=1;e=L(15/j)+1;4(e-1==15/j)e=e-1;C=A+Y-1;4(C>e)C=e;5+="<3 7=\'1A\'>1H "+h+\' 1I \'+e+"</3>";6 1d=L(h)-1;4(h>1){4(h==2){4(i=="n"){5+=\'<3 7="1N"><a 9="\'+B+\'">\'+13+\'</a></3>\'}c{5+=\'<3 7="g"><a 9="/r/s/\'+u+\'?&b-l=\'+j+\'">\'+13+\'</a></3>\'}}c{4(i=="n"){5+=\'<3 7="g"><a 9="#" v="I(\'+1d+\');z y">\'+13+\'</a></3>\'}c{5+=\'<3 7="g"><a 9="#" v="J(\'+1d+\');z y">\'+13+\'</a></3>\'}}}4(A>1){4(i=="n"){5+=\'<3 7="g"><a 9="\'+B+\'">1</a></3>\'}c{5+=\'<3 7="g"><a 9="/r/s/\'+u+\'?&b-l=\'+j+\'">1</a></3>\'}}4(A>2){5+=\' ... \'}1t(6 k=A;k<=C;k++){4(h==k){5+=\'<3 7="1L">\'+k+\'</3>\'}c 4(k==1){4(i=="n"){5+=\'<3 7="g"><a 9="\'+B+\'">1</a></3>\'}c{5+=\'<3 7="g"><a 9="/r/s/\'+u+\'?&b-l=\'+j+\'">1</a></3>\'}}c{4(i=="n"){5+=\'<3 7="g"><a 9="#" v="I(\'+k+\');z y">\'+k+\'</a></3>\'}c{5+=\'<3 7="g"><a 9="#" v="J(\'+k+\');z y">\'+k+\'</a></3>\'}}}4(C<e-1){5+=\'...\'}4(C<e){4(i=="n"){5+=\'<3 7="g"><a 9="#" v="I(\'+e+\');z y">\'+e+\'</a></3>\'}c{5+=\'<3 7="g"><a 9="#" v="J(\'+e+\');z y">\'+e+\'</a></3>\'}}6 1b=L(h)+1;4(h<e){4(i=="n"){5+=\'<3 7="g"><a 9="#" v="I(\'+1b+\');z y">\'+1i+\'</a></3>\'}c{5+=\'<3 7="g"><a 9="#" v="J(\'+1b+\');z y">\'+1i+\'</a></3>\'}}6 H=x.1G("H");6 1e=x.1F("1E-1D");1t(6 p=0;p<H.S;p++){H[p].1u=5}4(H&&H.S>0){5=\'\'}4(1e){1e.1u=5}}D 16(U){6 V=U.V;6 1j=L(V.1C$1B.$t,10);1s(1j)}D 1x(){6 f=o;4(f.d("/r/s/")!=-1){4(f.d("?Z-b")!=-1){u=f.F(f.d("/r/s/")+14,f.d("?Z-b"))}c{u=f.F(f.d("/r/s/")+14,f.d("?&b"))}}4(f.d("?q=")==-1&&f.d(".5")==-1){4(f.d("/r/s/")==-1){i="n";4(o.d("#E=")!=-1){h=o.F(o.d("#E=")+8,o.S)}c{h=1}x.1g("<m X=\\""+B+"W/T/Q?b-l=1&P=O-N-m&12=16\\"><\\/m>")}c{i="s";4(f.d("&b-l=")==-1){j=1z}4(o.d("#E=")!=-1){h=o.F(o.d("#E=")+8,o.S)}c{h=1}x.1g(\'<m X="\'+B+\'W/T/Q/-/\'+u+\'?P=O-N-m&12=16&b-l=1" ><\\/m>\')}}}D I(G){11=(G-1)*j;K=G;6 R=x.1v(\'1w\')[0];6 w=x.1r(\'m\');w.1f=\'1o/1n\';w.1l("X",B+"W/T/Q?1k-1m="+11+"&b-l=1&P=O-N-m&12=17");R.1h(w)}D J(G){11=(G-1)*j;K=G;6 R=x.1v(\'1w\')[0];6 w=x.1r(\'m\');w.1f=\'1o/1n\';w.1l("X",B+"W/T/Q/-/"+u+"?1k-1m="+11+"&b-l=1&P=O-N-m&12=17");R.1h(w)}D 17(U){1a=U.V.1y[0];6 1q=1a.1p.$t.F(0,19)+1a.1p.$t.F(1J,1K);6 1c=1M(1q);4(i=="n"){6 18="/r?Z-b="+1c+"&b-l="+j+"#E="+K}c{6 18="/r/s/"+u+"?Z-b="+1c+"&b-l="+j+"#E="+K}1O.9=18}',62,113,'|||span|if|html|var|class||href||max|else|indexOf|maksimal|thisUrl|showpageNum|nomerhal|jenis|postperpage|jj|results|script|page|urlactivepage|||search|label||lblname1|onclick|newInclude|document|false|return|mulai|home_page|akhir|function|PageNo|substring|numberpage|pageArea|redirectpage|redirectlabel|nopage|parseInt|nomerkiri|in|json|alt|summary|nBody|length|posts|root|feed|feeds|src|numshowpage|updated||jsonstart|callback|upPageWord||banyakdata|hitungtotaldata|finddatepost|alamat||post|nextnomer|timestamp|prevnomer|blogPager|type|write|appendChild|downPageWord|totaldata|start|setAttribute|index|javascript|text|published|timestamp1|createElement|loophalaman|for|innerHTML|getElementsByTagName|head|halamanblogger|entry|20|showpageOf|totalResults|openSearch|pager|blog|getElementById|getElementsByName|Page|of|23|29|showpagePoint|encodeURIComponent|showpage|location'.split('|'),0,{}))
//]]>
</script>
</b:if>
</b:if>

postperpage=10; số bài viết hiển thị trên mỗi trang
numshowpage=4; số nút hiển thị trên thanh Navigation
Có thể thay &#171; Trước và Tiếp &#187; thành từ bạn muốn


Bước 2: Một số style đẹp
Thêm 1 trong các đoạn code css sau vào trước thẻ ]]></b:skin> rồi Lưu Mẫu lại

Kiểu 1
#blog-pager-older-link a,#blog-pager-newer-link a,a.home-link{width:80px;text-align:center;display:inline-block;color:#fff;font:bold 12px Arial;text-transform:none;margin:0;padding:5px 5px;background:#555;border:1px solid #111}
.blog-pager,#blog-pager{clear:both;font:bold 12px Arial;text-align:center;padding:15px 10px}
.showpageNum a,.showpage a{background:#fff;text-decoration:none;white-space:nowrap;color:#222;margin:10px 3px;padding:5px 10px;border:1px solid #999}
.showpageNum a:hover,.showpage a:hover{color:#fff;text-decoration:none;background-color:#444;border:1px solid #000}
.showpageOf{display:none;margin:0}
.showpagePoint{color:#fff;text-decoration:none;background-color:#444;font-size:12px;margin:10px 3px;padding:5px 10px;border:1px solid #000}

Kiểu 2
.blog-pager,#blog-pager{font-size:normal}
.showpageArea{font-family:verdana,arial,helvetica;color:#000;font-size:11px;margin:10px}
.showpageArea a{color:#000;text-shadow:0 1px 2px #fff;font-weight:bold}
.showpageNum a{color:#000;padding:3px 8px;margin:0 4px;text-decoration:none;border:1px solid #999;-webkit-border-radius:3px;-moz-border-radius:3px;background:#f8b5a4 url(https://lh4.googleusercontent.com/-8bahjrCLLzU/UU8DsQt00NI/AAAAAAAATyo/MiETBQ-qRQ0/s90/pagenav1.png) 0 -60px repeat-x}
.showpageNum a:hover{border:1px solid #888;background:#f7cac9 url(https://lh4.googleusercontent.com/-8bahjrCLLzU/UU8DsQt00NI/AAAAAAAATyo/MiETBQ-qRQ0/s90/pagenav1.png) 0 -30px repeat-x}.showpageOf{margin:0 4px 0 0}
.showpagePoint{color:#666;padding:3px 8px;margin:2px;font-weight:bold;-webkit-border-radius:3px;-moz-border-radius:3px;border:1px solid #999;background:#f2f0f0 url(https://lh4.googleusercontent.com/-8bahjrCLLzU/UU8DsQt00NI/AAAAAAAATyo/MiETBQ-qRQ0/s90/pagenav1.png) 0 -5px repeat-x;text-decoration:none}
Bạn nào bị không hiện đủ bề rộng nút phân trang thì thay #blog-pager{font-size:normal} thành #blog-pager{font-size:normal;overflow:visible;} (Áp dụng từ Kiểu 2 đến Kiểu 11)

Kiểu 3
.blog-pager,#blog-pager{font-size:normal}.showpageArea{font-family:verdana,arial,helvetica;color:#000;font-size:11px;margin:10px}.showpageArea a{color:#000;text-shadow:0 1px 2px #fff;font-weight:normal}.showpageNum a{padding:3px 8px;margin:0 4px;text-decoration:none;border:1px solid #999;-webkit-border-radius:3px;-moz-border-radius:3px;background:#b1a7c3 url(https://lh4.googleusercontent.com/-zlDnvRF6vkc/UU8Dsbi6KUI/AAAAAAAATys/MuyxQSXFJAE/s90/pagenav2.png) 0 -60px repeat-x}.showpageNum a:hover{border:1px solid #888;background:#f7b36a url(https://lh4.googleusercontent.com/-zlDnvRF6vkc/UU8Dsbi6KUI/AAAAAAAATys/MuyxQSXFJAE/s90/pagenav2.png) 0 -30px repeat-x}.showpageOf{margin:0 4px 0 0}.showpagePoint{color:#444;text-shadow:0 1px 2px #333;padding:3px 8px;margin:2px;font-weight:700;-webkit-border-radius:3px;-moz-border-radius:3px;border:1px solid #999;background:#f7d5b0 url(https://lh4.googleusercontent.com/-zlDnvRF6vkc/UU8Dsbi6KUI/AAAAAAAATys/MuyxQSXFJAE/s90/pagenav2.png) 0 0 repeat-x;text-decoration:none}

Kiểu 4
.blog-pager,#blog-pager{font-size:normal}.showpageArea{font-family:verdana,arial,helvetica;color:#000;font-size:11px;margin:10px}.showpageArea a{color:#000;text-shadow:0 1px 2px #fff;font-weight:normal}.showpageNum a{padding:3px 8px;margin:0 4px;text-decoration:none;border-bottom:3px solid #fe9a2e;background:#f7f8e0}.showpageNum a:hover{border-bottom:3px solid #df01d7;background:#f6cee3}.showpageOf{margin:0 4px 0 0}.showpagePoint{color:#333;text-shadow:0 1px 2px #333;padding:3px 8px;margin:2px;font-weight:700;border-bottom:3px solid #fe9a2e;background:#f8e0f7;text-decoration:none}

Kiểu 5
.blog-pager,#blog-pager{font-size:normal}.showpageArea{font-family:verdana,arial,helvetica;color:#000;font-size:11px;margin:10px}.showpageArea a{color:#000;text-shadow:0 1px 2px #fff;font-weight:normal}.showpageNum a{padding:2px 8px;margin:0 4px;text-decoration:none;border-bottom:2px solid #5fb404;border-top:2px solid #5fb404;background:#effbf5}.showpageNum a:hover{border-bottom:2px solid #df01d7;background:#a9f5f2;border-top:2px solid #df01d7}.showpageOf{margin:0 4px 0 0}.showpagePoint{color:#fff;text-shadow:0 1px 2px #333;padding:2px 8px;margin:2px;font-weight:700;border-bottom:2px solid #5e610b;border-top:2px solid #5e610b;background:#5e610b;text-decoration:none}

Kiểu 6
.blog-pager,#blog-pager{font-size:normal}.showpageArea{font-family:verdana,arial,helvetica;color:#000;font-size:11px;margin:10px}.showpageArea a{color:#000;text-shadow:0 1px 2px #fff;font-weight:700}.showpageNum a{padding:3px 8px;margin:0 4px;text-decoration:none;border:1px solid #999;-webkit-border-radius:3px;-moz-border-radius:3px;background:#ddd url(https://lh4.googleusercontent.com/-Mr9smxMcLw4/UU8F_y4J7-I/AAAAAAAATzA/1sDDrLx7JiQ/s75/wp1.jpg) 0 -50px repeat-x}.showpageNum a:hover{border:1px solid #888;background:#ccc url(https://lh4.googleusercontent.com/-Mr9smxMcLw4/UU8F_y4J7-I/AAAAAAAATzA/1sDDrLx7JiQ/s75/wp1.jpg) 0 -25px repeat-x}.showpageOf{margin:0 4px 0 0}.showpagePoint{color:#fff;text-shadow:0 1px 2px #333;padding:3px 8px;margin:2px;font-weight:700;-webkit-border-radius:3px;-moz-border-radius:3px;border:1px solid #999;background:#666 url(https://lh4.googleusercontent.com/-Mr9smxMcLw4/UU8F_y4J7-I/AAAAAAAATzA/1sDDrLx7JiQ/s75/wp1.jpg) 0 0 repeat-x;text-decoration:none}

Kiểu 7
.blog-pager,#blog-pager{font-size:normal}.showpageArea{font-family:verdana,arial,helvetica;color:#000;font-size:11px;margin:10px}.showpageArea a{color:#000;text-shadow:0 1px 2px #fff;font-weight:700}.showpageNum a{padding:3px 8px;margin:0 4px;text-decoration:none;border:1px solid #919106;-webkit-border-radius:3px;-moz-border-radius:3px;background:#ddd url(https://lh5.googleusercontent.com/-pJP_vbUPc1o/UU8F_-YKXsI/AAAAAAAATzE/znj8c9Srky8/s75/wp2.jpg) 0 -50px repeat-x}.showpageNum a:hover{border:1px solid #aeae0a;background:#ccc url(https://lh5.googleusercontent.com/-pJP_vbUPc1o/UU8F_-YKXsI/AAAAAAAATzE/znj8c9Srky8/s75/wp2.jpg) 0 -25px repeat-x}.showpageOf{margin:0 5px 0 0}.showpagePoint{color:#fff;text-shadow:0 1px 2px #333;padding:3px 8px;margin:2px;font-weight:bold;-webkit-border-radius:3px;-moz-border-radius:3px;border:1px solid #919106;background:#666 url(https://lh5.googleusercontent.com/-pJP_vbUPc1o/UU8F_-YKXsI/AAAAAAAATzE/znj8c9Srky8/s75/wp2.jpg) 0 0 repeat-x;text-decoration:none}

Kiểu 8
.blog-pager,#blog-pager{font-size:normal}.showpageArea{font-family:verdana,arial,helvetica;color:#000;font-size:11px;margin:10px}.showpageArea a{color:#fff}.showpageNum a{padding:3px 8px;margin:0 4px;text-decoration:none;background:#363636 url(https://lh6.googleusercontent.com/-GzA3JzM7NwU/UU8F_6RNuFI/AAAAAAAATzM/kdh6xftfRzA/s75/wp3.jpg) 0 -25px repeat-x}.showpageNum a:hover{background:#044697 url(https://lh6.googleusercontent.com/-GzA3JzM7NwU/UU8F_6RNuFI/AAAAAAAATzM/kdh6xftfRzA/s75/wp3.jpg) 0 -50px repeat-x}.showpagePoint{color:#fff;padding:3px 8px;margin:2px;font-weight:700;background:#e30000 url(https://lh6.googleusercontent.com/-GzA3JzM7NwU/UU8F_6RNuFI/AAAAAAAATzM/kdh6xftfRzA/s75/wp3.jpg) 0 0 repeat-x;text-decoration:none}.showpageOf{margin:0 5px 0 0}

Kiểu 9
.blog-pager,#blog-pager{font-size:normal}.showpageArea{font-family:verdana,arial,helvetica;color:#000;font-size:11px;margin:10px}.showpageArea a{color:#fff}.showpageNum a{padding:3px 8px;margin:0 4px;text-decoration:none;border-top:2px solid #000;border-left:1px solid #000;border-right:1px solid #000;border-bottom:1px solid #000;background:#666 url(https://lh5.googleusercontent.com/-EBKl8z_n2Gk/UU8GAAztmNI/AAAAAAAATzU/Eggqyx00ppU/s75/wp4.jpg) 0 -25px repeat-x}.showpageNum a:hover{border-top:1px solid #999;border-left:1px solid #999;border-right:1px solid #999;border-bottom:2px solid #999;background:#999 url(https://lh5.googleusercontent.com/-EBKl8z_n2Gk/UU8GAAztmNI/AAAAAAAATzU/Eggqyx00ppU/s75/wp4.jpg) 0 -50px repeat-x}.showpagePoint{color:#fff;padding:3px 8px;margin:2px;font-weight:700;border-top:2px solid #000;border-left:1px solid #000;border-right:1px solid #000;border-bottom:1px solid #000;background:#000 url(https://lh5.googleusercontent.com/-EBKl8z_n2Gk/UU8GAAztmNI/AAAAAAAATzU/Eggqyx00ppU/s75/wp4.jpg) 0 0 repeat-x;text-decoration:none}.showpageOf{margin:0 5px 0 0}

Kiểu 10
.blog-pager,#blog-pager{font-size:normal}.showpageArea{font-family:verdana,arial,helvetica;color:#000;font-size:11px;margin:10px}.showpageArea a{color:#fff}.showpageNum a{padding:3px 8px;margin:0 4px;text-decoration:none;background:#333 url(https://lh6.googleusercontent.com/-WIJli17iGS0/UU8GAWbdvzI/AAAAAAAATzY/6kf9RnV63F4/s75/wp5.jpg) 0 -50px repeat-x}.showpageNum a:hover{background:#666 url(https://lh6.googleusercontent.com/-WIJli17iGS0/UU8GAWbdvzI/AAAAAAAATzY/6kf9RnV63F4/s75/wp5.jpg) 0 -25px repeat-x}.showpagePoint{color:#fff;padding:3px 8px;margin:2px;font-weight:700;background:#06a2b9 url(https://lh6.googleusercontent.com/-WIJli17iGS0/UU8GAWbdvzI/AAAAAAAATzY/6kf9RnV63F4/s75/wp5.jpg) 0 0 repeat-x;text-decoration:none}.showpageOf{margin:0 5px 0 0}

Kiểu 11
.blog-pager,#blog-pager{font-size:normal}.showpageArea{font-family:verdana,arial,helvetica;color:#fff;font-size:11px;margin:10px;padding:8px 20px;background:#333}.showpageArea a{color:#fff}.showpageNum a{padding:3px 8px;margin:0 4px;text-decoration:none;background:#666}.showpageNum a:hover{background:#aeb404}.showpagePoint{color:#fff;padding:3px 8px;margin:2px;font-weight:700;background:#da6100;text-decoration:none}.showpageOf{margin:0 5px 0 0}

Không có nhận xét nào:

Đăng nhận xét