Hey,
seems a bit too complicated to me...
I suggest you just wrap the dropdown in a form, use a submit on the
same page ($this->Form->create('Modelname', array('url' => $this-
>here));) to send the form to the same action you're in at this
moment.
In your controller use a RequestHandler-Part to get changes of the
dropdown and write them into a session variable. Then use a paginator
defintion directly within the controller, and set the limit of the
paginator to the value of the depending session-key.
That should be a 2-minute task, if you have any questions just ask, I
will post the code for you if you cannot get any further.
Hint:
To define the paginator from within an action (and not globally for a
whole controller), use the following code in your action:
public function index() {
$this->paginate['Modelname'] = array(
'conditions' => array(
'Modelname.deleted' => false),
'limit' => 10,
'order' => array(
'Modelname.created' => 'DESC'
)
);
$results = $this->paginate('Modelname');
$this->set(compact('results'));
}
(the code above implies you would use a condition on not-deleted
entries and an ordering of the field created in a descending way)
Second hint: replace the hard-coded limit of 10 to a Session key (e.g.
$this->Session->read('Settings.Model.action.limit'); )
On 30 Mrz., 09:04, Thomas <goo...@ellis-events.com> wrote:
> Nobody that can help?
>
>
>
>
>
>
>
> On Tuesday, March 27, 2012 10:23:12 AM UTC+2, Thomas wrote:
>
> > Am Montag, 26. März 2012 17:01:49 UTC+2 schrieb 100rk:
>
> >> Form using GET method, dropdown named 'limit' or 'show' with onchange = '
> >> *this.form*.submit();' - see pagination settings 'paramType' and
> >> 'maxLimit'.
>
> >>http://book.cakephp.org/2.0/en/core-libraries/components/pagination.h...
>
> > Works - nearly :-)
>
> > I added the form and select elements to my template:
>
> > index.ctp:
>
> > <?php
> > echo $this->Form->create(FALSE);
> > echo $this->Html->link('Add Post', array('controller' => 'posts',
> > 'action' => 'add'));
> > echo '<br><br>'.$this->Paginator->numbers(array('before'=>'Pages: '));
>
> > $options = array( 2 => 'two', 4 => 'four');
> > echo ' Show '.$this->Form->select('recordlimit', $options,
> > array('value'=>2, 'empty' => FALSE, 'onChange'=>'this.form.submit();')).'
> > records per page.';
> > ?>
>
> > And the following code in PostsController.php:
>
> > <?php
> > class PostsController extends AppController {
> > public $name = 'Posts';
> > public $helpers = array('Html', 'Form');
> > public $components = array('Session');
> > public $paginate = array(
> > 'paramType' => 'querystring',
> > 'limit' => 2,
> > 'order' => array(
> > 'Post.title' => 'asc'
> > )
> > );
>
> > function beforeFilter(){
> > $this->paginate['limit'] =
> > intval($this->request->data('recordlimit'));
> > }
>
> > In the debugger, I can now see that the "limit" option of the paginator
> > gets set to 4 if I select option "four", but I only get a single record and
> > a total of 5 pages (one record per page) shown after this.
>
> > I also don't know how I can access the current limit of the paginator from
> > the view to set the correct option in the select.
>
> > Also, the direct page links always look like this (limit = 1):
>
> >http://localhost/cakephp/posts?/posts=&page=2&limit=1
>
> > I know I'm nearly there - but CakePHP is quite complex and the learning
> > curve steep for me.
>
> > I urgently need results so any help is appreciated very much.
>
> > Thanks!
> > Thomas
--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php