Siebren solution will for sure work if getperson() is called with a
pagination link, but looking at first post it seems coming through
"requestAction".
Because it's a part of projectController (probably for a view
displaying the project and the persons attached to it), it seems the
solution is to make a pagination using ajax (calling
PersonsController to update a div in the initial view)..
hth
On Jan 8, 6:13 pm, "Siebren Bakker" <[EMAIL PROTECTED]> wrote:
> Ok, this is actually fairly simple.
> In the controller, you need to declare the paginator variable with this:
> var $paginate = array('limit' => 10, 'page' => 1);
> this tells the controller that you want to use the paginate helper, with a
> default page-length of 10 values (change at will).
>
> then you would change your function to the following to send a paginate
> array to the views.
> Function getpersons () {
> $this->set('persons', $this->paginate('Person')
>
> }
>
> and in the View: as an example
> <h1>People</h1>
> Showing Page <?php echo $paginator->counter(); ?>//displays what page you
> are viewing in the paginator array
> <ul>
> <?php foreach ($persons as $person): ?>//iterates through the paginator
> array
> <li><?php echo $person['Person']['username']; ?>:
> <?php echo $person['Person']['id']; ?> -
> <?php echo $person['person']['email']; ?>
> </li>
> <?php endforeach; ?>
> </ul>
> <?php echo $paginator->prev(); ?>//automagic previous page link/button
> <?php echo $paginator->numbers(); ?>//automagic clickable page numbers,
> seperated by pipe symbol '|'
> <?php echo $paginator->next(); ?>//automagic next page link/button
>
> Hope this helps you. You can also take a look at the 1.2 pagination
> tutorials on the Bakery website located
> here:http://bakery.cakephp.org/articles/view/basic-pagination-overview-3
> and here:http://bakery.cakephp.org/articles/view/advanced-pagination-1-2
>
> On Jan 8, 2008 10:22 AM, dandreta <[EMAIL PROTECTED]> wrote:
>
>
>
>
>
> > Hi!
> > I have 2 tables: projects and persons.
> > In my ProjectsController I have a function that shows in the view a
> > list of all the persons of the database. For it I have this:
> > $this -> set ('persons', $this -> requestAction ('/persons/getpersons
> > '));
>
> > And in PersonsController:
>
> > Function getpersons () {
> > return $this -> Person -> findAll ();
> > }
> > This works well, but what I want is to paginate the list of persons
> > and I dont know how can I do it.
> > What have I to change or add to obtain it?
> > Thanks and regards
>
> --
> In the name of Life, Liberty, and the pursuit of my sanity.
> Siebren Bakker(Aevum Decessus)
> -----BEGIN GEEK CODE BLOCK-----
> Version: 3.12
> GCS d- s+: a19 C++++ UL++ P L++
> !E W++ N(-) o? K? w(+) O? M-- V?
> PS+ PE Y- PGP- t+ 5? X- R tv--
> b++ Di D+ G+ e h! r y-
> ------END GEEK CODE BLOCK------
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---