php - How can I find the range of a field covered by each page of a paginated set? -


i have model task(id, start_date, end_date, description). use paginator like

    $this->paginator->settings = array(         'task'=>array(             'contain'=>$contain,             'limit'=> $limit,             'conditions'=>$conditions,             'order'=>'task.start_date asc',             'page'=> $page,     )); 

what i'm after able know range of start_date covered each page of paged set. instead of page numbers (i.e. in view generated $this->paginator->numbers()) i'd create links "2 weeks ago" , "today" jump page containing first task start_date > now()-14days, example.

i understand alter $conditions , set range on start_date, want whole set.

open other ideas on how achieve same result, or pointers in right direction.

you need calculate records before , after given start date of condition , divide number of records per page page on.

however, not user friendly, instead this:

pass start date , range in url , based on passed values build query use within pagination settings.

/something/index?range=last-two-weeks 

and check range value , switch value set right conditions. directly filter records user interested in clear understand url.


Comments