Blogger JSON Feed API-脚本src [英] Blogger JSON Feed API - script src

查看:53
本文介绍了Blogger JSON Feed API-脚本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 != &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 ??

推荐答案

如果未在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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆