I want to use different templates for my categories. E.g. there are 4 templates (t1, t2, t3, t4) and I want to assign them to my categories like

Dogs (t1)
- small dogs (t1)
- big dogs (t1)
Cats (t2)
Fishes (t3)
- small fishes (t3)
- big fishes (t4)

Right now all categories point to one template which is specified in the categories-tag like

{exp:channel:categories ...}
<a href="{path={my_template_group}/categoriesTemplate}"">{category_name}</a>

I have a lot of categories, so I want to do it systematically. I cannot list all the categories and manually link them to different templates.

Thanks in advance for any idea!

EDIT in reaction to Phil
The reason why I want to do this to keep the example above: For "Dogs" I have a LOT of content: How to feed them, the funniest name, how to make them obey etc. So I need a template with a lot of lists, links, entries ... For "Cats" I only have some funny pics, so I need a template just with a gallery. And so on.

2 Answers 2


This requires a couple of add-ons, but, is actually pretty easy to accomplish.

Build a list of links to your category pages (at /template_group_name/template_name/category_url_title):

{exp:channel:categories ...}
     <a href="{site_url}/template_group_name/template_name/{category_url_title}">{category_name}</a>

Here's the conditional logic for analyzing the categories in your template. It will look at the category URL segment (Seg2Cat add-on needed to retrieve category info from URL segments) and use speedy complex conditional using IfElse to determine which layout to use.

{exp:ifelse parse="inward"}
  {if "{segment_3_category_id}" == "id of big fishes"}
     ... big fish content ...
  {if:elseif "{segment_3_category_id}" == "id of fishes category" OR "{segment_3_category_parent_id}" == "id of fishes category"}
     ... fishes content ...
  {if:elseif "{segment_3_category_id}" == "id of dogs category" OR "{segment_3_category_parent_id}" == "id of dogs category"}
     ... dogs content ...
  {if:elseif "{segment_3_category_id}" == "id of cats category" OR "{segment_3_category_parent_id}" == "id of cats category"}
     ... cats content ...

The first check is for your "big fishes" special-case template; after that, it will look at the category (or parent category) of the category specified in the URL in order to display the correct content.

  • Hi Nick, that sounds very good, thanks for your answer! Just let me ask: the "... cats content ..." would be e.g. an embed? And: Don't you think this will lead to any performance-issues, checking >100 conditionals (though I've read the docs of the IfElse-Addon, just want to make sure)?
    – BNetz
    Commented Jan 13, 2014 at 19:56
  • If that code I came up with was wrapped in an {exp:channel:entries} loop, you'd want to avoid using an embed within each case - a snippet, or just the the presentation code itself, would be quicker. Hundreds of conditionals won't kill you, but, hundreds of embeds sure would. Commented Jan 13, 2014 at 20:06
  • 1
    Assuming you're using this template logic to select how you're showing a list of all items in a particular category, the channel entry loops would actually be contained inside of each condition, so an embed would be fine, as you'd only be including one of them. Commented Jan 13, 2014 at 20:09
  • Thank you very much, Nick - I am going to try this and give feedback!
    – BNetz
    Commented Jan 25, 2014 at 11:51
  • Nick, I think the way you described is working. My only problem is that I can't get running the Addon seg2cat. It always puts out empty stuff. But I think with the standard category-heading-tag it will work. Thank you very much for your help!
    – BNetz
    Commented Jan 25, 2014 at 14:54

you could use the {category_url_title} variable in the path for example

<a href="{path='template_group/{category_url_title}'}">{category_name}</a>

You will need to manually create each sub template within the group but if I am reading your question correctly that is what it sounds like you are trying to do.

My question might be why? What is it you are trying to accomplish surely there is an easier way than creating a separate template for each category. Whats the reasoning behind the separate templates maybe I can help you streamline what you are trying to accomplish.

  • Thanks Phil, I tried to edit my initial question, see the post above. The problem with your solution: I have >100 categories+subcategories+subsubcategories. With your solution I would have to create 100 templates, 80 of them identical.
    – BNetz
    Commented Jan 12, 2014 at 17:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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