Hi Steve,

That is a logic problem which simply goes away if you use PRG (Post
Redirect Get). See http://www.noswad.me.uk/Pagination/PRG/ for an
example and code you can download.

If you don't want to use PRG you will need for the links to 'pull' the
form data with each link - that requires ajax to work and there's an
example of that on my site too.

I think it's about time I edited that wiki page to point at the
bakery....

HTH,

AD7six
Please note:
The manual/bakery is a good place to start any quest for info.
The cake search (at the time of writing) erroneously reports less/no
results for the google group.
The wiki may contain incorrect info - read at your own risk (it's
mainly user submitted) :) You may get your answer quicker by asking on
the IRC Channel (you can access it with just a browser
here:http://irc.cakephp.org).

Dateve wrote:
> 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