Wednesday, July 20, 2016

Drupal: how to invoke a custom block into a template

Just do:

$block = module_invoke('custom_mod', 'block_view', 'products_menu');
print render($block['content']);

Where:

custom_mod is the name of the module
block_view it is called a "hook", don't change it
products_menu the machine name of the custom block

for view blocks

$block = module_invoke('views', 'block_view', 'user_profile-block');
print render($block['content']);

for regular blocks


$block = module_invoke('block', 'block_view', 18); 
print render($block['content']); 

No comments:

Post a Comment