1

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. As for as I can tell, I've got it set up right. I think their might just be something wrong with my switch code. This is my code in categories/_entry:

{% set categories = entry.categories.first %}
{% switch categories.slug %}
    {% case 'features' %}
        {% include 'categories/_feature.html' %}    
    {% case 'news' %}
        {% include 'categories/_news.html' %}
    {% default %}
        {% include 'categories/_news.html' %}
{% endswitch %}
  • 1
    What is your entry variable? You usually don't have one as a global in your categories template. Do you have a field called categories otherwise entry.categories would not make sense but you don't explain that in your question. What error do you receive? Categories do not have an entry type there is no way you can use different entry types for categories. What is your Features is it a record in your category group? We have not enough information and your question is a little bit confusing because you mixed things together that does not belong together. The code itself seems correct – Robin Schambach Jan 23 '18 at 22:34
  • You're right, there's not enough info there. But I was able to figure it out based on some of your questions, so thanks! – Bryce Jan 24 '18 at 0:39
1

The above isn't too clear, but what I was trying to do is use different templates for different category landing pages. It works with the following:

{% switch category.slug %}
    {% case 'features' %}
        {% include 'categories/_features.html' %}   
    {% case 'news' %}
        {% include 'categories/_news.html' %}
    {% default %}
        {% include 'categories/_news.html' %}
{% endswitch %}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.