2
<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 != &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 to make it work with a variable link ??

0

1 Answer 1

2

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.

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.