You are here

function calendar_views_default_views in Calendar 7

Same name and namespace in other branches
  1. 5.2 calendar.module \calendar_views_default_views()
  2. 5 calendar.module \calendar_views_default_views()
  3. 6.2 includes/calendar.views_default.inc \calendar_views_default_views()
  4. 7.2 includes/calendar.views_default.inc \calendar_views_default_views()

Set up so it can be used as an API to create default calendars for specific date fields.

Use variable_set() to establish criteria for default calendars. Set the variable in custom modules or in settings.

Example: Add a new default calendar to custom calendars that are already configured:

$options = variable_get('calendar_default_view_options', array()); $option = array( 'name' => 'example_event', 'description' => 'An example event calendar for the date field.', 'path' => 'example_event', 'types' => array('example_content_type'), 'date_fields' => array('field_example_date'), ); $options[] = $option; variable_set('calendar_default_view_options', $options);

File

includes/calendar.views_default.inc, line 30
Default views for the Calendar module.

Code

function calendar_views_default_views() {
  $views = array();

  // Construct the default view with default options.
  $view = calendar_views_construct();
  $views[$view->name] = $view;

  // Then see if there are any custom calendars to be created
  // using variable_get().
  $calendar_options = variable_get('calendar_default_view_options', array());
  foreach ((array) $calendar_options as $calendar_option) {
    $view = calendar_views_construct($calendar_option);
    $views[$view->name] = $view;
  }
  return $views;
}