
Membuat Recent Post With Navigation
Mungkin tulisan ini kali pertama ditahun 2013, ternyata sudah lama gak update blog disebabkan dengan numpuknya kerjaan, ini aja Admin sempatkan walau terkesan buru-buru. Langsung saja pada pembahasan tutorial selanjutnya yakni pembahasan cara membuat recent post pada blog yang dilengkapi dengan navigasi halaman.
Tips ini bisa Anda terapkan dalam blog baik pada gadget/widget ataupun langsung diterapkan pada template blog, tergantung dari Anda sendiri mau diletakkan dimana. Yang pasti hasil yang didapatkan akan mengoptimasi blog Anda pada pagerank.
Pemasangannya dan penerapnnya :
CSS
Biasanya kode ini dipasang di atas ]]></b:skin>
atau </style>
pada template Anda.
1code-line:1-12code-line:1-23code-line:1-34code-line:1-45code-line:1-56code-line:1-67code-line:1-78code-line:1-89code-line:1-910code-line:1-1011code-line:1-1112code-line:1-1213code-line:1-1314code-line:1-1415code-line:1-1516code-line:1-1617code-line:1-1718code-line:1-1819code-line:1-1920code-line:1-2021code-line:1-2122code-line:1-2223code-line:1-2324code-line:1-2425code-line:1-2526code-line:1-2627code-line:1-2728code-line:1-2829code-line:1-2930code-line:1-3031code-line:1-3132code-line:1-3233code-line:1-3334code-line:1-3435code-line:1-3536code-line:1-3637code-line:1-3738code-line:1-3839code-line:1-3940code-line:1-4041code-line:1-4142code-line:1-4243code-line:1-4344code-line:1-4445code-line:1-4546code-line:1-4647code-line:1-4748code-line:1-4849code-line:1-4950code-line:1-5051code-line:1-5152code-line:1-5253code-line:1-5354code-line:1-5455code-line:1-5556code-line:1-5657code-line:1-5758code-line:1-5859code-line:1-5960code-line:1-6061code-line:1-6162code-line:1-6263code-line:1-6364code-line:1-6465code-line:1-6566code-line:1-6667code-line:1-6768code-line:1-6869code-line:1-6970code-line:1-7071code-line:1-7172code-line:1-7273code-line:1-7374code-line:1-7475code-line:1-7576code-line:1-7677code-line:1-7778code-line:1-7879code-line:1-7980code-line:1-8081code-line:1-8182code-line:1-8283code-line:1-8384code-line:1-8485code-line:1-8586code-line:1-8687code-line:1-8788code-line:1-8889code-line:1-8990code-line:1-9091code-line:1-9192code-line:1-9293code-line:1-9394code-line:1-9495code-line:1-9596code-line:1-9697code-line:1-9798code-line:1-9899code-line:1-99100code-line:1-100#itp-recentss {
border:1px solid #585858;
width:100%;
margin:0 auto;
}
#recentss {
margin:0;
}
.itp-elemen {
border:1px solid #ccc;
margin:5px 0;
padding:5px;
height:79px;
}
.itp-elemen img {
background:#999;
padding:4px;
float:left;
height:70px;
margin-right:8px;
width:70px;
}
.itp-elemen h6,
.itp-elemen h6 a {
font-size:12px!important;
font-weight:700!important;
margin:0;
color:#111;
}
.itp-elemen:hover {
background-color:#c3c3c3;
}
.itp-elemen p {
font:14px Tahoma;
text-align:justify;
color:#555;
line-height:14px;
margin:5px 0;
}
#itp-loading {
color:#888;
font-family:Tahoma;
font-size:100px;
letter-spacing:-10px;
text-align:center;
text-shadow:-5px 0 1px #444;
background:#141414 url(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi4fUYWKETHs9ls6I1fGYuFZ14jTQIhh04DVkJNnO2RO4UeNPsPcbc6t7eph0Y5dPO2Af1_PoF5NjQKl9_N7CYIfqSWoqkvkzfYzlTIvX4V9RAzap9MuISgz0MqQlcSXmT_U8tjYgYK5uk/s1600/loading.gif) no-repeat 50% 50%;
height:470px;
border:1px solid #c3c3c3;
}
#itp-navigationfeed {
border:1px solid #c3c3c3;
color:#bbb;
font-family:Verdana;
font-size:12px;
text-align:center;
margin:0;
}
#itp-navigationfeed:hover {
background-color:#c3c3c3;
}
#itp-navigationfeed a {
color:#141414!important;
font-family:Tahoma!important;
font-size:12px!important;
font-weight:400!important;
display:block;
padding:5px 10px;
}
#itp-navigationfeed span {
padding:5px 10px;
}
#itp-navigationfeed .next {
float:right;
}
#itp-navigationfeed .previous {
float:left;
}
#itp-navigationfeed .home {
text-align:center;
}
#itp-navigationfeed a:hover,
#itp-navigationfeed span.noactived {
color:transparant!important;
}
JavaScript
Pasang diatas </head>
1code-line:2-12code-line:2-23code-line:2-34code-line:2-45code-line:2-56code-line:2-67code-line:2-78code-line:2-89code-line:2-910code-line:2-1011code-line:2-1112code-line:2-1213code-line:2-1314code-line:2-1415code-line:2-1516code-line:2-1617code-line:2-1718code-line:2-1819code-line:2-1920code-line:2-2021code-line:2-2122code-line:2-2223code-line:2-2324code-line:2-2425code-line:2-2526code-line:2-2627code-line:2-2728code-line:2-2829code-line:2-2930code-line:2-3031code-line:2-3132code-line:2-3233code-line:2-3334code-line:2-3435code-line:2-3536code-line:2-3637code-line:2-3738code-line:2-3839code-line:2-3940code-line:2-4041code-line:2-4142code-line:2-4243code-line:2-4344code-line:2-4445code-line:2-4546code-line:2-4647code-line:2-4748code-line:2-4849code-line:2-4950code-line:2-5051code-line:2-5152code-line:2-5253code-line:2-5354code-line:2-5455code-line:2-5556code-line:2-5657code-line:2-5758code-line:2-5859code-line:2-5960code-line:2-6061code-line:2-6162code-line:2-6263code-line:2-6364code-line:2-6465code-line:2-6566code-line:2-6667code-line:2-6768code-line:2-6869code-line:2-6970code-line:2-7071code-line:2-7172code-line:2-7273code-line:2-7374code-line:2-7475code-line:2-7576code-line:2-7677code-line:2-7778code-line:2-7879code-line:2-7980code-line:2-8081code-line:2-8182code-line:2-8283code-line:2-8384code-line:2-8485code-line:2-8586code-line:2-8687code-line:2-8788code-line:2-8889code-line:2-8990code-line:2-9091code-line:2-9192code-line:2-9293code-line:2-9394code-line:2-9495code-line:2-9596code-line:2-9697code-line:2-9798code-line:2-9899code-line:2-99100code-line:2-100101code-line:2-101102code-line:2-102103code-line:2-103104code-line:2-104105code-line:2-105106code-line:2-106107code-line:2-107108code-line:2-108109code-line:2-109110code-line:2-110<script type='text/javascript'>
//<![CDATA[
var numfeed = 5;
var startfeed = 0;
var urlblog = "https://nama-blog-anda.blogspot.com/";
var charac = 150;
var urlprevious, urlnext;
function idtutorplufeed(idtutor,mantap){
var showfeed = idtutor.split("<");
for(var i=0;i<showfeed.length;i++){
if(showfeed[i].indexOf(">")!=-1){
showfeed[i] = showfeed[i].substring(showfeed[i].indexOf(">")+1,showfeed[i].length);
}
}
showfeed = showfeed.join("");
showfeed = showfeed.substring(0,mantap-1);
return showfeed;
}
function showrecentss(json) {
var entry, posttitle, posturl, postimg, postcontent;
var showblogfeed = "";
urlprevious = "";
urlnext = "";
for (var k = 0; k < json.feed.link.length; k++) {
if (json.feed.link[k].rel == 'previous') {
urlprevious = json.feed.link[k].href;
}
if (json.feed.link[k].rel == 'next') {
urlnext = json.feed.link[k].href;
}
}
for (var i = 0; i < numfeed; i++) {
if (i == json.feed.entry.length) { break; }
entry = json.feed.entry[i];
posttitle = entry.title.$t;
for (var k = 0; k < entry.link.length; k++) {
if (entry.link[k].rel == 'alternate') {
posturl = entry.link[k].href;
break;
}
}
if ("content" in entry) {
postcontent = entry.content.$t;
} else if ("summary" in entry) {
postcontent = entry.summary.$t;
} else {
postcontent = "";
}
if ("media$thumbnail" in entry) {
postimg = entry.media$thumbnail.url;
} else {
postimg = "https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh4X1mC_cv9I5m8atdIBlil6DQQN_MzrO4q6XvZJT5iW4SxDv-Bx8vc-_bwCAiTldS_UBJKbwBnFOo-gmKqBYc05HWotK6M3GVvA8QYNUShu-DZpnILiWhyZ4XA8G5fzchYu-oOn30oQFA/s1600/idtp.png";
}
showblogfeed += "<div class='itp-elemen'>";
showblogfeed += "<a href='" + posturl + "' target='_blank'><img src='" + postimg + "' /></a>";
showblogfeed += "<h6><a href='" + posturl + "'>" + posttitle + "</a></h6>";
showblogfeed += "<p>" + idtutorplufeed(postcontent,charac) + "...</p>";
showblogfeed += "</div>";
}
document.getElementById("recentss").innerHTML = showblogfeed;
showblogfeed = "";
if(urlprevious) {
showblogfeed += "<a href='javascript:navigationfeed(-1);' class='previous'>◄ Previous</a>";
} else {
showblogfeed += "<span class='noactived previous'>◄ Previous</span>";
}
if(urlnext) {
showblogfeed += "<a href='javascript:navigationfeed(1);' class='next'>Next ►</a>";
} else {
showblogfeed += "<span class='noactived next'>Next ►</span>";
}
showblogfeed += "<a href='javascript:navigationfeed(0);' class='home'>Home</a>";
document.getElementById("itp-navigationfeed").innerHTML = showblogfeed;
}
function navigationfeed(url){
var p, parameter;
if(url==-1) {
p = urlprevious.indexOf("?");
parameter = urlprevious.substring(p);
} else if (url==1) {
p = urlnext.indexOf("?");
parameter = urlnext.substring(p);
} else {
parameter = "?start-index=1&max-results=" + numfeed + "&orderby=published&alt=json-in-script"
}
parameter += "&callback=showrecentss";
incluirscript(parameter);
}
function incluirscript(parameter) {
if(startfeed==1) {removerscript();}
document.getElementById("recentss").innerHTML = "<div id='itp-loading'></div>";
document.getElementById("itp-navigationfeed").innerHTML = "";
var archievefeed = urlblog + "/feeds/posts/default"+ parameter;
var recentss = document.createElement('script');
recentss.setAttribute('type', 'text/javascript');
recentss.setAttribute('src', archievefeed);
recentss.setAttribute('id', 'ITPLABEL');
document.getElementsByTagName('head')[0].appendChild(recentss);
startfeed = 1;
}
function removerscript() {
var elemen = document.getElementById("ITPLABEL");
var parent = elemen.parentNode;
parent.removeChild(elemen);
}
onload=function() { navigationfeed(0); }
//]]>
</script>
Penerapan HTML
1code-line:3-12code-line:3-2<div id="recentss"></div>
<div id="itp-navigationfeed"></div>
var numfeed = 5; ⇒ Jumlah label yang ditampilkan
var urlblog = "https://nama-blog-anda.blogspot.com/"; ⇒ Nama blog Anda.
var charac = 150; ⇒ Banyaknya karakter.
Semoga bermanfaat.
2 comments
saya coba dulu