4

I want my theme to control certain block settings, like which elements of the system branding block are enabled. To me it makes sense for that to be code in the theme, not a module, because at the moment the only way I've found to access the config programmatically involves using the theme name.

/** @var Drupal\Core\Config\Config $config */
$config = \Drupal::service('config.factory')->getEditable('block.block.my_theme_branding');
$config->set('settings.use_site_logo', false);
$config->save();

Since this is a one off config change, I think it should only happen when the theme is installed/activated. It there a theme function/hook that behaves like hook_install does for modules?

3

You may provide configuration via YAML files as part of a module, profile or theme install by adding them to the config/install directory inside the respective project. So, for example, a file block.block.my_theme_branding.yml would install the branding block into the specified region. This would then contain the setting to disable the site slogan by default. Take a look at block.block.bartik_branding.yml in the standard profile as a starting point.

If the specific block is provided by another module, then it should probably be placed in the config/optional directory.

0

That was a missing feature; however, after a conversation in IRC that is a feature that we want to implemented. Its currently been working at Add (back) hook_install for themes.

The solution from @mradcliffe have a lot limitation, because you cant override a anything unless you are a profile.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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