Hi, 

I am trying to figure out what is best way to get list of blocks that are used in all layouts, similar to list of fields used in various views (/admin/reports/fields/views-fields)?  Is there existing feature or I need to create a new feature for this?

Accepted answer

I want to thank our core developers - after looking around I found what I needed right where I wanted it :)screenshot of blocks menu /admin/reports/blocks

Most helpful answers

I am working with this as I develop the CKEditor Blocks module and noted the same need. It's important to me because Custom Blocks don't seem to have the Visibility Rules that Layouts contains.

Comments

Bottom line: I don't know of a module that does this.

There is one useful existing function: layout_get_block_info() will get you all existing block definitions. Block instances and their specific configurations for the particular layout, are stored within each layout configuration json file, under the key "content".

So, it shouldn't be very difficult to build a custom module that scans all layout files and builds a list of active blocks. 

Irina, this can be used as a basis for such module. You can also run this on Devel. It will get you an array organized by the module that defined the block, the block machine name ("delta"), and then an array of each instance of the block, with the block name, the layout name and the layout machine name.

$layout_names = config_get_names_with_prefix('layout.layout');
$layouts = config_load_multiple($layout_names);
$blocks = array();

foreach ($layouts as $layout) {
  foreach($layout['content'] as $uuid => $settings) {
    $module = $settings['data']['module'];
    $delta = $settings['data']['delta'];
    $blocks[$module][$delta][] = array(
      'title' => layout_get_block_info($module, $delta)['info'],
      'layout_title' => $layout['title'],
      'layout_name' => $layout['name'],
    );
  }
}

dpm($blocks);

Attached image with a portion of the output.

I am working with this as I develop the CKEditor Blocks module and noted the same need. It's important to me because Custom Blocks don't seem to have the Visibility Rules that Layouts contains.

@argiepiano, thank you so much, this is great!  I think that it is worth putting together as a module so people can use it moving forward.  I will think today of a layout for output that would be most efficient for my purpose and post it here.   Thank you for making code available - saves me hours that I could use now for designing Web-based UI :)

I want to thank our core developers - after looking around I found what I needed right where I wanted it :)screenshot of blocks menu /admin/reports/blocks