Skip to content

Instantly share code, notes, and snippets.

@Kindari
Created January 7, 2014 12:35
Show Gist options
  • Save Kindari/8298688 to your computer and use it in GitHub Desktop.
Save Kindari/8298688 to your computer and use it in GitHub Desktop.
<?php
return array(
/*
|--------------------------------------------------------------------------
| View Storage Paths
|--------------------------------------------------------------------------
|
| Most templating systems load templates from disk. Here you may specify
| an array of paths that should be checked for your views. Of course
| the usual Laravel view path has already been registered for you.
|
*/
'paths' => array(__DIR__.'/../views'),
/*
|--------------------------------------------------------------------------
| Pagination View
|--------------------------------------------------------------------------
|
| This view will be used to render the pagination link output, and can
| be easily customized here to show any view you like. A clean view
| compatible with Twitter's Bootstrap is given to you by default.
|
*/
'pagination' => 'pagination.simple',
);
<?php
$presenter = new PaginationPresenter($paginator);
$trans = $environment->getTranslator();
?>
<?php if ($paginator->getLastPage() > 1): ?>
<ul class="pager">
<?php
echo $presenter->getPrevious($trans->trans('pagination.previous'), 'myclass');
echo $presenter->getNext($trans->trans('pagination.next'), 'myclass');
?>
</ul>
<?php endif; ?>
<?php
use Illuminate\Pagination\BootstrapPresenter;
class PaginationPresenter extends BootstrapPresenter
{
public function getPageLinkWrapper($url, $page, $class='')
{
return '<li><a href="'.$url.'" class="' . $class . '">'.$page.'</a></li>';
}
/**
* Get the previous page pagination element.
*
* @param string $text
* @return string
*/
public function getPrevious($text = '&laquo;', $class = '')
{
// If the current page is less than or equal to one, it means we can't go any
// further back in the pages, so we will render a disabled previous button
// when that is the case. Otherwise, we will give it an active "status".
if ($this->currentPage <= 1)
{
return $this->getDisabledTextWrapper($text);
}
else
{
$url = $this->paginator->getUrl($this->currentPage - 1);
return $this->getPageLinkWrapper($url, $text, $class);
}
}
/**
* Get the next page pagination element.
*
* @param string $text
* @return string
*/
public function getNext($text = '&raquo;', $class = '')
{
// If the current page is greater than or equal to the last page, it means we
// can't go any further into the pages, as we're already on this last page
// that is available, so we will make it the "next" link style disabled.
if ($this->currentPage >= $this->lastPage)
{
return $this->getDisabledTextWrapper($text);
}
else
{
$url = $this->paginator->getUrl($this->currentPage + 1);
return $this->getPageLinkWrapper($url, $text, $class);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment