I do my pagination in the model. So you wouldn't need any logic in the controller. Just pass the page param and the param you use for the context switcher to the model and it will decide to paginate or not, and return the result set.
On Tue, Dec 8, 2009 at 9:40 AM, scs <[email protected]> wrote: > I am already using ContextSwitch helper and have two different view > scripts (one normal html view and one for excel view). > However, my pagination code was in the controller. If I did not > misunderstand, > I shall move the following code (pagination code) to the view script > (in this case to the html view) ? > Am I right? > > >> $page=$this->_getParam('page', 1); > >> $paginator = Zend_Paginator::factory($rows); > >> $paginator->setItemCountPerPage($limit); > >> $paginator->setCurrentPageNumber($page); > > Thanks... > > On Tue, Dec 8, 2009 at 4:29 PM, Matthew Weier O'Phinney > <[email protected]> wrote: > > -- scs <[email protected]> wrote > > (on Tuesday, 08 December 2009, 03:27 PM +0200): > >> Then this is what i will do :) > >> > >> $limit = ( ($format == 'excel') ? count($rows) : 100 ); > >> > >> $page=$this->_getParam('page', 1); > >> $paginator = Zend_Paginator::factory($rows); > >> $paginator->setItemCountPerPage($limit); > >> $paginator->setCurrentPageNumber($page); > >> > >> $this->view->applications = $paginator; > > > > This is really view logic. I'd recommend using the ContextSwitch action > > helper, and defining an "excel" context; this will allow you to have > > separate view scripts for your HTML and Excel contexts. Then, keep the > > logic in your controller minimal, and within your separate view scripts, > > handle pagination differently. > > > > > >> On Tue, Dec 8, 2009 at 3:23 PM, Саша Стаменковић <[email protected]> > wrote: > >> > Yes, but I thought you already solved that :) > >> > Some request param would be nice > >> > www.yourhost/controller/action/format/excel > >> > > >> > Regards, > >> > Saša Stamenković > >> > > >> > > >> > On Tue, Dec 8, 2009 at 10:19 AM, Саша Стаменковић <[email protected] > > > >> > wrote: > >> >> > >> >> Have you tried: > >> >> $paginator->setItemCountPerPage($paginator->getTotalItemCount()) > >> >> in excel context. > >> >> Thats the first thing coming to my mind. > >> >> Regards, > >> >> Saša Stamenković > >> >> > >> >> > >> >> On Tue, Dec 8, 2009 at 9:52 AM, scs <[email protected]> wrote: > >> >>> > >> >>> Hi, > >> >>> I have an html report that has paging. It list 100 records in every > page. > >> >>> I added an excel report to this action and need to disable the > paging > >> >>> feature > >> >>> in excel output/context. > >> >>> > >> >>> But I am not sure if there is a better way. > >> >>> > >> >>> Something like this or a better way? : > >> >>> //get format param from request > >> >>> ... > >> >>> if ($format != 'excel') { > >> >>> $page=$this->_getParam('page', 1); > >> >>> $paginator = Zend_Paginator::factory($rows); > >> >>> $paginator->setItemCountPerPage(100); > >> >>> $paginator->setCurrentPageNumber($page); > >> >>> > >> >>> $this->view->applications = $paginator; > >> >>> } else { > >> >>> $this->view->applications = $rows; > >> >>> } > >> >>> > >> >>> Thanks > >> >>> scs > >> >> > >> > > >> > > >> > > > > -- > > Matthew Weier O'Phinney > > Project Lead | [email protected] > > Zend Framework | http://framework.zend.com/ > > >
