Pager offset question
2009-08-24 18:14:39 GMT
We are having some troubles with our pager because we have been asked to display different number of items on first page.
We thought pager setStart() was the solution but we are having the following problems.
We started setting pager->SetStart for the offest we wanted in order to have a "home" page different and the following pages wih propel pager.
If we setStart value, every page starts with the value we set there, so, we figure out that setSart is not an offset for the whole set of elements, just for each page. Then set setStart(value) for each page, calculating the value for eachone: ( firstPageRowNumber + ((pageNum - 1 ) * regularPagesRowsNumber)
But the total pages is distorted, because seems that total pages is not counting (substracting) the offset... (I imagine this is the expected behavior ... but not our desired one)
For example, we have 34 records, a 3 records on first page and the rest pages 8 items. (34items - 3 on first page = 31 items / 8 per page = 4 peges) but pager calculates 5 pages instead of 4 so last page is empty.
We also try with setOffset on the criteria, but pager clears offset value.
Does anyone try to accomplish something similar? and how did you handle it?
Here is the code we have now
$pager = new PropelPager($criteria,"NewsPeer", "doSelect",$page,$perPage);
$pager->setStart($moduleConfig["newsInHome"] + ($perPage * ($page - 1 )));
A simple example of we want to accomplish (First page doesn't has to be handled with pager if that makes the problem easier)
page1= news 4,5,..11
page2= news 12,13,..19
page3= news 20,21,...27
page4= news 28,29, ... 34
Thanks in advance for any help