Open kelizoliva opened 5 years ago
Can you export your view and attach it here?
On Thu, Aug 1, 2019, 7:08 PM kelizoliva notifications@github.com wrote:
Working with fields coming from CiviCRM. Creating a view with an unformatted list I have no issues, but when using the FullCalendar format, I get: Display "Block" requires at least one date field.
There is a date field available, so not really sure what the issue is here. Has anyone else experienced this or something similar?
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/backdrop-contrib/fullcalendar/issues/7?email_source=notifications&email_token=AAGUX7MX3DEP2TWKVSAFR23QCN3HLA5CNFSM4IIYXKUKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HC6INRQ, or mute the thread https://github.com/notifications/unsubscribe-auth/AAGUX7L5B6FL2GHZJYMZNX3QCN3HLANCNFSM4IIYXKUA .
I almost pasted it in, but realized that would be obnoxious.
So this calendar currently pulls standard Backdrop date fields, but not CiviCRM fields. It may be possible to extend it to include CiviCRM date fields and I'm definitely open to that. It looks like this is where it's checking to make sure it's a date field:
https://github.com/backdrop-contrib/fullcalendar/blob/1.x-2.x/fullcalendar.module#L324-L341
So we'd need to think through how to handle CiviCRM dates (only if CIviCRM is installed, perhaps), especially in regard to the automated update funcitonality that exists where you can drag an event on the front end and have it update the date in the backend.
Awesome. I will take a look and see if I can figure it out, and will submit a PR if I do.
I do not seem to be able to figure out what I need to do to get this working. I tried creating a conditional statement in the fullcalendar.module file in the fullcalendar_field_is_date() function, but I'm obviously off because it resulted in errors. Here is what I have tried, maybe you could point me in the right direction?
function fullcalendar_field_is_date($field, $include_gcal = FALSE) {
if ($include_gcal && $field->field == 'gcal') {
return TRUE;
}
if (module_exists('civicrm') && (($field->field == 'end_date') || ($field->field == 'start_date') || ($field->field == 'registration_start_date') || ($field->field == 'registration_end_date'))) {
return TRUE;
}
return !empty($field->definition['is date']) && isset($field->field_info);
}
And the error:
Error: Call to undefined method civicrm_handler_field_datetime::get_items() in fullcalendar_prepare_events() (line 149 of /opt/buildkit/build/calendar/modules/fullcalendar/theme/theme.inc).
@kelizoliva Spitballing, but do you need to initialize CiviCRM in the case of a CiviCRM field before returning TRUE?
civicrm_initialize();
I'm not sure if there is anything helpful in https://www.drupal.org/project/civicrm_multiday_event, but I wrote that 4+ years ago to be able to display both Drupal and CiviCRM events with the same fullcalendar. I haven't touched that code in years, but it looks like @ericfg made some updated to a fork at https://github.com/cm-advanced/civicrm_multiday_event to get things working with the current versions of the CiviCRM and Drupal code the module leveraged. I'm not sure where Eric landed on Backdrop, but you might ping him to see if has any time to help with this.
@kelizoliva Spitballing, but do you need to initialize CiviCRM in the case of a CiviCRM field before returning TRUE?
civicrm_initialize();
I'm not sure that is the issue. I have it initialized an it is not making any difference. I am getting the following error (without adding that line):
Error: Call to undefined method civicrm_handler_field_datetime::get_items() in fullcalendar_prepare_events() (line 149 of /opt/buildkit/build/calendar/modules/fullcalendar/theme/theme.inc).
In theme.inc:
$events = array();
foreach ($rows as $delta => $row) {
// Collect all fields for the customize options.
$fields = array();
// Collect only date fields.
$date_fields = array();
foreach ($view->field as $field_name => $field) {
$fields[$field_name] = $view->style_plugin->get_field($delta, $field_name);
if (fullcalendar_field_is_date($field)) {
$date_fields[$field_name] = array(
'value' => $field->get_items($row),
'field_alias' => $field->field_alias,
'field_name' => $field->field_info['field_name'],
'field_info' => $field->field_info,
);
}
}
Where line 149 is 'value' => $field->get_items($row),
,
I'm thinking that the foreach statement will need some adjustment to account for civicrm date fields.
@kelizoliva I'll try to take a look at this but can't promise a timeline.
Would you prefer I push my current changes to a branch for you to review?
I appreciate you looking at this when you are able to fit it into your schedule!
@kelizoliva Sure sounds great!
OK, my changes are now in the civicrm_integration branch.
I've been looking this over a bit and wonder whether it makes more sense to have people add a CiviEvent field rather than an individual CiviEvent date field -- then (with some effort) we'd be able to pull both the start date and the end date from the event. Otherwise we'll just display the event start date.
I think you are right that we'll need to adjust this section of theme.inc
, and also create our own $field->get_items
functionality to populate the CiviEvent data as Views and FullCalendar are expecting it.
WIP: https://github.com/backdrop-contrib/fullcalendar/commit/89653354a8b369ddc62f692e23c07438e7c64c25
Feel free to keep working on it here if you try anything else that you think has potential. I'll get back to it at some point but appreciate any input you may have on it.
If I am understanding you correctly, this definitely sounds like a good solution; the Civi event date field name will always be the same (unlike in Backdop), so the idea makes total sense to me!
As an aside... Jack is at the SF Bay Area BADCamp this week getting Backdrop folks excited about Backdrop/CiviCRM integration and we think that this module would be a really great addition/carrot on a stick for folks wanting to move their Civi implementations to Backdrop!
@kelizoliva I'm absolutely not familiar with Civi events, but in case it's a timestamp (database field), and views support is defined, then the new module Fullcalendar Views NG might possibly work out of the box.
Working with fields coming from CiviCRM. Creating a view with an unformatted list I have no issues, but when using the FullCalendar format, I get:
Display "Block" requires at least one date field.
There is a date field available, so not really sure what the issue is here. Has anyone else experienced this or something similar?