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

Overview

Used for giving out unique codes to users, for example for offsite promotions.

This feature block provides a JavaScript method:

RegistrationCodeFeature.requestCode(feature_id, success_title, success_message, prefix_html)

You may also use the related JavaScript class sml.tag.RegistrationCode.

param description
feature_id The id of the registration_code feature block, given by {{ registration_code.id }}
success_title A text snippet which will be used as the title of the dialog box when a code is given to the user.
success_message An HTML snippet shown to the user when the code is given to them. It should contain a [[code]] token which will be replaced with the user's code.
prefix_html An HTML snippet which will be prepended to all the success and error messages. Example: a logo.

Configuration

Adding registration_code tag to the SML template editor and saving it:

{% registration_code name:"your_custom_name" %}{% endregistration_code %}

will allow you for further feature configuration.

Registration codes can be added from within the SML settings.

All you need to do is upload a CSV file in the following format, one code per line.

Code, Max Uses, Expires At
<code 1>,<max_uses>,<MM/DD/YYYY>
<code 2>,<max_uses>,<MM/DD/YYYY>
<code 3>,<max_uses>,<MM/DD/YYYY>

Attributes

name type required description
name string no Unique name to identify the specific feature instance that you are using in your template code. This is useful if you have multiple instances of the same feature on the same page. Defaults to "default".

Context Variables

name type description
registration_code.id integer This is the feature id which must be passed into the JavaScript call.

Examples

Simple Example

Use the default messages:

<button onclick="RegistrationCodeFeature.requestCode({{ registration_code.id }});">Get Code</button>

Complex Example

Trigger the request after a successful signup from a signup_form:

{% registration_code %}
    {% comment %}
        We need this separate function, since we can't embed an SML variable in the onsuccess directly.
    {% endcomment%}

    <script type="text/javascript">
    function success()
    {
      RegistrationCodeFeature.requestCode({{ registration_code.id }}, "Free promo code", '<h3>[[code]]</h3>', '<img src="http://www.example.com/logo.png" alt="Logo">');
    }
    </script>

    {% signup_form name:"signup" onsuccess:"success();" %}
        <div class="signup">
            <ol>
                <li>
                    <label for="confirm_email">Confirm Email</label>
                    <input type="text" name="confirm_email">
                </li>
            </ol>

            <p>{% signup_form_submit %}</p>
        </div>
    {% endsignup_form %}
{% endregistration_code %}

FAQ

There are currently no FAQs for this feature block.


Related Topics


Document generated by Confluence on Feb 12, 2013 09:09