Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
function THEMENAME_theme_suggestions_block_alter(array &$suggestions, array $variables) {
if (isset($variables['elements']['content']['#block_content'])) {
$suggestions[] = 'block__' . $variables['elements']['content']['#block_content']->bundle();
}
}
@puglyfe

This comment has been minimized.

Copy link

@puglyfe puglyfe commented Jun 12, 2017

just a quick tweak so that you can still override a specific instance of a custom block:

function THEMENAME_theme_suggestions_block_alter(array &$suggestions, array $variables) {
  if (isset($variables['elements']['content']['#block_content'])) {
    array_splice($suggestions, 1, 0, 'block__' . $variables['elements']['content']['#block_content']->bundle());
  }
}
@maxplus

This comment has been minimized.

Copy link

@maxplus maxplus commented Apr 5, 2018

Thanks, works great!

@heartdriven

This comment has been minimized.

Copy link

@heartdriven heartdriven commented Jul 10, 2020

Thanks @markconroy, that was exactly what I needed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.