Blesta Addons Posted August 25, 2014 Report Posted August 25, 2014 i want to override pagination setting , specially the total show result per page , i have put this code $settings = array_merge(Configure::get("Blesta.pagination_client"), array( 'total_results' => $this->total_announcements, // = 21 'results_per_page' => 6, 'uri'=> $this->base_uri . "plugin/announcements/client_main/index/[p]/", 'params'=>array('sort'=>$sort,'order'=>$order) ) ); $this->helpers(array("Pagination"=>array($this->get, $settings))); // $this->Pagination->setSettings(Configure::get("Blesta.pagination_ajax")); but is not working , it show 20 result instead of 6 result per page . what is working is the pagination tab , is calculated corectly , it show 4 page . i have missed something or this is a bug ? Quote
Blesta Addons Posted August 25, 2014 Author Report Posted August 25, 2014 i have fixed it by adding this to the module $this->setPerPage(6); how i can set it via controller ? Quote
Tyson Posted August 25, 2014 Report Posted August 25, 2014 i want to override pagination setting , specially the total show result per page , i have put this code $settings = array_merge(Configure::get("Blesta.pagination_client"), array( 'total_results' => $this->total_announcements, // = 21 'results_per_page' => 6, 'uri'=> $this->base_uri . "plugin/announcements/client_main/index/[p]/", 'params'=>array('sort'=>$sort,'order'=>$order) ) ); $this->helpers(array("Pagination"=>array($this->get, $settings))); // $this->Pagination->setSettings(Configure::get("Blesta.pagination_ajax")); but is not working , it show 20 result instead of 6 result per page . what is working is the pagination tab , is calculated corectly , it show 4 page . i have missed something or this is a bug ? What you have there looks like it should work to me, so long as you don't have a 'total_results' key, or 'total_results' = 0. Quote
Blesta Addons Posted August 25, 2014 Author Report Posted August 25, 2014 What you have there looks like it should work to me, so long as you don't have a 'total_results' key, or 'total_results' = 0. i think you have not understand the probleme . let say $settings = array_merge(Configure::get("Blesta.pagination_client"), array( 'total_results' => 21 , // = 21 'results_per_page' => 6, 'uri'=> $this->base_uri . "plugin/announcements/client_main/index/[p]/", 'params'=>array('sort'=>$sort,'order'=>$order) ) ); $this->helpers(array("Pagination"=>array($this->get, $settings))); this should normally show a page with 6 result and anvigation with 4 pages . but it show 20 result with pagination of 4 pages . when i have searched the code i have found request using $this->setPerPage() instead of results_per_page . the same code tested in native function like listing service and client , it always return 20 result insead of results_per_page value . can someone re-duplicate the case ? Quote
Tyson Posted August 25, 2014 Report Posted August 25, 2014 I meant 'total_pages' rather than 'total_results' above. I'd have to see how you're setting your results into the template to show you where it's going wrong. But the number of results you show on the page is independent of the pagination. It sounds like the pagination is working correctly by showing the correct number of pages for the number of results you say you have. However, the number of results you set in your template does not coincide with the number you told the pagination you would set. This sounds like an issue with how you're fetching or displaying the data rather than a problem with pagination. Using $this->setPerPage() in a model simply overrides the default 'per page' value of a query, which is generally used in calculating the result list to fetch in the limit clause of your queries. Quote
Blesta Addons Posted August 26, 2014 Author Report Posted August 26, 2014 so the pagination ha notthing related to the databse query LIMIT , we should adjust query limit to feat the pagination settings results_per_page . Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.