News:

Looking for documentation? Take a look on our wiki

Main Menu

[VM 4.0.6] - Pagination bug in VM router & quick fix

Started by Wedal, July 08, 2022, 12:52:51 PM

Previous topic - Next topic

Wedal

VirtueMart 4.0.6 10690 + Joomla 4.1.5

There are 2 problems with pagination in VM:

1) VM category pagination shows the same link for all pages. The problem leads to the VM router.

Quick fix:
/components/com_virtuemart/router.php

Before:

if ($start !== null &&  $limitstart!== null ) {
if(vmrouterHelper::$debug) vmdebug('Pagination limits $start !== null &&  $limitstart!== null',$start,$limitstart);
//$segments[] = self::lang('results') .',1-'.$start ;
} else if ( $start>0 ) {
//For the urls leading to the paginated pages
// using general limit if $limit is not set
if ($limit === null) $limit= vmrouterHelper::$limit ;
$segments[] = self::lang('results') .','. ($start+1).'-'.($start+$limit);
}


After:

if ($start !== null &&  $limitstart!== null ) {
if(vmrouterHelper::$debug) vmdebug('Pagination limits $start !== null &&  $limitstart!== null',$start,$limitstart);
//$segments[] = self::lang('results') .',1-'.$start ;
//} else if ( $start>0 ) {
} else if ( $limitstart > 0 ) {
//For the urls leading to the paginated pages
// using general limit if $limit is not set
if ($limit === null) $limit= vmrouterHelper::$limit ;
//$segments[] = self::lang('results') .','. ($start+1).'-'.($start+$limit);
$segments[] = self::lang('results') .','. ($limitstart + 1).'-'.($limitstart + $limit);
}


Also for some reason the $limit here is not the same as the one found in vmpagination.php. It breaks the order of the results.

Quick fix:
/administrator/components/com_virtuemart/helpers/vmpagination.php

Before:
$data->pages[$i]->link = JRoute::_($params . '&' . $this->prefix . 'limitstart=' . $offset);

After:
$data->pages[$i]->link = JRoute::_($params . '&' . $this->prefix . 'limitstart=' . $offset .'&limit='.$this->limit);

This is probably a bad solution, but it's the fastest I could dig up.


2) Joomla 4 uses new pagination layouts:
/layouts/joomla/pagination

The VM is looking for an overridden pagination layout at the old address:

$chromePath = VMPATH_THEMES . '/' . $app->getTemplate() . '/html/pagination.php';

Is it possible to make the VM use the Joomla 4 pagination overrides (/templates/our_template/html/layouts/joomla/pagination)?

tonis

Quote from: Wedal on July 08, 2022, 12:52:51 PM
VirtueMart 4.0.6 10690 + Joomla 4.1.5

There are 2 problems with pagination in VM:

1) VM category pagination shows the same link for all pages. The problem leads to the VM router.

Quick fix:
/components/com_virtuemart/router.php

Before:

if ($start !== null &&  $limitstart!== null ) {
if(vmrouterHelper::$debug) vmdebug('Pagination limits $start !== null &&  $limitstart!== null',$start,$limitstart);
//$segments[] = self::lang('results') .',1-'.$start ;
} else if ( $start>0 ) {
//For the urls leading to the paginated pages
// using general limit if $limit is not set
if ($limit === null) $limit= vmrouterHelper::$limit ;
$segments[] = self::lang('results') .','. ($start+1).'-'.($start+$limit);
}


After:

if ($start !== null &&  $limitstart!== null ) {
if(vmrouterHelper::$debug) vmdebug('Pagination limits $start !== null &&  $limitstart!== null',$start,$limitstart);
//$segments[] = self::lang('results') .',1-'.$start ;
//} else if ( $start>0 ) {
} else if ( $limitstart > 0 ) {
//For the urls leading to the paginated pages
// using general limit if $limit is not set
if ($limit === null) $limit= vmrouterHelper::$limit ;
//$segments[] = self::lang('results') .','. ($start+1).'-'.($start+$limit);
$segments[] = self::lang('results') .','. ($limitstart + 1).'-'.($limitstart + $limit);
}


Also for some reason the $limit here is not the same as the one found in vmpagination.php. It breaks the order of the results.

Quick fix:
/administrator/components/com_virtuemart/helpers/vmpagination.php

Before:
$data->pages[$i]->link = JRoute::_($params . '&' . $this->prefix . 'limitstart=' . $offset);

After:
$data->pages[$i]->link = JRoute::_($params . '&' . $this->prefix . 'limitstart=' . $offset .'&limit='.$this->limit);

This is probably a bad solution, but it's the fastest I could dig up.


Thank you for this fixes! I was also stucked with this bugs. Hopefully it will be ok in new version.

Milbo

Thank you for your fix. But I am not sure if it is the right way. I need to dig into it deeper. Do you mean the pagination of categories? or of products in categories?

Quote
2) Joomla 4 uses new pagination layouts:
/layouts/joomla/pagination
do you mean /templates/our_template/html/layouts/joomla/pagination.php ? I was already adding that, a check first on the other place. But I need to know it exactly, could be also /templates/our_template/html/layouts/joomla/pagination/pagination.php.

and I dont use any template with this override. The default joomla template (CAssiopeia) does not have it.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

Wedal

Hi Milbo,

QuoteThank you for your fix. But I am not sure if it is the right way. I need to dig into it deeper. Do you mean the pagination of categories? or of products in categories?
Products in categories.

Quotedo you mean /templates/our_template/html/layouts/joomla/pagination.php ? I was already adding that, a check first on the other place. But I need to know it exactly, could be also /templates/our_template/html/layouts/joomla/pagination/pagination.php.

and I dont use any template with this override. The default joomla template (CAssiopeia) does not have it.
Not pagination.php, but new Joomla 4 pagination layouts: list.php, links.php, link.php.

The idea is to use unified Joomla pagination layouts for VM. Now if we need to make changes to the pagination of the site (for example, change the arrow icons classes), we need to do it separately for the Joomla and VM pagination layouts, since the pagination layouts have been changed in J4 (split into three files).




Darko F.

Hi,
I'm using Joomla 4.2.1 and  VirtueMart 4.0.6 10690

Can confirm pagination don't work in category and also not in subcategory.
There in no problem if you fall. Problem is if you don't get up

veselinovm

I am using VM: 3.8.6 and Joomla 3.10.11
Pagination is not working well with fix tonis.
When you have to get back to first page, shows products of first page, but selected pagination stays on last number.

tonis

Quote from: veselinovm on September 08, 2022, 15:04:11 PM
I am using VM: 3.8.6 and Joomla 3.10.11
Pagination is not working well with fix tonis.
When you have to get back to first page, shows products of first page, but selected pagination stays on last number.

Hi, maybe because ist not the same version. On the 4. versions its working (at least for me).

hazael

Quote from: tonis on September 09, 2022, 22:20:19 PM
Hi, maybe because ist not the same version. On the 4. versions its working (at least for me).
Set the category with the product listing as the home page of your site. Then you may notice that it doesn't work.

tomis

Before:

if ($start !== null &&  $limitstart!== null ) {
if(vmrouterHelper::$debug) vmdebug('Pagination limits $start !== null &&  $limitstart!== null',$start,$limitstart);
//$segments[] = self::lang('results') .',1-'.$start ;
} else if ( $start>0 ) {
//For the urls leading to the paginated pages
// using general limit if $limit is not set
if ($limit === null) $limit= vmrouterHelper::$limit ;
$segments[] = self::lang('results') .','. ($start+1).'-'.($start+$limit);
}


After:

if ($start !== null &&  $limitstart!== null ) {
if(vmrouterHelper::$debug) vmdebug('Pagination limits $start !== null &&  $limitstart!== null',$start,$limitstart);
//$segments[] = self::lang('results') .',1-'.$start ;
//} else if ( $start>0 ) {
} else if ( $limitstart > 0 ) {
//For the urls leading to the paginated pages
// using general limit if $limit is not set
if ($limit === null) $limit= vmrouterHelper::$limit ;
//$segments[] = self::lang('results') .','. ($start+1).'-'.($start+$limit);
$segments[] = self::lang('results') .','. ($limitstart + 1).'-'.($limitstart + $limit);
}


Also for some reason the $limit here is not the same as the one found in vmpagination.php. It breaks the order of the results.

Quick fix:
/administrator/components/com_virtuemart/helpers/vmpagination.php

Before:
$data->pages[$i]->link = JRoute::_($params . '&' . $this->prefix . 'limitstart=' . $offset);

After:
$data->pages[$i]->link = JRoute::_($params . '&' . $this->prefix . 'limitstart=' . $offset .'&limit='.$this->limit);

Virtuemart 4.0.6. + Joomla 4.2.2

The pagination fix works partially. Back to page 1 not working. Any fix?

creationell

Quote from: tomis on September 24, 2022, 15:15:19 PM
Virtuemart 4.0.6. + Joomla 4.2.2

The pagination fix works partially. Back to page 1 not working. Any fix?

For version VM 4.0.6 + Joomla 4.1.5.

We "fixed" the problem with coming back to page one in this way:

/administrator/components/com_virtuemart/models/product.php

Line 1024:

Before:
$limitStart = vRequest::getInt ('limitstart', 0,'GET'); $app->getUserStateFromRequest ($limitStartString, 'limitstart', vRequest::getInt ('limitstart', 0,'GET'), 'int');

After:
$limitStart = vRequest::getInt ('limitstart', 0,'GET'); //$app->getUserStateFromRequest ($limitStartString, 'limitstart', vRequest::getInt ('limitstart', 0,'GET'), 'int');


kiro789

I can confirm too, the pagination don't work for products in category layout.
When you have to get back to first page or previous page, shows products of first page, but selected pagination stays on last number.
VirtueMart 4.0.7 10744 with Joomla 4.2.5.

Regards!

kiro789

The problem actually is the return results to 1-page and the url: /results,1-0.html
When you are on products in category.
When you go back from page 10 to 2 fo example - no problems.
When you want to go back from 10 to 1 here is the problem.
In the url is missig the /results,1-0.html and shows only .html and shows products from page 10.

Regards!

GJC Web Design

GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

kiro789

Yes, instaled the 4.0.8 10748. The same problem. Returns to page 1 don't works.

hazael

#14
Quote from: kiro789 on November 29, 2022, 06:40:26 AM
Yes, instaled the 4.0.8 10748. The same problem. Returns to page 1 don't works.
It doesn't work because your browser remembered the limit=''  variables from a different category which is different from the one you are using on the current page.
The current solution will never work on the homepage of domain.

Use only one value for your limit variable for all categories. It's best to remove the select option from the form in the template, which allows you to change the display of the number of products on one page.

A simple workaround is to add the selected category to the Joomla menu. At the end of the URL, you just need to manually add &limistart=0
Do as in the attached picture and your problem will disappear.