You are here

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

Add the array of display options to the view, with appropriate overrides.

1 call to ViewsUiBaseViewsWizard::add_displays()
ViewsUiBaseViewsWizard::instantiate_view in plugins/views_wizard/views_ui_base_views_wizard.class.php

File

plugins/views_wizard/views_ui_base_views_wizard.class.php, line 582
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 add_displays($view, $display_options, $form, $form_state) {

  // Display: Master.
  $default_display = $view
    ->new_display('default', 'Master', 'default');
  foreach ($display_options['default'] as $option => $value) {
    $default_display
      ->set_option($option, $value);
  }

  // Display: Page.
  if (isset($display_options['page'])) {
    $display = $view
      ->new_display('page', 'Page', 'page');

    // The page display is usually the main one (from the user's point of
    // view). Its options should therefore become the overall view defaults,
    // so that new displays which are added later automatically inherit them.
    $this
      ->set_default_options($display_options['page'], $display, $default_display);

    // Display: Feed (attached to the page).
    if (isset($display_options['feed'])) {
      $display = $view
        ->new_display('feed', 'Feed', 'feed');
      $this
        ->set_override_options($display_options['feed'], $display, $default_display);
    }
  }

  // Display: Block.
  if (isset($display_options['block'])) {
    $display = $view
      ->new_display('block', 'Block', 'block');

    // When there is no page, the block display options should become the
    // overall view defaults.
    if (!isset($display_options['page'])) {
      $this
        ->set_default_options($display_options['block'], $display, $default_display);
    }
    else {
      $this
        ->set_override_options($display_options['block'], $display, $default_display);
    }
  }
}