Dynamic Content using Freemarker

Overview

Dynamic content is made possible in Learndot using the Freemarker template engine. FreeMarker is an open source template engine. See 'What is Apache FreeMarker?' in the official web page.

Marking Content as Dynamic

Blurbs, pages, and other entities in Learndot can include values with dynamic content. To use Freemarker as part of a entities content, mark that field as including dynamic content. Here's how to create a dynamic entity:

  • Navigate to System > Content > Choose the entity (i.e Pages)
  • Click on the New button to create a new page. Or, click on the entity's name to View an existing page.  

  • Click on the Edit icon

  • Set Dynamic to Yes

Freemarker Syntax

You will need some programming knowledge in order to create dynamic content sections in TraningRocket. In order to learn the syntax and functions available to you when working in Freemarker, we recommend referring to the offical Freemarker documentation

The syntax is similar to other templating engines such as Velocity.


<#if x == 1>
  x is 1
</#if>

Learndot ships with a number of dynamic blurbs and page sections which should provide a basis for creating your own dynamic content.

Tag Libraries

When editing FreeMarker content in a blurb, page, etc. that has been marked as dynamic, you will have access to the following tag libraries.

Library

Prefix

Description

Url

Example

JSTL core

c

JSTL 1.1 core library

Example 1


JSTL fmt

fmt

JSTL 1.1 i18n-capable formatting library

Example 2


Spark

s

Custom tags used within Learndot Enterprise

Example 3

Import the content of a blurb named homeSidePromo.

<@s.blurb name="homeSidePromo" cssClass="blurb-box" />

Examples

The "target." prefix refers to the "Supported Entity" that you have selected. The Supported Entity that is provided will dictate which parameters can be used in the email template. Please see an example of "Enrollment" in the table below.

There is also a "to." prefix and "from." prefix which allow you to get details about the person receiving the email and the person sending the email.

 Click for the full list of Supported Entities

Full list of Supported Entities:

  • Access Right
  • Account
  • Affiliate
  • affiliate_payment
  • Affiliate Customer Order Conversion
  • Affiliate Opportunity Conversion
  • Affiliate Visit
  • Agreement
  • Agreement Template
  • binary_data
  • Blurb
  • Comment
  • Contact
  • contact_signed_up_activity_item
  • Contact File Attachment
  • Content
  • Content Access
  • Content Option
  • Content Option Resource
  • Content Session
  • Country State
  • Coupon / Rule
  • Course
  • course_category
  • course_event_attended_activity_item
  • course_pathway_session
  • Course Requirement
  • Course Type
  • Credit Card Payment
  • Digital Resource
  • Discount Use
  • eLearning
  • eLearning Session
  • eLearning Survey Response (Deprecated)
  • eLearning Testimonial (Deprecated)
  • Engagement
  • Enrollment
  • Enrollment Resource
  • event_extension
  • Event Resource
  • File Attachment
  • Forum
  • Forum Post
  • Forum Subscription
  • Forum Topic
  • Forum Topic Subscription
  • Instructor Led Training
  • Instructor Led Training Session
  • integration_data
  • knowledge_category_category
  • Knowledge Category
  • Label
  • learning_pathway_session
  • Learning Component Resource
  • Learning Pathway
  • Learning Plan
  • Learning Plan Item
  • Link Resource
  • Location
  • Location Feature
  • Multiple Choice Option
  • Multiple Choice Question
  • Multiple Choice Question Response
  • Navigational Link
  • Notification
  • Order
  • Order Discount
  • Order Line
  • Page
  • Product
  • product_option
  • Product Category
  • Provider
  • Public Class
  • Purchase Order Payment
  • Questionnaire
  • Questionnaire Response
  • Quiz
  • quiz_session
  • Request for Contact
  • SAML 2.0 Configuration
  • SAML 2.0 Connection
  • scheduled_report
  • Shipping Information
  • Skill
  • Social Connection
  • Staff Role
  • Step
  • Stream Post
  • Stream Post Comment
  • survey_response_metric
  • Survey Response
  • System Setting
  • Talent Opportunity
  • Talent Placement
  • Task
  • task_template
  • Template
  • Testimonial
  • Testimonial Response
  • Text Question
  • Text Question Response
  • Timesheet
  • Training Assessment Response
  • Training Credit Account
  • Training Credit Credit
  • Training Credit Debit
  • Training Credit Payment
  • Training Credit Redemption Request
  • Training Credits
  • Training Credit Usage
  • Training Opportunity
  • Training Survey Response
  • Trigger
  • User Connection
  • Virtual Machines
  • Watcher


Example of fields that are available for the Supported Entity Type of Enrollment. The Field names were found by doing a data or CSV export of the Enrolment objects in the admin console, and reading the column names from the reported csv file. You can do the same thing for other object types.

Supported Entity TypeField NameVariableNotes

Enrollment

expired

${target.expired?c}

?c converts a number to a string for display
http://freemarker.org/docs/ref_builtins_number.html 

orderItemId

${target.orderItemId}



createdById

${target.createdById}



modifiedBy.id

${target.modifiedBy.id}



modifiedBy.displayName

${target.modifiedBy.displayName}



modifiedBy.firstName

${target.modifiedBy.firstName}



modifiedBy.lastName

${target.modifiedBy.lastName}



modifiedBy.email

${target.modifiedBy.email}



orderItem.id

${target.orderItem.id}



orderItem.displayName

${target.orderItem.displayName}



orderItem.target

${target.orderItem.target}



UUID

${target.UUID}



enrolmentDate

${target.enrolmentDate?string("yyyy-MM-dd")}

?string("yyyy-MM-dd") is the way the date will be formatted
http://freemarker.org/docs/ref_builtins_date.html 

contact.id

${target.contact.id}



contact.displayName

${target.contact.displayName}



contact.firstName

${target.contact.firstName}



contact.lastName

${target.contact.lastName}



contact.email

${target.contact.email}



componentId

${target.componentId}



digitalContent

${target.digitalContent?size}

?size can be used when a list of data is returned to count the number of items in the list
http://freemarker.org/docs/ref_builtins_sequence.html#ref_builtin_size 

version

${target.version}



id

${target.id}



organization.id

${target.organization.id}



organization.displayName

${target.organization.displayName}



organization.name

${target.organization.name}



order.id

${target.order.id}



order.displayName

${target.order.displayName}



created

${target.created?string("yyyy-MM-dd")}

?string("yyyy-MM-dd") is the way the date will be formatted
http://freemarker.org/docs/ref_builtins_date.html 

component.id

${target.component.id}



component.displayName

${target.component.displayName}



associatedEntityId

${(target.associatedEntityId)!'n/a'}

${(variable)!'n/a'} wrapping the variable in this will show n/a if the variable is empty, rather than giving a null value - and breaking your template

associatedEntityType

${(target.associatedEntityType)!'n/a'}



completionDate

${(target.completionDate?string("yyyy-MM-dd"))!'n/a'}

?string("yyyy-MM-dd") is the way the date will be formatted
http://freemarker.org/docs/ref_builtins_date.html 

keywordLabel

${target.keywordLabel}



status

${target.status}



expiryDate

${(target.expiryDate?string("yyyy-MM-dd"))!'n/a'}

?string("yyyy-MM-dd") is the way the date will be formatted
http://freemarker.org/docs/ref_builtins_date.html 

keyword

${target.keyword}



modified

${target.modified}



modifiedById

${target.modifiedById}



contactId

${target.contactId}



createdBy.id

${target.createdBy.id}



createdBy.displayName

${target.createdBy.displayName}



createdBy.firstName

${target.createdBy.firstName}



createdBy.lastName

${target.createdBy.lastName}



createdBy.email

${target.createdBy.email}



sessionId

${target.sessionId}



session.id

${target.session.id}



session.displayName

${target.session.displayName}



account.id

${target.account.id}



account.displayName

${target.account.displayName}



account.name

${target.account.name}



enrolmentResources

${target.enrolmentResources?size}

?size can be used when a list of data is returned to count the number of items in the list
http://freemarker.org/docs/ref_builtins_sequence.html#ref_builtin_size 

displayName

${target.displayName}



comments

${target.comments?size}



associatedEntity.id

${(target.associatedEntity.id)!'n/a'}



associatedEntity.displayName

${(target.associatedEntity.displayName)!'n/a'}