Involver Developer Network : contest
This page last changed on Aug 15, 2012 by yuriy.kalynovskiy@involver.com.
OverviewThe 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
Context Variables
Default TagUnlike 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 %} LimitationsCurrently Success Page SML and Contest Entry Form SML do not support nested SML feature blocks. Caching ConsiderationsNo caching considerations. FAQ
ConfigurationIn 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 |