New Duration Fieldtype in ExpressionEngine 4
2/5/2018 / By Derek Jones
ExpressionEngine 7.5 has been Released! Learn More!
2/5/2018 / By Derek Jones
Dates are not the only way we measure or describe time. Take a movie theater’s web site. The date and time that a show starts is important. But so is its length. If you’re operating a movie review site, then you probably only care about its runtime. The Duration fieldtype is just what the doctor ordered.
Both the input and the output options are flexible. In the example of our movie above, “The Jungle Book”, the site builder has created a Duration field with minutes as the unit of measure. The content author can enter the runtime as 106 minutes or use colon notation of 1:46, indicating 1 hour and 46 minutes. Either way, ExpressionEngine knows the total time being indicated, and the site builder could display it as:
{runtime}
{!-- 1:46 --}
Or have full control over the formatting with the format=
parameter like:
{runtime format='%h hr, %m min'}
{!-- 1 hr, 46 min --}
In the field’s settings, the site builder can select either hours, minutes, or seconds as the unit of time. ExpressionEngine will cue the author in the placeholder text, so they are aware of what their input would signify. e.g. 42 hours vs. 42 minutes vs. 42 seconds. Movie and play runtimes, cooking times, travel times, cycling / running elapsed times, and more are all great fits for the new Duration fieldtype.
This article took you approximately 1m 6s / 1:06 / 1 minute and 6 seconds / 66 sec to read. ⏱
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.