2012-08-04 69 views
17

我有一个页面上有多个新闻项目。列表中的每个项目都必须有自己的与计数一样的按钮。如何将多个Facebook Like按钮与计数器在同一页上

是否有可能为同一页上的每条新闻计数多个Like按钮?

Multiple Facebook like button with count on the same page

+0

没有标记这个问题下来吧。我花时间发布答案,这是一个很好的问题。 – 2012-08-04 17:36:00

回答

13

每个像按钮的代码必须有它自己唯一的URL。

参考:http://developers.facebook.com/docs/reference/plugins/like/

我用PHP来实现这一目标,通过拉动从 数据库所需的所有相对URL,循环他们, 写返回数据的href PARAM的HTML5就像按钮代码。

您可以像我一样手动设置这些链接或设置动态系统。


html5按钮代码。

<div class="fb-like" data-href="'.$thepage[link1].'" data-send="false" data-layout="button_count" data-width="90" data-show-faces="false" data-font="tahoma" style="margin-left: auto; margin-right: auto; text-align: center;"></div> 

<div class="fb-like" data-href="'.$thepage[link2].'" data-send="false" data-layout="button_count" data-width="90" data-show-faces="false" data-font="tahoma" style="margin-left: auto; margin-right: auto; text-align: center;"></div> 

<div class="fb-like" data-href="'.$thepage[link3].'" data-send="false" data-layout="button_count" data-width="90" data-show-faces="false" data-font="tahoma" style="margin-left: auto; margin-right: auto; text-align: center;"></div> 

XFBML按钮

<fb:like href="http://anotherfeed.com?link=1" send="true" width="450" show_faces="true"></fb:like> 

<fb:like href="http://anotherfeed.com?link=2" send="true" width="450" show_faces="true"></fb:like> 

<fb:like href="http://anotherfeed.com?link=3" send="true" width="450" show_faces="true"></fb:like> 
+5

这只是我,还是这使得Chromes内存使用量猛涨? – 2014-10-05 09:18:47

相关问题