在LARAVEL中,我们有一个原生的引导分页:
<?php echo $posts->links(); ?>
结果是:
在CAKEPHP,我们可以提出:
<ul class="pagination">
<?php
echo $this->Paginator->prev('← Previous', array(
'class' => 'prev',
'tag' => 'li',
'escape' => false
), '<a onclick="return false;">← Previous</a>', array(
'class' => 'prev disabled',
'tag' => 'li',
'escape' => false
));
echo $this->Paginator->numbers(array(
'separator' => '',
'tag' => 'li',
'currentClass' => 'active',
'currentTag' => 'a'
));
echo $this->Paginator->next('Next →', array(
'class' => 'next',
'tag' => 'li',
'escape' => false
), '<a onclick="return false;">Next →</a>', array(
'class' => 'next disabled',
'tag' => 'li',
'escape' => false
)); ?>
</ul>
结果不那么漂亮:
那么,如何使用cakephp代码来制作相同的laravel结果?
答案 0 :(得分:2)
解决方案是:
echo $this->Paginator->numbers(
array('modulus' => 2,
'separator' => false,
'before' => '',
'ellipsis' => '<li class="disabled"><a>...</a></li>',
'after' => '',
'tag' => 'li',
'class' => false,
'currentClass' => 'active',
'currentTag' => 'a',
'first' => 3,
'last' => 3,
)
);
向安德烈·丹尼尔求助
答案 1 :(得分:2)
tb方式可以是:
<?php $paginator = $this->Paginator->params(); ?>
<?php if ($paginator['pageCount'] > 1): ?>
<div class="row">
<div class="col-md-12">
<nav class="text-center">
<ul class="pagination">
<?php
echo (!$this->Paginator->hasPrev()) ? '' : $this->Paginator->prev('«', array('tag' => 'li'), null, array('tag' => 'li', 'class' => 'disabled', 'disabledTag' => 'a'));
echo $this->Paginator->numbers(array(
'separator' => '',
'ellipsis' => '<li class="disabled"><a>...</a></li>',
'currentTag' => 'a',
'currentClass' => 'active',
'tag' => 'li',
'first' => 1,
)
);
echo (!$this->Paginator->hasNext()) ? '' : $this->Paginator->next('»', array('tag' => 'li', 'currentClass' => 'disabled'), null, array('tag' => 'li', 'class' => 'disabled', 'disabledTag' => 'a'));
?>
</ul>
</nav>
</div>
</div>
<?php endif; ?>