Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 12 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save markconroy/9daa7cc8ee95cbd87e19aef181afefb2 to your computer and use it in GitHub Desktop.
Save markconroy/9daa7cc8ee95cbd87e19aef181afefb2 to your computer and use it in GitHub Desktop.
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
Copy link

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
Copy link

maxplus commented Apr 5, 2018

Thanks, works great!

@heartdriven
Copy link

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