Skip to content

Instantly share code, notes, and snippets.

@dogmatic69
Created May 9, 2014 00:39
Show Gist options
  • Save dogmatic69/fec1e788630f12210d8e to your computer and use it in GitHub Desktop.
Save dogmatic69/fec1e788630f12210d8e to your computer and use it in GitHub Desktop.
bootstrap pagination in cake
class AppController extends Controller {
public $helpers = array(
'Paginator' => array(
'className' => 'Assets.BootstrapPaginator',
),
);
}
<?php
App::uses('PaginatorHelper', 'View/Helper');
class BootstrapPaginatorHelper extends PaginatorHelper {
public function numbers($options = array()) {
$defaults = array(
'tag' => 'li', 'before' => null, 'after' => null, 'model' => $this->defaultModel(), 'class' => null,
'modulus' => '8', 'separator' => ' | ', 'first' => null, 'last' => null, 'ellipsis' => '...',
'currentClass' => 'active', 'currentTag' => 'a'
);
return parent::numbers(Hash::merge($defaults, $options));
}
public function prev($title = '&laquo;', $options = array(), $disabledTitle = '<a href="#">&laquo;</a>', $disabledOptions = array()) {
$bootstraoDefault = array('tag' => 'li', 'escape' => false);
$options = Hash::merge($bootstraoDefault, $options);
$disabledOptions = Hash::merge($bootstraoDefault + array('class' => 'disabled'), $disabledOptions);
return parent::prev($title, $options, $disabledTitle, $disabledOptions);
}
public function next($title = '&raquo;', $options = array(), $disabledTitle = '<a href="#">&raquo;</a>', $disabledOptions = array()) {
$bootstraoDefault = array('tag' => 'li', 'escape' => false);
$options = Hash::merge($bootstraoDefault, $options);
$disabledOptions = Hash::merge($bootstraoDefault + array('class' => 'disabled'), $disabledOptions);
return parent::prev($title, $options, $disabledTitle, $disabledOptions);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment