You are here

public function InfiniteScroll::buildOptionsForm in Views Infinite Scroll 8

Provide the default form for setting options.

Overrides SqlBase::buildOptionsForm

File

src/Plugin/views/pager/InfiniteScroll.php, line 88

Class

InfiniteScroll
Views pager plugin to handle infinite scrolling.

Namespace

Drupal\views_infinite_scroll\Plugin\views\pager

Code

public function buildOptionsForm(&$form, FormStateInterface $form_state) {
  parent::buildOptionsForm($form, $form_state);
  $form['tags']['#access'] = FALSE;
  $options = $this->options['views_infinite_scroll'];
  $form['views_infinite_scroll'] = [
    '#title' => $this
      ->t('Infinite Scroll Options'),
    '#description' => $this
      ->t('Note: The infinite scroll option overrides and requires the <em>Use AJAX</em> setting for this views display.'),
    '#type' => 'details',
    '#open' => TRUE,
    '#tree' => TRUE,
    '#input' => TRUE,
    '#weight' => -100,
    'button_text' => [
      '#type' => 'textfield',
      '#title' => $this
        ->t('Button Text'),
      '#default_value' => $options['button_text'],
      '#description' => [
        '#theme' => 'item_list',
        '#items' => [
          '@next_page_count -- the next page record count',
          '@remaining_items_count -- the remaining amount of results',
          '@total -- the total amount of results returned from the view',
        ],
        '#prefix' => $this
          ->t('The following tokens are supported:'),
      ],
    ],
    'automatically_load_content' => [
      '#type' => 'checkbox',
      '#title' => $this
        ->t('Automatically Load Content'),
      '#description' => $this
        ->t('Automatically load subsequent pages as the user scrolls.'),
      '#default_value' => $options['automatically_load_content'],
    ],
    'initially_load_all_pages' => [
      '#type' => 'checkbox',
      '#title' => $this
        ->t('Initially load all pages up to the requested page'),
      '#description' => $this
        ->t('When initially loading a page beyond the first, this option will load all pages up to the requested page instead of just the requested page. So, if you have the pager set to 10 items per page, and you load the page with ?page=2 in the url, you will get page 0, 1 and 2 loaded for a total of 30 items. <em>Note that this could cause some long page load times when loading many pages.</em>'),
      '#default_value' => $options['initially_load_all_pages'],
    ],
  ];
}