how to make post relevant
Versi Indonesia:
Please select one of the tutorials below:
The first step >>
- Account login Blogger.com > > Layout > > Edit Html
- Tick the expand widget template
- Find the code like this
- Then copy and paste this code right below the code above
- If you already do not forget to save and see the results
- Find and paste the code below just above the code < /head >
- Then at the first save
- Find more like this code
- And put this code right below the code < /b:loop > < /b:if >
- Save the template and see the changes
< p > < data:post.body/ > < /p > or < data:post.body/ >
same thing.
< 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 >
The second step == >>
// < ![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 >
< 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 >
Hopefully, this tutorial is to bring the results that you expect.!
Category: Tips and tricks
0 komentar