2cara membuat post terkait
English Version:
Silakan pilih salah satu tutorials di bawah ini:
Langkah pertama === > >
- Login account Blogger.com > > Tata Letak > > Edit Html
- Centang expand widget template
- Cari kode seperti ini
- Lalu copy paste kode di ini tepat di bawah kode di atas
- Bila sudah jangan lupa save dan lihat hasilnya
< p > < data:post.body/ > < /p > atau < data:post.body/ > sama saja
< div class='similiar' >
< div class='widget-content' >
< h3 > post terkait < /h3 > < div id='data2010'/ > < br/ > < br/ >
< script type='text/javascript' >
var homeUrl3 = "< data:blog.homepageUrl/ >";
var maxNumberOfPostsPerLabel = 4;
var maxNumberOfLabels = 10;
maxNumberOfPostsPerLabel = 100;
maxNumberOfLabels = 3;
fungsi listEntries10 (json) (
var ul = document.createElement ( 'ul');
var maxPosts = (json.feed.entry.length < =
maxNumberOfPostsPerLabel)?
json.feed.entry.length:
maxNumberOfPostsPerLabel;
for (var i = 0; i < maxPosts; i + +) (
var entry = json.feed.entry [i];
var alturl;
for (var k = 0; k < entry.link.length; k + +) (
if (entry.link [k]. rel == 'alternate') (
alturl = entry.link [k]. href;
break;
)
)
var li = document.createElement ( 'li');
var a = document.createElement ( 'a');
a.href = alturl;
if (a.href! = location.href) (
var txt = document.createTextNode (entry.title. $
t);
a.appendChild (txt);
li.appendChild (a);
ul.appendChild (li);
)
)
for (var l = 0; l < json.feed.link.length; l + +) (
if (json.feed.link [l]. rel == 'alternate') (
var mentah = json.feed.link [l]. href;
var label = raw.substr (homeUrl3.length +13);
var k;
for (k = 0; k < 20; k + +) label = label.replace ( "%
20", "");
var txt = document.createTextNode (label);
var h = document.createElement ( 'b');
h.appendChild (txt);
var div1 = document.createElement ( 'div');
div1.appendChild (h);
div1.appendChild (ul);
document.getElementById ( 'data2010').
appendChild (div1);
)
)
)
fungsi search10 (query, label) (
var script = document.createElement ( 'script');
script.setAttribute ( 'src', query + 'feeds/posts/
default/- /'
+ Label +
'? Alt = json-in-script & callback = listEntries10');
script.setAttribute ( 'type', 'text / javascript');
document.documentElement.firstChild.appendChild
(script);
)
var labelArray = new Array ();
var numLabel = 0;
< b:loop values='data:posts' var='post' >
values='data:post.labels' < b:loop var='label' >
textLabel = "< data:label.name/ >";
var test = 0;
for (var i = 0; i < labelArray.length; i + +)
if (labelArray [i] == textLabel) test = 1;
if (test == 0) (
labelArray.push (textLabel);
var maxLabels = (labelArray.length < =
maxNumberOfLabels)?
labelArray.length: maxNumberOfLabels;
if (numLabel < maxLabels) (
search10 (homeUrl3, textLabel);
numLabel + +;
)
)
< /b: loop >
< /b: loop >
< /script >
< /div >
< /div >
< /b: if >
Langkah yang kedua == > >
- Cari dan paste kode di bawah ini tepat di atas kode < /head >
- Kemudian di save terlebih dahulu
- Cari lagi seperti kode ini
- tambahkan kode di bawah ini tepat di atas < /b:loop >
< /b:if > - Dan letakan kode ini di tepat di bawah kode < /b:loop >
< /b:if > - Simpan template dan lihat perubahannya
// < ![CDATA[
var relatedTitles = new Array();
var relatedTitlesNum = 0;
var relatedUrls = new Array();
function related_results_labels(json) {
for (var i = 0; i < json.feed.entry.length; i++) {
var entry = json.feed.entry[i];
relatedTitles[relatedTitlesNum] = entry.title.$t;
for (var k = 0; k < entry.link.length; k++) {
if (entry.link[k].rel == 'alternate') {
relatedUrls[relatedTitlesNum] = entry.link[k].href;
relatedTitlesNum++;
break;
}
}
}
}
function removeRelatedDuplicates() {
var tmp = new Array(0);
var tmp2 = new Array(0);
for(var i = 0; i < relatedUrls.length; i++) {
if(!contains(tmp, relatedUrls[i])) {
tmp.length += 1;
tmp[tmp.length - 1] = relatedUrls[i];
tmp2.length += 1;
tmp2[tmp2.length - 1] = relatedTitles[i];
}
}
relatedTitles = tmp2;
relatedUrls = tmp;
}
function contains(a, e) {
for(var j = 0; j < a.length; j++) if (a[j]==e) return
true;
return false;
}
function printRelatedLabels() {
var r = Math.floor((relatedTitles.length - 1) *
Math.random());
var i = 0;
document.write(' < ul >');
while (i < relatedTitles.length && i < 20) {
document.write(' < li > < a href="' + relatedUrls[r] +
'" > ' +
relatedTitles[r] + ' < /a > < /li > ');
if (r < relatedTitles.length - 1) {
r++;
} else {
r = 0;
}
i++;
}
document.write(' < /ul > ');
}
//]] >
< /script >
< data:postLabelsLabel/ >
< b:loop values='data:post.labels' var='label' >
< a expr:href='data:label.url'
rel='tag' > < data:label.name/ > < /a > < b:if
cond='data:label.isLast != "true"' > , < /b:if >
< /b:loop >
< /b:if >
< script expr:src='"/feeds/posts/default/-/" +
data:label.name + "?alt=json-in-
script&callback=related_results_labels&max-
results=10"' type='text/javascript'/ >
< /b:if >
< h4 > Realeted Post < /h4 >
< script type="text/javascript" >
removeRelatedDuplicates();
printRelatedLabels();
< /script >
< /b:if >
Semoga tutorial ini membawa hasil seperti yang anda harapkan.......!
Category: Tutorials blog
0 komentar