cms icon indicating copy to clipboard operation
cms copied to clipboard

Can't set a custom layout or template for a taxonomy

Open sebszocinski opened this issue 5 years ago • 9 comments

Bug Description

Setting a custom layout or template in your taxonomy yaml config doesn't register.

It appears to always be looking for the default locations. In our case we have our default layout under views/layouts/default.antlers.html which works fine with collections but not with taxonomies.

How to Reproduce

Extra Detail

Environment

Statamic version: 3.0.0.-beta-33

sebszocinski avatar Jun 30 '20 02:06 sebszocinski

Update: Turns out you can define these in the term.yaml itself, but not in the config yaml for the taxonomy... which to me seems a little odd? Is this likely to be fixed?

sebszocinski avatar Jul 28 '20 01:07 sebszocinski

You could set layout/template in the blueprint via a hidden field so it always applies to all terms.

robdekort avatar Sep 24 '20 07:09 robdekort

You could set layout/template in the blueprint via a hidden field so it always applies to all terms.

Are blueprints supposed to override the layout or template?

If no, is the above solution of a hidden field the best way to get that functionality?

If yes, I have a layout applied to a blueprint that is not being inherited by a page:

resources/blueprints/collections/pages/sidebar.yaml:

title: Sidebar
layout: layouts/sidebar

content/collections/pages/sidebar-example.md:

---
title: Sidebar
blueprint: sidebar

Neither the layout or template (if I set it) is not being picked up on the sidebar-example page. Is this related to the above taxonomy issue or should I create a separate issue?

mbryne avatar Nov 12 '20 12:11 mbryne

This issue has not had recent activity and has been marked as stale — by me, a robot. Simply reply to keep it open and send me away. If you do nothing, I will close it in a week. I have no feelings, so whatever you do is fine by me.

github-actions[bot] avatar Jan 12 '21 02:01 github-actions[bot]

I removed the stale label. It's still present and relating to: https://github.com/statamic/cms/issues/2403

Can this duplicate be removed?

jonassiewertsen avatar Jan 13 '21 08:01 jonassiewertsen

They are separate issues. This one is about custom templates, the other is about routes.

jasonvarga avatar Jan 13 '21 18:01 jasonvarga

Same issue here. I can confirm that setting the layout only work on the terms and not on the taxonomy. In fact the taxonomy YAML file seems to be oblivious to the whole "Cascade" thing.

Only current workaround for me:

  • Add layout: layouts/main to all existing terms
  • Add a hidden blueprint text field to the taxonomy with default: layouts/main so it gets automatically added to newly created terms.

lorisleiva avatar Mar 03 '21 10:03 lorisleiva

I've used the blueprint workaround to specify a custom layout for a term, but I can't see a way to customise the layout used for the index view. It defaults to layout - is there a way to change this?

stephenmeehanuk avatar Jun 10 '22 11:06 stephenmeehanuk

+1 for this feature as well. Hitting the same wall as @stephenmeehanuk

icemancast avatar Aug 15 '22 00:08 icemancast

Ran into this problem again this morning...

/blog/categories is my taxonomy index page. I can specify the correct layout for my terms, using a hidden field in the taxonomy blueprint.

But the index page is still defaults to resources/views/layout

Even though {{dump}} shows the correct layout?

#template: "blog/show"
#layout: "layouts/triple"

Statamic

Addons: 1
Antlers: runtime
Stache Watcher: Enabled
Static Caching: Disabled
Version: 3.4.1 PRO

I'd like to be able to configure the layout for my taxonomy index page, is there a workaround?

stephenmeehanuk avatar Feb 02 '23 10:02 stephenmeehanuk

This problem is still there in the latest version.

pawonpawon avatar Mar 26 '23 13:03 pawonpawon

As a temporary fix, I'm using this in routes/web.php

Route::statamic('/blog/categories', 'blog/categories/index', [
    'layout' => 'blog/layout'
]);

This is how I'm setting a layout for my category index page.

stephenmeehanuk avatar Apr 05 '23 13:04 stephenmeehanuk