Questions tagged [categories]

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

Filter by
Sorted by
Tagged with
2
votes
1answer
223 views

Save a selected category for a user (using a plugin)

I have some categories, and with the use of a category field a user can select these from within his / her profile. Which is shown in the image: In my Twig template I can get the user selections out ...
2
votes
1answer
948 views

Filter Entries field by category in the CP?

Is it possible to filter relations entries field by a category in a control panel entry? I would like to relate two channels using the entries field but I have 100 source entries so I was hoping to ...
2
votes
1answer
188 views

Grouping by Category with Multiple Keys

I've started off with this solution: http://craftcookbook.net/recipes/330 {% set testsByAllergenGroup = {} %} {% set entries = craft.entries.section('tests').order('title asc') %} {% set groups = ...
2
votes
0answers
323 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 ...
2
votes
0answers
116 views

Filtering products by categories and showing number of products related to selected category

I currently have about 420 products and over 100 of categories to choose from for each products, showing the list of categories and filtering it, works fine, and performance is not too bad when it's ...
2
votes
2answers
243 views

How to create a user editable dropdown field?

Trying to figure out the best way of handling this scenario: We have a data field for a entry type that should allow an editor in the CP to select one option from many (ie. a dropdown). However, we ...
2
votes
0answers
108 views

Timout on Entry Save if using Categories

I can't use "Categories" in Craft CMS, after hitting "Save" for an entry with Categories set, the page will take ~5minutes to load and typically time out. Usually, it does save the page and update the ...
2
votes
0answers
75 views

Showing entries based on parameters that may or may not be populated [duplicate]

I'm using a Matrix Field to display lists of entries. One extracts entries based on certain categories. They may or may not be set, but I need to use an "and" relatedTo parameter. At the moment it ...
1
vote
1answer
564 views

Is it possible to have category listing page of entries if the category is defined within a matrix block inside said entries?

I think I have been staring at this problems too long and I need a kick in the right direction... Here is what I have (the content modeling is a tad wonky but this is what we're dealing with): ...
1
vote
3answers
514 views

Trouble getting a list of categories that have entries for a specific category group

I have a long list of categories in a specific category group, but only want to show a list of the categories from this group that currently have an entry associated with them. I've been trying to ...
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
2answers
882 views

Using Categories with Structures?

I have two structures: Focus Areas & Initiatives. I'd like to be able to associate the two of these structures. Here's a potential example: Focus Areas: Sports Music Art Initiatives: ...
1
vote
1answer
60 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() ....
1
vote
1answer
96 views

Magazine possible in Craft?

I have been a wordpress user for the longest time, a friend of mine now uses Craft, I took a look at his backend and really liked the way he creates his content in it. I also like that it uses Twig. ...
1
vote
2answers
678 views

Use blog index template as category template

I have a blog listing page which works correctly. I also have categories that I would like to use the same template rather than creating a whole new template since the design is exactly the same. ...
1
vote
1answer
410 views

Create nested Category via PHP

In a custom plugin, I'm able to easily add a new Category: $category = new CategoryModel(); $category->groupId = 1; $category->getContent()->title = $categoryName; craft()->categories->...
1
vote
1answer
1k views

Get entries relatedTo multiple categories

I have searched and tried a few different ways but none have worked so not sure what is wrong. Example say I have a few categories case studies, featured, articles, videos... I have tried this way {...
1
vote
2answers
2k views

Category vs Tag

Is there a fundamental difference between a Craft Category and a Tag? I originally set up a site using Tags before the Category feature was available and now I'm adding a new section and trying to ...
1
vote
2answers
1k views

Error when using if statement in template

I have a page that shows all photos in a category, which is set by the last url segment and then the results re paginated. What i'm trying to do is say that if the last segment is 'all' then show all ...
1
vote
2answers
163 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
566 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
279 views

Sorting Entries field results by category

I have an entries field 'physicians'. I want to output the selections from that field and sort them by category (also named 'physicians') - with the category heading above each category group. I can'...
1
vote
1answer
152 views

How to use category in auto generated title?

I have an entry which has a category field. I want an auto-generated title for this entry that uses the assigned category title (first category title in case of multiple categories). I am not sure ...
1
vote
1answer
267 views

How to get Category URL from field in Matrix

This is my Matrix set up: I'm stumped to how to get the Categories URL. {% for block in entry.galleriesItem %} {% switch block.type %} {% case "galleriesItem" %} <a href="...
1
vote
1answer
81 views

Related Items in a Category not Appearing in Results

I am still having a problem looping through related posts. I get zero, not even the HTML. And there are no Craft template errors. There are plenty of entries that were assigned the same market, so ...
1
vote
1answer
323 views

How to separate a parent and it's children when looping through a category?

I have categories of cities and states set up as parents and children, for example: California - Los Angeles - San Francisco New York - New York City When I use: {% for place in entry....
1
vote
1answer
382 views

Show all tags related to a category?

Is it possible to show all tags that are related to a category? I can't find anything on it. Thanks. Edit: What I am looking for is this: I know a category slug or name. I want to get all tags ...
1
vote
1answer
390 views

Find matching asset (image) for category

What would be the best approach to have a list of categories (brands in my case.) and if an asset (image) exists that matches that brand name show that asset or instead show a placeholder image. <...
1
vote
1answer
548 views

Entries from all categories in a category group via URL?

I'm familiar with the option in the category settings that allows for categories within a category group to each have their own URLs: I have this setup and it is working fine. However, I'm wondering ...
1
vote
1answer
987 views

Entries grouped by Category and then Sub Category

Been trying to get this working for a few hours but no joy, hope someone can help. I'm looking like an post archive of all entries. Something like Category1 Sub Category 1 Entry / Entry Sub ...
1
vote
1answer
120 views

Looping through returns nothing after using dynamic routes to get the entry type and category

I'll explain a bit of the structure of the content and then proceed to the issue. So i have a website with a shop in it with the url mysite.com/shop/, it is an channel section, and its template is ...
1
vote
1answer
5k views

Impossible to access an attribute (title) on a string variable

I have a Video section with a field called videoCategory. I'm trying to pull in the first category on the _entry.html template. I'm pretty much following the the last example in the documentation at: ...
1
vote
2answers
342 views

Organize filtered entries by a specific category

I have an array of products that has already been filtered by a brand category. I want to display them in a list ordered by a size category. This is working, but I think there must be a better way: {%...
1
vote
2answers
230 views

Find the nth top-level category in a nav tag

I want to output some code after the 10th top level category in a category listing. For example... 1. 1.1. 1.2. 2. 2.1. 3. ... 10. Zoiks! The problem is, I can't use Twig's loop.index in a ...
1
vote
1answer
646 views

Linking to Search Results

Ok what i'm trying to achieve is a set of links which have "search parameters" attached to them. Which would be a "category" and an "option.field". Then when these links are clicked they display ...
1
vote
1answer
432 views

entries related To category not working with getNext function

I currently have one entry in a page and would like to display next and previous arrows. The next/previous entries should be in the same section and related to the same category. To do this I have ...
1
vote
1answer
1k views

How do I get entries of a child category, related to a parent category, defined in a URL segment?

My entry url structure looks like this: http://site.com/section/category/subcategory/entry_slug I'm trying to drill down to specific entries by using the url structure and I'm currently having ...
1
vote
3answers
22 views

Show only top level categories assigned to an entry

Having a bit of a brainfart here... If hotspotCategory is my entry's categoryfield and that category group has nested categories, how do I return only the top level categories? {% set entryCats = ...
1
vote
1answer
219 views

Order entries by a category field alphabetically then paginate

I've tried so many different things and can't get this to work... {% set makeCat = craft.categories() .group('make') .orderBy('title') .limit(21) %} {% paginate makeCat as pageInfo, ...
1
vote
2answers
142 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
267 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
186 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
106 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
183 views

hide section entries from one section

I’m new at Craft CMS and I hope someone of you could help me a little. At the moment I get all entries from my blog by {% paginate craft.entries.section('blogItem').limit(globalSettings.postsPerPage) ...
1
vote
1answer
144 views

Sort entries per category

I have a collection of entries in a structure, and each entry can be in multiple categories. Is it possible to sort the entries seperately for each category? So it would look something like this: ...
1
vote
1answer
725 views

Display entries related to Category Field

I'm sorry If this has been answered before, but I couldn't find any answer that would work for me. Maybe I'm just treating category fields the wrong way and I should be trying to do this with tags. ...
1
vote
2answers
233 views

Filtering dynamic criteria with AND

I have a form that is set up to include multiple values with checkboxes. I pass all those values into an array {% set specsQuery = craft.request.getParam('specs') %} {% set productSpecsCategory = ...
1
vote
1answer
205 views

Enforce search match multiple parameters

I actually found this code on here Search Form with Craft Commerce. I had a problem with this code pulling up products that didn't match, and then after creating a new product it worked for a bit and ...
1
vote
1answer
45 views

craft.commerce.products.ids() possible bug?

I'm using the following code on a category listing page to list the sub-categories that contain products: {% set entryIds = craft.commerce.products.ids() %} {% if category is defined %} {% set ...
1
vote
2answers
64 views

Show related entries grouped by category with category title and description

Anyone able to direct me on this? I have a page that allows you to pick related entries (cables) within the page I want to output the related entries (cables) but group them by their category. I have ...