Italian (Italy)
Knowledge Base  >  Vik Appointments  >  Hook  >  Calendario  >  Before Fetch Data

apply_filters_ref_array( 'vikappointments_before_fetch_calendar_data', bool $statusarray &$options )

Fires before fetching the calendar data in the front-end.


Description

Trigger hook before fetching the data needed to display a calendar in the front-end.

Useful, in example, to switch the calendar layout at runtime by altering the related array attribute. 


Parameters

$status

(bool)  True on success, false otherwise.

&$options

(array)  An array of search options.

  • id_ser - the ID of the selected service;
  • id_emp - the ID of the selected employee;
  • layout - the type of layout to use (weekly or monthly).

Example

The example below uses a different calendar layout for the services that belongs to the group with ID equals to 1.

/**
 * Trigger hook before fetching the data needed to display a calendar.
 * Useful, in example, to switch the calendar layout at runtime by altering
 * the related array attribute.
 *
 * @param  boolean  $status    True on success, false otherwise.
 * @param  array    &$options  An array of search options.
 */
add_filter('vikappointments_before_fetch_calendar_data', function($status, &$options)
{
    // fetch service data
    $service = JModelVAP::getInstance('service')->getItem($options['id_ser']);

    if ($service->id_group == 1)
    {
        // use weekly calendar for services under group #1
        $options['layout'] = 'weekly';
    }
    else
    {
        // otherwise fallback to monthly calendar
        $options['layout'] = 'monthly';
    }

    return $status;
}, 10, 2);

Changelog

Version Description
1.2 Introduced.
Ultimo aggiornamento: 2021-10-04
Utile?
Potrebbe interessarti: