PHP code example of josbeir / cakephp-paginator-sortmap

1. Go to this page and download the library: Download josbeir/cakephp-paginator-sortmap library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

josbeir / cakephp-paginator-sortmap example snippets



namespace App\Controller;

class FooController extends AppController
{    
    public function initialize()
    {
        parent::initialize();
        
        $this->loadComponent('Josbeir/Paginator.Paginator');
    }
    
    public function index()
    {
        $paginate = [
            'sortMap' => [
                'name' => 'name',
                'modified' => [ 'modified', 'name' ]
            ]
        ];
        
        // paginate FooTable
        $results = $this->Paginator->paginate($this->Foo, $paginate);
    }
}

[
    'sortMap' => [
        'foo' => 'bar'
    ]
]

[
    'sortMap' => [
        'foo' => [
            'Article.name',
            'Article.created'
        ]
    ]
]

[
    'sortMap' => [
        'foo' => [
            'Article.name',
            'Article.created' => 'asc'
        ]
    ]
]

[
    'sortMap' => [
        'name',
        'created'
    ]
]