diff --git a/core/modules/node/config/schema/node.schema.yml b/core/modules/node/config/schema/node.schema.yml index 52f88c8..506049b 100644 --- a/core/modules/node/config/schema/node.schema.yml +++ b/core/modules/node/config/schema/node.schema.yml @@ -82,18 +82,8 @@ search.plugin.node_search: label: 'Content search' mapping: rankings: - type: mapping - label: 'Content Ranking' - mapping: - comments: - type: integer - label: 'Number of comments' - relevance: - type: integer - label: 'Keyword relevance' - sticky: - type: integer - label: 'Content is sticky at top of lists' - promote: - type: integer - label: 'Content is promoted to the front page' + type: sequence + label: 'Content ranking' + sequence: + - type: integer + label: 'Influence' diff --git a/core/modules/node/config/search.page.node_search.yml b/core/modules/node/config/search.page.node_search.yml index cf0de1f..597f4e3 100644 --- a/core/modules/node/config/search.page.node_search.yml +++ b/core/modules/node/config/search.page.node_search.yml @@ -1,9 +1,10 @@ id: node_search -label: 'Content' +label: Content uuid: 25687eeb-4bb5-469c-ad05-5eb24cd7012c status: true langcode: en path: node weight: -10 plugin: node_search -configuration: { } +configuration: + rankings: { } diff --git a/core/modules/node/lib/Drupal/node/Plugin/Search/NodeSearch.php b/core/modules/node/lib/Drupal/node/Plugin/Search/NodeSearch.php index 89fc3bd..c71e079 100644 --- a/core/modules/node/lib/Drupal/node/Plugin/Search/NodeSearch.php +++ b/core/modules/node/lib/Drupal/node/Plugin/Search/NodeSearch.php @@ -274,7 +274,8 @@ protected function addNodeRankings(SelectExtender $query) { if ($ranking = $this->getRankings()) { $tables = &$query->getTables(); foreach ($ranking as $rank => $values) { - if ($node_rank = $this->configuration['rankings'][$rank]) { + if (isset($this->configuration['rankings'][$rank]) && !empty($this->configuration['rankings'][$rank])) { + $node_rank = $this->configuration['rankings'][$rank]; // If the table defined in the ranking isn't already joined, then add it. if (isset($values['join']) && !isset($tables[$values['join']['alias']])) { $query->addJoin($values['join']['type'], $values['join']['table'], $values['join']['alias'], $values['join']['on']); @@ -540,9 +541,6 @@ public function defaultConfiguration() { $configuration = array( 'rankings' => array(), ); - foreach ($this->getRankings() as $var => $value) { - $configuration['rankings'][$var] = 0; - } return $configuration; } @@ -567,7 +565,7 @@ public function buildConfigurationForm(array $form, array &$form_state) { '#title' => $values['title'], '#type' => 'select', '#options' => $options, - '#default_value' => $this->configuration['rankings'][$var], + '#default_value' => isset($this->configuration['rankings'][$var]) ? $this->configuration['rankings'][$var] : 0, ); } return $form; @@ -578,9 +576,12 @@ public function buildConfigurationForm(array $form, array &$form_state) { */ public function submitConfigurationForm(array &$form, array &$form_state) { foreach ($this->getRankings() as $var => $values) { - if (isset($form_state['values']['rankings_'.$var])) { + if (!empty($form_state['values']['rankings_'.$var])) { $this->configuration['rankings'][$var] = $form_state['values']['rankings_' . $var]; } + else { + unset($this->configuration['rankings'][$var]); + } } }