I am new to cake and I have a question regarding the pagination found
here http://wiki.cakephp.org/tutorials:pagination .

I have read and read, and unfortunately, I can not solve my "Search
value disappearing in the pagination element" problem. I simply create
a form, submit it, and the page displays properly, but once I try to go
to another page, the search_value was lost. (thus showing a normal
database query with no special where clause). I am thinking it has
something to do with passing an extra parameter? Is this the case? The
first time the controller receives the Post variable, but how do I keep
that search_value for subsequent pages?

Here are the pieces of code.

Controller Index function:
    $this->pageTitle = 'Throbbin Hood :: Porno for the masses since
1853';

    // If we came from the index
    if(isset($this->data['form']['search'])) {
      $search_value = $this->data['form']['search'];
      $criteria['Password']['url'] = "LIKE %{$search_value}%";
    }
    debug('11'.$criteria.'11');
    list($order, $limit, $page) = $this->Pagination->init($criteria);
    $passwords = $this->Password->findAll($criteria, NULL, $order,
$limit, $page);
    $this->set('passwords', $passwords);
    $this->render('index');

Index View:
<?php echo $html->formTag('/passwords'); ?>
  <?php echo $html->input('form/search'); ?>
  <?php echo $html->submit('Search');?>
</form>
<?php echo $this->renderElement('search'); ?>

Search Element View:
<table>
<?php
  $pagination->setPaging($paging);
  $th = array (
    $pagination->sortBy('url', 'Website'),
    $pagination->sortBy('username','Username'),
    $pagination->sortBy('password', 'Password'),
    $pagination->sortBy('dateFound','Date Found'),
  );

  echo $html->tableHeaders($th);
  foreach ($passwords as $password) {
    $tr = array (
      $html->link($password['Password']['url'],
$password['Password']['url'], array('target'=> '_blank')),
      $password['Password']['userName'],
      $password['Password']['password'],
      $password['Password']['dateFound'],
    );
    echo $html->tableCells($tr, array('style'=>'background:#E2E2E2'),
array('style'=>'background:transparent'));
  }
?>
</table>
<?php  echo $this->renderElement('pagination', $paging); ?>

Pagination View Element:
<div id='pagination'>
<?php
    if($pagination->setPaging($paging)):
      $prev = $pagination->prevPage('Previous',false);
      $prev = $prev ? $prev : $leftArrow;
      $next = $pagination->nextPage('Next',false);
      $next = $next ? $next : $rightArrow;
      $pages = $pagination->pageNumbers(" &nbsp;");
      echo $prev." ".$pages." ".$next;
    endif;
?>
</div>

I have attempted to search from the same page rather than have two
seperate pages (instead of index and search, I have combined them and
used only index).

I appreciate any help I get. Thanks
Steve.


--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups 
"Cake PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to