Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [categories]

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

1
vote
1answer
7 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
18 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 ...
1
vote
1answer
14 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
18 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
2answers
37 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
1answer
24 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
25 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
13 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
33 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
42 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 ...
1
vote
0answers
11 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
48 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
72 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. ...
0
votes
0answers
24 views

Isolating Category Groups in a Multi-Site Environment

I'm working on a multi-site project that will be a network of blogs. Each of the blogs use the same templates and the only thing that's different is the content. All of the entries are all taken care ...
2
votes
1answer
46 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
65 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
27 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
31 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 ...
1
vote
1answer
41 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 ...
2
votes
1answer
30 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 ...
3
votes
1answer
64 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
20 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
40 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
40 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
18 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 =...
0
votes
0answers
13 views

Empty Asset URL Error [duplicate]

Currently trying to call an Asset URL but it's returning an error as some categories do not have an Asset uploaded yet. Impossible to invoke a method ("url") on a null variable. Code running it: ...
1
vote
1answer
24 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
41 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
92 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('...
0
votes
0answers
20 views

Group listing by category and date order

I have a listing page and each entry is categorised as either Current, Forthcoming or Past. I need to be able to order the entries by their groups so that it shows all of the current entries first and ...
2
votes
2answers
62 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
43 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 ...
3
votes
1answer
190 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: ...
1
vote
2answers
38 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
28 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
0answers
19 views

Setting an Entry field using sum

I'm looking to set a 'score' property on my "category" field, this will be done by calculating how many entries are within that category similar to a 'Trending' feature. Is there any way to set a ...
1
vote
1answer
40 views

Best way to handle large amount of records

What is the best way to handle 20,000 simple records? The records need to be searchable and linked to categories. What is the best way to handle so many records when each records or entry would be a ...
0
votes
1answer
49 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, ...
1
vote
1answer
45 views

cannot get relatedTo by slug only ID

Can someone tell me why I am going crazy and cannot figure this simple relatedTo issue out? So I have a categories section called Case Studies and several categories within. I am trying to filter the ...
1
vote
1answer
48 views

Eager loading fields within categories

Is it possible to eagerLoad fields in categories? I have this code; {% set markets = craft.categories.group({ section: 'markets', with: ['bannerImage'] }) %} which for some reason is throwing ...
1
vote
2answers
56 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
0answers
34 views

Order Entries by Category Fields (with fallback)

This is almost a duplicate of this question I have a section which I want to sort by category field. But the categories are not mandatory. When I apply |group('refSorter.first().title') it will ...
0
votes
0answers
25 views

Optimize the conditional

How do I optimize/improve this specific conditional? There are around 40k categories and it takes forever to load the page. {% if category.level == 1 %} {% include '_clinics/categories/state' %} {...
1
vote
1answer
52 views

How are parent and child categories related in Craft database?

I am writing an API which directly connects to Craft database and retrieves data. I need to get the categories hierarchy. But I can not find how parent and child categories are related in the ...
0
votes
0answers
46 views

Get Entries from Section related to a category

I'm currently trying to get all entries which belong to a section which is related to that category. e.g. Category Brand Offer Offer belongs to a brand. Brand has a category field. {% set ...
1
vote
1answer
53 views

Ajax - How to create a Category through actionTrigger

I'm trying to create a jQuery/Ajax script to import data from a Wordpress API service and want to import the WP categories and tags into my database. I've managed to import the tags using an Ajax call ...
1
vote
0answers
42 views

Structure parent root - entry type or category urls?

Been rolling around with this for the last 36hrs trying to decide most useful option. The dilemma is how to preserve a structure and use categories - or not. Below is my structure: Food (section ...
2
votes
1answer
118 views

Sort CP Entries by Category

I know it's possible, using modifyEntrySortableAttributes, to sort the CP entries table by a custom field, when that field is a number, string, date/time, or bool. Would it be possible to sort a CP ...
1
vote
1answer
195 views

Craft 3 - How do you programatically update a field type that is a Category?

I have a Category element, locations, which I am trying to update programatically through a Craft 3 plugin that reads data from a CSV. The locations category has a Field Layout: latitude (Number), ...
1
vote
1answer
176 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). ...