GithubHelp home page GithubHelp logo

iskrisis / kirby-sortable Goto Github PK

View Code? Open in Web Editor NEW

This project forked from lukaskleinschmidt/kirby-sortable

0.0 1.0 0.0 2.12 MB

Making subpage managing a breeze

CSS 3.85% PHP 87.25% JavaScript 8.90%

kirby-sortable's Introduction


Help keeping me motivated :)

If you enjoy this plugin and want to support me you can buy me a beer.

Buy me a beer


Kirby Sortable Field

Manage subpages in the content area.
This plugin includes the sortable, modules and redirect field. The following animation shows the modules field in combination with the modules-plugin.

Preview

Scope of the plugin

In addition to the three fields the plugin has its own registry. A short overview of the fields.

sortable

The core field. It is the base for the modules field.
Change appereance in the blueprint or build your own field based on this one.

modules

The modules field is an extended sortable field. Bundled with the modules-plugin it is a very powerful tool. You can find further informations here.

To disable the field add c::get('sortable.field.modules', false); to your config.php.

redirect

Redirect a user to the parent of the currently visited panel page. Useful for pages that act as a container. You can find further informations here.

To disable the field add c::get('sortable.field.redirect', false); to your config.php.

Installation

To install the plugin, please put it in the site/plugins directory.
The plugin folder must be named sortable.

site/plugins/
    sortable/
        sortable.php
        ...

Download

You can download the latest version of the plugin from https://github.com/lukaskleinschmidt/kirby-sortable/releases/latest

With Git

If you are familiar with Git, you can clone this repository from Github into your plugins folder.

git clone https://github.com/lukaskleinschmidt/kirby-sortable.git sortable

Blueprint

After installing the plugin you can use the new field types. This blueprint shows all available options of the sortable field.

fields:
  title:
    label: Title
    type: text

  sortable:
    label: Sortable
    type:  sortable

    layout:  base
    variant: null

    limit: false

    parent: null
    prefix: null

    options:
      limit: false
  ...

layout

Load a registerd layout. The layout defines how a entry is rendered. Learn how to register your own layout.

variant

Load a registerd variant. A variant is used to change the naming of the field from page to modules for example. Learn how to register your own variant.

limit

Limit he number of visible pages. Example blueprint from the modules field.

  modules:
    label: Modules
    type: modules

    # Allow 5 visible modules overall
    limit: 5

    # Template specific option
    options:

      # Allow only 3 modules per template (applies to all templates)
      limit: 3
      module.gallery:

        # Allow only 1 visible gallery module (overwrites the current limit of 3)
        limit: 1

parent

Uid to use when looking for the container page. If left empty the field will look for subpages in the current page.

prefix

Template prefix to filter available subpages.

Registry

With the new registry you are now able to customize the visual appearance and modify or add custom functionality. The registry makes it possible to register layouts, actions, variants and translations.

// site/plugins/product-variants/product-variants.php

// Make sure that the sortable plugin is loaded
$kirby->plugin('sortable');

if(!function_exists('sortable')) return;

$kirby->set('field', 'variants', __DIR__ . DS . 'fields' . DS . 'variants');

$sortable = sortable();
$sortable->set('action', 'stock', __DIR__ . DS . 'actions' . DS . 'stock');
$sortable->set('layout', 'variant', __DIR__ . DS . 'layouts' . DS . 'variant');
$sortable->set('variant', 'variants', __DIR__ . DS . 'variants' . DS . 'variants');

As you can see in this example of a product variant field, the plugin can take care of registering all kinds of extensions, which will then be available in the sortable field or any field based on that.

List of registry extensions

These are all possible registry extensions you can register this way:

layout

// The layout directory must exist and it must have a PHP file with the same name in it
sortable()->set('layout', 'mylayout', __DIR__ . DS . 'mylayout');

Have a look at the base layout or the module layout.

action

// The action directory must exist and it must have a PHP file with the same name in it
sortable()->set('action', 'myaction', __DIR__ . DS . 'myaction');

Have a look at the available actions.

variant

// The variant directory must exist and can have multiple tranlation files
sortable()->set('variant', 'myvariant', __DIR__ . DS . 'myvariant');

Have a look at the modules variant or the sections variant.

translation

// The translation file must exist at the given location
sortable()->set('translation', 'en', __DIR__ . DS . 'en.php');
sortable()->set('translation', 'sv_SE', __DIR__ . DS . 'sv_SE.php');

Have a look at the available translations.

Extend the sortable field

Currently you can have a look at the modules field within this plugin. Since the field is included in the plugin all parts are registered within the plugin.

Also check out the demo branch. I will try to update the demo with a more meaningful example soon.

Requirements

kirby-sortable's People

Contributors

lukaskleinschmidt avatar pedroborges avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.