<p>You can also use multiple template paths as an array. Twig will search for the template until it finds one that matches.</p>

<pre><code>{% include ['categories/_'~category.slug, 'categories/_news'] %} 
</code></pre>

CC BY-SA 4.0
2020-05-16T01:26:11.220Z
2020-05-16T01:26:11.220Z
Leevi Graham
<p>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:</p>

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

CC BY-SA 3.0
2018-01-24T00:38:19.763Z
2018-01-24T00:38:19.763Z
Bryce
<p>I'm trying to use different entry types for certain categories. My category group is called <code>categories</code>, and the slug for Features is <code>features</code>. I have the category group pointed to <code>categories/_entry</code>. 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 <code>categories/_entry</code>:</p>

<pre><code>{% 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 %}
</code></pre>

CC BY-SA 3.0
2018-01-23T22:34:55.720Z
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
CC BY-SA 3.0
2018-01-24T00:39:04.903Z
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
<categories><category><switch>
Switch entry type based on the category
# Switch entry type based on the category

(Asked by: username_0 on 2018-01-23)

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 %}

**Tags:** categories, category, switch
> **Comments:**
> **username_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  
> **username_0**: 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!  

---

## 2 answers

### Answer by username_2 on 2020-05-16. Score: 1

You can also use multiple template paths as an array. Twig will search for the template until it finds one that matches.
{% include ['categories/_'~category.slug, 'categories/_news'] %}


---

### Answer by username_0 on 2018-01-24. Score: 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 %}


---

