cakephp – Pagination always shows 20 images


I'm making a gallery that uses CakePHP's Pagination. The problem is that I only want to show 15 images per page, but regardless of the value I put in public $paginate , in the limit, 20 images are always shown. With the line $this->Paginator->settings =$this->paginate; uncommented this works, but causes routes that contain page numbers to not work correctly. DebugKit also shows that the Soptions array is empty. Why is this happening? Is there any way to make this work with this commented out line? I'm using Cake 2.4.4.


public $components = array('Paginator');
public $paginate = array('maxLimit' => 15, 'order' => array('modified' => 'desc'), 'contain' => array('GalleryImage', 'GalleryVideo'));

public function displayImages(){
        $this->set('title_for_layout', 'Galeria de Fotografias');
        $this->layout = 'default';

        //$this->Paginator->settings =$this->paginate;

        //$gallery_images = $this->GalleryImage->find('all');
        $this->set('gallery_images', $gallery_images);

    //$image_display = $gallery_image['path']



  text-align: left;
 <table width="90%">
        foreach( $gallery_images as $gallery_image ):?>
    <td align="center" class="thumbnail" style="display:inline-block;">
        $src =$this->webroot. 'img/Gallery/' .$gallery_image['GalleryImage']['name'];
        echo "<a href=\"".$src. "\" rel=\"lightbox\">".$this->Timthumb->image('/img/Gallery/' . $gallery_image['GalleryImage']['name'] , array('width' => 267, 'height' => 189))."  </a>";
    <?php $i++;
            echo "</tr><tr>";
<?php endforeach ?>

<div class="pagesDiv">
<ul class="pagination">
  <li><?php echo $this->Paginator->first(__('Primeira', true), array());?></li>
  <li><?php echo $this->Paginator->numbers(array('separator' => ''  ,'currentTag' =>'span' ,'class' => 'numbers', 'first' => false, 'last' => false));?></li>
  <li><?php echo $this->Paginator->last(__('Última', true), array('class' => 'disabled'));?></li>


Try this:

public $paginate = array(
    'maxLimit' => 10,  //Registros por página
    'limit' => 100  //Registros por consulta
    'paramType' => 'querystring' //Esta linha analisa o parâmetro fornecido pelo link.
$this->Paginator->settings = $this->paginate;
$resultado = $this->Paginator->paginate('Model');

The code above would result in 10 pages, with 100 results in total.

Or like this:

$this->Paginator->settings = array(
        'SeuModel' => array(
                'limit' => 20,
                'maxLimit' => 100,
                'order' => array('SeuModel.campo' => 'ASC') // Por exemplo
        'OutroModel' => array( ... )
Scroll to Top