Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
paginator with user defined page sizes...
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  7 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Thomas  
View profile  
 More options Mar 26 2012, 10:27 am
From: Thomas <goo...@ellis-events.com>
Date: Mon, 26 Mar 2012 07:27:40 -0700 (PDT)
Local: Mon, Mar 26 2012 10:27 am
Subject: paginator with user defined page sizes...

Hi,

I would like to include a dropdown into an overview page that allows the
user to select the paginator page size himself, e.g. 10, 25, 50, 100
items/page

But since there is no "form" or "submit" on the overview page, I don't know
how I can get the value of the select input control.

Is there a CakePHP "standard" way to do something like this?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
100rk  
View profile  
 More options Mar 26 2012, 11:01 am
From: 100rk <lubomir.st...@gmail.com>
Date: Mon, 26 Mar 2012 08:01:49 -0700 (PDT)
Local: Mon, Mar 26 2012 11:01 am
Subject: Re: paginator with user defined page sizes...

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


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Thomas  
View profile  
 More options Mar 27 2012, 4:23 am
From: Thomas <goo...@ellis-events.com>
Date: Tue, 27 Mar 2012 01:23:12 -0700 (PDT)
Local: Tues, Mar 27 2012 4:23 am
Subject: Re: paginator with user defined page sizes...

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 '&nbsp;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


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Thomas  
View profile  
 More options Mar 30 2012, 3:04 am
From: Thomas <goo...@ellis-events.com>
Date: Fri, 30 Mar 2012 00:04:32 -0700 (PDT)
Local: Fri, Mar 30 2012 3:04 am
Subject: Re: paginator with user defined page sizes...

Nobody that can help?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
DigitalDude  
View profile  
 More options Mar 30 2012, 6:57 pm
From: DigitalDude <e.blumsten...@googlemail.com>
Date: Fri, 30 Mar 2012 15:57:47 -0700 (PDT)
Local: Fri, Mar 30 2012 6:57 pm
Subject: Re: paginator with user defined page sizes...
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:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Thomas  
View profile  
 More options Apr 2 2012, 4:44 am
From: Thomas <goo...@ellis-events.com>
Date: Mon, 2 Apr 2012 01:44:28 -0700 (PDT)
Local: Mon, Apr 2 2012 4:44 am
Subject: Re: paginator with user defined page sizes...

Hi,

thanks you for your feedback!

I have tried to change my code according to your suggestions but hit a wall
just at the first step:

I now changed the page template index.ctp:

    $options = array( 2 => 'two', 4 => 'four');
    echo $this->Form->create('Posts', array('url' => $this->here));
    echo '&nbsp;Show '.$this->Form->select('recordlimit', $options,
array('value'=>2, 'empty' => FALSE, 'onChange'=>'this.form.submit();')).'
records per page.';
    echo $this->Form->end();

But I get a "missing controller" error: *Error: * *CakephpController* could
not be found.

The initial URL reads: http://localhost/cakephp/posts, but the form action
reads:

<form action="/cakephp/cakephp/posts">

Note the additional "cakephp" part, it looks as if $this->here returns a
wrong URL

I have removed the 'url' definition which fixed that but I would like to
understand the logic or idea behind this 'feature'

You also wrote:

In your controller use a RequestHandler-Part to get changes of the

> dropdown and write them into a session variable.

But I did not find out what a "RequestHandler-Part" might be or how to use
a session from within the controller - I'm currently quite overwhelmed by
the huge amount of classes, helpers, components etc. that CakePHP offers -
plus I'm also struggling with the transition from my current language
(Xbase++, which is some xBase dialect) to PHP - especially the heavy use of
multiply nested arrays is quite confusing to me.

So please be patient with me ;-)

Thomas


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Thomas  
View profile  
 More options Apr 30 2012, 8:42 am
From: Thomas <goo...@ellis-events.com>
Date: Mon, 30 Apr 2012 05:42:44 -0700 (PDT)
Local: Mon, Apr 30 2012 8:42 am
Subject: Re: paginator with user defined page sizes...

Still can't get this to work... :-(


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »