mirror of
https://github.com/silverstripe/silverstripe-blog
synced 2024-10-22 11:05:58 +02:00
add meta links for previous and next pages in pagination
This commit is contained in:
parent
6525f1c109
commit
dae2ba0e5f
@ -3,6 +3,7 @@
|
||||
namespace SilverStripe\Blog\Model;
|
||||
|
||||
use PageController;
|
||||
use SilverStripe\Control\Director;
|
||||
use SilverStripe\Control\RSS\RSSFeed;
|
||||
use SilverStripe\ORM\ArrayList;
|
||||
use SilverStripe\ORM\FieldType\DBDatetime;
|
||||
@ -432,6 +433,39 @@ class BlogController extends PageController
|
||||
return $posts;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the absolute link to the next page for use in the page meta tags. This helps search engines
|
||||
* find the pagination and index all pages properly.
|
||||
*
|
||||
* @example "<% if $PaginationAbsoluteNextLink %><link rel="next" href="$PaginationAbsoluteNextLink"><% end_if %>"
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function PaginationAbsoluteNextLink()
|
||||
{
|
||||
$posts = $this->PaginatedList();
|
||||
if ($posts->NotLastPage()) {
|
||||
return Director::absoluteURL($posts->NextLink());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the absolute link to the previous page for use in the page meta tags. This helps search engines
|
||||
* find the pagination and index all pages properly.
|
||||
*
|
||||
* @example "<% if $PaginationAbsolutePrevLink %><link rel="prev" href="$PaginationAbsolutePrevLink"><% end_if %>"
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function PaginationAbsolutePrevLink()
|
||||
{
|
||||
$posts = $this->PaginatedList();
|
||||
if ($posts->NotFirstPage()) {
|
||||
return Director::absoluteURL($posts->PrevLink());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays an RSS feed of blog posts.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user