doujiu3768 2013-06-19 20:38
浏览 42
已采纳

如何根据传递给页面的变量使facebook like按钮具体化

i am working on a website that is big into php databases i'm trying to get it so there is a (facebook)like button for every post that is made for the site. the only problem is the facebook likes are not individualized and are page specific so when i like 1 they all get liked. this would not be a problem if i could put each one in the comment section of the post since it is on a different page but each comment section is individualized by a php id variable that i pass to it (which does not actually change the url but only what shows up on the page). is there any way that i could make it so that each like button behaves on its own? here is the site i have been working on.

www.linkerbolt.com

  • 写回答

1条回答 默认 最新

  • dongmen1925 2013-06-19 20:41
    关注

    In the div that you've created which contains the facebook like button, you can add a data-href property, and in this property you can add a link to whichever page you want :

    data-href="www.whicheverpageyouwant.com"
    

    In your case, you would need a different URL for each post. You can create a page that receives a post id and displays a single post (www.yoursite/posts/35) and set the data-href to point to each corresponding page when you have to display several on the same page.

    Ficticious example :

    <?php foreach ($forumPosts as $post) : ?>
    
        <div class="fb-like" 
            data-href="wwww.yoursite/forumpost/<?php echo $post['id'];?>" 
            data-send="true" 
            data-width="450" 
            data-show-faces="true" />
    
    <?php endforeach; ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 想问一下树莓派接上显示屏后出现如图所示画面,是什么问题导致的
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号