Beispiel #1
0
 /**
  * Overrides Drupal\views\Plugin\views\wizard\WizardPluginBase::defaultDisplayFiltersUser().
  */
 protected function defaultDisplayFiltersUser(array $form, FormStateInterface $form_state)
 {
     $filters = parent::defaultDisplayFiltersUser($form, $form_state);
     $tids = array();
     if ($values = $form_state->getValue(array('show', 'tagged_with'))) {
         foreach ($values as $value) {
             $tids[] = $value['target_id'];
         }
     }
     if (!empty($tids)) {
         $vid = reset($form['displays']['show']['tagged_with']['#selection_settings']['target_bundles']);
         $filters['tid'] = array('id' => 'tid', 'table' => 'taxonomy_index', 'field' => 'tid', 'value' => $tids, 'vid' => $vid, 'plugin_id' => 'taxonomy_index_tid');
         // If the user entered more than one valid term in the autocomplete
         // field, they probably intended both of them to be applied.
         if (count($tids) > 1) {
             $filters['tid']['operator'] = 'and';
             // Sort the terms so the filter will be displayed as it normally would
             // on the edit screen.
             sort($filters['tid']['value']);
         }
     }
     return $filters;
 }
Beispiel #2
0
 /**
  * Overrides Drupal\views\Plugin\views\wizard\WizardPluginBase::defaultDisplayFiltersUser().
  */
 protected function defaultDisplayFiltersUser(array $form, FormStateInterface $form_state)
 {
     $filters = parent::defaultDisplayFiltersUser($form, $form_state);
     if (!empty($form_state['values']['show']['tagged_with']['tids'])) {
         $filters['tid'] = array('id' => 'tid', 'table' => 'taxonomy_index', 'field' => 'tid', 'value' => $form_state['values']['show']['tagged_with']['tids'], 'vocabulary' => $form_state['values']['show']['tagged_with']['vocabulary']);
         // If the user entered more than one valid term in the autocomplete
         // field, they probably intended both of them to be applied.
         if (count($form_state['values']['show']['tagged_with']['tids']) > 1) {
             $filters['tid']['operator'] = 'and';
             // Sort the terms so the filter will be displayed as it normally would
             // on the edit screen.
             sort($filters['tid']['value']);
         }
     }
     return $filters;
 }