如何添加 Facebook 的“赞”按钮到 Blogger 博客?

发布于 2024-08-29 09:43:52 字数 852 浏览 5 评论 0原文

我想将新的 Facebook“喜欢”按钮添加到我的 Blogger 网站。

我必须将 URL 传递给 iframe src 中的博客文章。

我可以从 获取 Blogger 帖子 URL,但无法将其放入 src 字符串中,因为 Blogger 的模板系统很奇怪。

我想这样做:

<iframe allowTransparency='true' frameborder='0' scrolling='no'
src='http://www.facebook.com/plugins/like.php?href=<data:post.url/>&amp;layout=standard&amp;show-faces=true&amp;width=450&amp;action=like&amp;colorscheme=light'
style='border:none; overflow:hidden; width:450px; height:px'/>

但 Blogger 抱怨:

无法解析您的模板,因为它的格式不正确。请确保所有 XML 元素都正确关闭。
XML 错误消息:与元素类型“null”关联的属性“src”的值不得包含“<”性格。”

有人有这个工作吗?

I want to add the new facebook "like" button to my Blogger website.

I have to pass the URL to the blog posts in the iframe src.

I can get the Blogger posts URL from <data:post.url/> but I can't put that in a src string because Blogger's template system is weird.

I want to do this:

<iframe allowTransparency='true' frameborder='0' scrolling='no'
src='http://www.facebook.com/plugins/like.php?href=<data:post.url/>&layout=standard&show-faces=true&width=450&action=like&colorscheme=light'
style='border:none; overflow:hidden; width:450px; height:px'/>

but Blogger complains:

Your template could not be parsed as it is not well-formed. Please make sure all XML elements are closed properly.
XML error message: The value of attribute "src" associated with an element type "null" must not contain the '<' character."

Does anybody have this working yet?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

入怼 2024-09-05 09:43:52

试试这个,

<iframe allowTransparency='true' 
        expr:src='"http://www.facebook.com/plugins/like.php?href=" + data:post.url + "&layout=button_count&show_faces=false&width=75&action=like&font=trebuchet+ms&colorscheme=light"' 
        frameborder='0' scrolling='no' 
        style='border:none; overflow:hidden; height: 20px'/>

try this,

<iframe allowTransparency='true' 
        expr:src='"http://www.facebook.com/plugins/like.php?href=" + data:post.url + "&layout=button_count&show_faces=false&width=75&action=like&font=trebuchet+ms&colorscheme=light"' 
        frameborder='0' scrolling='no' 
        style='border:none; overflow:hidden; height: 20px'/>
烟凡古楼 2024-09-05 09:43:52

使用本教程添加“点赞”按钮 - FB 推出了“点赞”按钮的新设计 - http://www.bloggerplugins.org/2010/04/facebook-like-button-for-blogger.html

Use this tutorial to add the like button - FB has rolled out a new design for the like button - http://www.bloggerplugins.org/2010/04/facebook-like-button-for-blogger.html

假装不在乎 2024-09-05 09:43:52

我在 WikiHow 上编写了使用 iframe 方法的分步指南:
http://www.wikihow.com/Add-Facebook-Like-to- Blogger

如果它不适合您,请告诉我。本质上,您的 src 需要使用 expr:src 语法,并进行字符串/数据连接。

JavaScript 版本号称更灵活,但仍有很多人在浏览器中禁用 JavaScript 或使用某些 NoScript 插件。

I wrote a step-by-step guide for using the iframe method on WikiHow:
http://www.wikihow.com/Add-Facebook-Like-to-Blogger

Let me know if it doesn't work for you. Essentially, your src needs to use the expr:src syntax, with string/data concatenation.

The JavaScript version is claimed to be more flexible, but there are still many people who disable JavaScript in their browsers or use some NoScript add-on.

萌吟 2024-09-05 09:43:52

第 1 步:请将 JavaScript SDK 应用到您的模板。

第 2 步:找到这一行

第 3 步:将其放在后面

<b:if cond='data:post.url'>
  <fb:like action='like' colorscheme='light' expr:href='data:post.url' layout='standard' show_faces='false' width='450'/>
</b:if>

保存即可完成;)

STEP 1: kindly apply JavaScript SDK to your template.

STEP 2: find this line <b:includable id='post' var='post'>

STEP 3: put this after it

<b:if cond='data:post.url'>
  <fb:like action='like' colorscheme='light' expr:href='data:post.url' layout='standard' show_faces='false' width='450'/>
</b:if>

Save it and your done ;)

风吹过旳痕迹 2024-09-05 09:43:52

我在更改模板时也遇到了同样的错误。因此,我通过使用 JavaScript 函数 document.write 找到了解决方案:

    <script>
    document.write('<iframe src="http://www.facebook.com/plugins/like.php?href=<data:post.url/>&layout=standard&show_faces=true&width=450&action=like&font=verdana&colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:450px; height:80px"></iframe>');
</script>

只需将上述代码放在博客文章部分的末尾即可。

两个注意事项:

  • Irwan 的解决方案应该可以工作(我还没有尝试过),但这意味着必须加载 FB SDK。对于关心博客性能的人来说,这可能是一个问题。

  • Maggie 的解决方案工作正常,但不允许用户独立喜欢帖子。

人们可以在这里看到它的工作原理:http://fliscorno.blogspot.com/

I was also having the same error when changing the template. So I found a solution by using the JavaScript function document.write:

    <script>
    document.write('<iframe src="http://www.facebook.com/plugins/like.php?href=<data:post.url/>&layout=standard&show_faces=true&width=450&action=like&font=verdana&colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:450px; height:80px"></iframe>');
</script>

Just place the above code at the end of your blog post section.

Two notes:

  • Irwan's solution should work (I haven't try it) but it means that the FB SDK must be loaded. That might be an issue for who is concerned with the blog performance.

  • Maggie's solution works fine but it doesn't allow one to like the posts independently.

One can see it working here: http://fliscorno.blogspot.com/

眼泪淡了忧伤 2024-09-05 09:43:52

胡安·豪尔赫的解决方案应该有效。

恕我直言,在博客上使用 javascript SDK 比使用 iframe 方法要优雅得多(我在博客上尝试了这两种方法)。

以下是我就该主题发表的几篇文章的链接(包括在属性内使用博主表达式等以及如何使用 javascript sdk 将“点赞”按钮合并到您的博客模板中)

: yanivkessler.com/search/label/blogger" rel="nofollow">http://blog.yanivkessler.com/search/label/blogger

希望这有帮助...

Juan Jorge's solution should work.

IMHO using the javascript SDK on blogger is much more elegant than using the iframe approach (I tried both on my blog).

Here is a link to several posts I've made on the subject (including using blogger expressions inside attributes and such and how to incorporate a like button using javascript sdk into your blog template):

http://blog.yanivkessler.com/search/label/blogger

Hope this helps...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文