usesExposedFormInBlock example

// Check all Views for displays with an exposed filter block.     foreach ($this->viewStorage->loadMultiple() as $view) {
      // Do not return results for disabled views.       if (!$view->status()) {
        continue;
      }
      $executable = $view->getExecutable();
      $executable->initDisplay();
      foreach ($executable->displayHandlers as $display) {
        if (isset($display) && $display->getOption('exposed_block')) {
          // Add a block definition for the block.           if ($display->usesExposedFormInBlock()) {
            $delta = $view->id() . '-' . $display->display['id'];
            $desc = $this->t('Exposed form: @view-@display_id', ['@view' => $view->id(), '@display_id' => $display->display['id']]);
            $this->derivatives[$delta] = [
              'admin_label' => $desc,
              'config_dependencies' => [
                'config' => [
                  $view->getConfigDependencyName(),
                ],
              ],
            ];
            $this->derivatives[$delta] += $base_plugin_definition;
          }

      }

      $options['link_display'] = [
        'category' => 'pager',
        'title' => $this->t('Link display'),
        'value' => $link_display,
        'desc' => $this->t('Specify which display or custom URL this display will link to.'),
      ];
    }

    if ($this->usesExposedFormInBlock()) {
      $options['exposed_block'] = [
        'category' => 'exposed',
        'title' => $this->t('Exposed form in block'),
        'value' => $this->getOption('exposed_block') ? $this->t('Yes') : $this->t('No'),
        'desc' => $this->t('Allow the exposed form to appear in a block instead of the view.'),
      ];
    }

    /** @var \Drupal\views\Plugin\views\exposed_form\ExposedFormPluginInterface $exposed_form_plugin */
    $exposed_form_plugin = $this->getPlugin('exposed_form');
    if (!$exposed_form_plugin) {
      
Home | Imprint | This part of the site doesn't use cookies.