Page 1 of 1

Jump back to the same pagination site

Posted: 01 Nov 2024, 22:28
by oesch.web@gmail.com
I have after some search found a solution to my old problem:
I have a lot of products and use pagination. Wenn i enter a product and return, then the pagination is allways at the beginning.

The solution is quit simple:
1) Store the limitstart in the session at category/view.html.php:
// Hole den aktuellen `limitstart`-Wert aus der URL und speichere ihn in der Session
$limitstart = $app->input->getInt('limitstart', 0);
$app->setUserState('com_phocacart.category.limitstart', $limitstart);

$this->t['limitstart'] = $limitstart;
$this->t['pagination'] = $model->getPagination($this->t['categoryid']);

2) Füge in der item/tmpl/default.php folgenden Code hinzu:
// Hole den `limitstart`-Wert aus der Session, falls er nicht in der URL vorhanden ist
$app = Factory::getApplication();
$limitstart = $app->input->getInt('limitstart', $app->getUserState('com_phocacart.category.limitstart', 0));

3) Passe den Rücksprung-Link in item/tmpl/default.php wie folgt an:
// Hole den `limitstart`-Wert, entweder aus der URL oder aus der Session
$limitstart = Factory::getApplication()->input->getInt('limitstart', Factory::getApplication()->getUserState('com_phocacart.category.limitstart', 0));

if (isset($this->category[0]->id)) {
$linkUp = Route::_(PhocacartRoute::getCategoryRoute($this->category[0]->id, $this->category[0]->alias) . '&limitstart=' . $limitstart);
echo '<a href="' . $linkUp . '">Zurück zur Kategorie</a>';
}
// Note: this is only a link, can easily be adjusted to be a button.

May be this can be added to the final Version Joomla 5? It would be a graet jump vorwards?

Re: Jump back to the same pagination site

Posted: 06 Nov 2024, 01:54
by Jan
Hi, thank you for the info, I will talk to other developers about this, to be sure, it is not in conflict somewhere.

Thank you, Jan

Re: Jump back to the same pagination site

Posted: 06 Nov 2024, 02:10
by Cony
Hi,

what about to use just simple <a href="javascript:history.go(-1)">Back to products list</a>

Re: Jump back to the same pagination site

Posted: 06 Nov 2024, 02:16
by Cony
Or, use $_SERVER['HTTP_REFERER']...

Re: Jump back to the same pagination site

Posted: 06 Nov 2024, 08:58
by mino182
Cony wrote: 06 Nov 2024, 02:10 Hi,

what about to use just simple <a href="javascript:history.go(-1)">Back to products list</a>
When you go from product to product, it will go back to previous product, instead of the list...