3

My aim is to make a Views grid of existing blocks in Drupal 7 (Might be possible without any additional code\module in Drupal 8).

I've tried to make a Content based View and filter it via Block ID's, but when I came to filter this View, I found no such option.

I've tried to check the "Relationships" option to see if I can add a relationship to Blocks but no such option was available there either.

Therefore, I wonder if a View of existing block is even an option naturally.

didn't see any Block-relevant filter option

3
  • Blocks are not entities in Drupal so they are not supported by Views. I'm sorry to say your only option here is going to be custom code or using the excellent drupal.org/project/panels module which can get you most of the way there - though bear in mind it won't be automatic. i.e. You'll need to add the blocks yourself.
    – webkenny
    Jan 29, 2015 at 1:43
  • I did say Panels in my comment, no? :)
    – webkenny
    Jan 29, 2015 at 16:47
  • I might have missed it because of the color + too fast reading of the moment. Anyways, I'm sure I've seen a way to add the block themselves (after they have already been created). Indeed, Panels seems to be the best solution.
    – user16289
    Jan 30, 2015 at 6:07

1 Answer 1

2

This question seems like a perfect illustration of why you'd use the Bean module (to actually create such view as in this question). Here is a quote about its project page:

Think of a Bean as a method to provide new types (compared to node this would be a content type) which then provides an add content interface to create as many blocks as you require (see screenshot below). The bean content can then be placed around the site just like any other block.

This module also works great in combination with the UUID and UUID Features Integration modules. And after you become familiar with the Bean module, you might find other cases in your site where you also want to use this module (which somehow compensates the fact that you need to add another module).

The video tutorial Drupal Bean module tutorial - using Bean Admin UI provides a great introduction to really understand the power of this module, and the kind of things you can do with it (by only using site building techniques, no custom coding involved). It also shows how the Bean module transforms Drupal blocks into fieldable entities.

In this specific case, after you enabled the BEAN module, you should be able to create a view of blocks. As an illustration, have a look at this (basic) view (in Views export format):

$view = new view();
$view->name = 'blocks_created_with_bean';
$view->description = '';
$view->tag = 'default';
$view->base_table = 'bean';
$view->human_name = 'View of blocks created via the BEAN module';
$view->core = 7;
$view->api_version = '3.0';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */

/* Display: Master */
$handler = $view->new_display('default', 'Master', 'default');
$handler->display->display_options['title'] = 'View of blocks created via the BEAN module';
$handler->display->display_options['use_more_always'] = FALSE;
$handler->display->display_options['access']['type'] = 'none';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['pager']['type'] = 'full';
$handler->display->display_options['pager']['options']['items_per_page'] = '10';
$handler->display->display_options['style_plugin'] = 'table';
$handler->display->display_options['style_options']['columns'] = array(
  'bid' => 'bid',
  'label' => 'label',
  'title' => 'title',
  'type' => 'type',
  'uid' => 'uid',
  'url' => 'url',
);
$handler->display->display_options['style_options']['default'] = '-1';
$handler->display->display_options['style_options']['info'] = array(
  'bid' => array(
    'sortable' => 0,
    'default_sort_order' => 'asc',
    'align' => '',
    'separator' => '',
    'empty_column' => 0,
  ),
  'label' => array(
    'sortable' => 0,
    'default_sort_order' => 'asc',
    'align' => '',
    'separator' => '',
    'empty_column' => 0,
  ),
  'title' => array(
    'sortable' => 0,
    'default_sort_order' => 'asc',
    'align' => '',
    'separator' => '',
    'empty_column' => 0,
  ),
  'type' => array(
    'align' => '',
    'separator' => '',
    'empty_column' => 0,
  ),
  'uid' => array(
    'sortable' => 0,
    'default_sort_order' => 'asc',
    'align' => '',
    'separator' => '',
    'empty_column' => 0,
  ),
  'url' => array(
    'align' => '',
    'separator' => '',
    'empty_column' => 0,
  ),
);
/* Field: Block: Internal, numeric block ID */
$handler->display->display_options['fields']['bid']['id'] = 'bid';
$handler->display->display_options['fields']['bid']['table'] = 'bean';
$handler->display->display_options['fields']['bid']['field'] = 'bid';
/* Field: Block: Label */
$handler->display->display_options['fields']['label']['id'] = 'label';
$handler->display->display_options['fields']['label']['table'] = 'bean';
$handler->display->display_options['fields']['label']['field'] = 'label';
/* Field: Block: Title */
$handler->display->display_options['fields']['title']['id'] = 'title';
$handler->display->display_options['fields']['title']['table'] = 'bean';
$handler->display->display_options['fields']['title']['field'] = 'title';
/* Field: Block: Type */
$handler->display->display_options['fields']['type']['id'] = 'type';
$handler->display->display_options['fields']['type']['table'] = 'bean';
$handler->display->display_options['fields']['type']['field'] = 'type';
/* Field: Block: Uid */
$handler->display->display_options['fields']['uid']['id'] = 'uid';
$handler->display->display_options['fields']['uid']['table'] = 'bean';
$handler->display->display_options['fields']['uid']['field'] = 'uid';
/* Field: Block: URL */
$handler->display->display_options['fields']['url']['id'] = 'url';
$handler->display->display_options['fields']['url']['table'] = 'views_entity_bean';
$handler->display->display_options['fields']['url']['field'] = 'url';
$handler->display->display_options['fields']['url']['link_to_entity'] = 0;

/* Display: Page */
$handler = $view->new_display('page', 'Page', 'page');
$handler->display->display_options['path'] = 'view-of-blocks-created-via-the-bean-module';

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.