You are here

protected function ViewsUiBaseViewsWizard::set_default_options in Views (for Drupal 7) 7.3

Sets options for a display and makes them the default options if possible.

This function can be used to set options for a display when it is desired that the options also become the defaults for the view whenever possible. This should be done for the "primary" display created in the view wizard, so that new displays which the user adds later will be similar to this one.

Parameters

array $options: An array whose keys are the name of each option and whose values are the desired values to set.

object $display: The display which the options will be applied to. The default display will actually be assigned the options (and this display will inherit them) when possible.

object$default_display: The default display, which will store the options when possible.

1 call to ViewsUiBaseViewsWizard::set_default_options()
ViewsUiBaseViewsWizard::add_displays in plugins/views_wizard/views_ui_base_views_wizard.class.php
Add the array of display options to the view, with appropriate overrides.

File

plugins/views_wizard/views_ui_base_views_wizard.class.php, line 849
Provides the interface and base class for Views Wizard plugins.

Class

ViewsUiBaseViewsWizard
A very generic Views Wizard class - can be constructed for any base table.

Code

protected function set_default_options($options, $display, $default_display) {
  foreach ($options as $option => $value) {

    // If the default display supports this option, set the value there.
    // Otherwise, set it on the provided display.
    $default_value = $default_display
      ->get_option($option);
    if (isset($default_value)) {
      $default_display
        ->set_option($option, $value);
    }
    else {
      $display
        ->set_option($option, $value);
    }
  }
}