Menu

Support is limited till 28. July 2025, because of holiday absences. We try to respond urgent cases!

#627 Output rendering

Parent Category:
DPCalendar
Category:
Misc
Last Updated:
Allon Moritz, Monday, 02 December 2024 09:55
Created:
Wednesday, 06 June 2012 06:27
Hits:
25593

Introduction

To compile strings with event information, DPCalendar uses a template engine called mustache.

It works by expanding tags in a template using values provided in a hash or object. Statement from http://mustache.github.com/mustache.5.html

The idea is that mustache should simplify the output customization in your Joomla calendar for non PHP developers. This syntax is mostly used in language strings for notifications or the content plugin.

Syntax

On most language strings which do need some event data the mustache codes are used. Basically the {{parameter}} describes a variable passed to the output. {{#start_list}} is the beginning of an iteration over a list where the {{/start_list}} tag is the end of it. Mustache ensures the variables are HTML escaped. If you want to render it as it should be , use three mustaches like {{{parameter}}}

More mustache information can be found here.

Example

Here is an example of a DPCalendar output:

{{#events}}<p>{{date}}<br/>{{{description}}}<br/>We are at: {{#location}}{{country}}, {{city}}{{/location}}</p>{{/events}}

will be rendered as

<p>19.02.2012<br/>Example description with <b>HTML</b>content</br>We are at: USA, New York</p>?

Empty block

It is possible to have som kind of if else logic in mustache. A block with a # defines an array, object or not empty variable. An inverted section begins with a ^ character and catches all empty values. The following example renders the text "No events found, come back later!" when there are no events found:

{{#events calid=9}}<p>{{title}}</p>{{/events}}{{^events}}<p>No events found, come back later!</p>{{/events}}

Keep in mind that {{/events}}{{^events}} must be come directly after each other, no spaces or other characters are allowed, otherwise it fails to render it correctly.

Variables

DPCalendar provides a wide range of variables which can be used in a mustache ready text. The text must be started with {{#events}} and end with {{/events}} even when it is only one single event. The event attributes like id, title, url or state are available and the following list of the extra variables which are passed together with the output text to the mustache engine:

  • calendarLink
    Link to the calendar menu item if one is available, with the calendar selected where the event belongs to.
  • backLink
    Link to the events details page.
  • color
    The color of the calendar or event.
  • calendarName
    The name of the calendar the event belongs to.
  • date
    A date string where only the dates and times are shown which are relevant in the format {{startDate}} {{startTime}} - {{endDate}} {{endTime}}.
    • Single part day
      Start date and time and end time
    • Single full day
      Start date
    • Multiple part day
      Start date and time and end date and time
    • Multiple full day
      Start date and end date The format of the date and time can be configured in the DPCalendar options!!
  • startDate
    Start date of the event. The format of the date and time can be configured in the DPCalendar options!!
  • startTime
    Start time of the event. _The format of the date and time can be configured in the _DPCalendar options!!
  • endDate
    End date of the event. _The format of the date and time can be configured in the _DPCalendar options!!
  • endTime
    End time of the event. _The format of the date and time can be configured in the _DPCalendar options!!
  • dateSeparator
    The - sign as date separator
  • year
    The year when the event starts.
  • monthNr
    The month as number when the event starts.
  • month
    The month when the event starts.
  • day
    The day of month when the event starts.
  • canEdit
    If the user can edit the event.
  • editLink
    The link to the event edit page.
  • canDelete
    If the user can delete the event.
  • deleteLink
    The link to the event delete page.
  • images
    The images can be references like {{images.image_full}}. The following fields are available:
    • {{image_intro}}
    • {{image_intro_alt}}
    • {{image_intro_caption}}
    • {{image_full}}
    • {{image_full_alt}}
    • {{image_full_caption}}
  • location
    An array of locations. Inside the location tag you can use all the fields from a location like {{street}}, {{city}} or {{room}}. A simple output can look like {{#location}}Happens here {{country}}{{/location}}. The following fields are available:
    • {{full}}
      This is a special field which creates a comma separated string of the fields of the location
    • {{title}}
    • {{alias}}
    • {{country}}
      The country id
    • {{country_code}}
      The country code like GB
    • {{country_code_value}}
      The country name like United Kingdom
    • {{province}}
    • {{city}}
    • {{zip}}
    • {{street}}
    • {{number}}
    • {{room}}
    • {{latitude}}
    • {{longitude}}
    • {{url}}
    • {{description}}
    • {{language}}
  • {{description}}
    The description of the event. In the event tooltip the description gets truncated to 200 characters.
  • {{description_truncated}}
    The truncated description of the event. This variable is only available in the upcoming module and list views and contains the read more button and ellipses.
  • stateName
    The state name of the event as string, like 'Published'.
  • author
    The author name.
  • authorMail
    The author E-Mail address.
  • avatar
    If an avatar system is available an avatar image will be set.
  • capacity
    The capacity as number or text "unlimited".
  • capacityRemaining
    The remaining capacity.
  • bookings
    The booking objects.
  • ticket
    An array of ticket objects. Inside the ticket tag you can use all the fields from a ticket like {{email}}, {{name}} or {{country_code}}. A simple output can look like {{#ticket}}Name: {{name}}{{/location}}. The following fields are available:
    • {{id}}
    • {{user_id}}
    • {{user_name}}
    • {{uid}}
    • {{email}}
    • {{name}}
    • {{telephone}}
    • {{country}}
    • {{country_code}}
    • {{country_code_value}}
    • {{province}}
    • {{city}}
    • {{street}}
    • {{number}}
    • {{price}}
    • {{type}}
    • {{type_label}}
      The label of the ticket type from the prices array of the event
  • copyGoogleUrl
    The url to copy the event to google.
  • copyOutlookUrl
    The url to create an ICS file which can be imported into MS Outlook.
  • header
    If the list of events should be grouped is the header the textual representation.
  • calendarNameLabel
    The label of the calendar name.
  • titleLabel
    The label of the title.
  • dateLabel
    The label of the date.
  • locationLabel
    The label of the location.
  • descriptionLabel
    The label of the description.
  • authorLabel
    The label of the author.
  • copyLabel
    The label of the copy links.
  • copyGoogleLabel
    The label of the copy to google link.
  • copyOutlookLabel
    The label of the copy to outlook.
  • urlLabel
    The label of the url
  • hitsLabel
    The label of the hits.
  • language
    The actual language where the data is displayed.
  • emptyText
    The replacement text when there are no events found. Here is an example how this text can be used.
    {{#events}}<p>{{title}}</p>{{/events}}{{^events}}<p>{{emptyText}}</p>{{/events}}
  • field-[*] The event custom fields objects. You can directly access every field with the prefix field- and then the name. For example when the field has the name XYZ, you can use the way {{#field-XYZ}}{{value}}{{/field-XYZ}} to render the value of it.

Comments (0)

We use cookies on our website. Some of them are essential for the operation of the site, while others help us to improve this site and the user experience (tracking cookies). You can decide for yourself whether you want to allow cookies or not. Please note that if you reject them, you may not be able to use all the functionalities of the site.