This page last changed on Oct 18, 2011 by jed.wheeler@involver.com.

Overview

Share 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 Considerations

This tag has no caching considerations.


Attributes

name type required description
label string false Defaults to "Share". Allows you to change the text (or html) of the generated share link.
image URL false Allows you to attach an image to the share object.
image_link URL false Used when an image is provided and you wish to provide a URL to link to.
link URL false URL that you wish the share name/action_text to link back to (by default links back to the Facebook Fan Page from which the item was shared).
href URL false URL that you wish the share name to link back to.
message string false This attribute has been Deprecated.  Facebook no longer allows developers to pre-populate share text.
description string false If image is defined, it allows you to provide description for it.
caption string false If image is defined, it allows you to provide caption for it.
name string false If image is defined, it allows you to provide name for it.
action_text string false Allows you to define text for the action_link when the items is shared to the wall (by default that text is Facebook Page name).
action_link URL false Allows you to define URL for the action_text. If 'link' URL is defined, defaults to it; otherwise defaults to Facebook Tab from which share occurs. Note: the Tab url will not include any page_params (see Global Context Variables ).
user_prompt_message string false Allows you to override the default question for the share dialog that shows up above the text area box.
class string false The class attribute for the share link
style string false The style attribute for the share link
onclick string false The handler for javascript code on every click of the share link
onfirstclick string false Same as onclick, except the javascript is only executed on the first click of the share link

Security Issues

Facebook 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 %}

Examples

Simple Example

1. 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 %}

FAQ

Question: 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