public function render(\Koch\Pagination\Pagination $pagination) { $lastPage = $pagination->getLastPage(); $numberOfPages = $pagination->getNumberOfPages(); $current_page = $pagination->getCurrentPage(); $url = 'URL'; $html = '<nav class="pagination">'; $html .= sprintf('<a href="%s">‹ %s</a>', str_replace('{page}', 1, $url), _('First')); if ($pagination->hasPreviousPage()) { $html .= sprintf('<a href="%s"><</a>', str_replace('{page}', $pagination->getPreviousPage(), $url)); } // render page range around the current page for ($i = 1; $i <= $numberOfPages; ++$i) { if ($i === $current_page) { $html .= sprintf('<li class="active">%s</li>', $i); } else { $html .= sprintf('<a href="%s">%s</a>', str_replace('{page}', $i, $url), $i); } } if ($pagination->hasNextPage()) { $html .= sprintf('<a href="%s">></a>', str_replace('{page}', $pagination->getNextPage(), $url)); } if ($lastPage) { $html .= sprintf('<a href="%s"> %s›</a>', str_replace('{page}', $lastPage, $url), _('Last')); } $html .= '</nav>'; return $html; }
public function render(\Koch\Pagination\Pagination $pagination) { $html = '<nav class="pagination">'; if ($previous_page) { $html .= sprintf('<a href="%s">« %s </a>', str_replace('{page}', $pagination->getPreviousPage(), $url), _('previous')); } else { $html .= '« ' . _('previous'); } $html .= '|'; $html .= sprintf('%s, %s, %s, %s', _('Page'), $current_page, _('of'), $total_pages); $html .= '|'; $html .= sprintf('%s, %s, – %s %s %s', _('Items'), $current_first_item, $current_last_item, _('of'), $total_items); $html .= '|'; if ($pagination->hasNextPage()) { $html .= sprintf('<a href="%s"> %s »</a>', str_replace('{page}', $pagination->getNextPage(), $url), _('Next')); } else { $html .= _('pagination.next') . ' »'; } $html .= '</nav>'; return $html; }