2012-02-13 84 views
2

我正在一个显示场地列表的网站上工作,并希望为列表中的每个场地添加一个Foursquare“保存”按钮。是否可以在单个页面上显示多个Foursquare“保存”按钮?我尝试过创建多个vCard块(每个场地一个),并在每个块中插入一个“保存”按钮,但是这些位置没有被拾取。在一个页面上多个Foursquare“保存”按钮

回答

2

检查了widgets.jswidgets.asyncbundle.js的来源后,我发现将'Save to Foursquare'按钮的属性设置为VCard的ID将会链接这两个。像这样:

<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文档中未类=“电子名片”的)使用类=“电子名片” – sglessard 2012-02-22 15:06:36

+0

它的工作很好的为我的博客。我有一个需要去的地方,他们现在工作很好。希望4sq团队在未来构建一个更好的解决方案,就像隐藏文本字段一样,因为文本字段的值已成为场地的URL。这可以为页面作者减少很多工作。 – 2012-04-27 02:04:44

+0

这很好。请注意,如果您是组织,则vcard格式有点不同:在父元素上class =“org fn”,然后在包含组织名称的子元素上使用class =“organization-name”。使用这个功能,我可以让我们的两个博物馆位置显示相对的4Square保存按钮。 – 2013-05-20 20:54:37

-1

保存到foursquare小部件的进行中文档可以通过@https://developer.foursquare.com/overview/widgets访问。他们会随着时间的推移被清理干净,但应该足以帮助这个和未来的小部件相关的问题=)。

特别是,有关您所需的“data-context”属性的文档将很快推送到链接页面。

+0

该文档没有提到页面上多个按钮的'data-context'属性,因此提到这个并且说'但是应该足够好来帮助这个和未来的小部件相关的问题'并不是帮助... – 2012-04-02 15:22:40

+0

The文档将很快更新,以包括该属性 – akdotcom 2012-04-05 17:56:48

+0

好吧,不知道你在为4sq工作,无论如何,当你知道它不包含属性仍然有误导性时,提及文档作为解决方案。添加到您的答案,它将在文档中很快描述,我会撤销我的downvote。 – 2012-04-06 15:50:54

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> 
相关问题