getRankings example

unset($build['uid']);
    return $build;
  }

  /** * Adds the configured rankings to the search query. * * @param $query * A query object that has been extended with the Search DB Extender. */
  protected function addNodeRankings(SelectExtender $query) {
    if ($ranking = $this->getRankings()) {
      $tables = &$query->getTables();
      foreach ($ranking as $rank => $values) {
        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']);
          }
          $arguments = $values['arguments'] ?? [];
          $query->addScore($values['score']$arguments$node_rank);
        }
      }
Home | Imprint | This part of the site doesn't use cookies.