[fw-general] Pagination with routes not working.
Hi all. I'm having a bit of a problem trying to get the pagination working using a route. It is not printing the page numbers in the a href of the urls. so it just goes to wedding/bouquets/category instead of wedding/bouquets/category/2 etc The pagination shows, but I do not get the correct links. they just point to the base page. And when i go to wedding/bouquets/category/2 etc if shows the correct page too. So all is working except the links, which show, but don't function correctly. Also is it possible to link the number 1 link back so it doesnt have the 1 there. ie the base page? wedding/bouquets/category and have page 2 go to wedding/bouquets/category/2 etc in my bootstrap i have these routes set already $route = new Zend_Controller_Router_Route( 'wedding/bouquets/:bouquet', array( 'controller' = 'wedding', 'action' = 'bouquet' ) ); $router-addRoute('bouquet',$route2); $route3 = new Zend_Controller_Router_Route( 'wedding/bouquets/:bouquet/:page', array( 'controller' = 'wedding', 'action' = 'bouquet' ) ); in the wedding controller, bouquet action i have the following $bouquet = new Bouquet(); if ($category_id 0) { $obj = $bouquet-fetchAll('bouquet_category='.$category_id); $array = $obj-toArray(); $this-view-paginator = Zend_Paginator::factory($array); $this-view-paginator-setCurrentPageNumber($this-_getParam('page')); $this-view-bouquet = $bouquet-fetchAll('bouquet_category='.$category_id); return; } then in my view i have ?php if (count($this-paginator)): ??= $this-paginationControl($this-paginator, 'Sliding', 'my_pagination_control.phtml'); ? ul ?php echo $this-partialLoop('partials/_bouquets.phtml', $this-paginator); ? /ul ?= $this-paginationControl($this-paginator, 'Sliding', 'my_pagination_control.phtml'); ? ?php endif; ? and the my_pagination_control.phtml looks like this ?php if ($this-pageCount): ? div class=paginationControl !-- Previous page link -- ?php if (isset($this-previous)): ? ?= $this- url(array('page' = $this-previous)); ? lt; Previous | ?php else: ? lt; Previous | ?php endif; ? !-- Numbered page links -- ?php foreach ($this-pagesInRange as $page): ? ?php if ($page != $this-current): ? ?= $this- url(array('page' = $page)); ? ?= $page; ? | ?php else: ? ?= $page; ? | ?php endif; ? ?php endforeach; ? !-- Next page link -- ?php if (isset($this-next)): ? ?= $this- url(array('page' = $this-next)); ? Next gt; ?php else: ? Next gt; ?php endif; ? /div ?php endif; ? thanks for any help given. It is always much appreciated. -- View this message in context: http://www.nabble.com/Pagination-with-routes-not-working.-tp20657017p20657017.html Sent from the Zend Framework mailing list archive at Nabble.com.
Re: [fw-general] Pagination with routes not working.
Hi, Have you tried: $route = new Zend_Controller_Router_Route( 'wedding/bouquets/:bouquet', array( 'controller' = 'wedding', 'action' = 'bouquet', 'page' = 1 ) ); So this makes page default to 1 if not set. You may also want to be careful with this part: $obj = $bouquet-fetchAll('bouquet_category='.$category_id); $array = $obj-toArray(); This is fine if there are only ever a small amount of rows, if you try this with large result sets you will eat memory. You are much better to limit your query. To do this you can use the tableSelectAdpater. Hope this helps Keith 2008/11/24 Ace Paul [EMAIL PROTECTED]: Hi all. I'm having a bit of a problem trying to get the pagination working using a route. It is not printing the page numbers in the a href of the urls. so it just goes to wedding/bouquets/category instead of wedding/bouquets/category/2 etc The pagination shows, but I do not get the correct links. they just point to the base page. And when i go to wedding/bouquets/category/2 etc if shows the correct page too. So all is working except the links, which show, but don't function correctly. Also is it possible to link the number 1 link back so it doesnt have the 1 there. ie the base page? wedding/bouquets/category and have page 2 go to wedding/bouquets/category/2 etc in my bootstrap i have these routes set already $route = new Zend_Controller_Router_Route( 'wedding/bouquets/:bouquet', array( 'controller' = 'wedding', 'action' = 'bouquet' ) ); $router-addRoute('bouquet',$route2); $route3 = new Zend_Controller_Router_Route( 'wedding/bouquets/:bouquet/:page', array( 'controller' = 'wedding', 'action' = 'bouquet' ) ); in the wedding controller, bouquet action i have the following $bouquet = new Bouquet(); if ($category_id 0) { $obj = $bouquet-fetchAll('bouquet_category='.$category_id); $array = $obj-toArray(); $this-view-paginator = Zend_Paginator::factory($array); $this-view-paginator-setCurrentPageNumber($this-_getParam('page')); $this-view-bouquet = $bouquet-fetchAll('bouquet_category='.$category_id); return; } then in my view i have ?php if (count($this-paginator)): ??= $this-paginationControl($this-paginator, 'Sliding', 'my_pagination_control.phtml'); ? ul ?php echo $this-partialLoop('partials/_bouquets.phtml', $this-paginator); ? /ul ?= $this-paginationControl($this-paginator, 'Sliding', 'my_pagination_control.phtml'); ? ?php endif; ? and the my_pagination_control.phtml looks like this ?php if ($this-pageCount): ? div class=paginationControl !-- Previous page link -- ?php if (isset($this-previous)): ? ?= $this- url(array('page' = $this-previous)); ? lt; Previous | ?php else: ? lt; Previous | ?php endif; ? !-- Numbered page links -- ?php foreach ($this-pagesInRange as $page): ? ?php if ($page != $this-current): ? ?= $this- url(array('page' = $page)); ? ?= $page; ? | ?php else: ? ?= $page; ? | ?php endif; ? ?php endforeach; ? !-- Next page link -- ?php if (isset($this-next)): ? ?= $this- url(array('page' = $this-next)); ? Next gt; ?php else: ? Next gt; ?php endif; ? /div ?php endif; ? thanks for any help given. It is always much appreciated. -- View this message in context: http://www.nabble.com/Pagination-with-routes-not-working.-tp20657017p20657017.html Sent from the Zend Framework mailing list archive at Nabble.com. -- -- [MuTe] --
Re: [fw-general] Pagination with routes not working.
thanks for the quick response Keith. I gave that one a go, but no luck unfortunately. Will look into the tableSelectAdapter also. Still very new to ZF so taking baby steps at the moment. thanks for your help -- View this message in context: http://www.nabble.com/Pagination-with-routes-not-working.-tp20657017p20658202.html Sent from the Zend Framework mailing list archive at Nabble.com.
Re: [fw-general] Pagination with routes not working.
Hey Ace, i had the same problem. I solved it by making a link which leading me to the page with pagination like this before: wedding/bouquets/category (above wasnt work for me) and this one works: wedding/bouquets/category/1 //in bootstrap $route3 = new Zend_Controller_Router_Route( 'wedding/bouquets/:bouquet/:page', array( 'controller' = 'wedding', 'action' = 'bouquet' ) // $obj = $bouquet-fetchAll('bouquet_category='.$category_id); //in controller $db = Zend_Registry::get ( 'db' ); $select = $db-select () -from ( 'bouqets', array ('*' ) ) -where ( 'bouquet_category= ?', $category_id ); // Instantiate the Zend Paginator and give it the Zend_Db_Select instance Argument ($selection) $paginator = Zend_Paginator::factory($select); // Set parameters for paginator $paginator-setCurrentPageNumber($this-_getParam(page)); // Note: For this to work of course, your URL must be something like this: http: //localhost:/index/index/page/1 - meaning we are currently on page one, and pass that value into the setCurrentPageNumber $paginator-setItemCountPerPage(3); $paginator-setPageRange(5); //$paginator-setCurrentPageNumber(2); // Make paginator available in your views $this-view-paginator = $paginator; Ace Paul wrote: Hi all. I'm having a bit of a problem trying to get the pagination working using a route. It is not printing the page numbers in the a href of the urls. so it just goes to wedding/bouquets/category instead of wedding/bouquets/category/2 etc The pagination shows, but I do not get the correct links. they just point to the base page. And when i go to wedding/bouquets/category/2 etc if shows the correct page too. So all is working except the links, which show, but don't function correctly. Also is it possible to link the number 1 link back so it doesnt have the 1 there. ie the base page? wedding/bouquets/category and have page 2 go to wedding/bouquets/category/2 etc in my bootstrap i have these routes set already $route = new Zend_Controller_Router_Route( 'wedding/bouquets/:bouquet', array( 'controller' = 'wedding', 'action' = 'bouquet' ) ); $router-addRoute('bouquet',$route2); $route3 = new Zend_Controller_Router_Route( 'wedding/bouquets/:bouquet/:page', array( 'controller' = 'wedding', 'action' = 'bouquet' ) ); in the wedding controller, bouquet action i have the following $bouquet = new Bouquet(); if ($category_id 0) { $obj = $bouquet-fetchAll('bouquet_category='.$category_id); $array = $obj-toArray(); $this-view-paginator = Zend_Paginator::factory($array); $this-view-paginator-setCurrentPageNumber($this-_getParam('page')); $this-view-bouquet = $bouquet-fetchAll('bouquet_category='.$category_id); return; } then in my view i have ?php if (count($this-paginator)): ??= $this-paginationControl($this-paginator, 'Sliding', 'my_pagination_control.phtml'); ? ul ?php echo $this-partialLoop('partials/_bouquets.phtml', $this-paginator); ? /ul ?= $this-paginationControl($this-paginator, 'Sliding', 'my_pagination_control.phtml'); ? ?php endif; ? and the my_pagination_control.phtml looks like this ?php if ($this-pageCount): ? div class=paginationControl !-- Previous page link -- ?php if (isset($this-previous)): ? ?= $this- url(array('page' = $this-previous)); ? lt; Previous | ?php else: ? lt; Previous | ?php endif; ? !-- Numbered page links -- ?php foreach ($this-pagesInRange as $page): ? ?php if ($page != $this-current): ? ?= $this- url(array('page' = $page)); ? ?= $page; ? | ?php else: ? ?= $page; ? | ?php endif; ? ?php endforeach; ? !-- Next page link -- ?php if (isset($this-next)): ? ?= $this- url(array('page' = $this-next)); ? Next gt; ?php else: ? Next gt; ?php endif; ? /div ?php endif; ? thanks for any help given. It is always much appreciated. -- View this message in context: http://www.nabble.com/Pagination-with-routes-not-working.-tp20657017p20661726.html Sent from the Zend Framework mailing list archive at Nabble.com.