This page last changed on Aug 17, 2012 by yuriy.kalynovskiy@involver.com.

Overview

Used to insert an url into a template that links to the Facebook tab hosting the SML template and passes through an arbitrary set of key/value parameters that are made available via the global context variable page_params.

Attributes

name type required description
url string false If specified the tag will add page_params to this value instead of the tab url

Other than attributes specified above, any arbitrary key/value pairs can be passed as attributes to this tag to be made available through the page_params global context variable.

Examples

Simple example

{% page_params_link some_key:"some_value" another_key:"another_value" %}

=> http://www.facebook.com/pages/A-Fan-Page/99999999?v=app_9999999&app_data=zzyJwYWdlX3BhcmFtcsdfsmb2dsfiJiYXIifX0%3D

If the Facebook tab is loaded with the url generated by the page_params_link output, the key/values specified will be available through the context variable page_params.

e.g.

{% if page_params.some_key == "some_value" %}
The link was used
{% else %}
Link was not used
{% endif %}

Using page_params_link to set different variables on a render

<a href="{% page_params_link some_key: "some_value" %}">Some value</a>< /br>
<a href="{% page_params_link some_key: "some_value_2" %}">Some Value 2</a>
<div id="display">
    {% if page_params.some_key == "some_value" %}
        <!-- Will display if the first link is used -->
        {% render partial:"some_partial" some_variable:"value_1" %}
    {% elsif page_params.some_key == "some_value_2" %}
        <!-- Will display if the second link is used -->
        {% render partial:"some_partial" some_variable:"value_2" %}
    {% else %}
        <!-- will display in all other cases -->
        {% render partial:"some_partial" some_variable:"default_value" %}
    {% endif %}
</div>

Using page_params_link to share a unique entry in a contest

In this contest there are page_params_link powered shares in the success message partial, the item gallery, and the featured item box. This provides examples of the tag being used both with the share SML tag and with the sml.ui.Facebook.share javascript method.

{% editable_setting headerColor label:"Color of top Header" type:"string" default:"red" %}

<style>
  h1 {color:{{headerColor}};}
  p {color: blue;}
  #gallery, #featured {border: 1px solid #ccc; marging:10px; padding:10px;}
  #gallery li {float: left; list-style:none; margin-right: 5px;}
  #featured .share {float:left;}
  #featured .rate {float:right;}
  #featured .recipeSteps {clear:both;}
  .clear {clear:both;}
</style>

{% partial name:"form" %}
{% contest_form rules_var:"sweeprules" %}
      <ul>
        {% unless contest_user_is_registered %}
        <li><label>Your Name</label>: <input type="text" name="registration[name]" value="{{contest_user.name}}" /></li>
        <li><label>Email</label> <input type="text" name="registration[email]" /></li>
        {% endunless %}
        <li><label>Recipe Name</label> <input type="text" name="submission[recipeName]" /></li>
        <li><label>Steps</label>: <textarea name="submission[recipeSteps]" >&nbsp;</textarea></li>
        <li><label>Picture</label>: {% image_upload_field name:"submission[foodPic]" %}</li>
      </ul>
     <p><input type="submit" value="Submit"></p>
  {% endcontest_form %}
{% endpartial %}

{% partial name:"success" %}
  <div class="success">
    <h3>Thanks for entering {{contest_entry.registration.name}}!</h3>
    <p>Your recipe for {{contest_entry.submission.recipeName}} looks delicious!  Why not <a href="#" class="share">share it with your friends</a>?</p>

    {% editable_image name:"coupon" %}
  </div>

{% capture shareURL %}{% page_params_link entryNumber:contest_entry.id %}{% endcapture %}
<script>
  $(document).ready(function() {
    $('a.share').click(function(event) {
        sml.ui.Facebook.share({
            user_message_prompt: "What is on your mind?",
            attachment: {
              name: '{{contest_entry.submission.recipeName}}',
              caption: 'A delicious recipe by {{contest_entry.registration.name}}',
              href: '{{ shareURL }}',
              description: '{{contest_entry.submission.recipeSteps | truncate::120}}',
              media: [{
                type: 'image',
                src: '{{contest_entry.submission.foodPic}}',
                href: '{{ shareURL }}'
              }]
            },
            action_links: [{
              text: 'Visit My Page',
              href: '{{ shareURL }}'
            }],
            success: function(post_id) {
              sml.log("Success!");
            },
            error: function() {
              sml.log("Error! ");
            }
        });
    })
  })
</script>
{% endpartial %}

{% partial name:"featured" %}
<div class="featuredIMG">{{featured.submission.foodPic | resize_to:"400" | img_tag:featured.submission.recipeName }}</div>
            <h3>{{featured.submission.recipeName}}</h3>
            <div class="share">
              {% capture shareURL %}{% page_params_link entryNumber:featured.id %}{% endcapture %}
            {% share featured link:shareURL image_link:shareURL href:shareURL image:featured.submission.recipePhoto description:featured.submission.recipeSteps name:featured.submission.recipeName %}
            </div>
            <div class="rate">
              {% rate featured %}
            </div>
            <div class="recipeSteps">
              {{featured.submission.recipeSteps | newline_to_br}}
            </div>
          {% facebook_comments featured %}
{% endpartial %}

{% contest name:"vjones" %}
  <div class="pitch">
    {% editable_html name:"contestPitch" %}
  </div>

  <h3>Enter our fabulous contest!</h3>
   <p>{% contest_form_link entry_form_partial:"form" success_partial:"success" %}Enter Now!{% endcontest_form_link %}</p>

    <div id="featured">
      {% if page_params.entryNumber.size > 0 %}
      <h1> share was used</h1>
      content item # : {{page_params.entryNumber }}
        {% get_content_item my_item content_item_id:page_params.entryNumber  %}
        {% render partial:"featured" featured:my_item %}
      {% else %}
      <h1> share was not used </h1>
        {% render partial:"featured" featured:parent.content_items.first %}
      {% endif %}
    </div>

    <div id="gallery">
      {% paginate parent.content_items per_page:5 %}
        <ul>
          {% for entry in content_items %}
          <li>
            {% ajax_link partial:"featured" featured:entry container:"featured" %}
              {{entry.submission.foodPic | resize_to:"square" | resize_to:"180" | img_tag:entry.submission.recipeName }}
            {% endajax_link %}
            <h3>{{entry.submission.recipeName}}</h3>
            {% capture shareURL %}{% page_params_link entryNumber:entry.id %}{% endcapture %}
            {% share entry link:shareURL image_link:shareURL href:shareURL image:entry.submission.recipePhoto description:entry.submission.recipeSteps name:entry.submission.recipeName %}

          </li>
          {% endfor %}
        </ul>
      {% endpaginate %}
      <div class="clear">&nbsp;</div>
    </div>

{% endcontest %}

<script>
  var sweeprules = {
    'registration[email]': {required: true, email: true},
    'registration[name]': {required: true},
    'submission[recipeName]': {required: true},
    'submission[steps]': {required: true},
    'submission[foodPic]': {required: true}
  }
</script>
Document generated by Confluence on Feb 12, 2013 09:09