├── 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 |
19 | 23 | 24 | 28 |
29 | 31 | 36 | set('field', 'prevnext', __DIR__ . DS . 'field'); 3 | $kirby->set('blueprint', 'fields/prevnext', __DIR__ . '/definition.yml'); -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "kirby-panel-prevnext", 3 | "description": "Panel siblings navigation", 4 | "author": "Jens Törnell ", 5 | "version": "0.1", 6 | "type": "kirby-plugin", 7 | "license": "MIT" 8 | } -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # Kirby Panel Prevnext 2 | 3 | *Version 0.1* 4 | 5 | Navigate to siblings in the panel. Multilanguage support. 6 | 7 | ![Screenshot](docs/prevnext.gif) 8 | 9 | ## Installation 10 | 11 | Use one of the alternatives below. 12 | 13 | ### 1. Kirby CLI 14 | 15 | If you are using the [Kirby CLI](https://github.com/getkirby/cli) you can install this plugin by running the following commands in your shell: 16 | 17 | ``` 18 | $ cd path/to/kirby 19 | $ kirby plugin:install jenstornell/kirby-panel-prevnext 20 | ``` 21 | 22 | ### 2. Clone or download 23 | 24 | 1. [Clone](https://github.com/jenstornell/kirby-panel-prevnext.git) or [download](https://github.com/jenstornell/kirby-panel-prevnext/archive/master.zip) this repository. 25 | 2. Unzip the archive if needed and rename the folder to `kirby-panel-prevnext`. 26 | 27 | **Make sure that the plugin folder structure looks like this:** 28 | 29 | ``` 30 | site/plugins/kirby-panel-prevnext/ 31 | ``` 32 | 33 | ### 3. Git Submodule 34 | 35 | If you know your way around Git, you can download this plugin as a submodule: 36 | 37 | ``` 38 | $ cd path/to/kirby 39 | $ git submodule add https://github.com/jenstornell/kirby-panel-prevnext site/plugins/kirby-panel-prevnext 40 | ``` 41 | 42 | ## Setup 43 | 44 | ### 1. Blueprint 45 | 46 | To make it work as expected, add the following code to your blueprint: 47 | 48 | ``` 49 | fields: 50 | prevnext: prevnext 51 | ``` 52 | 53 | ## Changelog 54 | 55 | **0.1** 56 | 57 | - Inital release 58 | 59 | ## Requirements 60 | 61 | - [**Kirby**](https://getkirby.com/) 2.3+ 62 | 63 | ## Disclaimer 64 | 65 | This plugin is provided "as is" with no guarantee. Use it at your own risk and always test it yourself before using it in a production environment. If you find any issues, please [create a new issue](https://github.com/jenstornell/kirby-panel-prevnext/issues/new). 66 | 67 | ## License 68 | 69 | [MIT](https://opensource.org/licenses/MIT) 70 | 71 | It is discouraged to use this plugin in any project that promotes racism, sexism, homophobia, animal abuse, violence or any other form of hate speech. 72 | 73 | ## Credits 74 | 75 | - [Jens Törnell](https://github.com/jenstornell) --------------------------------------------------------------------------------