Pagination Problem between list views

Discussion and education for beginner / novice programmers interested in embarking on the development process to take advantage of the extensible nature of the Joomla! CMS.

Moderators: tjay, seadap, Rogue4ngel, matthewhayashida

Forum rules
Post Reply
User avatar
tfuller
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Tue Sep 20, 2005 11:30 pm
Location: Oregon
Contact:

Pagination Problem between list views

Post by tfuller » Fri Mar 21, 2008 8:00 pm

I have an interesting problem I hope someone in the forum can help me with.

In my component I have several list views that have the possibility of multiple pages.

What's happening is that certain variables, namely $limit and $limitstart are persisting when the admin clicks from page 2 of list 1 to (what is supposed to be) page 1 of list 2. The trouble is that list 1 may have more than one page, but if list 2 has only page of results then nothing shows up. I notice that in my query in the second view LIMIT 20 140 shows up when it should be LIMIT 20 0. The 140 is coming from the last view list when the admin selected a page of results starting with row 140 from a previous view.

I have tried using a getUser to grab the 'view' and use it to try and reset the limit and limitstart in the model but it doesn't seem to have an effect. I have also noticed in the debug that I am getting two queries for my main list - one with no limit and limitstart and one with an incorrect limit and limit start.

Code: Select all

// Get the pagination request variables
		$limit	   = $mainframe->getUserStateFromRequest( 'global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 0);
		$limitstart = $mainframe->getUserStateFromRequest( $option.'limitstart', 'limitstart', 0 );
		// In case limit has been changed, adjust limitstart accordingly
		$limitstart = ($limit != 0 ? (floor($limitstart / $limit) * $limit) : 0);
		$testview 	= JRequest::getVar( 'view' );
		if ($testview != 'mimetypelist') 
			{
				$filter_order = '';
				$filter_order_Dir = '';
				$limit = 0;
				$limitstart = 0;
				$this->setState('limit', $limit);
				$this->setState('limitstart', $limitstart);
			}
		$this->setState('limit', $limit);
		$this->setState('limitstart', $limitstart);
It also seems to happen with $filter_order and $filter_order_Dir and I do seem to have had success in resetting these so at least I don't get 500 errors with "unknown column" MySQL errors.

Any ideas? Is there a way to reset the user variables when you go from one view to another?

Joomla 1.5.1
Check out my new component Bible Study:
http://joomlacode.org/gf/project/biblestudy/

Post Reply