Blogger JSON Feed API-脚本src [英] Blogger JSON Feed API - script src
问题描述
<script type="text/javascript">
//<![CDATA[
function mycallbackk(e) {
for (var i = 0; i < e.feed.entry.length; i++) {
var d = e.feed.entry[i];
contentcontent = d.content.$t;
var divvv = document.createElement("div");
divvv.innerHTML = contentcontent;
var imggg = divvv.getElementsByTagName("a")[1];
function printRelatedLabels_thumbs() {
for (var j = 0; j < d.link.length; j ++) {
if (d.link[j].rel == 'alternate') {
var purl = d.link[j].href;
break;
}
}
var title = d.title.$t,
author = d.author[0].name.$t,
tag = d.category[0].term,
img = d.media$thumbnail.url;
var itemerwsds = ("<img src="+ img +"></img><h3><a href="+ purl +">"+ title +"<a/></h3><div class='post-infooo'><a>"+ tag +"</a><a>"+ author +"</a></div><div>" + imggg + "</div>");
document.write(itemerwsds);
}
}
}
//]]>
</script>
当我选择这样的链接>>>>时
When I select a link like this >>>> it works
<script src="http://templatertl.blogspot.com/feeds/posts/default/-/gooo?max-results=3&alt=json-in-script&callback=mycallbackk"></script>
====================
=====================
但是,当添加这样的变量>>>>时,它不起作用
But When adding a variable like this >>>> it does not work
<b:loop values='data:post.labels' var='label'>
<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=mycallbackk&max-results=3"' type='text/javascript'/>
</b:if>
</b:loop>
如何使其与可变链接一起使用?
How to make it work with a variable link ??
推荐答案
如果未在Blog Widget b:widget
标记之外使用数据布局标记data:post.labels
,则其将返回空,因为未定义post
命名空间.
The data layout tag data:post.labels
will return empty if used outside the Blog Widget b:widget
tag as the post
namespace is not define.
在Blog小部件中包含<b:includable id='post' var='post'>
框(如果您希望代码也可以在移动设备上使用,请在<b:includable id='mobile-post' var='post'>
框内)添加脚本块
Include the script block inside the <b:includable id='post' var='post'>
(and <b:includable id='mobile-post' var='post'>
block if you want the code to work on mobile as well)block present in the Blog widget
这篇关于Blogger JSON Feed API-脚本src的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!