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

Overview

The contest feature block provides a framework for running contests in SML. In addition to this documentation we have a tutorial available (Chapter 5 - Blush Magazine Photo Contest) that walks through building a contest from scratch.

On this page:

Please see the sub-pages for relevant information on


Attributes

name type required description
name string no This is the unique name the SML will use to look up which contest instance to use.

Context Variables

name type description configured in contest settings as
contest.title string Returns a String which is title with the contest name.
Contest Name
contest.rules_text

string Returns text rules that the administrator set for the contest.
Rules Text
contest.rules_url
string Returns URL to the contest rules.
Rules URL
contest.privacy_policy_text
string Returns text with privacy policy
disclosure.
Privacy Policy Text
contest.privacy_policy_url
string Returns URL for the privacy policy specified by user.
Privacy Policy URL
contest.activated_at
string Returns the date when the contest will be active. Server Timezone is PST
Contest Starts At
contest.expired_at
string Returns the date when the contest will be closed. Server Timezone is PST
Contest Ends At
contest.winning_contest_entries
Array Returns array of contest entries that were marked as winner by admin.
 
contest.contest_entries
Array
Returns array of contest entries that were marked as approved by admin.
 
contest.contest_items
Array
Returns array of all entries to the contest, including entries that have not been approved or which have been removed. Not recommended for use except as a debugging tool.

Default Tag

Unlike most feature blocks, contests cannot run without being configured. Using the default tag without any code inside will generate an error message saying the contest has not yet been built.

{% contest %}{% endcontest %}

Limitations

Currently Success Page SML and Contest Entry Form SML do not support nested SML feature blocks.


Caching Considerations

No caching considerations.


FAQ

  1. Can you install the same contest code on multiple fan pages?
    Yes, any SML code is portable across fan pages.
  2. Can the contest entry content be shared across contests on multiple fan pages?
    No, we currently do not support linking contest feature blocks across multiple fan pages.
  3. Are we able to track the traffic from each of the contests?
    Yes, each fan page is tracked separately in AMP.

Configuration

In your SML template you can start with adding the contest feature block:

{% contest %}
  <h2>Contest: {{ contest.title }}.</h2>

  <p>Contest Rules: <a href="{{ contest.rules_url }}">Contest Rules</a></p>

  <p>Privacy Policy: {{ contest.privacy_policy_text }}</p>

  <p>
    Contest Activated at: {{ contest.activated_at }}<br>
    Contest Expired at: {{ contest.expired_at }}
  </p>

  {% partial name:'my-entry-form' %}
    {% contest_form %}
      <h3>My Entry Form</h3>
      <p>Mood: <input type="text" name="submission[mood]"></p>
      <p>Before Photo: {% image_upload_field name:'submission[before_photo]' %}</p>
      <p><input type="submit" value="Submit"></p>
    {% endcontest_form %}
  {% endpartial %}

  {% partial name:'my-success' %}
    <h3>Thank you for your submission!</h3>
    <p>Your Phrase: {{ contest_entry.submission.mood }}</p>
    <p>Your Before Photo: <img src="{{ contest_entry.submission.before_photo }}" alt=""></p>
  {% endpartial %}

  {% contest_form_link entry_form_partial:"my-entry-form" success_partial:"my-success" %}Submit Your Entry{% endcontest_form_link %}

  <h3>Winners</h3>

  {% for entry in contest.winning_contest_entries %}
    <img src="{{ entry.submission.before_photo | resize_to:'350'}}" alt="">
  {% endfor %}

  <h3>Entries</h3>
  <ul class="block-quote">
    {% for entry in contest.contest_entries %}
      <li>
        <p>{{ entry.submission.mood }}</p>
        <img src="{{ entry.submission.before_photo | resize_to:'250' }}">
      </li>
    {% endfor %}
  </ul>
{% endcontest %}

Notice how you can define your Entry Form and Success SML in partial blocks. The partial names are then passed to the contest_form_link block.

By default, the form will be loaded in a dialog. If you'd like the form to appear in another element on the canvas, you may pass in an id to the DOM you want to populate, like so:

{% contest_form_link entry_form_partial:"my-entry-form" success_partial:"my-success" div_id:'form_container'%}Submit Your Entry{% endcontest_form_link %}

<div id="form_container">
  <!-- To be filled upon "Submit Your Entry" link click -->
</div>

You can also control the size of the entry form by passing in attributes 'form_height' and 'form_width'. For example:

{% contest_form_link entry_form_partial:"my-entry-form" success_partial:"my-success" form_height:300 form_width:520 %}Submit Your Entry{% endcontest_form_link %}

The default dialog title will be 'Submission'. To change the name of the dialog title, you can pass the attribute 'dialog_title':

{% contest_form_link entry_form_partial:"my-entry-form" success_partial:"my-success" dialog_title:"Submit Your Entry" %}Submit Your Entry{% endcontest_form_link %}

Note, when the user first clicks the contest_form_link, the contest SML application will prompt the user for Facebook User Authorization. Subsequent clicks will not prompt for permission.

You can display submitted and administrator-approved entries by using for loop (note: the above configuration assumes that you are configuring entry form with the code from Example section below):

{% for entry in contest.contest_entries %}{% endfor %}
Document generated by Confluence on Feb 12, 2013 09:09