2

I have a view that is set up to report breaking news from a "breaking news" text field. But this field is often empty, and in the no results behaviour, we would like to show one of our special offer blocks instead.

I can see an option for "Entity:Rendered Entity" in no results behaviour, but this is only nodes or users, I cant see a way to display a pre existing block?

2 Answers 2

2

There is a module that exposes blocks to the view header/footer and no results. It's called the Views Block Area.

This module exposes all available blocks as a views area. This way you can add any block inside a footer or header from your view.

Blocks that are generated by views, can't be selected. These blocks can be inserted by views areas.

This is also only for Drupal 7

1
  • Ah! Perfect! Just what I was looking for, thank you.
    – Collins
    Commented Aug 27, 2014 at 19:29
0

This answer is for Drupal 7...

The quick and dirty way would be to use a Global: Text area. With the PHP text filter enabled, you can input the PHP code necessary to render your block.

$block = block_load( $module, $delta);  // if you defined the block via UI, then go to the configuration page for the block.  The configure URL follows the structure: block/manage/MODULE/DELTA/configure
$output = drupal_render(_block_get_renderable_array(_block_render_blocks(array($block))));
print $output;

See block_load() and _block_get_renderable_array(). The PHP Filter is explained here: https://www.drupal.org/node/1046700

Here's a really long conversation of people struggling to just try to render a block by hand: https://www.drupal.org/node/1034524

Optimally I'd be able to point you to a module, but I can't find one.

2
  • I would avoid PHP Filter if at all possible. Commented Aug 27, 2014 at 19:25
  • I agree. Good module find. Commented Aug 27, 2014 at 20:20

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.