Page 1 of 1

Pagination in back-end breaks when filtering database result

Posted: Fri Mar 16, 2012 6:46 pm
by clongato
I´ve noticed a weird problem in Joomla 2.5.1 backend. Whenever you filter results from the database - articles listing, redirect links listing, custom components listing - and you click to edit a record that´s not listed on page 1 (say 2 or 3) and then you return to the list view you´re redirected back to page 1 regardless the page the record you edited is.

How to make this problem happen:
1. Go to any list view.
2. Type anything in any of the filters so that the query returns more than one page of results.
3. Go to page 2.
4. Click to edit any record.
5. Click Close or Save and Close to get back to list view.
Voilà, you´re back to page 1 again.

This only happens if you´re using the filter.

Anyone knows how to fix this?

Claudio

Re: Pagination in back-end breaks when filtering database re

Posted: Wed Mar 28, 2012 1:52 pm
by kuloun
Hi, I have exactly the same problem.

Version 1.7.1 and Version 2.5.2

Re: Pagination in back-end breaks when filtering database re

Posted: Wed Mar 28, 2012 2:37 pm
by kuloun
I just found a temporary solution on V 1.7.1. I guess it will be similar for 2.5

file:

Code: Select all

/libraries/joomla/application/component/modellist.php
Function (around line 345):

Code: Select all

public function getUserStateFromRequest($key, $request, $default = null, $type = 'none', $resetPage = true)
	{
		$app = JFactory::getApplication();
		$old_state = $app->getUserState($key);
		$cur_state = (!is_null($old_state)) ? $old_state : $default;
		$new_state = JRequest::getVar($request, null, 'default', $type);

		if (($cur_state != $new_state) && ($resetPage)){
			JRequest::setVar('limitstart', 0);
		}

		// Save the new value only if it is set in this request.
		if ($new_state !== null) {
			$app->setUserState($key, $new_state);
		}
		else {
			$new_state = $cur_state;
		}

		return $new_state;
	}
Comment out :

Code: Select all

		if (($cur_state != $new_state) && ($resetPage)){
			JRequest::setVar('limitstart', 0);
		}
The result code should be:

Code: Select all

public function getUserStateFromRequest($key, $request, $default = null, $type = 'none', $resetPage = true)
	{
		$app = JFactory::getApplication();
		$old_state = $app->getUserState($key);
		$cur_state = (!is_null($old_state)) ? $old_state : $default;
		$new_state = JRequest::getVar($request, null, 'default', $type);

/*
This should be commented out
		if (($cur_state != $new_state) && ($resetPage)){
			JRequest::setVar('limitstart', 0);
		}
*/
		// Save the new value only if it is set in this request.
		if ($new_state !== null) {
			$app->setUserState($key, $new_state);
		}
		else {
			$new_state = $cur_state;
		}

		return $new_state;
	}
I have no idea if it will affect anything else at the moment, but it does what I need.

Re: Pagination in back-end breaks when filtering database re

Posted: Wed Dec 05, 2012 6:49 pm
by VisiGod
It seems that getUserStateFromRequest needs a new parameter in the end. You need to set resetPage to false.

Example:

$this->getUserStateFromRequest('com_xpto.filter.category_id', 'filter_category_id', 0, 'uint', false);

Re: Pagination in back-end breaks when filtering database re

Posted: Fri Jan 03, 2014 11:10 pm
by testcouch
This pagination issue is still not fixed in latest Joomla 2.5.17!:o