add meta links for previous and next pages in pagination

This commit is contained in:
Florian Thoma 2017-05-03 11:44:37 +10:00
parent fef1462f56
commit 4f1eb3d227

View File

@ -758,7 +758,6 @@ class Blog_Controller extends Page_Controller
if ($year) {
$this->blogPosts = $dataRecord->getArchivedBlogPosts($year, $month, $day);
return $this->render();
}
@ -1044,6 +1043,36 @@ class Blog_Controller extends Page_Controller
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.
*
@ -1128,4 +1157,5 @@ class Blog_Controller extends Page_Controller
return false;
}
}
}