strapi-plugin-categorizer
v2.0.10
Published
A plugin that lets you categorize content quickly.
Downloads
73
Readme
Strapi plugin categorizer v.2
A plugin that lets you categorize content quickly.
WARNING 2.0.X is ALPHA VERSION
From version 2.0.0 categorizer changes the npm package to strapi-plugin-categorizer
, v2 not backward compatible to v1.
Installation
yarn add strapi-plugin-categorizer
yarn build
Guide
- Create your custom collection type. (
Category
) - Add string field
name
- Add relation hasOne to
Category
, name the relation fieldparent
. - Switch to content manager view, add your categories to collection:
- if no parent assigned, - parent is
null
, this is a root - if category has parent, this is a branch - a subcategory
- After you created your
Categories
structure, you have to add two fields to your target collection:
categories
- hasMany relation toCategories
categoriesCategorizer
- the categorizer field, that is going to be used to build relationsName
-categoriesCategorizer
target
-categories
targetName
-name
maxDepth
-4
- After you set up, you should be able to select relations based on your structure, when you hit save, you should get array of relations in
categories
field.
FEATURES
- [x] supports multiple categorizer fields per collection
- [x] supports user created collections
- [x] feature: multiple categorizers on one target*
- [x] feature: clear for categorizer dropdown
- [ ] need validation for user entered configuration data
- [ ] strapi data transfer
* multiple categorizers on one target - allows to target same relation field from more then one categorizer to handle case where you need additional categories, like Gifts or New.
About
categorizer
is a kind of relation builder based on json created in custom field.
The categorizer
field would let you select filtered relations one by one, then in beforeCreate or beforeUpdate, those json would be used to build actual relations for categories
field.
Collection that should have following structure:
_______________________ _______________________ _______________________
| | | | | |
| "root" | ____\ | "branch" | ____\ | "leaf" |
| parent: null | / | parent: "root" | / | parent: "branch" |
|_______________________| |_______________________| |_______________________|
Requirements
@strapi/strapi
< 4.11.0
- [email protected]
@strapi/strapi
>= 4.11.0
- strapi-plugin-categorizer
The plugin will add:
- Custom Field
Categorizer
- Lifecycle hooks for contentType that are going to target
categorizer
json fields.
NOTICE:
- Categories can have only one parent.
- Relations are not updated in Content Editor View if updated from lifecycle hook.
- It's recommended to hide or disable editing for field
categories
, since on every updated the relations would regenerate fromcategorizer
. - Data-transfer not supported (will break selection but not relations)
The purpose of this is to be able to do that:
http://localhost:1337/api/cars?filters[categories][title][$eq]=sedan