diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/area/Pager.php b/core/modules/views/lib/Drupal/views/Plugin/views/area/Pager.php index dc63247..6221d81 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/views/area/Pager.php +++ b/core/modules/views/lib/Drupal/views/Plugin/views/area/Pager.php @@ -21,8 +21,46 @@ class Pager extends AreaPluginBase { /** * {@inheritdoc} */ + protected function defineOptions() { + $options = parent::defineOptions(); + $options['disable_pager_region'] = array('bool' => TRUE, 'default' => FALSE); + + return $options; + } + + + /** + * {@inheritdoc} + */ + public function buildOptionsForm(&$form, &$form_state) { + parent::buildOptionsForm($form, $form_state); + + // Remove the 'Display if empty' checkbox. As this doesn't make sense for a + // pager, as it is determined by results. + unset($form['empty']); + + $form['disable_pager_region'] = array( + '#type' => 'checkbox', + '#title' => $this->t('Disable pager region'), + '#description' => $this->t('Remove the regular pager region from the rendered view output.'), + '#default_value' => $this->options['disable_pager_region'], + ); + } + + /** + * {@inheritdoc} + */ + public function preRender(array $results) { + if ($this->options['disable_pager_region']) { + $this->view->display_handler->setRenderPagerRegion(FALSE); + } + } + + /** + * {@inheritdoc} + */ public function render($empty = FALSE) { - if (!$empty || !empty($this->options['empty'])) { + if (!$empty) { if ($this->view->display_handler->renderPager()) { return $this->view->renderPager($this->view->exposed_raw_input); } diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php b/core/modules/views/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php index f37f950..225b749 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php +++ b/core/modules/views/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php @@ -100,6 +100,13 @@ protected $usesAreas = TRUE; /** + * Whether or not the pager region should be rendered. + * + * @var bool + */ + protected $renderPagerRegion = TRUE; + + /** * Constructs a new DisplayPluginBase object. * * Because DisplayPluginBase::initDisplay() takes the display configuration by @@ -2453,13 +2460,33 @@ public function query() { public function renderFilters() { } /** - * Not all display plugins will suppert pager rendering. + * Not all display plugins will support pager rendering. + * + * @return bool + * Whether this display should render the pager or not. */ public function renderPager() { return TRUE; } /** + * @return bool + */ + public function renderPagerRegion() { + return $this->renderPagerRegion; + } + + /** + * Sets the renderPagerRegion property. + * + * @param bool $value + * Whether or not the pager region should be rendered. + */ + public function setRenderPagerRegion($value) { + $this->renderPagerRegion = (bool) $value; + } + + /** * Render the 'more' link */ public function renderMoreLink() { diff --git a/core/modules/views/views.theme.inc b/core/modules/views/views.theme.inc index 65f8ac4..c3a1ac9 100644 --- a/core/modules/views/views.theme.inc +++ b/core/modules/views/views.theme.inc @@ -62,7 +62,7 @@ function template_preprocess_views_view(&$variables) { // Render title for the admin preview. $variables['title'] = !empty($view->views_ui_context) ? filter_xss_admin($view->getTitle()) : ''; - if ($view->display_handler->renderPager()) { + if ($view->display_handler->renderPager() && $view->display_handler->renderPagerRegion()) { $exposed_input = isset($view->exposed_raw_input) ? $view->exposed_raw_input : NULL; $variables['pager'] = $view->renderPager($exposed_input); }