sylvainjule / kirby-categories Goto Github PK
View Code? Open in Web Editor NEWCreate and manage multi-language categories in Kirby
License: MIT License
Create and manage multi-language categories in Kirby
License: MIT License
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
Hi Sylvain,
there is an issue with the way you handle the categories indexes when adding a new category...
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.
I would suggest not using this.localValue.length
to define the newIndex
in Categories.vue
.
Here are different options :
newIndex() {
const indexes = !this.localValue || !this.localValue.length ? [0] : this.localValue.map((item) => item.panelIndex)
return Math.max(...indexes) + 1
}
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...
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.