Stable9 override the material_base templates

Created on 27 December 2022, almost 2 years ago
Updated 24 January 2024, 11 months ago

Problem/Motivation

This one broke my site.

Steps to reproduce

Seems like the chain of the theming should be (the order of the base):

My Custom Theme(Material Top) -> Material Base MDC -> Material Base -> Material Stable 9

But since we moved Material Stable 9 into the material_base folder(issue 3316641), when Drupal looks for a template, it will find the material_stable9 version of it. Effectively not using material_base templates at all (since material_stable9 has all)

The Drupal process is here:
web/core/includes/theme.inc:225

$files = \Drupal::service('file_system')->scanDirectory($path, $regex, ['key' => 'filename']);

This function gets invoked for all enabled themes (as it should), and scan blindly the entire directory for html.twig files.

For example:
Trying to render: menu-local-tasks.html.twig:
1st version: material_base/templates/navigation/menu-local-tasks.html.twig
2nd version (overrides the first) material_base/themes/material_stable9/templates/navigation/menu-local-tasks.html.twig

So when this function get's invoked the first time with material_stable9 it will correctly return the 2nd version.
But the second time, when invoked against material_base it will mistakingly still returns the 2nd version.
Essentially when your active theme search this template up the base themes tree, we only get the material_stable9 version.

Proposed resolution

I'm not sure what the solution should be here.

As a quick workaround, we have copied the entire templates directory into our own theme.
cp -a material_base/templates ../custom/material_top

Remaining tasks

Code/Documentation change

If I'm missing something, and I mess something up during the upgrade from 2.x-beta to 2.0 , please let me know.

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Closed: works as designed

Version

2.0

Component

Code

Created by

🇮🇱Israel jkdev

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇮🇱Israel jkdev

    Since upgrading to Drupal 10, re-surface the issue,
    The only simple solution was to get the material_stable9 out of material_base.

    mv web/themes/contrib/material_base/themes/material_stable9 web/themes/contrib

    in-addition.
    there was a small issue with normalize library.
    in web/themes/contrib/material_stable9/material_stable9.info.yml:92 it was:
    core/normalize: stable/normalize
    it should be:
    core/normalize: stable9/normalize

  • 🇬🇪Georgia iamdroid

    Hi @jkdev,

    Have you tried to update to v3 ?

    material_stable9 theme had been removed from dependencies in favor of core's stable9. Hope it helps.

  • 🇮🇱Israel jkdev

    Will give v3 a try.
    Thanks!

Production build 0.71.5 2024