VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Coding Central => Topic started by: derek webster on September 03, 2020, 15:06:38 PM

Title: small addition to router.php to stop error message with Search range
Post by: derek webster on September 03, 2020, 15:06:38 PM
VirtueMart 3.8.4 10335

Hi Ive had a little bit of development work done and I'd like to submit this for inclusion into future VM builds.
We wnted our sef results to be cleaner - so changed /results,1-100?keyword=searchterm to this /results?keyword=searchterm

in Router.php we were getting an error when searching when there was no limit defined.

the following fixes the error...

if(isset($splitted[1])) { // This is the IF clause that fixes the error
$results = explode('-',$splitted[1],2);
//Pagination has changed, removed the -1 note by Max Milbers NOTE: Works on j1.5, but NOT j1.7
// limitstart is swapped by joomla to start ! See includes/route.php
if ($start = $results[0]-1) $vars['limitstart'] = $start;
else $vars['limitstart'] = 0 ;
$vars['limit'] = (int)$results[1]-$results[0]+1;
} // end of If caluse

Title: Re: small addition to router.php to stop error message with Search range
Post by: Milbo on June 17, 2022, 11:28:30 AM
I just wonder if vm4 works for you as expected. The if check is now very different to before

if ( self::compareKey($splitted[0] ,'results')){
array_pop($segments);
$results = explode('-',$splitted[1],2);
//Pagination has changed, removed the -1 note by Max Milbers NOTE: Works on j1.5, but NOT j1.7
// limitstart is swapped by joomla to start ! See includes/route.php
if ($start = $results[0]-1) $vars['limitstart'] = $start;
else $vars['limitstart'] = 0 ;
$vars['limit'] = (int)$results[1]-$results[0]+1;

} else {
$vars['limitstart'] = 0 ;

}