//

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 != &quot;true&quot;'>
</b:if>
<b:if cond='data:blog.pageType == &quot;item&quot;'>
<script expr:src='&quot;/feeds/posts/default/-/&quot; + data:label.name + &quot;?alt=json-in-script&amp;callback=mycallbackk&amp;max-results=3&quot;' type='text/javascript'/>
</b:if>
</b:loop>

      

How do I make it work with a variable reference?

+3


source to share


1 answer


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

+2


source







All Articles