0

I have created a drupal 8 subtheme.

I have some blocks that have twig template overrides in the parent theme based on custom block machine names.

For example mywackynavbar.

In the subtheme, I can inherit my blocks and their placement but the machine name of the new block is: mysubtheme_mywackynavbar.

Drupal will not let me rename my block to the name that already exists and it doesn't appear in my available list of blocks in the subtheme.

How can I access it? (Or do I have to manually re-create EVERY template with my subtheme's prefix?)

I tried - as per the official documentation on subtheming, including the following in the theme file:

/**
 * Implements hook_theme_suggestions_HOOK_alter for blocks.
 */
 function shaved_theme_suggestions_block_alter(&$suggestions, $variables) {

  // Load theme suggestions for blocks from parent theme.
  foreach ($suggestions as &$suggestion) {
    $suggestion = str_replace('subtheme_', 'parent_', $suggestion);
  }
}

But the blocks I want to use don't have a prefix in the parent theme. To be honest I just want the blocks copied over "as is" machine name and all.

Your Answer

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

Browse other questions tagged or ask your own question.