Ticket #867 (closed Feature Request: fixed)
Pagination: option to hide pagination info in url when linking back to first page
| Reported by: | neovive2 | Owned by: | Geert_DD |
|---|---|---|---|
| Priority: | minor | Milestone: | 2.2.1 |
| Component: | Libraries | Version: | 2.2 Release |
| Keywords: | pagination | Cc: |
Description
It would be nice to have a configuration option in the pagination library that hides the display of pagination variables in the url when linking back to the first page.
For example: in a blog, the first page "/blog/home" defaults to displaying the first five without any page info in the url, the next page "/blog/home/?page=2" or "/blog/home/page/2" displays the next five. When you click on the "previous" link, the url for the first page is now "/blog/home/?page=1" or "/blog/home/page/1". This extra url information is not necessary and could potentially be flagged as duplicate content by search engines.
Currently the only solution is to create a custom pagination view file and do multiple str_replace calls (or one nested str_replace) to modify the url for the first page:
<?php if ($first_page): ?>
<?php
// a quick way to remove the page parameter on the first page - ?page=1 should not be displayed
$url = str_replace('{page}', 1, $url);
$url = str_replace('?page=1', '', $url);
?>
<a href="<?php echo $url ?>">‹ <?php echo Kohana::lang('pagination.first') ?></a>
<?php endif ?>
It would be cleaner and easier to have the proper url sent directly by the Pagination library instead of having to add code to the view.
