Created
May 9, 2014 00:39
-
-
Save dogmatic69/fec1e788630f12210d8e to your computer and use it in GitHub Desktop.
bootstrap pagination in cake
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AppController extends Controller { | |
public $helpers = array( | |
'Paginator' => array( | |
'className' => 'Assets.BootstrapPaginator', | |
), | |
); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 = '«', $options = array(), $disabledTitle = '<a href="#">«</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 = '»', $options = array(), $disabledTitle = '<a href="#">»</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