It seems simple enough, but I've got a custom content type called 'news' that always displays under the URL alias /news/[articlename]

I've created a specific layout for it, also dubbed 'news' which shows fine as a layout template option.

When I try to edit layouts however, I can't get it to show on pages within this path.  The inline help says "Use the "%" (percent) symbol to indicate a wildcard in the path. i.e. "node/%" or "node/%/edit" - so I'm using "news/%"

It doesn't work for things like mydomain.com/news/todaysnews etc.  

I do however have a view set up on the path mydomain.com/news/ - and if I use "news" or "news/" it shows just fine there. For some reason the wildcard isn't working in particular at least as I understand it should.

What am I missing here?

In case it's relevant I should point out that I have one other custom layout I'm using for the Home page and as a default, but neither should override the one with a specific path right?  

Under 'contexts' it says "Position 2: news/%" under context with the type "string pass-through".  

Any help much appreciated.

 

Accepted answer

Try a context of "node/%" and then add a visibility condition for content type (or URL path).

Most helpful answers

Keep in mind that the "%" symbol is not actually a wildcard but a placeholder for contexts. There is an open issue to rename this.

If therefore you create a custom layout path news/%, paths like news/whatever will not use this layout. There is currently no core functionality to do this. 

Hello  👋

As @laryn said, something like this should work:

Comments

Try a context of "node/%" and then add a visibility condition for content type (or URL path).

Thank you!  Seems a little counter-intuitive given the description underneath the path field (what are the actual options there even then, node/%, view/%?) but it worked.

Keep in mind that the "%" symbol is not actually a wildcard but a placeholder for contexts. There is an open issue to rename this.

If therefore you create a custom layout path news/%, paths like news/whatever will not use this layout. There is currently no core functionality to do this. 

@docwilmot

Thank you! That explains why I had such problems getting paths to work. Perhaps in the next release (if not too late) changing the docs to clarify that?