Forum for discussing general topics related to Couch.
7 posts Page 1 of 1
If I create a multi day event, it shows on the calendar but only on the start date, would be nice if it can show from the start date to the end date on the calendar

I found this guide but not yet used it viewtopic.php?f=2&t=8928 but just seeing if was a nicer way to do it as the user said it's a ugly way to do it
Update: I have tried viewtopic.php?f=2&t=8928 method but does not work unfortunately on couchcms v2.2
Sorry but really need help on this one as can't work this one out

I looked at integrating fullcalendar but that went over my head and unsure how to create the events for that in couchcms so gone back to the default couchcms calendar but can't work out how to get multiday events to show across the days, for example if I create a multi day event in the couchcms admin side and set the start date as 3-5-2019 and the end date as 5-5-2019, on the calendar in the front end, it would be good to show the event across the two days instead of it showing on just the start date
Ian, as I admitted in the thread you mentioned, multi-day events are not natively supported by Couch.
My suggestion would be to use a JS calendar library (there are several out there) for this and couple it with Couch in the backened.
I looked at fullcalendar, I know how to get it displaying on the site but am unsure how to integrate the couchcms into it in the backend?
I'm going to have a crack using fullcalendar

I have added it on the page calendar.php and it's getting the events from fullcalendar/php/get-events.php

Been having a think and wondering if the couchcms tags/coding below can be added to get-events.php file so the admin user can add events in the couchcms admin side so the get-events.php file would look like the following. I am no doubt wrong with it, just trying to work it out

Code: Select all

<?php require_once( '../../cms/cms.php' ); ?>

<cms:template title='Calendar' order='9' clonable='1'>

    <cms:editable name='desc' label='Description' type='textarea' />
    <cms:editable name='location' label='Location' type='text' />

    <cms:editable name="start_time" label="Time From (24 Hrs)"
      opt_values=' Unspecified |
                  00:00 | 00:30 | 01:00 | 01:30 | 02:00 | 02:30 | 03:00 | 03:30 |
                  04:00 | 04:30 | 05:00 | 05:30 | 06:00 | 06:30 | 07:00 | 07:30 |
                  08:00 | 08:30 | 09:00 | 09:30 | 10:00 | 10:30 | 11:00 | 11:30 |
                  12:00 | 12:30 | 13:00 | 13:30 | 14:00 | 14:30 | 15:00 | 15:30 |
                  16:00 | 16:30 | 17:00 | 17:30 | 18:00 | 18:30 | 19:00 | 19:30 |
                  20:00 | 20:30 | 21:00 | 21:30 | 22:00 | 22:30 | 23:00 | 23:30 |'
      type='dropdown'
    />

    <cms:editable name="end_time" label="Time Until (24 Hrs)"
      opt_values=' Unspecified |
                  00:00 | 00:30 | 01:00 | 01:30 | 02:00 | 02:30 | 03:00 | 03:30 |
                  04:00 | 04:30 | 05:00 | 05:30 | 06:00 | 06:30 | 07:00 | 07:30 |
                  08:00 | 08:30 | 09:00 | 09:30 | 10:00 | 10:30 | 11:00 | 11:30 |
                  12:00 | 12:30 | 13:00 | 13:30 | 14:00 | 14:30 | 15:00 | 15:30 |
                  16:00 | 16:30 | 17:00 | 17:30 | 18:00 | 18:30 | 19:00 | 19:30 |
                  20:00 | 20:30 | 21:00 | 21:30 | 22:00 | 22:30 | 23:00 | 23:30 |'
      type='dropdown'
    />
   
    <cms:editable
    name='start_date'
    label='Start Date'
    type='datetime'
    format='dmy'     
    fields_separator=','
    default_time='@current'
    required='1'
    validator='MyEvent::start_date'
    validator_msg='myevent::start_date=Incorrect date format'
/>
   
    <cms:editable name='end_date'
    label='Event End Date (if multi-days event)'
    type='datetime'
   format='dmy'
    fields_separator=','
   default_time='@current'
    />
   
</cms:template>

<?php

//--------------------------------------------------------------------------------------------------
// This script reads event data from a JSON file and outputs those events which are within the range
// supplied by the "start" and "end" GET parameters.
//
// An optional "timeZone" GET parameter will force all ISO8601 date stings to a given timeZone.
//
// Requires PHP 5.2.0 or higher.
//--------------------------------------------------------------------------------------------------

// Require our Event class and datetime utilities
require dirname(__FILE__) . '/utils.php';

// Short-circuit if the client did not give us a date range.
if (!isset($_GET['start']) || !isset($_GET['end'])) {
  die("Please provide a date range.");
}

// Parse the start/end parameters.
// These are assumed to be ISO8601 strings with no time nor timeZone, like "2013-12-29".
// Since no timeZone will be present, they will parsed as UTC.
$range_start = parseDateTime($_GET['start']);
$range_end = parseDateTime($_GET['end']);

// Parse the timeZone parameter if it is present.
$timeZone = null;
if (isset($_GET['timeZone'])) {
  $timeZone = new DateTimeZone($_GET['timeZone']);
}

// Read and parse our events JSON file into an array of event data arrays.
$json = file_get_contents(dirname(__FILE__) . '/../json/events.json');
$input_arrays = json_decode($json, true);

// Accumulate an output array of event data arrays.
$output_arrays = array();
foreach ($input_arrays as $array) {

  // Convert the input array into a useful Event object
  $event = new Event($array, $timeZone);

  // If the event is in-bounds, add it to the output
  if ($event->isWithinDayRange($range_start, $range_end)) {
    $output_arrays[] = $event->toArray();
  }
}

// Send JSON to the client.
echo json_encode($output_arrays);
?>

<?php COUCH::invoke(); ?>
I have found this guide online for fullcalendar https://itsolutionstuff.com/post/how-to ... ample.html but just unsure about integrating couchcms into it so events can be created from the couchcms admin side, would the cms editable tags be added to the add_events.php file if I was to use the coding from that link?
7 posts Page 1 of 1