We’re rewarding the question askers & reputations are being recalculated! Read more.

Questions tagged [categories]

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

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

Get saved sub category on user

I have my users setup with a category field that links to a category of countries and each country has states/provinces. I have my form setup to only display the states listed under United States. ...
2
votes
2answers
51 views

Can a Category Entry have an Author

This may be basic but not finding the right way to do it so here is a question. I have a category page where each has its own url and have custom fields on it. But for some reason the author is not ...
1
vote
2answers
867 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: ...
3
votes
1answer
1k views

Load Category in Plugin

I have a category that I'm trying to load via a plugin. Looking at the categories service I see there is a function called "getCategoryById" but I don't know what the ID is so instead I'm loading the ...
2
votes
2answers
569 views

Display an entry's level 1 categories only if the entry is not related to any of that category's children

I'm struggling with how to do this in Twig... I feel like it would be easier in a full programming language. If an entry's categories look like this: A - A1 - A2 B C - C1 I need to ...
0
votes
1answer
177 views

Get user field category

I have a matrix that contains a block with a category field. I want to loop over the matrix models, in PHP, to get data. Here's what I have so far: foreach ($user->networksMatrix as $key => $...
0
votes
1answer
132 views

How do I get all categories with at least one entry [duplicate]

I want all categories that have at least one entry that uses it.
3
votes
1answer
881 views

Filter by multiple categories

I need to filter a sections entries by more than one category but only return entries that belong to all category id's passed in a URL parameter. Now I can get the correct output if the id's are hard ...
11
votes
2answers
3k views

How to filter entries by clicking multiple categories on front end

I would like to be able to filter my entries list by multiple categories on the front end. For example, if I first click a category button "lunge" then the results would show entries which are ...
3
votes
1answer
1k views

How do I combine search for categories and entries into one set of search results?

I have a search page. I can search either categories or entries using {% set entries = craft.entries.search(query).order('score') %} {% set categories = craft.categories.search(query).order('score') %...
1
vote
2answers
340 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: {%...
2
votes
2answers
1k views

Category field in entry

I am trying to show an image that is defined on a category - named photos. I have an entry page with a list of all category entries listed at the bottom. I'd like to show this image but I'm still ...
2
votes
1answer
941 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 ...
0
votes
1answer
492 views

Create a custom field with my plugin data

I want to create a field like categories but using my plugin data. I need to be able to select one element in entry page to get all the elements from my plugin group base on that selection. do i go ...
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 ...
0
votes
1answer
68 views

Show Entries Based on Category - Localised Site

I have the following code to display entries based on a single category: {# Identify the primary category you want #} {% set cat = craft.categories.title('events').level(1).first() %} {# Grab an ...
2
votes
1answer
345 views

List Categories by 0-9 and A-Z

I'm trying to output a list of Brand names grouped by first letter. But some items have a number or symbol in the name. I want to list first the Numbers and symbols under 0-9 and the rest of the ...
3
votes
1answer
4k views

Craft entries related on a category page

So i'm trying to output blog entries related to a category. I first created a category group ('categories') I added several categories to the group ('innovation', 'teams', etc) I added a category ...
0
votes
1answer
603 views

Entries field: Output entries related to category

I have an entries field (activityPicker) that links to other entries in a different section. These other entries have categories (things-to-do and things-to-eat), and I'm trying to figure out how to ...
1
vote
1answer
152 views

Get all categories from a CategoryGroupModel through API

When I get a CategoryGroup with the following $category = craft()->categories->getGroupByHandle('productEnvironment'); I Just can't figure out how to get the categories inside this category. ...
3
votes
1answer
231 views

Saving Category through API

I'm trying to create a category through the api to import a load of datas, but I'm stuck, the category won't be saved, and the saveCategory() method just returns false $category = new CategoryModel(...
13
votes
2answers
1k views

Difference between categories and structures

The recent updates to categories have been great and provide a lot of flexibility. But now I find myself struggling to decide what should be a category group and what should be a structure. For ...
1
vote
1answer
377 views

Find entries that have a category selected from a category field within a matrix block

I've got a Section that uses a Matrix field, that has a block, that has a categories field in it. I want to find all entries using this Matrix field, who has a categories field and has a certain ...
2
votes
1answer
187 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 = ...
5
votes
2answers
2k views

Order entries by category field

I'm loading a set of entries related to 'category' and ordering them by the value of a Dropdown field in the entries. This work well using this code: {% set entries = craft.entries.relatedTo(category)...
4
votes
1answer
498 views

How can i apply “current” class for category nav?

I've browsed the questions and answers here and i can't find anything that works for what i'm trying to do! I am using this as the main menu of my site (so it is in _layout.html) {% nav category in ...
1
vote
1answer
1k views

Displaying Sub Categories on Category Page

First, a disclamer -- I am new to Craft CMS. With that said, I am trying to create a category page whereby the page will show the title, description and image of the sub-categories of the current ...
1
vote
1answer
95 views

Can entries in a category be reordered?

Can entries in a category be reordered in a similar way that entries in a Structure can be reordered? If not, how can entries in a category be reordered manually?
1
vote
0answers
74 views

Is .relatedTo().total() returning all source elements if none are found? [closed]

I'm using categories and relating them to entries. If using .relatedTo().total() I'm seeing the total number of ALL entries if none of the entries are related to a particular category. If using ....
1
vote
0answers
84 views

Link to Category Index in Rich Text Field [closed]

I have a Category group set up with URLs enabled. I'm just wondering if it's possible to link to a Category Index from the Link feature within a Rich Text Field. I realize I can manually create my own ...
2
votes
2answers
229 views

Performance of a categories list with post count

Let's say I'm outputting a list/nav of categories, with the count of entries in each category, as described in other questions: {% nav category in craft.categories.group('...') %} {% set ...
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 ...
7
votes
2answers
1k 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 ...
2
votes
1answer
294 views

Segment to filter through categories slug

I've seen plenty examples of using the uri segment like below, but it ain't working for me, anyone had same sort of issue? {% set segment = craft.request.segment(2) %} {% set pageCats = craft....
8
votes
1answer
1k views

Building a simple search by multiple categories

Is it possible to build the following/is it the right way in Craft. Been through the docs and searched but stuck. I just need to build a form on one page with a dropdown select for 2 categories; ...
4
votes
2answers
1k views

Best way to programmatically create categories?

We're working on an XML import plugin to migrate content from another CMS. What's the best way to create a new category (with a name, slug etc.) and assign it to the entry when running $entryModel = ...
3
votes
2answers
962 views

Adding active class to category link

I have a category page displaying only the entries associated with the respective category. I have added a dynamic sub nav for categories using the following: <ul> {% nav category in craft....
2
votes
0answers
107 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
1answer
114 views

How can I only get the entries that are related to an active category

In the product overviews and search results on my website are also products listed which are related to passive categories. Is there a way to get only entries which are related to active categories? ...
4
votes
1answer
599 views

How can I output a list of categories that are not empty?

In other words, categories must have at least one enabled entry assigned to them.
2
votes
1answer
520 views

List the categories an entry is part of?

I'm new to all of this and so far Categories from a templating point of view are confusing me a bit. I'm loving Craft so far but some concepts are causing me some headaches to adjust to! What i'm ...
1
vote
1answer
376 views

frontend editing, show selected category

I have this in my edit form {% set categories = craft.categories.group('jobCategory') %} <label for="fields[jobCategory]">Job Category:</label> <select id="jobCategory" name="...
2
votes
1answer
655 views

How do I output the value of a field from a Category selected from a Matrix?

I'm new to craft so this is a bit newbie question. I have a category group with a set of categories, each category has a plain text field associated with it. The category group is then used as a ...
1
vote
1answer
734 views

If Entry is related to Category-A, then print xyz

I have succussfully been able to list entries within the 'brandx' category slug, but I can't figure out a way to print specific content only if the current 'product' listing is related to the 'brandx' ...
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 ...
8
votes
1answer
4k views

Users relatedTo multiple categories

Trying to get users in a members group related to multiple categories. {% set services = craft.categories.group('services').slug('service-1, service-2') %} {% set locations = craft.categories.group('...
1
vote
1answer
519 views

How to order categories in key/value for loop?

This is what I'm trying to accomplish: All categories displayed on one page, with entries returned from each. Only six entries shown in each category. Categories need to be in a specific order. I've ...
1
vote
2answers
1k views

relatedTo 'and' with 'or'

Is the following possible: {% set issue = craft.entries(section: 'issues', slug: 'october-2014').first() %} {% set categoryOne = craft.categories({ group: 'articles', slug: 'category-slug-one'}) %} {...
2
votes
1answer
118 views

How do I show entries that do not have a certain category?

I’m aware of the relatedTo() parameter for entries that belong to a category but how can I show entries that are NOT relatedTo() a certain category?
1
vote
1answer
562 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): ...