Jump back to the same pagination site

Phoca Cart - complex e-commerce extension
oesch.web@gmail.com
Phoca Member
Phoca Member
Posts: 28
Joined: 06 Jan 2020, 11:35

Jump back to the same pagination site

Post 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?
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 48402
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Jump back to the same pagination site

Post 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
If you find Phoca extensions useful, please support the project
Cony
Phoca Member
Phoca Member
Posts: 10
Joined: 24 Mar 2011, 15:51

Re: Jump back to the same pagination site

Post by Cony »

Hi,

what about to use just simple <a href="javascript:history.go(-1)">Back to products list</a>
Last edited by Cony on 06 Nov 2024, 02:16, edited 1 time in total.
Cony
Phoca Member
Phoca Member
Posts: 10
Joined: 24 Mar 2011, 15:51

Re: Jump back to the same pagination site

Post by Cony »

Or, use $_SERVER['HTTP_REFERER']...
mino182
Phoca Professional
Phoca Professional
Posts: 189
Joined: 12 Feb 2015, 13:30

Re: Jump back to the same pagination site

Post 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...
Post Reply