Categories and sub categories for Strapi collection - categories

Working with Strapi I have a collection 'Events' that has a category 'Music' and the subcategories 'Jazz', 'Funk', 'Samba'.
How do I create a taxonomy system as WordPress has for its posts in Strapi???

This seem to work for me at this moment:
Create category
Under "Parent" column there is now dropdown for each sub category
Create new category and select Parent category
GraphQL
I used idea from: https://forum.strapi.io/t/how-to-create-nested-categories-in-v4/16416

The feature is still outstanding https://github.com/strapi/strapi/issues/8708

Related

Finding code for laravel category subcategories task

Create Category Module with Parent and subcategory. Both Category handle in same table. Table name should be category_master with fields id, cat_parent_id, cat_title, cat_status, created-at, updated_at. Than after get all parent category with subcategory in frontend give checkbox the all category. max 3 parent category should be checkable at a time
I want code of this task.

Getting records through parentID from CategoryCollection in Typo3

I am using CategoryCollection to get the records of a specific category ID, but the problem is it only loads the exact category for e.g I have parent > child and I have attached child category ID to a record and I select child category, then it shows me the record fine, but if I select parentID, then it does not show the child category record.
$collection = \TYPO3\CMS\Frontend\Category\Collection\CategoryCollection::load(
$categoryID,
true,
'tx_myextension_table_name',
'categories'
);
Is there any built-in way to get the records of all child category if I select parent ID from CategoryCollectionor do I have to write something custom for that?
Unfortunately there is no built-in solution for complex selections like this. You will indeed need to write your own logic which could work like this:
Find categories whose parent is your category
Repeat this recursively for every category found until you don't find any children for each category anymore
Do a custom IN() query with the list of category UIDs
If you have deep category trees, the list of category UIDs could be put in a custom cache. You can use the root category UID or a hash thereof as key. These cache entries should be tagged with sys_category. Alternatively you can add a sys_category_<uid> tag for every category UID in your list. This ensures that whenever something changes about one of the categories, the cache entries are dropped and you can rebuild the list.

extbase query builder injection of one repository to another repository

I have a question regarding extbase if I need to inject a reposotory into another reposotry for getting join condition in the query what I need to do for that?
For example this query
$query = $this->createQuery()
->statement('
SELECT tx_casmarketing_domain_model_category.uid, tx_casmarketing_domain_model_category.name
FROM tx_casmarketing_domain_model_category, tx_casmarketing_domain_model_ad
WHERE tx_casmarketing_domain_model_ad.ad_cat = tx_casmarketing_domain_model_category.uid ')
This query I am trying to access through
$query = $this->createQuery();
$query->matching(
);
Basically I am trying to inject one ad repository to category repository because there is no relationship defined in model for that.
my model contain category to ads relationship so when i access ads throughs adRepository I automcally accesss the cateogrys along with adCategory Repository, but in vise-virsa when i need category which has been selected for the ads i can only access through joining in query becus i do not have that relationship in my model. i need that category for my doropdown list in ads that how many ads category corrently ads contain...
this->adrepository->findAll() i automcally access ads with selected cateogry because this relationship already exist in my model but i need some how $this->categoryRepository($this->adrepository->finAll())
in drop down list i need only that category which is currently active. I can access this through simple query like i mention above but i need it through extbase query stuff becuse with extbase query way i can use buitin functionaly of typo3 like time stamp for start and end and hidden builtin functionality i want
->statement('
SELECT tx_casmarketing_domain_model_category.uid, tx_casmarketing_domain_model_category.name
FROM tx_casmarketing_domain_model_category, tx_casmarketing_domain_model_ad
WHERE tx_casmarketing_domain_model_ad.ad_cat = tx_casmarketing_domain_model_category.uid ') this is working but i want to conver it thourgh extbase query
To make it work with common repository methods you have to define the object-relations in TCA (and not sure if in model too). Then you can use functions like $query->equals('category',$category) or $query->contains('category',$category).
What is the purpose of your query? You are trying to find all categories that are are assigned by an "ad"?

What's the deference between product catalog and category in Ofbiz?

What's the deference between product catalog and category in Ofbiz ?
I think all of them is a group or set of product that have one or more common characteristics. But in Ofbiz's using one Catalog have many Category ?
Thanks!
They are similar, but catalog contains a list of categories with different purposes: home page categories, search categories, etc.
http://ofbiz.135035.n4.nabble.com/Product-Category-and-Catalog-td4636208.html

Symfony2 sonata admin bundle list mapping with mongodb odm

I have a collection 'Category' which contains its parent and childs in itself.
I am using sonata admin bundle to generate list. And I want is to list the categories in such a way that the default list should contains only the top level categories (i.e. only those categories which do not have parents).
And with a link to sub-categories list all the child categories of that particular parent category.
How could I do that?
First define method createQuery in your admin which restricts query to top parents.
When children are in collection self referenced to entity Category then you can display this collenction in list column.