Display Pattern: Fieldset

Summary

 

For company events you have start and end dates. Calculate the duration from the two fields (Id: start; Id: end) in a fieldset (Id: duration) and show the values in days, or only the start date.

{% if data.duration.end %} {% assign end = data.duration.end | date: '%s' %} {% assign start = data.duration.start | date: '%s' %} {% assign durationSeconds = end | minus: start %} {% assign durationDays = durationSeconds | divided_by: 3600 | divided_by: 24 %} This event lasted {{ durationDays }} days. {% else %} This event started data.duration.start | local_date: "%d.%m.%Y %H:%M:%S". {% endif %}

Setup in Picturepark

  • Layer: "Corporate Information"

  • Fieldset: "Duration" 

    • Field: Start

    • Field: End

Field Value Access

data.corporateInformation.duration | fieldset_list: "Duration"
data.corporateInformation.duration | fieldset_name: "Duration"

  • In this case, the underlying duration information comes from the fieldset schema. The Liquid Filter accesses either the Display Pattern List or Name of the Fieldset schema "Duration."

Use Case

In the Fieldset schema, the Display Pattern could calculate the duration in days, when an end date is provided or otherwise just show the start date.

{% if data.duration.end %} {% assign end = data.duration.end | date: '%s' %} {% assign start = data.duration.start | date: '%s' %} {% assign durationSeconds = end | minus: start %} {% assign durationDays = durationSeconds | divided_by: 3600 | divided_by: 24 %} This event lasted {{ durationDays }} days. {% else %} This event started data.duration.start | local_date: "%d.%m.%Y %H:%M:%S". {% endif %}



FotoWare Switzerland AG - CH-5033 Buchs - Switzerland
https://picturepark.com - support@picturepark.com
© 2023 FotoWare Switzerland AG