Skip to content

Commit

Permalink
[4.x] Fix paginated page links for com_finder and com_content archive (
Browse files Browse the repository at this point in the history
…#43953)

* fix com_finder pagination

* Codestyle

* cs fix

* Update components/com_finder/src/View/Search/HtmlView.php

Co-authored-by: Quy <[email protected]>

* Append missing catid parameter in archive view

* also cover title search

* add additional parameters from PR #43954

* update ID filter

* PHPCS

---------

Co-authored-by: Hannes Papenberg <[email protected]>
Co-authored-by: Quy <[email protected]>
Co-authored-by: Richard Fath <[email protected]>
  • Loading branch information
4 people authored Aug 22, 2024
1 parent 8a868a3 commit 2d707c0
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 9 deletions.
3 changes: 3 additions & 0 deletions components/com_content/src/View/Archive/HtmlView.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ class HtmlView extends BaseHtmlView
*/
public function display($tpl = null)
{
$app = Factory::getApplication();
$user = $this->getCurrentUser();
$state = $this->get('State');
$items = $this->get('Items');
Expand Down Expand Up @@ -219,6 +220,8 @@ public function display($tpl = null)
$this->pagination = &$pagination;
$this->pagination->setAdditionalUrlParam('month', $state->get('filter.month'));
$this->pagination->setAdditionalUrlParam('year', $state->get('filter.year'));
$this->pagination->setAdditionalUrlParam('filter-search', $state->get('list.filter'));
$this->pagination->setAdditionalUrlParam('catid', $app->input->get('catid', [], 'array'));

$this->_prepareDocument();

Expand Down
22 changes: 22 additions & 0 deletions components/com_finder/src/View/Search/HtmlView.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,28 @@ public function display($tpl = null)
// Flag indicates to not add limitstart=0 to URL
$this->pagination->hideEmptyLimitstart = true;

// Add additional parameters
$queryParameterList = [
'f' => 'int',
't' => 'array',
'q' => 'string',
'l' => 'cmd',
'd1' => 'string',
'd2' => 'string',
'w1' => 'string',
'w2' => 'string',
];

foreach ($queryParameterList as $parameter => $filter) {
$value = $app->input->get($parameter, null, $filter);

if (is_null($value)) {
continue;
}

$this->pagination->setAdditionalUrlParam($parameter, $value);
}

// Check for errors.
if (count($errors = $this->get('Errors'))) {
throw new GenericDataException(implode("\n", $errors), 500);
Expand Down
2 changes: 1 addition & 1 deletion libraries/src/Cache/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,7 @@ public static function makeId()
'view' => 'WORD',
'layout' => 'WORD',
'tpl' => 'CMD',
'id' => 'INT',
'id' => 'STRING',
];

// Use platform defaults if parameter doesn't already exist.
Expand Down
22 changes: 14 additions & 8 deletions libraries/src/Pagination/Pagination.php
Original file line number Diff line number Diff line change
Expand Up @@ -665,21 +665,27 @@ protected function _buildDataObject()

// Platform defaults
$defaultUrlParams = [
'format' => 'WORD',
'option' => 'WORD',
'view' => 'WORD',
'layout' => 'WORD',
'tpl' => 'CMD',
'id' => 'INT',
'Itemid' => 'INT',
'format' => 'WORD',
'option' => 'WORD',
'controller' => 'WORD',
'view' => 'WORD',
'layout' => 'STRING',
'task' => 'CMD',
'template' => 'CMD',
'templateStyle' => 'INT',
'tmpl' => 'CMD',
'tpl' => 'CMD',
'id' => 'STRING',
'Itemid' => 'INT',
];

// Prepare the routes
$params = [];
$input = $this->app->getInput();

// Use platform defaults if parameter doesn't already exist.
foreach ($defaultUrlParams as $param => $filter) {
$value = $this->app->input->get($param, null, $filter);
$value = $input->get($param, null, $filter);

if ($value === null) {
continue;
Expand Down

0 comments on commit 2d707c0

Please sign in to comment.