Involver Developer Network : share
This page last changed on Oct 18, 2011 by jed.wheeler@involver.com.
OverviewShare is used to "Share" a content item. The only required parameter is the context variable name for the content item that is being shared by the user. By default, SML will use any metadata available to populate the share options. Share, like all other SML social tags, must be used within a 'for' loop. If you need to set up a share outside of a 'for' loop you'll need to use share (JS), or facebook_like. Caching ConsiderationsThis tag has no caching considerations. Attributes
Security IssuesFacebook does not currently support secure urls for images embedded within shares. Because the SML editable_image tag dynamically serves the image in http or https, depending on the user's current browsing mode, images inserted into a facebook share from an editable image or any other source that exports secure urls will fail to show the image in https mode. This is a facebook platform bug that we cannot control. Until it is fixed, you can compensate in your SML code by capturing the editable as a variable and then use the replace filter to replace any calls for https: with a call for http: {% capture image %}{% editable_image name:"my_image" src_only:true %}{% endcapture %} {% capture http_image %}{{ image | replace:"http:","https:" }}{% endcapture %} {% for some_item in feature_block.set_of_items %} {% share some_item image:http_image %} {% endfor %} ExamplesSimple Example1. Share tweet:
{% twitter_feed %}
{% for tweet in twitter_feed.tweet_items %}
<p>
{{ tweet.title | twitter_link | auto_link }}
- {% share tweet %}
</p>
{% endfor %}
{% endtwitter_feed %}
2. Share coupon: {% coupon name:"hotdeals" %} <div class="fan-content box coupon-box"> <div class="box-header"> {% for current_coupon in coupon.coupon_items limit:1 %} {% share current_coupon %} {% endfor %} <h2>Hot Deals</h2> </div><!-- /.box-header --> <div class="box-body"> {% for current_coupon in coupon.coupon_items limit:1 %} <img src="{{current_coupon.image_url}}" alt="Two Free 5x7 HP photo greeting cards. Try the HP Kiosk on us."> {% endfor %} </div><!-- /.box-body --> </div><!-- /.coupon-box --> {% endcoupon %} 3. Share with hard-coded text (share image captured from an RSS feed): {% rss_feed %} {% assign feedshare = rss_feed.feed_items.first %} {% capture share_image %}{{ feedshare.default_image.cached_url }}{% endcapture %} {% for blog_post in rss_feed.feed_items limit: 1 %} <p> {% share blog_post name:"Share Title Text" description:"Share main body text" image:share_image href:application_url %}</p> {% endfor %} {% endrss_feed %} 4. User "Badges" generated from an image_gallery {% image_gallery %} <table> {% tablerow image in image_gallery.image_items cols:3 %} {% capture badge %}{{ image.image_url | resize_to:"square" | resize_to:"90" | img_tag:image.title }}{% endcapture %} {% capture description %}I've earned the {{ image.title }} Badge! Wow, I sure am cool!{% endcapture %} {% share image label:badge image:image.image_url name:image.title caption:image.title description:description onclick:"Analytics.logClickthrough('Badge Post Count')" %} {% endtablerow %} </table> {% endimage_gallery %} FAQQuestion: Is there an attribute to change the app name that appears in the share dialog at the bottom of the other text? ("via AppName") Answer: No. Facebook inserts this text automatically. If a new app is created with the correct name then Facebook will use that name instead. Related Topics |
![]() |
Document generated by Confluence on Feb 12, 2013 09:09 |