You are here

function views_data_export_plugin_display_export::preview in Views data export 7.4

Same name and namespace in other branches
  1. 6.3 plugins/views_data_export_plugin_display_export.inc \views_data_export_plugin_display_export::preview()
  2. 6 plugins/views_data_export_plugin_display_export.inc \views_data_export_plugin_display_export::preview()
  3. 6.2 plugins/views_data_export_plugin_display_export.inc \views_data_export_plugin_display_export::preview()
  4. 7 plugins/views_data_export_plugin_display_export.inc \views_data_export_plugin_display_export::preview()
  5. 7.3 plugins/views_data_export_plugin_display_export.inc \views_data_export_plugin_display_export::preview()

TBD - What does 'preview' mean for bulk exports? According to doc: "Fully render the display for the purposes of a live preview or some other AJAXy reason. [views_plugin_display.inc:1877]"

Not sure it makes sense for Bulk exports to be previewed in this manner? We need the user's full attention to run the batch. Suggestions: 1) Provide a link to execute the view? 2) Provide a link to the last file we generated?? 3) Show a table of the first 20 results?

Overrides views_plugin_display_feed::preview

File

plugins/views_data_export_plugin_display_export.inc, line 562
Contains the bulk export display plugin.

Class

views_data_export_plugin_display_export
The plugin that batches its rendering.

Code

function preview() {
  if (!$this
    ->is_batched()) {

    // Can replace with return parent::preview() when views 2.12 lands.
    if (!empty($this->view->live_preview)) {

      // Change the items per page.
      $this->view
        ->set_items_per_page(20);

      // Force a pager to be used.
      $this
        ->set_option('pager', array(
        'type' => 'some',
        'options' => array(),
      ));
      return '<p>' . t('A maximum of 20 items will be shown here, all results will be shown on export.') . '</p><pre>' . check_plain($this->view
        ->render()) . '</pre>';
    }
    return $this->view
      ->render();
  }
  return '';
}