Skip to content

Commit

Permalink
Upgrade how the pager link is made.
Browse files Browse the repository at this point in the history
  • Loading branch information
laceysanderson committed Dec 16, 2024
1 parent b6cb665 commit 944a9af
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/ChadoSearch/ChadoSearchPluginBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Drupal\chado_search\ChadoSearch;

use Drupal\chado_search\ChadoSearch\Interfaces\ChadoSearchInterface;
use Drupal\Core\Link;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Component\Plugin\PluginBase;
use Drupal\Core\Form\FormState;
Expand Down Expand Up @@ -300,11 +301,12 @@ public function addPager(array $form, int $num_results): array {
$params = $query_params;
$params['offset'] = $prev_offset;
$params['page_num'] = $prev_page_num;
$left_arrow = l(
$route_name = 'chado_search.form.' . $this->id();
$left_arrow = Link::createFromRoute(
$left_arrow,
$this->urlPath(),
$route_name,
$params,
[
'query' => $params,
'html' => TRUE,
]
);
Expand All @@ -322,21 +324,22 @@ public function addPager(array $form, int $num_results): array {
$params = $query_params;
$params['offset'] = $next_offset;
$params['page_num'] = $next_page_num;
$right_arrow = l(
$route_name = 'chado_search.form.' . $this->id();
$right_arrow = Link::createFromRoute(
$right_arrow,
$this->urlPath(),
$route_name,
$params,
[
'query' => $params,
'html' => TRUE,
]
);
}

$form['pager'] = [
'#type' => 'markup',
'#markup' => '<span class="pager-prev">' . $left_arrow . '</span>'
'#markup' => '<span class="pager-prev">' . $left_arrow->toString() . '</span>'
. '<span class="pager-page">' . ' - Page ' . $page_num . ' - ' . '</span>'
. '<span class="pager-next">' . $right_arrow . '</span>',
. '<span class="pager-next">' . $right_arrow->toString() . '</span>',
'#prefix' => '<div class="chadosearch-pager-container"><div class="pager">',
'#suffix' => '</div></div>',
'#weight' => 100,
Expand Down

0 comments on commit 944a9af

Please sign in to comment.