Skip to content

Commit

Permalink
add meta links for previous and next pages in pagination
Browse files Browse the repository at this point in the history
  • Loading branch information
xini committed May 25, 2017
1 parent fef1462 commit 4f1eb3d
Showing 1 changed file with 33 additions and 3 deletions.
36 changes: 33 additions & 3 deletions code/model/Blog.php
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,6 @@ public function archive()

if ($year) {
$this->blogPosts = $dataRecord->getArchivedBlogPosts($year, $month, $day);

return $this->render();
}

Expand Down Expand Up @@ -838,7 +837,7 @@ public function tag()
if($this->isRSS()) {
return $this->rssFeed($this->blogPosts, $tag->getLink());
} else {
return $this->render();
return $this->render();
}
}

Expand Down Expand Up @@ -882,7 +881,7 @@ public function category()
if($this->isRSS()) {
return $this->rssFeed($this->blogPosts, $category->getLink());
} else {
return $this->render();
return $this->render();
}
}

Expand Down Expand Up @@ -1043,7 +1042,37 @@ public function PaginatedList()

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.
*
Expand Down Expand Up @@ -1128,4 +1157,5 @@ private function isRSS()
return false;
}
}

}

0 comments on commit 4f1eb3d

Please sign in to comment.