evenEmpty example

// Merge the exposed query parameters.     if (!empty($this->view->exposed_raw_input)) {
      $url->mergeOptions(['query' => $this->view->exposed_raw_input]);
    }
    return $url;
  }

  /** * {@inheritdoc} */
  public function render() {
    $rows = (!empty($this->view->result) || $this->view->style_plugin->evenEmpty()) ? $this->view->style_plugin->render($this->view->result) : [];

    $element = [
      '#theme' => $this->themeFunctions(),
      '#view' => $this->view,
      '#pre_render' => [[$this, 'elementPreRender']],
      '#rows' => $rows,
      // Assigned by reference so anything added in $element['#attached'] will       // be available on the view.       '#attached' => &$this->view->element['#attached'],
      '#cache' => &$this->view->element['#cache'],
    ];

    
'#title' => $this->t('Show the empty text in the table'),
      '#default_value' => $this->options['empty_table'],
      '#description' => $this->t('Per default the table is hidden for an empty view. With this option it is possible to show an empty table with the text in it.'),
    ];

    $form['description_markup'] = [
      '#markup' => '<div class="js-form-item form-item description">' . $this->t('Place fields into columns; you may combine multiple fields into the same column. If you do, the separator in the column specified will be used to separate the fields. Check the sortable box to make that column click sortable, and check the default sort radio to determine which column will be sorted by default, if any. You may control column order and field labels in the fields section.') . '</div>',
    ];
  }

  public function evenEmpty() {
    return parent::evenEmpty() || !empty($this->options['empty_table']);
  }

  public function wizardSubmit(&$form, FormStateInterface $form_state, WizardInterface $wizard, &$display_options$display_type) {
    // If any of the displays use the table style, make sure that the fields     // always have a labels by unsetting the override.     foreach ($display_options['default']['fields'] as &$field) {
      unset($field['label']);
    }
  }

  /** * {@inheritdoc} */
public function execute() {
    return $this->view->render($this->display['id']);
  }

  /** * Builds the view result as a renderable array. * * @return array * Renderable array or empty array. */
  public function render() {
    if (!empty($this->view->result) && $this->view->style_plugin->evenEmpty()) {
      return $this->view->style_plugin->render($this->view->result);
    }
    return [];
  }

  /** * {@inheritdoc} */
  public function usesExposed() {
    return FALSE;
  }

  
Home | Imprint | This part of the site doesn't use cookies.