Jump to content

Override Pagination Setting


Blesta Addons

Recommended Posts

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 ?

 

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 ?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...