16 votes
Accepted

How would I include the first category slug in the section's entry URL format?

This got it working for me: /section/{categoryFieldName.first.slug}/{slug}
user avatar
  • 1,661
16 votes
Accepted

Get categories for current page/entry

You can access the categories through the category field itself. {% for category in entry.categoryFieldHandle %} {{ category.title }} {% endfor %}
user avatar
10 votes
Accepted

How to filter entries by clicking multiple categories on front end

First, I would use something like training in your query string. It's a little more readable and you aren't searching for the words lunge and dumbbell anywhere in those entries, just entries related ...
user avatar
  • 2,563
10 votes
Accepted

Detecting if page is a 'category' or 'entry'

It'd be nice to see an example of your HTML block. From your comments it sounds like you may be using the same HTML block for Entry and Category pages but need to know which variable to use in the ...
user avatar
  • 13.2k
9 votes

Perform "inclusive" relatedTo query with multiple categories

That and argument only applies to the other top-level relatedTo arguments. If one of those arguments targets multiple elements (e.g. categories), those will still be glued together with “OR”. You ...
user avatar
6 votes

Detecting if page is a 'category' or 'entry'

Testing for the pre-populated variables is probably the only way to do this. But as you're asking for a single (global) var to test against, I believe you're looking for a way to have clean, dry code ...
user avatar
  • 35.8k
6 votes

Get the Category name into the URL for an entry

A Categories field can be related to several categories. So you'll either need to limit your Category field to a single Category relationship or you'll need to make some assumption in how you build ...
user avatar
  • 13.2k
6 votes

Display entries by category (multiple categories)

You can use .relatedTo(category) {% for category in craft.categories.group('categoryName') %} <h2>{{category.title}}</h2> {% for entry in craft.entries.section('news').relatedTo(...
user avatar
5 votes
Accepted

How to use localized categories properly?

To answer my own question see below: As carlcs pointed out correctly the problem actually isn't located in getting the category - which works just well and is the right way to do it - but in how the ...
user avatar
  • 171
5 votes

Get categories for current page/entry

If might be your wording but I can see two potential answers here. You either want to list categories set through a category field on the entry, in that case the code Douglas has supplied will work ...
user avatar
  • 3,594
5 votes

Display a list of categories excluding the current one

With a little help I got there: {% set categories = craft.categories.group('developmentType').id('not ' ~ category.id) %} <ul> {% for category in categories %} <li><a href="{{ ...
user avatar
5 votes

How to limit number of entries returned from a group filter?

The reason limit() isn't working is that is a method on the ElementCriteriaModel you get from craft.entries. Because you're actually dealing with a standard array when you access catEntries, what ...
user avatar
  • 4,361
5 votes
Accepted

How to display the title of a category based on its ID?

First you’ll need to grab the category ID from the query string, using craft.request.getQuery(): {% set catId = craft.request.getQuery('catId') %} Then you can fetch the CategoryModel via craft....
user avatar
5 votes

How to display all entries within a given category

Your mistake is in getting the category. Instead of what you have try: {% set category = craft.categories.group('allcategories').slug('photos').find() %} Getting elements in Craft use ...
user avatar
4 votes

How would I include the first category slug in the section's entry URL format?

As I understand it, you want the url for an entry to be /section/category-slug/entry-slug. This is a little tricky, because if the entry has no category defined, it won't have a url, which is why you ...
user avatar
4 votes
Accepted

Add category to uri

In the CP, in the settings window for 'categories' you can set whether 'Categories in this group have their own URLs', and define the 'Category URL Formats' for categories and subcategories, and ...
user avatar
4 votes
Accepted

Compose URL POST parameters to filter entries by category?

I'd split the parameter string into an array and then loop through the categories and use a conditional to check if the value already exists in the parameter. It's not so easy to describe in detail, ...
user avatar
  • 35.8k
4 votes
Accepted

How do I create a list of categories and display the entries relating to each of these categories that have at least one entry?

Here's the link to relevant the "Get Help" article: How do I list the entries related to a category? These really helpful tutorials are somewhat hidden on builtwithcraft.com, I overlooked them more ...
user avatar
  • 35.8k
4 votes
Accepted

Paginate with category filter?

Try using the relatedTo() filter as explained here: http://buildwithcraft.com/help/entries-related-to-category {% paginate craft.entries.section('products').relatedTo(requestCategory).limit(9) as ...
user avatar
  • 769
4 votes

How do I display the Category Title?

It depends how you're fetching the category. But if you've defined the template when setting up the categories it would be called be within a var called 'category', which would be a category object. ...
user avatar
4 votes
Accepted

Method for creating Category Group landing pages

2nd Revision: The category group field layout is for categories within that group. Categories groups do not have fields assigned to them, only to the categories within a group. 1st Revision: To get ...
user avatar
3 votes
Accepted

Display entries by Category (Category in Super Table)

Not sure if you're still looking for an answer, but relation support has just been added to Super Table 0.3.7. Previously, relations wouldn't work with Super Table, as its a little bit of a special ...
user avatar
  • 3,392
3 votes
Accepted

Loop through category groups

I'm not seeing any obvious ways to access groups directly in Twig. There may be a more direct way, idk — but this should work. {% set categoryGroupNames = [] %} {% for category in craft.categories %} ...
user avatar
3 votes
Accepted

Category vs Tag

You probably did not yet come across this site: "Categories and Tags – Everything in its right place." Craft's explanation about Categories: You can set up Category Groups for managing different ...
user avatar
  • 35.8k
3 votes
Accepted

Possible to assign fields (or an image) to a category?

The Craft Categories page is very useful. To assign an entry to a category, create a category field, and require it in the entry type (you are probably already doing this). When you create a ...
user avatar
3 votes
Accepted

Reordering entries tied to categories?

If you reverse the relationship then you should be able to order the entries (i.e. add products to an entries field within the category, instead of adding categories to a categories field within the ...
user avatar
3 votes
Accepted

check if a route segment matches a section entry type

Take a look at the {% exit %} tag. You should be able to do something very similar, since your search will return no results if the entry type does not exist. {% set entries = craft.entries.type(...
user avatar
3 votes
Accepted

Category filter returning all entries

I suggest changing the couple places where you use getParam('offerCategory') to getParam('category') so it matches the parameter set in the URL.
user avatar
  • 2,455
3 votes
Accepted

Display Category Group Name in Template

You're close! It's slightly counterintuitive but group is a property of a category. So you need to grab the group from an actual category. This would work: {% set catName = craft.categories.group('...
user avatar
  • 6,442
3 votes

Working with multiple categories

I figured it out! If anyone is stuck at the same place here’s my solution: {# category is 'ford' #} {% set entries = craft.entries.section('support').relatedTo(category).find() %} {% set ...
user avatar

Only top scored, non community-wiki answers of a minimum length are eligible