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
Join us in building a kind, collaborative learning community via our updated Code of Conduct.

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

0
votes
0answers
10 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
22 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
37 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
24 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
25 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
15 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
26 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
42 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
18 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
33 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
34 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
14 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
21 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
26 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
74 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
17 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 ...
1
vote
2answers
44 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
35 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 ...
2
votes
1answer
136 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
35 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
27 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
33 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
34 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
36 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
33 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
45 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
30 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
40 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
42 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
52 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
29 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 ...
1
vote
1answer
90 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
130 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
115 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
1answer
59 views

How to include search results where keyword input exists only as a category title?

I have a request to extend an existing "advanced search" form (multiple fields, including keyword and a categories dropdown) so that entries with a category that matches the keyword input are returned....
3
votes
1answer
347 views

Element API display entries by category

With v2 of the Element API plugin, I'm having issues with working out how to return entries that are in a particular category. I've got the slug in the API route but can't work out what the query ...
1
vote
1answer
53 views

Switch entry type based on the category

I'm trying to use different entry types for certain categories. My category group is called categories, and the slug for Features is features. I have the category group pointed to categories/_entry. ...
1
vote
0answers
49 views

Category counts for query results

I'm trying to display results from a search. I want to display the categories represented by the search results and the entry count for that category. Think of how Amazon's "refine results" sidebar ...
1
vote
1answer
53 views

Get Related Entries and then filter those by specific category in url segment

Channels: Photographers Photos - entries field handle "photographers" - categories field handle "category" url structure where segment 2 is the photographer slug and segment 3 is the ...
1
vote
1answer
26 views

Entries from different category levels brought together

I have an issue with categories with different levels: I have a group of categories which have a structure like this: First form: 1.0 Group – 1.1 Subgroup – 1.2 Items in subgroup Second form: - 1....
0
votes
0answers
18 views

Find unpopulated categories [duplicate]

I know I can find categories "related to" actual entries so I can list just the populated ones. {% set entries = craft.entries.section('news').ids() %} {% set categories = craft.categories....
0
votes
0answers
30 views

For loop outputs different values from same variable

I try to list the content of a category with two different levels: first Level: "disciplines" second level: i.e. "flutes" Each list item is a link to a pop-up layer where the content (titel, body) ...
1
vote
1answer
16 views

error when trying to loop through grouped entries according to dropdown field

I was trying to follow this example from stack overflow to loop through a list of entries and output them by a custom dropdown field {% set allEntries = craft.entries.section('resource').find() %} {% ...
1
vote
1answer
53 views

One select search for Users in user.group

I'm a complete newby on Craft CMS and twig templating so please bear with me. I currently have a users base which I want to filter by category (a custom field) This would be my only input search ...
1
vote
1answer
51 views

relatedTo working for one category group but not another

I'm trying to show a list of entries related to the same category on a page that contains a single entry. I have two category separate category fields in the entry, both with one category each ...
1
vote
1answer
138 views

Selecting descendants of a category when ancestor is clicked

I have a question about combining Twig and jQuery in Craft. I have a couple of filters on a page that outputs some entries: http://www.joycefdn.org/grants My categories are organized like this: ...
2
votes
1answer
80 views

Need .last() functionality for categories – .last() will be deprecated going forward

I have a matrix block that calls a category channel. The categories are nested three levels "deep" at times. I want to select first, second or third level links as needed. When I use .last(), I can ...