2012-02-13 4 views
2

私は、会場のリストを表示し、リスト内の各会場にフォースクエアの「保存」ボタンを追加したいサイトに取り掛かりました。 1ページに複数のFoursquareの「保存」ボタンを表示することは可能ですか?私は、複数のvCardブロック(各会場ごとに1つ)を作成し、各ブロックに「保存」ボタンを挿入しようとしましたが、場所が選択されていません。複数のFoursquareの「保存」ボタンを1ページにまとめました

答えて

2

widgets.jswidgets.asyncbundle.jsの出所を調べたところ、「Save to Foursquare」ボタンの属性をVCardのIDに設定すると、これら2つがリンクされることがわかりました。同様に:

<div id="hcard-Station-Amsterdam-Centraal" class="vcard"> 
    <span class="fn"> 
     <span class="given-name">Station Amsterdam Centraal</span> 
    </span> 
    <div class="adr"> 
     <div class="street-address">stationsplein 15</div> 
     <span class="locality">Amsterdam</span>, 
     <span class="region">Amsterdam</span> , 
     <span class="postal-code">1012AB</span> 
    </div> 
</div> 
<div id="hcard-Jaarbeursplein" class="vcard"> 
    <span class="fn"> 
     <span class="given-name">Jaarbeursplein</span> 
    </span> 
    <div class="adr"> 
     <div class="street-address">Jaarbeursplein</div> 
     <span class="locality">Utrecht</span>, 
     <span class="region">Utrecht</span>, 
     <span class="postal-code">3521AL</span> 
    </div> 
</div> 

<a href="https://foursquare.com/intent/venue.html" class="fourSq-widget" data-context="hcard-Station-Amsterdam-Centraal" data-variant="wide">Save to foursquare</a> 
<a href="https://foursquare.com/intent/venue.html" class="fourSq-widget" data-context="hcard-Jaarbeursplein" data-variant="wide">Save to foursquare</a> 

しかし、これは文書化されていないため、近い将来変更される可能性があります。

+0

は(4Qドキュメントのようではないクラス= "vCardの")クラス= "vCardの" を使用してください – sglessard

+0

それは私のブログのための素晴らしい働きました。私は訪問する場所のリストを持っていて、彼らは今素晴らしい仕事をしています。将来的には、テキストフィールドの値が会場のURLと同じように、隠れたテキストフィールドのようなより良いソリューションを構築するために、4sqチームを希望します。それはページ作成者のための多くの努力を減らすことができます。 –

+0

これは素晴らしい動作します。あなたが組織の場合、vcardの書式設定は、親要素のclass = "org fn"、組織名を含む子要素のclass = "organization-name"のように少し異なります。これを使用して、2つの博物館の場所に相対的な4Square Saveボタンを表示させることができました。 –

-1

save-to-foursquareウィジェットの進行中のドキュメントにアクセスできるのは、@https://developer.foursquare.com/overview/widgetsです。彼らは時間がたつにつれてきれいになるでしょうが、これと将来のウィジェット関連の質問を助けるのに十分なはずです。

特に、必要な「データコンテキスト」属性に関するドキュメントは、すぐにリンクページにプッシュされます。

+0

ドキュメントには、ページ上の複数のボタンの 'data-context'属性は書かれていないので、それを参照し、 'これと将来のウィジェット関連の質問を助けるのに十分であるはずです'と言います。 –

+0

ドキュメントはすぐにその属性を含むように更新されます – akdotcom

+0

あなたが4sqのために働いていることを知らなかった、とにかく、属性をカバーしていないことを知っているときにドキュメントを解決策として言及しても、すぐにドキュメントに記述され、私は自分のdownvoteを元に戻すことをあなたの答えに加えてください。 –

0

"データ-VID" でこれを試してみてください:

<!-- Place this anchor tag where you want the button to go --> 
<br /> 
All In PartyRadio Studio<a href="https://foursquare.com/intent/venue.html" class="fourSq-widget" data-vid="50575a55e0e27c7feb062116">Save to foursquare</a> 
<br /> 
Sing Sing Music Hall<a href="https://foursquare.com/intent/venue.html" class="fourSq-widget" data-vid="4d47d1fe2165721ebe9ac0d7">Save to foursquare</a> 
<br /> 
Retro Klub<a href="https://foursquare.com/intent/venue.html" class="fourSq-widget" data-vid="4d437d813616b60c2764dac2">Save to foursquare</a> 
<br /> 
Tisza Dokk<a href="https://foursquare.com/intent/venue.html" class="fourSq-widget" data-vid="4f73231de4b0e3a99689cc61">Save to foursquare</a> 
<br /> 
Zöld Zsiráf Kultúrpart<a href="https://foursquare.com/intent/venue.html" class="fourSq-widget" data-vid="4ffad97ef13633933ececa5f">Save to foursquare</a> 

<!-- Place this script somewhere after the anchor tag above. If you have multiple buttons, only include the script once. --> 
<script type='text/javascript'> 
    (function() { 
    window.___fourSq = {"uid":"606"}; 
    var s = document.createElement('script'); 
    s.type = 'text/javascript'; 
    s.src = 'http://platform.foursquare.com/js/widgets.js'; 
    s.async = true; 
    var ph = document.getElementsByTagName('script')[0]; 
    ph.parentNode.insertBefore(s, ph); 
    })(); 
</script> 
関連する問題