Problem occurred during pagination

Permalink 2 users found helpful
Hi, I performing pagination using database item list. I creating this using single page. I am performing search operation here.I'm getting user search values from single page.
After click on the search button I'm performing search operation.
I filter the query using the database item list
All are working perfectly.
But if I'm going to next page from pagination button, I'm getting invalid argument supplied for foreach() error.
before search my url is mysite/index.php/search_leaves/
after going to search function my url is mysite/index.php/search_leaves/search
if I press the second page in pagination button, it show the url like mysite/index.php/search_leaves/?&ccm_paging_p=2

I used the below code in my search function of my controller.
$LeaveList->setItemsPerPage(10);
$this->set('Summary',$LeaveList);
$currentPage = Page::getCurrentPage();
$this->set('LeaveList', $LeaveList->getPage());
$this->set('LeavePagination', $LeaveList->displayPagingV2(Loader::helper('navigation')->getLinkToCollection($currentPage), true));

how to solve this problem???
please give some suggestions...

cjramki
 
mkly replied on at Permalink Reply
mkly
Maybe change
$this->set('LeavePagination', $LeaveList->displayPagingV2(Loader::helper('navigation')->getLinkToCollection($currentPage), true));

to
$this->set('LeavePagination', false, true));


Regards,
Mike
http://mkly.io
cjramki replied on at Permalink Reply
cjramki
Thanks for the reply Mike,
$this->set('LeavePagination', $LeaveList->displayPagingV2(Loader::helper('navigation')->getLinkToCollection($currentPage), false));

This line performing The above line second parameter only sending the value from controller to single page.
if I used like this
$this->set('LeavePagination', false, true);

what value will assign to LeavePagination in single pages from this controller?
cjramki replied on at Permalink Reply
cjramki
bump
hereNT replied on at Permalink Reply
hereNT
Do you need to set the name space? I know that helps with pagination on page lists:

$namespace = 'dpm_' . $this->getCollectionObject()->getCollectionID();
$pl->enableStickySearchRequest($namespace);
cjramki replied on at Permalink Reply
cjramki
Thanks for the reply...
Sorry, I could not understand how to use strickySearchRequest. I could not find any detailed documentation or how-to about this.
any way thanks for suggest me to use name space.
It is helped me on showing more than one paginating result.
cjramki replied on at Permalink Best Answer Reply
cjramki
I solved this issue.
In my controller's view function I placed my filter query and set the value from controller to view. This will only will execute if the session variable is set
public function view() {
    Loader::model('ListforDetails');
    $List = new ListforDetails();
    if (isset($_SESSION['var1'])) {
        $data['var1'] = $_SESSION['var1'];
        $data['var2'] = $_SESSION['var2'];
        $data['var3'] = $_SESSION['var3'];
        $List - > filter('field1', $data['var1'], '=');
        $List - > filter('field2', $data['var2'], '=');
        $List - > filter('field3', $data['var3'], '=');
    }
    $List - > setItemsPerPage(10);
    $this - > set('forSummary', $List);
    $currentPage = Page::getCurrentPage();
    $this - > set('LeaveList', $LeaveList - > getPage());

In my search function I get the search values from single page form and I manually add those values in session. Then simply call view function.
public function search()
{
      $data['var1']=$this->post('val1');
      $data['var2']=$this->post('val2');
      $data['var3']=$this->post('val3');
      foreach ($data as $key=>$sessData)
      {
      $_SESSION[$key]=$sessData;
      }
      echo $this->view();
}

In my application I disabled my browser back button action. so, I placed my button called "back" in my form. If the user click on the back button, I unset the session array values like,
public function back()
   {
      unset($_SESSION['var1']);
      unset($_SESSION['var2']);
      unset($_SESSION['var3']);
      echo $this->redirect('prev_url');
   }

Finally I solved this issue...
Thanks for the help @Mike, @hereNT.
And thanks to @Remo for make me understanding about pagination in concrete5.

Regards,
CJ Ramki