Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 295107

Remove block config id from being used as an html id or template suggestion

$
0
0

Follow up to #1927608: Remove the tight coupling between Block Plugins and Block Entities once that lands.

That issue almost removed everything related to a block configuration entity from the rendering pipeline of a single block, allowing block rendering logic to be fully reused to render blocks whose configuration is not stored in their own config entities, such as ones that are part of Panels panes. All that remains is this code from template_preprocess_block():

  if ($id = $variables['elements']['#block']->id()) {
    $config_id = explode('.', $id);
    $machine_name = array_pop($config_id);
    $variables['block_html_id'] = drupal_html_id('block-' . $machine_name);
    $variables['theme_hook_suggestions'][] = 'block__' . $machine_name;
  }

Meaning, we reverse engineer the "machine name" of the block as the last part of its CMI file name, and then use that for the block's HTML ID and for a template suggestion. Per the same reasoning as in #1968360: Change notice: Remove per-region block markup, we suggest to remove that.

Question for front-end developers: Can we remove it entirely, or do we need to replace it with some other concept of a "block instance identifier"? What are use-cases where an HTML ID is needed or where you'd want to implement a template override on a per-instance basis (i.e., you added two blocks with the same exact configuration, but different machine names, and you want their markup to be different)?


Viewing all articles
Browse latest Browse all 295107

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>