Jump back to the same pagination site
Posted: 01 Nov 2024, 22:28
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?
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?