Building Your Zippy Courses Theme Part 4: Template Data

Using Data in Your Templates

If the structure (HTML) and control (Handlebars) within your templates are the bones and nervous system of your theme and the CSS is the fancy hairdo and perfect complexion, then the data are the muscles that drive the entire system.

Just like your favorite college anatomy course, it's time to memorize the scientific name of every single muscle!

Just kidding. You'll always be able to look here for a cheat sheet of what data you can access and when you can access it :)

Note: As a heads up, this page is primarily meant to be a reference, so it will be a bit longer than our other items in this series.

Core Data

Core Data can be thought of as content that will always be present, on every single page load. Most pieces fall into different categories that will help you find them. Let's walk through them one-by-one.

Alerts

Alerts are messages that are sent to your user, typically after they complete (or attempt to complete) an action, and will only appear one time to the user.

Example: Your user has updated their profile, so the alerts data will include a success message confirming their update.

You can access alerts using the alerts path:

{{#if alerts }} <div class="alerts"> {{#each alerts}} {{!-- show each alert here --}} <p class="alert alert-{{type}}">{{message}}</p> {{/each}} </div> {{/if}}

Each alert will have two pieces of data:

  • type: a single word describing the type of alert. Can be success, warning, danger, error (the same as danger) or info.
  • message: the message to be shown for the alert.

Assets

The assets path holds data related to the static resources of your theme, found in the various resources/ folders. You can find the following data in the assets path:

  • favicon: The URL for your favicon file.
  • css: A list of all of the available css files in your resources/css/ folder. For themes that support variations (alternative styles), there is a special variant path to access the current variant stylesheet. Example Path: {{ assets.css.custom }} will load the URL for the file located at resources/css/custom.css.
  • js: A list of all of the available javascript files in your resources/js/ folder. 
  • images: A list of all of the available images files in your resources/images/ folder. Please note that file extensions are removed when Zippy Courses gathers all of the file URLs and prepares them for your templates, so make sure to not give a JPG and PNG the same file name. If both photo.jpg and photo.png are in your image resources, only one image path will be shared with your template. Example Path: {{ assets.images.photo1 }} will load the URL for the file located at resources/images/photo1.jpg.
  • core: Core assets are used to share required resources that must be loaded in your template to ensure that they function. This allows pieces such as checkout forms and opt in forms to function correctly.
    • js: Currently the only required set of core assets. You will find the following items: manifest, vendor, and app. They must be loaded in that order in your template. Example path: {{ assets.core.js.manifest }}

Note: If you have any nested directories in your css/, js/, and images/ resources, the file path will be accessible using dot notation. This is similar to how you would access any templates that have been stored in nested directories.

Entity

Entity data will be available to you on every page that is loaded on your site. You can think of an entity as the noun that you or your visitor are interacting with. Are you viewing a course? Then your entity is a course and has course specific data. Are you viewing a page? Then the entity is a page and has page specific data.

For consistency, any time you are loading a page, you will always have access to the currently viewed entity.

Let's take a look at each of the various entity types one-by-one, starting with commonly used pieces of data:

Common Data

There are many types of information that are similar between entities (such as a page and a course). A good example is a title, which both pages and courses have.

Because these types of information are so common, we've collected them all into their own group. Every entity will receive a full list of its attributes but will sometimes tell you to check the Common Data list for more information about the attribute.

The following are commonly used pieces of data for multiple entities:

  • blocks: Blocks are the "building blocks" of content in Zippy Courses. Pages and lessons use them the most, and they come in a variety of flavors: html (for text based content), audio, image, video, and opt-in-modals. We'll list all of the data that they can contain and indicate which fields apply to which blocks below.
    • html: An opinionated HTML output to display the block.
    • id: The block ID.
    • index: What number the block is in for the entity (starting with 0).
    • isAudioBlock: Audio blocks only. Whether this is an audio block.
    • isHtmlBlock: Html/Content blocks only. Whether this is an html block.
    • isImageBlock: Image blocks only. Whether this is an image block.
    • isOptInModalBlock: Opt In Modal blocks only. Whether this is an opt in modal block.
    • isVideoBlock: Video blocks only. Whether this is a video block.
    • reference: Data that is a part of the content of the block. Can vary from block to block. See below for block-by-block breakdown of the reference data.
    • type: can be 'content,' 'video,' 'audio,' 'opt_in_form_modal,' or 'image.'
    • title: Audio and Opt In blocks only. The block title.
  • date: Information on the date the order was made.
    • timestamp: The UNIX timestamp of the date.
    • localDate: The full date of an order. Example: January 1, 2017.
    • localDateTime: The full date and time of an order. Example: January 1, 2017 3:22pm.
  • description: A brief description of your entity (usually 200 characters or less).
  • featuredImage: A set of information about the featured image for this entity. The following information is included:
  • featuredVideo: The URL of your featured video.
  • id: The unique ID of your user. This is a Universally Unique ID, so every course, student, product, etc. in your site will have a wholly unique identifier.
  • is: Information related to the status of the entity, for convenience.
    • draft: Is your entity a draft?
    • published: Is your entity published?
    • trash: Has your entity been deleted?
  • has: A list of resources that your entity may have but are not required.
    • featuredMedia: Whether your entity has a featured image or a featured video.
    • featuredImage: Whether your entity has a featured image.
    • featuredVideo: Whether your entity has a featured video.
  • price: Information regarding the price, including:
    • amount:
      • amount: A decimal-based representation of the amount (5.00).
      • integer: An integer-based representation of the amount (500).
      • currency:
        • label: Such as "USD" or "EUR".
        • symbol: The HTML symbol for the currency. Examples: $ ($) or € (€).
    • terms: A set of data with the following information:
      • is:
        • recurring: Whether or not the price is for a subscription or payment plan.
      • numPayments: How many payments are in the order. 0 for Subscriptions, 1 for single or free, > 1 for payment plans.
      • frequency:
        • interval: The number of periods (see below) between payments.
        • period: 'once,' 'day,' 'week,' 'month,' or 'year.'
    • long: The long form price of the order, such as "$99 per month."
  • status: Will always be 'draft,' 'published,' or 'trash.'
  • title: The title of your entity.
  • urls: Important URLs for the entity, including:
    • view: The frontend URL for the entity.
    • edit: The URL to edit the entity (will only work for admins).

Example:

<header class="c-masthead c-masthead--{{ entity.content-type }}">  
    {{#if entity.layoutOptions.showNav }}  {{> common.navigation }}  {{else}}  {{#unless entity.layoutOptions }}  {{> common.navigation }}  {{/unless}}  {{/if}}
    <code><div class="c-masthead__content container">
    {{#if entity.title}}
        <h1 class="c-masthead__title">{{ entity.title }}</h1>
    {{/if}}

    {{#if entity.description}}
        <p class="c-masthead__description">{{ entity.description }}</p>
    {{/if}}
</div>
</header>

In the example above, you can see how entity data is used to control what is displayed at the top of a page.

Block Reference Data

Each block that you use when building content has slightly different extra data that is stored in its reference path. Let's review each block type to see the data available to you:

All Block References:

  • id: The reference ID. See Common Data for more information.
  • type: The reference type, will usually mirror the parent block's type.

Uploaded File References (Images, Audio):

  • basename: The file name, such as my-photo.jpg.
  • url: The full URL that can be used to access the file.
  • size: The size of your file in bytes.
  • status: ready, unless your file is in the process of being uploaded.
  • directory: This will always be either zippycourses.images or zippycourses.downloads.
  • extension: The file extension, such as .mp3 or .jpg.

Opt In Modal Reference:

  • buttonText: The text of the button that opens the modal with the opt in form.
  • content: The content to display in the modal.
  • form: Details of the form itself, including the following information:
    • buttonText: The text of the button that submits the form.
    • disclaimer: The disclaimer that details how you will use (and respect) the email they submit.
    • redirectUrl: Where users are redirected after submitting the form.
    • integration: The name of the service the form uses, such as 'aweber' or 'mailchimp.'
  • title: The title of the modal.

Courses (Private)

Course data on your site is one of the most complex pieces of information you will manage, because it is composed of many smaller pieces working together.

When you are working with a course that will be displayed for a student enrolled in your course, you will have access to the following information:

  • content: You set the content for an enrolled course in the Course Details tab of your editor. See Common Data for more information.
  • description: See Common Data for more information.
  • entries: Alias for units (see below).
  • featuredImage: You set the featured image for an enrolled course in the Course Details tab of your Course Editor. See Common Data for more information.
  • featuredVideo: You set the featured video URL for an enrolled course in the Course Details tab of your Course Editor. See Common Data for more information.
  • id: See Common Data for more information.
  • is: See Common Data for more information.
  • has: See Common Data for more information.
  • lessons: A list of lessons in this course that the student has access to. See Course Entries (Private) below for a full list of data each lesson will have. Only lessons the student has access to from their purchases will be included, even if they cannot yet view them due to prerequisites.
  • progress: How far the student has progressed in the course as a percentage. Example: 50
  • slug: Used in the URL to identify the course. If your course URL is: http://test.zippycourses.com/course/my-course, then the slug is my-course. If you do not manually set a slug in your Course Details, then the slug is automatically set to be the course ID.
  • status: See Common Data for more information.
  • synopsis: Alias for description.
  • testimonials: A list of testimonials that you have created in the Public Details tab of your Course Editor. See Testimonials for details on what information each testimonial will contain.
  • tiers: A list of tiers that you have created in the Units & Lessons tab of your Course Editor. See Tiers for details on what information each tier will contain.
  • title: See Common Data for more information.
  • units: A list of units in this course that the student has access to. See Course Entries (Private) below for a full list of data each unit will have. Only units the student has access to from their purchases will be included, even if they cannot yet view them due to prerequisites.
  • urls: See Common Data for more information.

Courses (Public)

When you are working with a course that will be displayed for a visitor or a student who is not enrolled in your course, you will have access to all of the same information you do when working with a course that someone is enrolled in (see the Courses (Private) section below), with the following differences:

  • Public Details instead of Course Details: When retrieving information such as the content or synopsis or featuredMedia of your course, Public Course Information will be retrieved from the Public Details tab of your Course Editor instead of the Course Details tab.
  • No progress information: Because there is no student information associated with the course when someone is not enrolled, there is no progress data.
  • Public Course Entries, Units and Lessons will be used: Public Course Entries contain the same information as the private ones but have not been filtered by a single student's enrollment. All published units and lessons in the course will be included.

Course Entries (Private)

Both units and lessons are considered to be Course Entries. When viewing a lesson, you will access the lesson data using the {{entity}} path. When working with a lesson that is part of a course (on a course page), you will have access to the same information but often access it using a loop to go through all of the units or lessons of a course.

When working with a Course Entry that is being viewed by an enrolled student, you will have access to the following data about the entry:

Note: Some course entry data is specific to a unit or a lesson. We will indicate below when it applies exclusively to one or the other.

  • blocks: See Common Data for more information.
  • course: Limited information regarding the course this entry is a part of, including:
    • id: The course ID; See Common Data for more information.
    • title: The course title; See Common Data for more information.
  • dateAvailable: Whether or not the entry is scheduled to be available for the student yet.
  • description: See Common Data for more information.
  • downloads: Lessons only. A list of downloads that the entry is a part of.
  • featuredImage: See Common Data for more information.
  • featuredVideo: See Common Data for more information.
  • id: See Common Data for more information.
  • index: What number the unit is in the course (starting with 0) or the lesson is in the unit.
  • is: See Common Data for more information. In addition to the common data, the following information is available for enrolled course entries:
    • available: Whether or not the student has met all of the entry's prerequisites.
    • completed: Lessons only. Whether or not the student has completed the lesson.
    • required: Lessons only. Whether or not the lesson is required.
    • unavailable: Whether or not the entry is unavailable due to pre-requisites.
  • has: See Common Data for more information.
  • lessons: Units only. All of the lessons that are a part of the unit. Review this Course Entries (Private) section to see all of the information each lesson will have.
  • lessonsCount: Units only. The number of lessons in the unit.
  • number: What number the unit is in the course (starting with 1) or the lesson is in the unit.
  • parent: Lessons only. Contains information about the unit that this lesson belongs to.
  • prerequisites: Information on which prerequisites for the entry have been met, including:
    • progress: Whether or not all previous lessons that are required have been completed.
    • quiz: Whether or not all prior quizzes have been passed.
    • date: Whether or not the entry is scheduled to be available for the student yet.
  • progress: Units only. How far the student has progressed in the current unit as a percentage. Example: 50
  • quiz: Lessons only. A quiz that belongs to the lesson. See Quizzes for details on what information the quiz will contain.
  • status: See Common Data for more information.
  • title: See Common Data for more information.
  • tiers: A list of tiers that the entry is a part of. See Tiers for details on what information each tier will contain.
  • type: 'unit' or 'lesson'.
  • urls: See Common Data for more information.

Course Entries (Public)

When working with a Course Entry that is being viewed by a visitor, you will have access to the following data about the entry:

  • course: Limited information regarding the course this entry is a part of, including:
    • id: The course ID; See Common Data for more information.
    • title: The course title; See Common Data for more information.
  • description: See Common Data for more information.
  • featuredImage: See Common Data for more information.
  • featuredVideo: See Common Data for more information.
  • id: See Common Data for more information.
  • index: What number the unit is in the course (starting with 0) or the lesson is in the unit.
  • is: See Common Data for more information.
  • has: See Common Data for more information.
  • lessons: Units only. All of the lessons that are a part of the unit. Review this Course Entries (Public) section to see all of the information each lesson will have.
  • lessonsCount: Units only. The number of lessons in the unit.
  • number: What number the unit is in the course (starting with 1) or the lesson is in the unit.
  • parent: Lessons only. Contains information about the unit that this lesson belongs to.
  • status: See Common Data for more information.
  • title: See Common Data for more information.
  • tiers: A list of tiers that the entry is a part of. See Tiers for details on what information each tier will contain.
  • type: 'unit' or 'lesson'.
  • urls: See Common Data for more information.

Pages

If you are not viewing a course or a Course Entry on your site, there is a very high chance that you are viewing a page. The following data is available to all pages:

  • blocks: See Common Data for more information.
  • description: See Common Data for more information.
  • id: See Common Data for more information.
  • is: See Common Data for more information. In addition to the standard is information, pages have the following details:
    • home: Whether or not the page is the home page.
  • has: See Common Data for more information. In addition to the standard has information, pages have the following details:
    • role: Whether or not the page has a specialized role on your site, such as a profile page or course dashboard page.
  • layout: Which layout file your template should use.
  • layoutOptions: Controls for which page elements should be displayed, including:
    • showNav: Whether or not to show the page navigation.
    • showFooter: Whether or not to show the page footer.
  • role: Usually 'default', unless the the page plays a specialized role on your site. Examples of roles include: login, register, forgot-password, reset-password, course-dashboard, profile, thank-you, affiliate-application, affiliate-preferences, and affiliate-dashboard. Most pages with roles are created automatically.
  • status: See Common Data for more information.
  • title: See Common Data for more information.
  • urls: See Common Data for more information.

Tiers

Tiers are ways of organizing levels of access within a course and controlling which content is available to a student. They are used with courses, units, and lessons, instead of in isolation, so their information is very simple.

That's it!

Testimonials

Testimonials are always included as part of something else, such as a course or a product. Here is the data that you can find in a testimonial:

  • id: See Common Data for more information.
  • title: See Common Data for more information.
  • name: The name of the person who is represented as making the testimonial.
  • content: The content of the testimonial.
  • image: See Common Data for more information, specifically the featuredImage data, for information on what is included.

Quizzes

Quizzes are a part of lessons that allow you to perform assessments on your student's progress. Quizzes are provided with the following data:

  • id: See Common Data for more information.
  • enabled: Whether or not the quiz is currently enabled for the lesson.
  • entryId: The ID of the lesson the quiz belongs to.
  • html: The pre-rendered HTML necessary to output the quiz. Quizzes are dynamic in nature, so we recommend using this pre-generated HTML to include your quizzes.
  • minScore: The minimum passing score expressed as a percentage. Example: 80.
  • quizTaken: Whether or not the quiz has been taken.
  • bestSubmission: If the quiz has been taken before by the student, the following information will be available:
    • id: See Common Data for more information.
    • score: The score the student received on the attempt.
    • passed: Whether or not the quiz was passed.
  • required: Whether or not the quiz must be taken before the student may continue to progress through the course.
  • url: The URL where the quiz can be taken.

Orders

Order entities contain information about a specific order, including the product purchased, payment(s) made, and the customer. Orders are provided with the following data:

  • customer: Information about the customer that purchased the product, including:
    • id: See Common Data for more information.
    • name: The customer's full name.
    • firstName: The customer's first name.
    • middleName: The customer's middle name.
    • lastName: The customer's last name.
    • email: The customer's email address.
  • date: See Common Data for more information.
  • id: See Common Data for more information.
  • payments: A list of payments that will each include the following data:
    • date: See Common Data for more information.
    • id: See Common Data for more information.
    • paid: See price in Common Data for more information.
    • status: Will always be 'pending,' 'paid,' 'failed,' or 'refunded.'
    • title: See Common Data for more information.
    • gateway: The payment gateway used, such as 'paypal,' 'stripe,' or 'infusionsoft.'
    • gatewayId: The ID of the payment that the gateway created when the payment was made. Format varies from gateway to gateway.
  • product: Information about the product purchased, including:
    • available: Whether or not the product is currently available for sale.
    • availability: Whether or not the product is currently available for sale according to various criteria.
    • description: See Common Data for more information.
    • id: See Common Data for more information.
    • is:
      • free: Whether or not the product was free.
      • active: Whether or not the product is active.
      • launchWindow: If the product uses launch windows, whether or not the current time is within a launch window.
    • title: See Common Data for more information.
    • visibility: Whether the product will be visible in various circumstances, including:
      • course: Will the product appear on a public course page?
  • status: The following statuses are valid:
    • completed: No more payments will be executed on the order (such as a payment plan), and all required payments were successful.
    • active: A status for recurring orders that indicates all required payments have been made.
    • canceled: A status for recurring orders indicating that the order was canceled prior to completion.
    • delinquent: A status for recurring orders indicating that a payment has been missed or failed.
    • refunded: A status for non-recurring orders indicating that the order has been refunded.
  • summary: Summary details for the order, including:
    • totalPaid: See price in Common Data for more information.
    • numPaymentsMade: How many payments have been made in the order (useful for recurring orders).
    • numPaymentsRequired: How many payments will be made when the order is completed (0 for subscriptions).
  • title: See Common Data for more information.
  • type: Will always be 'free,' 'single,' 'subscription,' or 'payment-plan.'
  • urls: See Common Data for more information.

Forms

Form data stores essential information about the core forms used throughout your Zippy Courses site, such as Login and Registration.

You can access the following information in your forms path:

  • login: Information for your login form, including:
    • method: The submission method for your form (POST).
    • action: The action (or location) to use when submitting the form.
  • register: Information for your login form, including:
    • method: The submission method for your form (POST).
    • action: The action (or location) to use when submitting the form.
  • forgot-password: Information for your forgot password form, including:
    • method: The submission method for your form (POST).
    • action: The action (or location) to use when submitting the form.
  • reset-password: Information for your reset password form, including:
    • method: The submission method for your form (POST).
    • action: The action (or location) to use when submitting the form.
  • affiliate: Information for all affiliate forms including:
    • register: Information regarding the form that allows existing users to become affiliates, including:
      • method: The submission method for your form (POST).
      • action: The action (or location) to use when submitting the form.
    • apply: Information regarding the form that allows visitors (people without accounts on your site) to become affiliates, including:
      • method: The submission method for your form (POST).
      • action: The action (or location) to use when submitting the form.

In addition to the information specifically about important forms, you will also find two additional bits of significant information in your forms path:

  • token: In every form you create, you must include a hidden input named _token and have it use the value of this variable using {{ forms.token }}.
  • old: For every field that has been submitted in a previous attempt to submit a form, it will be stored for one additional page load in the event of an error. For example, if your field has a field with the name attribute, firstName, you can access what was submitted by using {{ forms.old.firstName }}. This can provide convenience for people filling out your forms - just be careful to never do this for password fields.

Links

Link data is a static resource that gives you access to the common pages on your Zippy Courses site. The following links are available to use:

  • affiliate: A set of affiliate related links:
    • dashboard: The dashboard where affiliates can see their performance as an affiliate.
    • preferences: Where an affiliate can edit their preferences for their affiliate account, such as preferred payment type.
    • application: Where a user can apply to become an affiliate.
  • dashboard: Your student's Course Dashboard page.
  • directory: The Course Directory on your Zippy Courses site.
  • login: Where a visitor goes to log in.
  • logout: Where a visitor goes to log out of their session.
  • user: A collection of user account links, including:
    • orders: Where a user can view all of their orders on your site.
    • profile: Where a user can update their profile.
    • email-preferences: Where a user can manage which emails they want to receive from you.
    • password: URLs related to the password for your users account, including:
      • manage: Where a user can change their password.
      • reset: Where a logged out user can initiate the password reset process.

Example:

    {{!-- Below is a segment of code from a top navigation --}}

<div class="collapse navbar-collapse" id="primary-navbar">
    <ul class="navbar-nav ml-auto">
        <li class="nav-item">
        <a href="{{ links.dashboard }}" class="nav-link">My Courses</a>
        </li>
        <li class="nav-item dropdown">
        <a class="nav-link dropdown-toggle" href="{{ links.user.profile }}" id="navbarDropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">My Account</a>
        <div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
            <a href="{{ links.user.profile }}" class="dropdown-item">Edit Profile</a>
            <a href="{{ links.user.orders }}" class="dropdown-item">My Orders</a>
            <div class="dropdown-divider">
            </div>
            <p>
                <a href="{{ links.logout }}" class="dropdown-item">Logout</a>
            </p>
        </div>
        </li>
    </ul>
</div>

The above example shows how links are used in the context of a top navigation menu. You can see links such as {{ links.user.profile }} or {{ links.logout }} in action.

Request

Request data gives you access to the information that is sent from the browser to the server when a URL is visited. This includes query variables in the URL or POST data from a form.

Each individual record is accessible using the name of the data. For example, if you were to visit the following thank you page:

http://example.zippycourses.com/thank-you?order=12345

You could access the order parameter from the URL using this statement in your templates: {{ request.order }}. Easy, right?

And if you submitted a form with the following input:

<input name="firstName" value="" />

On the template for the page processing the submission, you would be able to access it using the following statement: {{ request.firstName }}

If the path you specify is not present in the Request data, there will be no output for the statement.

Site

Site data has basic information about the configuration of your Zippy Courses site. You will find the following information in your site path:

  • contactEmail: The email that you send and receive emails from, typically for support purposes.
  • lang: The ISO 639-1 Code that indicates the language for your site's documents. Can be used with the opening html tag.
  • logo: The URL of the image that has been uploaded as a site logo or an empty string ('') if no logo was uploaded.
  • mastheadBackground: If your theme supports a header background, the URL of that image will be stored here.
  • name: The name of your site.
  • owner: Your name.
  • slug: In the following URL: http://test.zippycourses.com, the slug would be test. Every site on Zippy Courses has a unique slug.
  • url: The full URL for your site. If you are using a custom domain, it will be your custom domain. Otherwise, it will be a subdomain of Zippy Courses.

Example:

{{!-- Below is a segment from a top navigation template --}}

<div class="c-brand navbar-brand">
    {{#if site.logo}}
    <a href="{{ site.url }}" class="c-brand__link">
    <img class="c-brand__logo" src="{{ site.logo }}" alt="{{ site.name }} Logo">
    </a>
    {{else}}
    <p class="c-brand__name">
        <a href="{{ site.url }}" class="c-brand__link">{{ site.name }}</a>
    </p>
    {{/if}}
</div>

The above example uses various site information to alternatively show a logo or the name of a site, depending on whether your site has a logo uploaded.

Settings

Settings data exposes a limited cross-section of the settings on your site that will be required to fully complete your templates. Here are the current settings available for you to use in your templates:

  • affiliate: Settings related to your affiliate program. The following pieces of information are available in this group:
    • enrollment: Information related to the enrollment of your affiliate program.
      • open: Whether or not your affiliate program is open for public enrollment.
      • approvalRequired: Whether or not a new affiliate requires administrator approval before selling.
    • terms.content: The HTML content of the terms and conditions for your affiliate program.
    • cookies: Details related to how cookies function for your affiliate program.
      • duration: How many days the cookies are valid.
      • method: Always 'first' or 'last,' which refers to which affiliate gets credit for a referral when two or more affiliates make a referral.
    • payout: Details related to the payout schedule for your affiliate program.
      • refundPeriod: The number of days a student has to request a refund for their purchase.
      • schedule: The period of time in which payouts are made. Options: week, month, quarter.
      • rate: The default commission rate as a percentage. Default is 50.
  • payment: Details related to how you accept payment on your site. These settings are important for creating checkout forms.
    • gateway: The currently selected payment gateway, such as 'stripe' or 'paypal.'
    • type: Always either 'external' or 'credit-card.' External processors are services such as PayPal or SamCart that redirect you to their sites for checkout. Credit card processors are services such as Stripe or Infusionsoft that do not require redirecting your user to a third party site for payment processing.

Example:

{{!-- A block of code from an affiliate layout template --}}

<div class="card card--aff-register my-5">
    <header class="card-header">
    <h3 class="card-title">{{ entity.title }}</h3>
    </header>
    <div class="card-block">
        {{#if settings.affiliate.enrollment.open }}
            {{> common.blocks blocks=entity.blocks }}
            {{#if user }}
                {{> forms.affiliate.apply }}                
            {{else}}
                {{> forms.affiliate.register }}                
            {{/if}}
        {{else}}
        <div class="alert alert-warning">
            <p>
                <strong>Our Affiliate Program is not currently open!</strong><br>
                This may change in the future, so please feel free to check back again soon, or 
                <a href="mailto:{{ site.contactEmail }}">contact us</a> for more information on becoming an affiliate.
            </p>
        </div>
        <p>
                    {{/if}}
        </p>
    </div>
</div>

In the above example, affiliate settings are checked to determine whether a user should see a registration form (if the affiliate program is open) or whether they should see an alert alerting them that the program is not available.

Student

Student data, accessed via the student path, is identical to the User data, with one additional piece of information:

  • courses: This is a set of course data which exposes all of the information about the course the student is enrolled in. Please see the entity information about Courses (found above) to see the information available for you to use in each course.

User

User data contains information about the currently logged in user, such as yourself or a student. You will find the following information in your user path:

  • id: The unique ID of your user. This is a Universally Unique ID which you can learn more about by clicking here.
  • email: The user's email address.
  • name: A user's name, composed of the various parts:
    • first: The user's first name.
    • middle: The user's middle name.
    • last: The user's last name.
    • full: The user's full name using the following format: firstName middleName lastName.
  • is: A list of roles that your user has. You can check against the following roles:
    • student: Will always be true for a logged in user.
    • affiliate: Will be true for any user who is a registered affiliate.
    • admin: Will only be true for you or your own site.
  • marketing: Information about how and when the current user can be marketed to.
    • preferredFormat: Will always be text or html.
    • subscriptions: A list of people's subscriptions to the emails for particular courses. Each subscription will have the following information:
      • id: The ID of the particular course subscription.
      • status: Will always be 'subscribed' or 'unsubscribed.'
      • type: Currently will always be 'course.'
      • title: The title of the course this subscription refers to. Example:
<div class="card">
    <header class="card-header">
    <h3 class="card-title">Your Contact Details</h3>
    </header>
    <pre>
<code><div class="card-block">
    <form method="POST">
        <div class="form-group">
            <label for="userFirstName">First Name</label>
            <input type="text" id="userFirstName" name="firstName" class="form-control" value="{{ user.name.first }}">
        </div>
        <div class="form-group">
            <label for="userMiddleName">Middle Name</label>
            <input type="text" id="userMiddleName" name="middleName" class="form-control" value="{{ user.name.middle }}">
        </div>
        <div class="form-group">
            <label for="userLastName">Last Name</label>
            <input type="text" id="userLastName" name="lastName" class="form-control" value="{{ user.name.last }}">
        </div>

        <input type="hidden" name="userId" value="{{ user.id }}" />
        <input type="hidden" name="_token" value="{{ forms.token }}" />

        <button type="submit" class="btn btn-primary">Update Profile</button>
    </form>
</div>

The above example uses user data to pre-populate a form with information that is already known about the current user.

Utilities

Utilities data is a set of static data that allows you to perform complex tasks, such as a list of all of the countries in the world and their country code.

  • countries: A list of all countries with the following attributes:
    • name: The name of the country (in English).
    • code: The two character country code to identify the country.

More utility data will be added in the future as the most common needs for themes are identified.

Example:

 {{!-- The following dropdown is from an affiliate preferences page --}}


    <select name="address.country" id="addressCountry" class="form-control">
          {{#each utilities.countries }}  <option value="{{ code }}" {{#eq code @root.affiliate.address.country }}selected{{/eq}}>{{ name }}  {{/each}}
    </select>

In the example above, we use the list of countries to render a dropdown list of all of the available countries and choose the currently selected country.

Holy Moly...

Yes, that was a massive data dump! However, we encourage you to think about this page not as a part of a tutorial but more as a reference when you are building your themes.

This page will be kept updated with any additions that are made to the template data structures.

Ready for more?! Let's move on to What's Required in a Theme!