Podcast #128: We chat with Kent C Dodds about why he loves React and discuss what life was like in the dark days before Git. Listen now.

Questions tagged [categories]

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

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

How to create ordered list of categories from multiple category groups

I have got multiple category groups and I need to concatenate them into one list for a filter UI element. At the moment I have the following: {% set categories = craft.categories.group('colour').all(...
3
votes
2answers
59 views

Showing a list of selected/related categories to entry

I have a suitability category field in my product type that allows the content writer to select which categories this product is associated with. But my issue is that on the product page I need to ...
2
votes
1answer
78 views

Method for creating Category Group landing pages

I have a selection of category groups as follows: Suitability Colour Finish etc They all have many categories within them. I have set up some routes for /suitability etc to show the user a /shop/...
1
vote
0answers
87 views

Combining multiple categories based on URL segments

I have two category groups - brands and resources. Under these I have product videos and documentation entries - section ‘resources’. I’m using the brands categories elsewhere for products too so I’ve ...
6
votes
1answer
214 views

Reorder selection of categories in category fieldtype

I'm looking to reorder my selected categories within a category field. I'm hoping this is possible because the order an editor selects these categories is important, primarily for the .first() ...
1
vote
1answer
39 views

Relation fallback if no category has been selected

I have a filter with a few different parameters that get pulled in and I was wondering if there was a relatedTo wildcard that I could use. Here's the relevant code: {% set function = craft.app....
3
votes
1answer
26 views

Output values from all entries in a specific section EXCEPT those with a specific category id

Currently, this is NEARLY doing what I want except instead of the output being entries that do NOT have the id, it's output is ONLY the entries with the id. I'm not sure why, since I've included the '...
1
vote
1answer
57 views

Grouping entries by category - most efficient approach

I have come up with the following code to group entries by categories; {% set hotTubs = craft.entries() .section('newHotTubs') .orderBy('price asc') %} {% set hotTubsCats = craft.categories() ....
5
votes
2answers
941 views

Get the Category name into the URL for an entry

I have a gallery which is categorised. The gallery is a Structure section where the user adds an entry and then assigns it to a category - all good. At the moment, when clicking on an entry title the ...
4
votes
1answer
571 views

Craft 3 Multi Category and Field Search

Looking for the solution to searching entries in one section that are related to multiple categories and match number field criteria. This is for a used auto website. Categories: Make/Model/Trim: ...
2
votes
0answers
304 views

Searching for Multiple Categories and Tags

I've been pulling my head for the past day on how to filter products with multiple categories. After a long search, I found and implemented on my project, Advanced Search with tags and categories It ...
1
vote
2answers
161 views

Multiple Category Sources Field

I want to utilise the Category field type but with the ability to choose from multiple category sources (as with Entries). I noted in cms/src/fields/Categories.php that $this->allowMultipleSources ...
1
vote
1answer
21 views

Is there a query parameter to get categories that are related to anything else?

I'm looking for a way to query all categories that have at least one relation. I'm not looking for the relatedTo() parameter, which would give me categories related to something specific. Basically, ...
1
vote
1answer
103 views

Get categories ordered by the associated entries' postDate

I'm looking to show recent categories ordered by their associated entries' postDate. Is this possible? I don't want to list the entries within the category I simply want to list 4 categories that ...
1
vote
1answer
23 views

Create several subcategories without using the GUI in craft

I have to create the following categories hierachically : One book has between 1 and 150 chapters. I have to do this for several books. Dealing with chapters is painful using the GUI. Is there any ...
1
vote
1answer
69 views

Filter by category and update URL

This may be a simple question but I am not sure how to approach it - again trying to work out best practice for these things! I have a "single" at /our-work, which among other things displays a ...
2
votes
1answer
177 views

Craft 3 query children of sub categories

Just wondering how to only query the children on subcategories. For example... Food ├── Fruit │ ├── Apples │ ├── Bananas │ └── Oranges └── Vegetables ├── Brussels sprouts ├── Carrots ...
1
vote
2answers
459 views

URI for nested categories in Craft 3

I am trying to set up the URIs for some nested categories in Craft 3 but am having some issues. My structure is basically: service-one |-subservice-one-a |-subservice-one-b service-two |-subservice-...
1
vote
2answers
156 views

Nested category navigation

I am trying to achieve the following markup for my categories navigation: <h3><a href="categoryurl">Top Category One</a></h3> <ul> <li><a href="categoryurl"&...
1
vote
1answer
276 views

Element API - Entries Related to a Category

In Craft 3, I want to list all the categories in a group and all the entries related to them. How can I do this?
1
vote
2answers
157 views

Filtering by categories AND tags with full match

We're trying to filter by categories AND tags in the one form. However can't seem to get things working as we would like. Essentially, we have a form that pulls in the tags and allows multiple ...
0
votes
1answer
18 views

field from category not available via craft.categories

my categories have a custom field called titleTag for SEO as well as a number of other fields. When I render them at their URI (/categories/cat1) I can output those fields easily with {{category....
1
vote
3answers
72 views

Returning entries that contain both categories

I'm creating a filter and would like to return entries that must contain multiple categories (and behavior, not or). A sample url would be /events?cat=2,3. {% set eventCat = craft.request.getParam('...
1
vote
1answer
66 views

Setting up multiple category listing pages on site with multiple locales

I’m having trouble setting up an additional category listing page from the one I have set with the Category URI Format and Template settings in my Category Site Settings. Specifically, I’m having ...
2
votes
3answers
732 views

Is it possible to bulk-edit a field across multiple entries at once?

I would like to know if it's possible to select multiple entries and update a field for them all at once – for example, give all the selected entries the same category.
1
vote
0answers
66 views

Getting the order for categories.lft rgt

While trying to assign a global CSS class based on the order of the categories based on the drag and drop in the admin editor. The categories I'm using is a single 1 level deep category. It seems ...
1
vote
1answer
276 views

Display categories not related to an entry

I'm trying to output a list of categories that are not related to a particular entry (in order to show a list of services other than the service related to the current entry). I have this code which ...
2
votes
2answers
182 views

How do I hide tags in a category that have no entries?

Entries can have one of two categories and one tag. (People = entries | program = categories | year = tag) On the pages I'd like to display entries related to the category and grouped by tag. ...
3
votes
1answer
205 views

Categories within matrix for relatedTo

I have a matrix field with a category field. I need to group these matrix items by category and give them headings which I'll use for tabs. This is how I'd do it for entries but is it possible for ...
2
votes
1answer
97 views

How to display entries filtered from more than one category

I want to try to learn how I can filter entries by multiple categories. I realise similar questions have been asked in the past, but all the answers are for specific use cases. All I want to do is ...
3
votes
1answer
309 views

Get related posts excluding current post in Craft 3

In Craft 3, I’m trying to get the five most recent other posts sharing a category with the current post. I got this far: {% for relatedPost in craft.entries.relatedTo(entry.newsCategory).limit(5) %} ...
1
vote
1answer
97 views

Joining sections (Channel) to query based on a related item attribute

I've been trying this for a while now, so might have read this before. Sorry about that, I'm struggling really hard to get this right. At first I tried (wrongly) with the eager load features. I have ...
2
votes
1answer
76 views

Craft 2 categories locale issue

I have a craft2 site running quite happily with 8 languages. I noticed recently that a dropdown selection of category entries is not working when the locale is changed to chinese (locale = 'zh'). So ...
2
votes
1answer
64 views

How to exclude child elements when looping through categories?

I've got a few categories set up with a few child categories for each. Each one has assets (PDFs) assigned to them, by going into the assets, double clicking, and setting the category field there. So ...
3
votes
1answer
532 views

Order by score and another field

Currently I am sorting a category template with this: 'featured desc, postDate desc' Works as expected. But I would like to sort it first on the featured field, then on the score. Such as 'featured ...
4
votes
1answer
386 views

Filtering multiple categories with URL queries

I am trying to filter using categories. I have to filters type and size, in the url. /products.html?size=medium,large&type=polo-shirt,jeans In my template, I am doing the following {% set sizes ...
1
vote
1answer
33 views

Returning entries based on Relationships across different category groups using 'and'

I'm trying to figure out how to set up my relatedTo paramaters to do a category search. Normally it's not a problem but in this case I need something more complex than normal. I have multiple ...
1
vote
2answers
112 views

Category not loading template

I have created a new Category on a Craft 3 website but it will not load the template specified. Have other categories all working fine and can't get this one working at all. Category Config below I ...
2
votes
1answer
49 views

Can I get entries related to one category from a specific site?

If I can get entries in a category like this: {% set entries = craft.entries.section('sectionSlug').relatedTo('categorySlug').all() %} And a entries from another site like this: {% set entries = ...
1
vote
1answer
45 views

Falling back to Parent Category if no asset exists

I'm trying to make it so that if an entry image does not exist, then fall back to the category image that the entry belongs to. Right now this isn't working and is receiving an error. {% set feature =...
2
votes
2answers
856 views

How do I conditionally set active state in category navigation?

Here is the code I am trying to use to set an active state for category navigation: {% for category in categories %} <li {% if craft.request.segment(2) == "{{ category.slug }}" %}class=...
4
votes
2answers
781 views

Is it possible to limit users to adding/editing entries in specific categories?

I'm building a site that regroups several properties, and I'd like each manager to edit content in his property only. All properties use the same templates and share content between each other. I ...
1
vote
1answer
53 views

Only display the first tier of categories

I'm looking to only display the top level parent categories on my Template, but unfortunately, everything I try seems to error out and still display all of the children categories as well. My current ...
1
vote
0answers
68 views

Filters using multiple query strings with pagination and Craft Commerce

I want to build the ability for the user to be able to filter by certain categories when browsing an existing category. As well as this I would like the user to be able to control the ordering of ...
1
vote
1answer
217 views

Craft 3 - Programatically get all the values contained in a field of type category

I want to programmatically get all the values contained in a field of type category. I am doing this on Elements::EVENT_AFTER_SAVE_ELEMENT. If I dump $event->element->getFieldValue('...
1
vote
2answers
279 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
1answer
84 views

Garnish event when changing category group

When I am on the categories index (admin/categories), is there a Garnish event that fires when you select a different category group in the sidebar? I want to add some custom JS after the AJAX request ...
1
vote
2answers
135 views

Group entries by Category and then in each category by related entry field

I have a channel with categories and an entries field. I need to first group all entries by their category. This is working fine. {% set entries = craft.entries.section('publicationsChannel') %} {% ...
1
vote
1answer
46 views

Commerce categories issue

I am trying to develop an email commerce site that is easy for customers to navigate. The way that I would like to do it is so that I have a range of different parent categories and that when a ...
0
votes
1answer
295 views

Categories Related To Matrix Fields

Please help me build my sandwich locator maker :) I have 3 categories, breads, meats, condiments I have a Section called subShops with a matrix field. My matrix field is called sandwichBuilder, ...