我知道這裏是https://developers.facebook.com/docs/reference/plugins/comments/ 它生成的JavaScript和HTML代碼。 繼承人我的意思 https://dl.dropbox.com/u/63111556/ubuntu.png如何將Facebook評論框與我網站上的文章相關聯?
在我的網站,我想創建一個博客,所以用戶帖子評論 現在將有來自用戶 我怎樣才能使涉及到具體的一個評論框不同崗位挑在我的網站上的帖子?
我知道這裏是https://developers.facebook.com/docs/reference/plugins/comments/ 它生成的JavaScript和HTML代碼。 繼承人我的意思 https://dl.dropbox.com/u/63111556/ubuntu.png如何將Facebook評論框與我網站上的文章相關聯?
在我的網站,我想創建一個博客,所以用戶帖子評論 現在將有來自用戶 我怎樣才能使涉及到具體的一個評論框不同崗位挑在我的網站上的帖子?
更改data-href
在每個用法的div。你可以將其設置爲一個元素的ID或交的數量,使它們各不相同:
<div class="fb-comments" data-href="http://yourwebsite.com/#postIDorNumber" data-width="470" data-num-posts="10"></div>
<div class="fb-comments" data-href="http://yourwebsite.com/#postIDorNumber2" data-width="470" data-num-posts="10"></div>
<div class="fb-comments" data-href="http://yourwebsite.com/#postIDorNumber3" data-width="470" data-num-posts="10"></div>
應該很容易落實到一個博客的帖子ID動態地添加到data-href
的代碼,該Facebook頁面生成是這樣的:
<div class="fb-comments" data-href="http://example.com" data-width="470" data-num-posts="10"></div>
我reccomend給每個帖子一個單獨的URL表示: /博客/食品/我夾心 /博客/食品/我的雞,油炸餅
只需在呈現帖子列表時更改data-href
參數。
例如:
<?php
foreach($posts as $post) {
echo '<div class="post">';
echo '<div class="post-title">' . $post->title . '</div>';
echo '<div class="post-content">' . $post->content . '</div>';
echo '<div class="post-comments"><div class="fb-comments" data-href="http://yoursite.com/blog/' . $post->url . '" data-width="470" data-num-posts="10"></div></div>';
echo '</div>';
}
?>
對不起,花了這麼長時間我把一張圖片鏈接起來?我將如何爲每個「帖子」創建鏈接?所有的帖子都將是一頁 – Thefirstkilla 2013-03-18 21:38:21
剛纔解釋說給你配偶?這是一個讓一個不同的URL放入div的'data-href'參數的例子,這個參數將永久地代表帖子。 – freshnode 2013-03-18 21:39:50
我看到我想在頁面上發佈多個帖子 – Thefirstkilla 2013-03-18 21:53:41
因此基於你,我想元素ID – Thefirstkilla 2013-03-18 21:36:11
所以數據HREF = 「http://yourwebsite.com/#element ID」 Dropbox的鏈接??? – Thefirstkilla 2013-03-18 21:36:39
每個評論必須有一個獨特的'數據href' ..你可以做任何你喜歡的任何組合。只要它讓你訪問相關頁面'data-href ='http:// www.yoursite.com/blog/pageID.html#elementID-fb-comments-unique-whatever'。如果評論只會在博客入口頁面和每頁一個評論框中,我會堅持使用後的url:'data-href =「http://www.yoursite/blog-post-4.html」 ' – kingkode 2013-03-18 21:39:10