Skip to content

Instantly share code, notes, and snippets.

View Dynamo6Dev's full-sized avatar

Dev @ Dynamo6 Dynamo6Dev

View GitHub Profile
@mediabeastnz
mediabeastnz / silverstripe-prev-next.php
Last active March 11, 2021 13:07
SilverStripe Prev / Next Controls
public function PrevNextPage($Mode = 'next') {
if($Mode == 'next'){
return SiteTree::get()->filter(array("ParentID" => $this->ParentID, "Sort:GreaterThan" => $this->Sort))->sort("Sort ASC")->limit(1)->first();
}
elseif($Mode == 'prev'){
return SiteTree::get()->filter(array("ParentID" => $this->ParentID, "Sort:LessThan" => $this->Sort))->sort("Sort DESC")->limit(1)->first();
}
else{
return false;