Use the bakery my boy, use the bakery

http://bakery.cakephp.org/articles/view/advanced-pagination-1-2
http://wiki.kabturek.info/paginating_search_results

On Jul 31, 5:22 pm, gmarziou <[EMAIL PROTECTED]> wrote:
> Hello,
>
> I have written a "search" form with some criteria that are then
> combined as conditions used by paginate().
> It works, I get the first page of my list of results but when I click
> on 2nd page I come back to the form.
> The paginated list is the generic index view generated by bake.
>
> My understanding is the problem comes from the URL that does not
> change between the form and its result page but I don't how to change
> this.
> Probably the form should point to another action and my search()
> method should be split
>
> I did put some of my code below.
>
> As a side note, it's rather unfortunate that the API is not homogenous
> between findAll() and paginate():
>
> $players = $this->Player->findAll($conditions);
>
> $players = $this->paginate(null, array('conditions'=>$conditions));
>
> Thanks,
>
> Gael
>
> players/search.ctp:
>
> <?php
> echo $form->create('Player', array('url' => 'search'));
> echo $this->element('country_list');
> echo $form->input('gender', array('type' => 'select', 'options' =>
> array('-' => 'Any', 'M' => 'Man', 'F' => 'Woman')));
> echo $form->input('class', array('type' => 'select', 'options' =>
> array(0 => 'Any', 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)));
> echo $form->submit('Search');
> echo $form->end();
> ?>
>
> players_controller.php:
>
>   function search() {
>     if (empty ($this->data)) {
>        $this->render();
>     } else {
>       $conditions = array ();
>       $country = $this->data['Player']['country'];
>       if ($country != '---') {
>          $conditions['Player']['country_id'] = "=$country";
>       }
>       $gender = $this->data['Player']['gender'];
>       if ($gender != '-') {
>          $conditions['Player']['sex'] = "=$gender";
>       }
>       $class = $this->data['Player']['class'];
>       if ($class > 0) {
>          $conditions['Player']['class'] = "=$class";
>       }
>       $players = $this->paginate(null, array('conditions'=>
> $conditions));
>       $this->set('players', $players);
>       $this->render("index");
>     }
>   }


--~--~---------~--~----~------------~-------~--~----~
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