$collection->add('ninetten', 'diez y nueve'); $collection->add('twenty', 'viente'); $collection->add('twenty one', 'viente uno'); $collection->add('twenty two', 'viente dos'); $collection->add('twenty three', 'viente tres'); $collection->add('twenty four', 'viente cuatro'); $collection->add('twenty five', 'viente cinco'); $collection->add('twenty six', 'viente seis'); $collection->add('twenty seven', 'viente siete'); $collection->add('twenty eight', 'viente ocho'); $collection->add('twenty nine', 'viente nueve'); $collection->add('thirty', 'treinte'); $datasource = new A_Pager_Array($collection->toArray()); // temporary hack until pager supports Collections $pager = new A_Pager($datasource); $pager->setPageSize(3); // create a request processor to set pager from GET parameters $request = new A_Pager_Request($pager); $request->process(); $template = new A_Template_Include('templates/standard_pagination.tpl'); // create a HTML writer to output #$helper = new A_Pager_HTMLWriter($pager); // get rows of data $start_row = $pager->getStartRow(); $end_row = $pager->getEndRow(); $rows = $datasource->getRows($start_row, $end_row); $helper = new PagerHelper($pager, $template, 2); ?> <p><?php echo $helper->render();
// initialize an array for testing $first = 0; $last = 75; for ($i = $first; $i <= $last; ++$i) { $myarray[$i]['id'] = $i; $myarray[$i]['text'] = 'This is row ' . $i; $myarray[$i]['sort'] = $last - $i; } #$myarray = null; // create a data object that has the interface needed by the Pager object $datasource = new A_Pager_Array($myarray); $datasource->orderBy('text'); } // create pager using values from datasource and request params $pager = new A_Pager($datasource); $pager->setPageSize(25); // change from default of 10 of you want $pager->setOrderByFields(array('id', 'text', 'sort'), 'text'); // allowed orderby fields and starting sort // create a request processor to set pager from GET parameters #$request = new PagerRequest($pager); $request = new A_Pager_Request_Session($pager); $request->process(); if ($pager->hasPages()) { // create a HTML writer to output $writer = new A_Pager_HTMLWriter($pager); // get rows of data $start_row = $pager->getStartRow(); $end_row = $pager->getEndRow(); $rows = $datasource->getRows($start_row, $end_row); // display the data
// initialize an array to testing for ($i = 43; $i <= 75; ++$i) { $myarray[$i] = 'This is row ' . $i; } // create a data object that has the interface needed by the Pager object $datasource = new A_Pager_Array($myarray); // create pager using values from datasource and request params $pager = new A_Pager($datasource); $pager->setRangeSize(5); $request = new A_Pager_Request($pager); $request->process(); $writer = new A_Pager_HTMLWriter($pager); $start_row = $pager->getStartRow(); $end_row = $pager->getEndRow(); $pager2 = new A_Pager($datasource); $pager2->setPageSize(5); $pager2->setRangeSize(3); $pager2->setPageParameter('page2'); $pager2->setPageSizeParameter('page_size2'); $pager2->setLastRowParameter('last_row2'); $request->__construct($pager2); $request->process(); $writer2 = new A_Pager_HTMLWriter($pager2); $start_row2 = $pager2->getStartRow(); $end_row2 = $pager2->getEndRow(); $writer->setExtraParameters($writer2->getParameters($pager2->getCurrentPage())); $writer2->setExtraParameters($writer->getParameters($pager->getCurrentPage())); $rows = $datasource->getRows($start_row, $end_row); $n = $start_row; #echo '<pre>' . print_r($rows, 1) . '</pre>'; echo '<table border="2"><tr><td valign="top">';