2012-08-03 59 views
1

我正在使用jquery.prettyPhoto在我的網站上顯示相冊。我激活了social_tools以在每張照片下方顯示twitter和facebook小部件。所有圖片都有相同數量的臉書喜歡prettyPhoto

問題是,如果有人喜歡一張照片,所有其他照片都喜歡,所以每張照片有234個喜歡。

這是因爲我的location.href在另一張圖片顯示時沒有改變?

代碼激活我的專輯是:

$.fn.prettyPhoto({ 
    slideShow: 3000, 
    social_tools: '' 
    +'<div class="pp_social">' 
     +'<div class="twitter">' 
     +'<a href="http://twitter.com/share" class="twitter-share-button" data-count="none">Tweet</a>' 
     +'<script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>' 
     +'</div>' 
    +'<div class="facebook">' 
     +'<iframe src="http://www.facebook.com/plugins/like.php?locale=nl_NL&href='+location.href+'&amp;layout=button_count&amp;show_faces=true&amp;width=500&amp;action=like&amp;font&amp;colorscheme=light&amp;height=23" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:500px; height:23px;" allowTransparency="true"></iframe>' 
    +'</div>' 
    +'</div>' 
}); 

我怎樣才能解決這個問題?

在此先感謝。

+0

圖像'src'的圖像'id'是否有佔位符(或類似的東西)? – 2012-08-03 08:10:56

回答

0

我編輯了jquery.prettyPhoto插件來解決這個問題。

在Facebook的鏈路被替換我增加了額外的佔位符的部分:

// Rebuild Facebook Like Button with updated href 
if(settings.social_tools){ 
    facebook_like_link = settings.social_tools.replace('{location_href}', encodeURIComponent(location.href)).replace('{image_src}',encodeURIComponent(location.protocol+'//'+location.host+pp_images[set_position])); 
    $pp_pic_holder.find('.pp_social').html(facebook_like_link); 
} 

額外的佔位符是{image_src}並且正在由所述圖像位置取代。

0

前段時間我有同樣的問題,雖然沒有使用jquery.prettyPhoto。我有一系列的對象,每個對象都有一個單獨的網頁。和你一樣,當有人喜歡其中一個物體時,他們每個人都會喜歡它。

問題是,「喜歡」被鏈接到相同的地址,因此被認爲是相同的。一旦我們確定他們每個鏈接到不同的地址,它就解決了這個問題。

0

我只是做:

// Rebuild Facebook Like Button with updated href 
if(settings.social_tools){ 
    facebook_like_link = settings.social_tools.replace('{location_href}', pp_images[set_position]); 
    $pp_pic_holder.find('.pp_social').html(facebook_like_link); 
} 

和它的工作!

圖像網址像href一樣傳遞給FB。現在FB明白這是一個不同的網址。

相關問題