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 by adding a variable like this -> - it doesn't 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 do I make it work with a variable reference?
source to share
The data composition tag data:post.labels
will return empty if used outside of the Blog Widget tag b:widget
because the namespace post
is undefined.
Include the script block inside the block <b:includable id='post' var='post'>
(and <b:includable id='mobile-post' var='post'>
if you want the code to work on mobile too) that is present in the blog widgets
source to share