You are here

availability_calendars.views.inc in Availability Calendars 6.2

Views support for Availability Calendars.

Availability Calendars supports the views module. An availability calendar is defined to Views as an "available" field attached to a node. Therefore, you won't be able to sort on it, but you will be able to filter on it. To filter on availability we need a period to check onm availability. These 2 dates can be provided by the view, by arguments, or by the visitor (exposed).

@author Erwin Derksen (http://drupal.org/user/750928)

File

availability_calendars.views.inc
View source
<?php

/**
 * @file
 * Views support for Availability Calendars.
 *
 * Availability Calendars supports the views module. An availability calendar
 * is defined to Views as an "available" field attached to a node. Therefore,
 * you won't be able to sort on it, but you will be able to filter on it. To
 * filter on availability we need a period to check onm availability. These 2
 * dates can be provided by the view, by arguments, or by the visitor (exposed).
 *
 * @author Erwin Derksen (http://drupal.org/user/750928)
 */

/**
 * Implements hook_views_data_alter().
 *
 * We don't join with the node table, we do that in a subquery, so we have to
 * alter the node entry itself instead of providing table data ourselves by
 * implementing hook_views_data().
 */
function availability_calendars_views_data_alter(&$views_data) {
  $views_data['node']['available'] = array(
    'title' => t('Available'),
    'help' => t('Allows to filter on availability for a given period.'),
    'argument' => array(
      'handler' => 'views_handler_argument_date',
    ),
    'filter' => array(
      'handler' => 'availability_calendars_handler_filter_availability',
    ),
  );
  return $data;
}
function availability_calendars_views_handlers() {
  return array(
    'handlers' => array(
      'availability_calendars_handler_filter_availability' => array(
        'parent' => 'views_handler_filter_date',
      ),
    ),
  );
}