GithubHelp home page GithubHelp logo

sylvainjule / kirby-categories Goto Github PK

View Code? Open in Web Editor NEW
20.0 20.0 1.0 36 KB

Create and manage multi-language categories in Kirby

License: MIT License

PHP 34.87% Vue 48.84% JavaScript 1.26% SCSS 15.03%

kirby-categories's People

Contributors

sylvainjule avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

dodovoelkel

kirby-categories's Issues

Error upon adding an item

Just checking out your plugin, and when I try to add a (second) item to the categories field; I get an error: Cannot read property '0' of undefined?

Tried in a fresh starterkit with Kirby 3.5.3

Issue with indexes numbering

Hi Sylvain,
there is an issue with the way you handle the categories indexes when adding a new category...

How to reproduce it

Let say I have a list of 3 categories with indexes 1, 2 and 3. If I remove the category number 2 which is in in the middle of my list, then if I add a new category, the new category id and panelIndex will be 3, which is already taken by the third category of my initial list.

How to fix it

I would suggest not using this.localValue.length to define the newIndex in Categories.vue.

Here are different options :

  1. If you want to increment indexes based on the highest existing index :
newIndex() {
    const indexes = !this.localValue || !this.localValue.length ? [0] : this.localValue.map((item) => item.panelIndex)
    return Math.max(...indexes) + 1
}
  1. If you want to fill unused indexes :
newIndex() {
    const indexes = !this.localValue || !this.localValue.length ? [] : this.localValue.map((item) => item.panelIndex)
    for (var i = 1; i <= indexes.length + 1; i++) {
        if (indexes.indexOf(i) == -1) {
            return i
        }
    }
}

There is probably better ways of writing this, though...

Category Field in site.yml

Hey,
first of all: Thank you very much for this solution. I was struggling all the time with my multilanguage sites and this is exactly what I need.
I wonder if its possible to create category fields inside the site blueprint. If i try for example:

    'sylvainjule.categories.watch' => [
        'site'     => 'fruits',
    ]

it doesn't seem to sync.

Kind regards

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.