Sunday, June 16, 2013

Pagination With Twitter Bootstrap and CakePHP

Pagination element for CakePHP like twitter bootstrap





Code:
 <div class="pagination">  
  <ul>  
   <?php  
   echo ($this->Paginator->current() > 3) ? $this->Paginator->first('first ', array('tag' => 'li')) : '';  
   echo ($this->Paginator->hasPrev()) ? $this->Paginator->prev(__('prev ', true),  
      array('tag' => 'li', 'id' => 'prev' . rand(2, 9000)), null, array('escape' => false)) : '';  
   echo $this->Paginator->numbers(array('modulus' => 7, 'separator' => ' ', 'tag' => 'li'));  
   echo ($this->Paginator->hasNext()) ? $this->Paginator->next(__(' next', true),  
     array('tag' => 'li'), null, array('escape' => false)) : '';  
   echo ((int) $this->Paginator->counter(array('format' => '%pages%')) > 10) ?  
     $this->Paginator->last('last', array('tag' => 'li')) : '';  
   echo $this->Js->writeBuffer();  
   ?>  
  </ul>  
  </div>