duanbai1370 2012-04-19 10:35
浏览 96
已采纳

为动态加载的内容添加唯一的fb like按钮

I need to add a facebook like button to menu items from a php cp menu –

I’m thinking of pulling in the information from each menu div and having it fill in meta data before sending it to facebook

<div class="menu_content_cell">
<span class="menu_title"><?php echo $menuItem['item_name']?></span>
<?php if($menuItem['item_desc']) {?>                                                    <br />
<span class="menu_description"><?php echo $menuItem['item_desc']?></span><?php } ?>
</div>

to fill in

      <html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:og="http://ogp.me/ns#"
      xmlns:fb="http://www.facebook.com/2008/fbml">
    <head>
    <title>Sample</title>
    <meta property="og:title" content="Site Name <?php echo $menuItem['item_name']?>"/>
    <meta property="og:type" content="food"/>

    <meta property="og:site_name" content="Site Name"/>
    <meta property="og:description"
          content="<?php echo $menuItem['item_desc']?>"/>

    <meta http-equiv="refresh" content="0;url=http://www.sample.com/menu.php"/>
  </head>

<body>
</body>
</html>

is this possible, or am I barking up the wrong tree?

How would I do it? Maybe if I could get a unique id for each menu item - I'm sure this is possible but I'm struggling to piece the parts of the puzzle together

Thanks in Advance

  • 写回答

2条回答 默认 最新

  • donglin317704291 2012-04-19 10:41
    关注

    Facebook indexes objects by urls, different urls mean different objects in their graph.

    For example, these pages will be considered different:

    And so, you should differentiate pages which you want users to like by their urls, and based on the dynamic part (either using query string or pretty urls) output different og tags on the server side.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
  • ¥15 路易威登官网 里边的参数逆向
  • ¥15 Arduino无法同时连接多个hx711模块,如何解决?
  • ¥50 需求一个up主付费课程
  • ¥20 模型在y分布之外的数据上预测能力不好如何解决
  • ¥15 processing提取音乐节奏
  • ¥15 gg加速器加速游戏时,提示不是x86架构
  • ¥15 python按要求编写程序
  • ¥15 Python输入字符串转化为列表排序具体见图,严格按照输入
  • ¥20 XP系统在重新启动后进不去桌面,一直黑屏。