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

后端 未结 15 1098
闹比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条回答
  •  猫巷女王i
    2021-01-30 02:21

    D7:

    
    

    'module_name' = The machine name of the module (i.e. the module's folder name). This is true for core modules too, so for instance 'search', 'user' and 'comment' would all work here.

    'block_delta' = The machine name of the block. You can determine what this is by visiting the block administration page and editing the block. The URL for editing a webform block, for instance, would be something like:

    Drupal 7: admin/structure/block/manage/webform/client-block-11/configure

    In this example, 'webform' is the module's name, 'client-block-11' is the block's delta.

    Custom blocks will have module name of 'block' and a number for a delta, which you can also find by editing the block.

    More information: http://drupal.org/node/26502

提交回复
热议问题