How to insert a block into a node or template in Drupal 7?

后端 未结 15 1085
闹比i
闹比i 2021-01-30 01:46

In Drupal 6, it was easy to insert a block into a template with the following code:

$block = module_invoke(\'views\', \'block\', \'view\', \'block_name\');
print         


        
15条回答
  •  心在旅途
    2021-01-30 02:16

    This appears to be the solution for inserting blocks into templates for Drupal 7, but it seems a bit clunky and I have no idea about impact on performance:

    $block = block_load('views', 'block_name');      
    $output = drupal_render(_block_get_renderable_array(_block_render_blocks(array($block))));        
    print $output;
    

    If anyone has a better procedure, please do add.

提交回复
热议问题