开发者

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?


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!


In D6, if you want the block contents themed like a block:

$block = module_invoke('views', 'block', 'view', 'block_name');
print theme('block', (object) $block);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜