I found one interesting solution to manage everything you need in
Pagination..

basicaly, it is all cake. I had an issue, for example, I had to make
two different paginations, depending on which page are you looking for
the same model (admin or regular user). In pagination var, you can set
everything you want, from order for pagination to condition for which
ones to show (my e.g , post must be published by admin in order to be
viewed by a regular user on the comments page. So I have admin view
and regular index for posts).
There is only one problem left, and that is count ! No mater what
condition you take, cake's pagination will always show you count for
all of the database entries and then you can throw away your code. You
have to rewrite pagination count function in order to make it work,
but then the other one will not work. So I just rewrited the
pagination funciton and made one paramter that it receive. I made it a
global variable in app controller to make it visible no matter what,
because for some reason if I just added param to function it didn't
work. So i set it globaly for 1 if I want the first count and for 2 if
I want the other one (depending on how i have set var paginations
condition) and it is all.

Let me know if you need thew source code...

On Aug 20, 5:19 pm, Philip Thompson <[email protected]> wrote:
> Hi all.
>
> I've done plenty of searching and been unable to find a solution yet. I'm 
> also fairly new to Cake, but not to PHP. I have ajax pagination working from 
> the currently-view controller/model. However, if I attempt to paginate a list 
> that comes from a different model/controller, I only get 1 result.
>
> From Hardware, I get a properly paginated list of hardware items. Hardware 
> has a belongsTo relationship to HardwareType and Location. From Location, I 
> want to include a paginated list of hardware items. If I call the same method 
> from LocationsController as I do in HardwaresController, I only get 1 result.
>
> <?php
> class HardwaresController extends AppController
> {
>     public $components = array('RequestHandler');
>     public $helpers = array('Js'=>array('Mootools'));
>     public $paginate = array(
>         'Hardware' => array(
>             'limit' => 3,
>             'order' => array(
>                 'Hardware.name' => 'ASC'
>             ),
>         ),
>     );
>
>     public function index () {
>         $this->set('hardware', $this->listing()); // This works as expected
>     }
>
>     public function listing () {
>         return $this->paginate('Hardware');
>     }
>
> }
>
> class LocationsController extends AppController
> {
>     ...
>     public function view ($id) {
>         ...
>         App::import('Controller', 'Hardwares');
>         $Hardwares = new HardwaresController;
>         $Hardwares->constructClasses();
>         $this->set('hardwares', $Hardwares->listing()); // This is only 1 
> result
>     }
>
> }
>
> class Hardware extends AppModel
> {
>     public $name = 'Hardware';
>     public $belongsTo = array('HardwareType', 'Location');
>     public $order = array('Hardware.name ASC');
>     ...}
>
> ?>
>
> Can anyone explain why I'm only getting a single result (which is the actual 
> first result) and/or please provide some assistance on how to resolve the 
> issue?
>
> Thanks in advance.
>
> ~Philip
>
> http://lonestarlightandsound.com/
>
> "innerHTML is a string. The DOM is not a string, it's a hierarchal object 
> structure. Shoving a string into an object is impure and similar to wrapping 
> a spaghetti noodle around an orange and calling it lunch."

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" 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