News:

Support the VirtueMart project and become a member

Main Menu

pagination bug in J20 & J17

Started by mrajko, January 23, 2012, 19:31:30 PM

Previous topic - Next topic

mrajko

whatever is set by default, pagination works well initially,
but,
if You change to 10 items per page (for example, or any other number), then, back to "all", You will got mess : all products w.subcategories on stack

tnyari

I have same problem, and i spent few hours to solve them.
The cause of the problem is the Joomla cannot recognise some params in url. When you change the page items number, the select field onchange event handle url call from the select option value. That url containing amperstand "&" characters like "&".
I can only solve this issue by modify the /administrator/components/com_virtuemart/helpers/vmmodel.php -> VmPagination class declaration,-> getLimitBox() method (from row 680.):


} else {
$getArray = (JRequest::get( 'get' ));
$link ='';
if (array_key_exists('limit', $getArray)) unset ($getArray['limit']);

foreach ($getArray as $key => $value ) $link .= '&'.$key.'='.$value;
$link[0] = "?";
$link = 'index.php'.$link ;
if(!empty($sequence)){
$sequenceArray = explode(',', $sequence);
foreach($sequenceArray as $items){
$limits[]=JHtml::_('select.option', JRoute::_( $link.'&limit='. $items), $items);
}

} else {
if($this->_perRow===1) $this->_perRow = 5;
$iterationAmount = 4;
for ($i = 1; $i <= $iterationAmount; $i ++) {
$limits[] = JHtml::_('select.option',JRoute::_( $link.'&limit='. $i*$this->_perRow) ,$i*$this->_perRow );
}

$limits[] = JHTML::_('select.option',JRoute::_( $link.'&limit='. $this->_perRow * 10) , $this->_perRow * 10 );
$limits[] = JHTML::_('select.option',JRoute::_( $link.'&limit='. $this->_perRow * 20) , $this->_perRow * 20 );
// vmdebug('getLimitBox',$this->_perRow);
}
$selected= JRoute::_( $link.'&limit='. $selected) ;
$js = 'onchange="window.top.location.href=this.options[this.selectedIndex].value">';

$html = JHTML::_('select.genericlist',  $limits, 'limit', 'class="inputbox" size="1" '.$js , 'value', 'text', $selected);
}


i changed the option value to decode back JRoute output for "&amp;" to "&" with htmlspecialchars_decode function like this:


} else {
$getArray = (JRequest::get( 'get' ));
$link ='';
if (array_key_exists('limit', $getArray)) unset ($getArray['limit']);

foreach ($getArray as $key => $value ) $link .= '&'.$key.'='.$value;

////Limit FIX for 0 - all value
$limits = array(); ///Reset limit value
$limits[] = JHTML::_('select.option',htmlspecialchars_decode(JRoute::_( $link.'&limit=0')) , JText::_('ALL_ITEMS') ); //// htmlspecialchars_decode uses for links FIXED


$link[0] = "?";
$link = 'index.php'.$link ;
if(!empty($sequence)){
$sequenceArray = explode(',', $sequence);
foreach($sequenceArray as $items){
$limits[]=JHtml::_('select.option', htmlspecialchars_decode(JRoute::_( $link.'&limit='. $items)), $items);//// htmlspecialchars_decode uses for links FIXED
}

} else {
if($this->_perRow===1) $this->_perRow = 5;
$iterationAmount = 4;
for ($i = 1; $i <= $iterationAmount; $i ++) {
$limits[] = JHtml::_('select.option',htmlspecialchars_decode(JRoute::_( $link.'&limit='. $i*$this->_perRow)) ,$i*$this->_perRow );//// htmlspecialchars_decode uses for links FIXED
}

$limits[] = JHTML::_('select.option',htmlspecialchars_decode(JRoute::_( $link.'&limit='. $this->_perRow * 10)) , $this->_perRow * 10 );//// htmlspecialchars_decode uses for links FIXED
$limits[] = JHTML::_('select.option',htmlspecialchars_decode(JRoute::_( $link.'&limit='. $this->_perRow * 20)) , $this->_perRow * 20 );//// htmlspecialchars_decode uses for links FIXED
// vmdebug('getLimitBox',$this->_perRow);
}
$selected= htmlspecialchars_decode(JRoute::_( $link.'&limit='. $selected)) ; //// htmlspecialchars_decode uses for links FIXED
$js = 'onchange="window.top.location.href=this.options[this.selectedIndex].value">';

$html = JHTML::_('select.genericlist',  $limits, 'limit', 'class="inputbox" size="1" '.$js , 'value', 'text', $selected);
}



This hack solve the problem what occurs when you select all item also.

I just tested on Joomla 1.7.3. and VM 2.0

Milbo

Did you check the svn? Please check the svn. I am quite sure I fixed 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/

tnyari

Quote from: Milbo on January 25, 2012, 20:12:53 PM
Did you check the svn? Please check the svn. I am quite sure I fixed it.
Hi Milbo,
I checked, and the zero value problem is fixed!