Search code examples
phpdrupaldrupal-blocksdrupal-templates

Drupal show block data in a template region


i have a dynamic block data (from database) for one of my modules and it is displayed in the right sidebar.

Now my template is changed and i want to integrate this block data into one of my .tpl files. How can i proceed?


Solution

  • You have not specified the version of Drupal you are using, for Drupal 6 this would do it:

    $block = module_invoke('views', 'block', 'view', 'block_name');
    print $block['content'];
    

    For drupal 7, you could try this (clunkier) approach:

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

    Hope that helps!