Advertisement
Guest User

Untitled

a guest
May 29th, 2014
19
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.03 KB | None | 0 0
  1. public function NavigationLink($direction){
  2.         switch($direction){
  3.             case 'next':
  4.                 $sort = 'Sort:GreaterThan';
  5.                 break;
  6.             case 'prev':
  7.                 $sort = 'Sort:LessThan';
  8.                 break;
  9.             default:
  10.                 return false;
  11.         }
  12.         $page = BlogPage::get()->filter(array(
  13.             'ParentID' => $this->ParentID,
  14.             $sort => $this->Sort
  15.         ))->sort('Sort ASC')->first();
  16.  
  17.         return $page;
  18.     }
  19.  
  20.     public function BlogNavigation($class = 'blog-navigation'){
  21.         if($prev = self::NavigationLink('prev')){
  22.             $prevLink = '<li><a href="'.$prev->Link().'">'.$prev->Title.'</li>';
  23.         }else{
  24.             $prevLink = '';
  25.         };
  26.         if($next = self::NavigationLink('next')){
  27.             $nextLink = '<li><a href="'.$next->Link().'">'.$next->Title.'</a></li>';
  28.         }else{
  29.             $nextLink = '';
  30.         };
  31.         return '<ul class="'.$class.'">'.$prevLink.$nextLink.'</ul>';
  32.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement