Skip to content

a perch template filter to compute an event end time from a field on the template named 'program_duration'

Notifications You must be signed in to change notification settings

montlewis/PerchCMS-EndTime-Template-Filter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 

Repository files navigation

PerchCMS-EndTime-Template-Filter

This template filter will set an event end time as a date field. This is particularly handy in creating events where the event start time is set and then an event duration field is set. This template filter will return a date that is the start time plus the value of the duration. If there is no duration value set, it defaults to 3 hours.

installation

  • Download the latest version
  • Place the MontlewisTemplateFilter_eventendtime.class.php in the folder perch/addons/templates/filters/
  • Include the class in the file perch/addons/templates/filters.php
include('filters/MontlewisTemplateFilter_eventendtime.class.php');
  • Add a field to your template: <perch:content id="program_duration" label="Duration" type="number" suppress size="s" help="Optional. ie: ‘Enter the length of the event in hours (ie 6.5 for an event that starts at 8:30 and goes to 3pm." step="0.25" > (make sure you set the correct perch appspace):

Configuration

Enable template filters

You need to enable template filters in your config file perch/config/config.php:

define('PERCH_TEMPLATE_FILTERS', true);

Usage

<perch:content id="eventDateTime" filter="eventendtime" format="l, F jS, Y g:ia">

Notes

If there is a field on the template named program_duration, it will use the value in that field to compute the event ending time. Otherwise, it will default to 3 hours. you can change the default by editing this line of the template filter:

$endTime = date('Y-m-d H:i:s',strtotime('+3 hour',strtotime($value)));

About

a perch template filter to compute an event end time from a field on the template named 'program_duration'

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages