Questions tagged [categories]

Categories are taxonomies for your entries, users, and assets.

Filter by
Sorted by
Tagged with
1 vote
1 answer
365 views

Categories on a Front-end form

I have searched the forum and cannot find the answer to my question. I know how to populate a dropdown with the categories that are already in the system, but what happens if the category that needs ...
0 votes
0 answers
35 views

Element API: Group Categories by Groups

I want to use the Element API to output a hierarchical JSON list of categories grouped by category group. For example: { "groups": [ { "id": 2, &...
1 vote
1 answer
54 views

Entry URI Format from an Entries Field (Categories)

i am trying to set the url format for some entries to include the category slugs set for it within a category entry field - i can get the first one like this {eventCategory.one().slug}/{slug} but ...
1 vote
1 answer
52 views

Only show entries related to child category if it exists

I have a categories field for outputting products to a map. The categories linked to that field have a parent/child relationship. With {% set products = craft.entries.section('products').relatedTo(...
0 votes
2 answers
339 views

Nested categories URI format on entries

I have a Category Group that can be 3 levels deep. Each category has its own page and its URI structure appends each category as you go deeper, like so: {parent ? parent.uri : 'root-uri' }/{slug} ...
1 vote
1 answer
133 views

Twig Runtime Error on Craft 4 Getting Started Tutorial

I'm working through the 'getting started' tutorial and I've run into an error I can't get passed. I've created the Category Group: 'Topics' and then created the Field 'PostCategories' and connected it ...
1 vote
1 answer
65 views

Check if eager-loaded category exists on product

On my craft commerce project i eager-load categories which belong to a prodcut. in my product template i do for eager -loading: {% do craft.app.elements.eagerLoadElements( className(product), [...
0 votes
0 answers
39 views

How to list categories only related to enabled entries or disabled child entries

Edit: solved in comments My entries are set up as a parent > child structure. A single entry can either have children or not have any. If parent has children, the children entries are put in a ...
0 votes
0 answers
33 views

Matching entries against category custom field

I have two channels, pages and products and category groups for categories and regions. The pages entry type has a field where you can select entries from products based on their category and region. ...
1 vote
1 answer
1k views

Craft 3 - Can't access the craft() in plugin controller

I'm making a Craft 3 plugin to read a CSV file and insert the data as Categories. I used pluginfactory.io to scaffold my plugin. I can't access craft() in my controller (ImportCsvController.php). ...
1 vote
1 answer
40 views

How to group assets by category/sub-category

I have a section called “products” that has an asset field called “product-docs”. The assets are pdf files that have a Category field. Each product can have many different types of documents; to make ...
1 vote
1 answer
74 views

Batch retrieve the entry count per category item in facet filter

I'm building a facet filter using Craft Commerce products and Craft categories. I have a "Brand" category and each product entry has a brand defined. Same for the other facet filters that ...
2 votes
2 answers
190 views

Convert Categories into Structure entries

We chose to create a set of content on our site as a category group. We're starting to port over content from our old site (Drupal) and have realized a few bummers — the main one being no revision ...
2 votes
1 answer
31 views

How to display a category on the site?

Please help me to display the categories. I have a category group with a huge category tree. Can I somehow output not the whole group of categories, but only a certain category with its child ...
1 vote
1 answer
21 views

Is there a way to mutate categories through GraphQL for a specific siteId?

The graphQL does not support siteId parameter in category mutation. How could I mutate the content for a specific siteId?
1 vote
1 answer
65 views

Entries field within structure

Not sure whether it's a bug or the correct behavior. How do I see the parent category just like the categories do? Entries field related to the category group (another project)
1 vote
1 answer
23 views

How to display the final/child category of an entry, not parent category as default

I have the following categories Tech (1 entry: case A) 1.1 Apps 1.2 Software (2 entries: case B) Fashion 2.1 Clothing (1 entry: case C) 2.2 Shoes ... When using {{ entry.categories.one().url }}, it ...
1 vote
1 answer
209 views

How to filter a categories query

I have a categories group named "Title" in my backend. In that group I have 15 categories, but I want to display only 3 specific categories on the frontend. How can I filter my query and ...
0 votes
0 answers
28 views

How to append the category field data nested inside a section to an input tag?

while clicking the input tag it should display its related entries Based on the category field the data selected in the backend value should get appended to the input tag. When looping through the ...
1 vote
1 answer
161 views

How to programmatically create category groups and categories in Craft 3/4

I am struggling to create a new category group and category programmatically. I've found a few examples for creating an entry, and one for creating categories in Craft 2, but I can't get it working in ...
1 vote
1 answer
204 views

GraphQL - Optional relatedTo value

I have a component which lists events and can be configured to filter by category. Query: query Events($filter: [String]) { entries( section: "event" relatedToCategories: {group: &...
1 vote
2 answers
168 views

Hiding categories in real time with Sprig in a faceted search

I've built three buttons with checkbox dropdowns that display categories that filter the content below based on categories. I am currently using the relatedTo function to only display the categories ...
1 vote
0 answers
56 views

Updated to Craft CMS 4.2.5 and now the "New Category" button is missing in Control Panel [closed]

Like the title says. I've just updated to the latest version while building out a new site in Craft CMS and the New Category button is missing from the Categories screen in the CP. Both when you go to ...
1 vote
2 answers
209 views

What is the best way to create breadcrumbs based on a categories?

I have a question related to breadcrumbs. I have a multiple categories with level 3 hierarchy, now if I assign only one category to any product it works for me to create the breadcrumbs based on the ...
0 votes
1 answer
482 views

GraphQL - Categories with entries

Is it possible to get categories with related entries with one graphQL query? I have the following query: query MyQuery { categories(relatedToEntries: {section: "entryType"}) { id ...
1 vote
1 answer
132 views

How do you Eager Load Category Fields with Pagination

I have two category fields, teamCategory and articleCategories, on a news listing page that I'm trying to eager load. Problem is, when I add the eager loading it no longer outputs the categories. I ...
3 votes
1 answer
550 views

Eager loading categories and assets inside related entries for gallery

I am looking for some advice on how to best streamline a gallery system on a site, but having trouble wrapping my head around the syntax needed to eager load nested asset fields with categories inside ...
1 vote
2 answers
178 views

Feed-me import nested categories from CSV/Google sheets

I'm currently able to import nested categories from a Google Sheets when they already exist. But when a child category does not exist, the category is created at the first level. It's quite logic ...
1 vote
1 answer
42 views

Events with Speaker: Categories or Channel

Sorry for this general question, i am building a large archive site with many (>1000) Events. Every Event has one or more Speaker. At the moment I am using two channels: "events" and &...
1 vote
1 answer
51 views

Bad Gateway when using cached category query

I'm trying to find all tiers that have associated entries for a selection dropdown. This does not work, and throws a 502 error {% set allTeirs = craft.categories.group('catPartnerTeirs') %} {% set ...
1 vote
1 answer
64 views

Find First Entry That Matches Current Category

I need help. I am creating a category listing which I have working great. The next step is where I'm struggling a bit as I can't seem to query the related entries on a loop basis. For each "...
1 vote
1 answer
96 views

Are categories first class citizens compared to tags?

I understand the difference between categories and tags. I am trying to choose between them as my taxonomy is not very deep and tags seem just as good as categories. But it occurs to me that ...
1 vote
1 answer
35 views

Assign category to entry using a plugin

Feel like I'm going crazy here... I've got this snippet of code. I find my entry based on title key/value. I find my category ids based on alcohol key/value. I attempt to set the entry category ...
1 vote
1 answer
27 views

Error when clicking on a category in admin (related to SEOMatic?)

I get the atatched error when clicking in the admin of my site - it seems to be related to SEO Matic but not sure? Anybody any idea? Many thanks Malcolm
2 votes
4 answers
1k views

How can I show the child category and not it's parent - but other times show it's parent?

I have a categories field on an entry that can have one or many children. I am able to output everything - but would like to restrict the field a bit more. If a child has been selected, I do not want ...
1 vote
0 answers
46 views

GraphQL API query to load all related data

How to write a query to load entries with its category or any other related data. For example I have cars that related to the BMW category. How I can access the category data in the query that fetch ...
1 vote
1 answer
414 views

Filter entries based multiple category groups

This is related with Split categories by levels / List categories merged by name which I explain more on detail there, after that I take the suggestion of create separate category groups, so: I have ...
1 vote
1 answer
99 views

Everything comes null when I try to filter entries by category - Craftcms 3

There's an issue when I filtering by categories but everything comes null, I was debugging code but all the entries has the same problem! But I don't know why does this happens? The entry comes well ...
7 votes
2 answers
2k views

Listing categories with post count in a nav?

I'm trying to list my categories (and sub categories, just one sub level) as a nav, and have the number of entries in each of those categories beside each one. There is another question on here which ...
0 votes
0 answers
101 views

Split categories by levels / List categories merged by name

I have a scenario where I need category levels (4 levels) split in different sections of the page, also some categories have the same name, I explain: I need to list entries based on a category group ...
1 vote
1 answer
837 views

Element API: Get Entries Related to Category with Query Parameter

I'm using the Element API Plugin to create an API, with which I want to get entries related to one category, but dynamically with the category set in the Url. What I have so far in the config/element-...
1 vote
1 answer
69 views

Use same handle for different fields on different entry types

I've got two entry types: blog and job. Each has a category field but different category groups: blogCategories and jobCategories. I would like to write a Twig include to accept either a blog or a job ...
1 vote
2 answers
93 views

Count number of consecutive years in category array

I need to count the number of consecutive years a user has been a member of our organization. For example, if they've been a member from in 2018, 2019, 2020 and 2021, their loyalty will be 4 years. If ...
2 votes
2 answers
142 views

Order entries by related "Year" category and paginate?

I have a section called Library, and a category group called libraryYears. The categories in that group are just years (2021, 2020, 2019...) Each entry in the Library is related to a year in the ...
1 vote
1 answer
76 views

How to search for Entries that have a particular Category set within a Matrix field in the Control Panel?

I have an arrangement like this: Entry type 'people' └ Matrix field 'offices' └ Block type 'office' └ Category field 'building' On the Entries screen, how can I search for people that have a ...
1 vote
1 answer
54 views

Adding Categories navigation to show certain entries

I'm abit lost as to how to structure my FAQ page. I have a single FAQ page that pulls in every FAQ post, these posts come from the FAQ Entries channel. But On the single FAQ page, how do I add a ...
1 vote
1 answer
68 views

Get the Sub-Category Link from Category field in a Structure (output with Nav tag)

I am creating a Structure for the main navigation that has two possible choices for the Link: Entries field or a Categories field. The answer I received here showed me how to setup the basics but if ...
0 votes
0 answers
53 views

How do you Paginate if Looping through element queries directly is deprecated?

I want to create a basic product listing page based on categories. I created a template that dynamically shows all items based on the category that is passed to it based on the help I received here. ...
4 votes
1 answer
736 views

How do you import hierarchical data that uses the adjacency list model into Craft Structures or Categories?

Craft makes it nice and easy for us to have hierarchy in Structures or Categories. Many other popular CMS platforms support hierarchical data as well but some support it using a different data model. ...
0 votes
1 answer
117 views

Paginate based on items in a Category

I'm trying to wrap my head around Pagination in Craft. I have a template that outputs a list of products based on the Category that is passed to it from this thread: {# Fetch the entries related to ...

1
2 3 4 5
11