├── definition.yml ├── docs └── prevnext.gif ├── field ├── assets │ └── css │ │ └── style.css ├── prevnext.php └── template.php ├── kirby-panel-prevnext.php ├── package.json └── readme.md /definition.yml: -------------------------------------------------------------------------------- 1 | type: prevnext -------------------------------------------------------------------------------- /docs/prevnext.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kirby-deprecated-plugins/kirby-panel-prevnext/fd148ce8b14e6ba4a096aa8e78a5ef9b9c9271be/docs/prevnext.gif -------------------------------------------------------------------------------- /field/assets/css/style.css: -------------------------------------------------------------------------------- 1 | .plugin-prevnext { 2 | display: flex; 3 | flex-wrap: wrap; 4 | justify-content: space-between; 5 | } 6 | 7 | .plugin-prevnext a { 8 | margin: .5em; 9 | } 10 | 11 | .plugin-prevnext .prev i { 12 | margin-right: .5em; 13 | } 14 | .plugin-prevnext .next i { 15 | margin-left: .5em; 16 | } 17 | 18 | .plugin-prevnext a { 19 | color: #777; 20 | } 21 | 22 | .plugin-prevnext a:hover { 23 | color: #000; 24 | } 25 | 26 | .plugin-prevnext .prev { 27 | margin-right: .5em; 28 | } 29 | 30 | .plugin-prevnext .next { 31 | margin-left: .5em; 32 | } -------------------------------------------------------------------------------- /field/prevnext.php: -------------------------------------------------------------------------------- 1 | url(); 8 | 9 | $obj = ( $item->hasPrev() ) ? $item->prev() : $item->siblings()->last(); 10 | 11 | echo $obj->url(); 12 | return $obj; 13 | } 14 | // Forward one 15 | public static function forward( $item ) { 16 | $obj = ( $item->hasNext() ) ? $item->next() : $item->siblings()->first(); 17 | return $obj; 18 | } 19 | // Jump 20 | public static function jump( $steps, $item = null ) { 21 | //$item = ( ! empty( $item ) ) ? $item : page(); 22 | for( $i = 0; $i < abs( $steps ); $i++ ) { 23 | if( $steps <= 0 ) { 24 | $item = self::reverse( $item ); 25 | } else { 26 | $item = self::forward( $item ); 27 | } 28 | } 29 | return $item; 30 | } 31 | } 32 | // Wrapper function for template 33 | page::$methods['jump'] = function($page, $steps) { 34 | return pagejump::jump( $steps, $page ); 35 | };*/ 36 | 37 | class PrevnextField extends BaseField { 38 | static public $fieldname = 'prevnext'; 39 | static public $assets = array( 40 | 'css' => array( 41 | 'style.css', 42 | ) 43 | ); 44 | 45 | public function input() { 46 | #echo $this->page->prev()->slug(); 47 | #echo page($this->page->id())->prev()->slug(); 48 | $html = tpl::load( __DIR__ . DS . 'template.php', $data = array( 49 | 'page' => $this->page 50 | )); 51 | return $html; 52 | } 53 | } -------------------------------------------------------------------------------- /field/template.php: -------------------------------------------------------------------------------- 1 | id()); 3 | 4 | if( $page_obj->siblings()->count() > 1 ) { 5 | if ( $page_obj->hasPrev() ) { 6 | $prev = $page_obj->prev(); 7 | } else { 8 | $prev = $page_obj->siblings()->last(); 9 | } 10 | 11 | if ( $page_obj->hasNext() ) { 12 | $next = $page_obj->next(); 13 | } else { 14 | $next = $page_obj->siblings()->first(); 15 | } 16 | ?> 17 | 18 |