Menu

#627 Output rendering

Parent Category:
DPCalendar
Category:
Misc
Last Updated:
Allon Moritz, Wednesday, 20 December 2023 10:55
Created:
Wednesday, 06 June 2012 06:27
Hits:
23486

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>?

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. Here is the list of the available variables which are passed together with the output text to the mustache engine:

  • id
    The id of the calendar or event.
  • 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.
  • title
    The title of the event.
  • 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.
  • url
    The url of the event.
  • hits
    The hit counter of the event.
  • 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.
  • capacityUsed
    The used capacity.
  • capacityRemaining
    The remaining capacity.
  • bookings
    The booking objects.
  • tickets
    The tickets objects.
  • 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}}<br>...<br>{{/events}}<br>{{^events}}<br>{{emptyText}}<br>{{/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.