Questions tagged [categories]

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

Filter by
Sorted by
Tagged with
3
votes
1answer
611 views

Display a list of categories excluding the current one

In a template for a category page, I'm trying to output a list of links through to all categories within a category group but exclude the category that the user is on. Does that make sense? What I'm ...
3
votes
2answers
649 views

Check if Category is in Query

I'm trying to check to see if a particular category (In a loop) exists in a query submitted from a search form. At the moment I'm doing this inside a 'childCategory' loop... {% for childCategory in ...
0
votes
1answer
2k views

How to create a template file for Categories?

below is my categories url. http://example.com/index.php?p=categories/vaporizers i create a template files for categories like templates/categories/index.html templates/categories/_entry.html my ...
1
vote
1answer
145 views

Using categories to filter assets

I am new to Craft and have a decent handle on the basics, but I am struggling a little getting this to work. Here is what I would like to do: I have a banner with bxslider which will be looping ...
1
vote
1answer
425 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->...
2
votes
1answer
243 views

Category Nav tag with control over the depth that {% children %} goes

Looking at the docs, i can see that the category {% nav %} loop uses the categoryGroup as the starting point. But, i want the first top level category within the category group as the starting point. ...
2
votes
2answers
1k views

Conditional Logic to show or hide fields in the admin?

I'm looking for a way to show or hide fields when editing an entry based on items selected. I need to manage a list of businesses and my plan is to have a channel to hold them all. But based on the ...
0
votes
1answer
103 views

Performance hit from Entry Url Format with multiple {% if %} clauses?

With help from this answer, I've got an Entry Url Format that can include top, 2nd, or 3rd-level categories. It works for any of these situations: top-level-category/entry.slug top-level-category/...
1
vote
1answer
71 views

Entries Related by Category with Filler Entries After

At the bottom of an entry I want to display links for eight other posts. To make this useful, what I'd like to do is: start with entries that are related to the post currently being viewed by ...
1
vote
1answer
466 views

Landing Page with Same URL Structure as Category

I have a category group called "Resource Categories" and categories within it have their own urls. Category Url Formats: top-level categories: resources/{slug} nested categories: {parent.uri}/{slug} ...
2
votes
1answer
243 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 ...
5
votes
1answer
2k views

Showing categories in Channel Entry URLs

I have a site which has two blog-like sections, which I'll call Blog and News. Each has a few categories. The categories are different in each section. An article always has (only) 1 category assigned ...
2
votes
1answer
388 views

Multiple categories filter

I have a channel section called Members. I have 2 category groups (categoriesMembres & cantons). My goal: show entries only related to a specific category in categoriesMembres and loop through ...
0
votes
2answers
1k views

Display Category Entries Based on Slug

I am trying to display entries based on the last segment in the url and then paginate. Here's what I have so far but it's not displaying any entries: {% set categorySlug = craft.request....
2
votes
1answer
1k views

How to populate Category field form frontend form?

I have a frontend form that has a select list for language. This field will allow for one language to be selected. In the backend I have a field set up for my entries as a category field populated by ...
1
vote
1answer
2k 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 {...
2
votes
1answer
478 views

Loop through category groups

I've looped through individual category groups to find each parent/child category, but is there a way to loop through and only show Category Group names?
1
vote
1answer
6k 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
1answer
276 views

Getting Entry By Category for Landing Pages In A Structure

I have a site governed by a structure, including the homepage. I have several "parental" landing pages with research areas (Atlantic, Pacific, Midwest etc ) intended to be the gateway to the ...
4
votes
1answer
791 views

Saving Entry with Category field

I am stuck on saving entry with a category field. The error message I get is about not being able to create/update the entry in the relations table. $accomodationTypecategory = ['title'=>'Hotel'] ...
4
votes
1answer
929 views

Related to entries in categories in a plugin

Ok I can do this in twig but after searching high and low I can't find a good example of how to do it in a plugin. I have a user profile field called interests which holds an array of what they are ...
3
votes
3answers
2k views

Filter entries by multiple categories

I am trying to set up a form with checkboxes that allows users to filter entries by selecting multiple categories, but I am not quite getting it right. Currently this is my form: {% set ...
2
votes
3answers
929 views

Getting the first category of the deepest level for an entry

I want to get the first category of the deepest level for an entry. For example if the category structure looks like this Ocean Life > Fish > Gold Fish I want "Gold Fish" Here is what I've come up ...
2
votes
1answer
51 views

When accessing a Category url is there direct access to the Category's fields?

I have setup a category group to use Url's. When navigating to that url does the template have direct access to that category's inputs like you would with and entry? Or do you have to use the segment ...
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
909 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
586 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
182 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
150 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
932 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
4k 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
2k 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
348 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
1k 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
518 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
69 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
355 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
624 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
156 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
240 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(...
14
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
398 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
201 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
3k 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
536 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
6 7
8
9 10