1、把下面代码放在<head></head>中。其中的"i < 12"是控制文章数量的,建议数值不要太大,以免影响浏览速递。
2、找到下面黑色的代码,在</b:if>与</b:loop>之间,插入如下红色的代码。注意:"max-results=12"是控制相关文章的显示数值。<script type="text/javascript">
//<![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 < 12) {
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>
<b:if cond='data:post.labels'>
<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:if cond='data:blog.pageType == "item"'>
<script expr:src='"/feeds/posts/default/-/" + data:label.name + "?alt=json-in-script&callback=related_results_labels&max-results=12"' type='text/javascript'/>
</b:if>
</b:loop>
</b:if>
3、找到自己想要显示相关文章的位置,将下面红色代码放进去,保存就OK那了。本例就放在评论前,如下面黑色代码。
<b:if cond='data:blog.pageType == "item"'>
<script type="text/javascript"> removeRelatedDuplicates(); printRelatedLabels(); </script> </b:if>
<div id='comments'>
<a name='comments'/>
<h4>
<b:if cond='data: post.numComments == 1'>
1 条评论:
<b:else/>
<data:post.numComments/> 条评论:
</b:if>
</h4>
<dl id='comments-block'>
<b:loop values='data: post.comments' var='comment'>
<dt class='comment-author' expr:id='"comment-" + data:comment.id'>
<a expr:name='"comment-" + data: comment.id'/>
<b:if cond='data:comment.authorUrl'>
<a expr:href='data:comment.authorUrl' rel='nofollow'><data:comment.author />
4、完成,看看效果吧!
8 条评论:
[url=http://levitranowdirect.com/#nfivl]buy levitra online[/url] - levitra 20 mg , http://levitranowdirect.com/#pjnbs cheap generic levitra
[url=http://viagranowdirect.com/#vrrzp]buy viagra[/url] - cheap generic viagra , http://viagranowdirect.com/#enhql cheap viagra online
[url=http://viagraboutiqueone.com/#hcohi]viagra online[/url] - viagra online , http://viagraboutiqueone.com/#bkusr buy viagra
[url=http://buyonlineaccutanenow.com/#qmquo]accutane 5 mg[/url] - accutane without prescription , http://buyonlineaccutanenow.com/#yptrv accutane 10 mg
[url=http://orderviagradirectlyonline.com/#dimwe]viagra without prescription[/url] - purchase viagra , http://orderviagradirectlyonline.com/#igiec viagra 25 mg
[url=http://buyreliablezithromaxonline.com/#jmqvn]buy cheap zithromax[/url] - cheap zithromax online , http://buyreliablezithromaxonline.com/#wccvw zithromax 500 mg
Tutorials cialis generic cialis,cialis cialis, generic viagra generic cialis,buy viagra cialis
http://genericcialispricegnf.com#cialis online http://cialisonlinepillsgkd.com#cialis pills http://genericviagraonlinejvrg.com#generic viagra http://buyviagraonlinertvr.com#buy viagra
You would be amazed at what number of everyone is reducing their auto insurance costs by $500 or higher. Medical payment coverage also covers the insured in addition to their family within the event of being struck by way of a vehicle while walking, jogging, and running, etc. You will also get understanding of different forms of coverage and many types of sorts of specifics of different companies once you research in order to find Texas auto insurance quotes with the assistance of engines like google on internet. xSZdudg, [url=http://www.igetcheapcarinsurance.com/alberta-auto-insurance-quotes-online/]alberta auto insurance quotes online[/url], poCOMhw, [url=http://www.igetcheapcarinsurance.com/ez-auto-insurance-arkadelphia-ar/]ez auto insurance arkadelphia ar[/url], xAjnFSi, [url=http://www.igetcheapcarinsurance.com/motor-insurance-gender-divide-under-threat/]motor insurance gender divide under threat[/url], ZLNmPog,
发表评论