开发者

How to render block programmatically with standard theme

I know how to get block data by module_invoke(),

but how to use standard block theme for rendering it.

I tried to use 开发者_如何学运维theme() function but with no success.

Could somebody give me advice?

Regards


Taken from the API comments for theme_block

// setup vars
$module = 'system';
$delta = 0; // could also be a string

// renders the "Powered by Drupal" block
// @see hook_block()
// @see module_invoke()
$block = module_invoke($module, 'block', 'view', $delta);

// must be converted to an object
$block = !empty($block) ? (object)$block : new stdclass;

$block->module = $module;
$block->delta = $delta;
$block->region = 'whateverYouWant';

echo theme('block',$block);

Haven't tested it but it seems to be doing what you want. This uses the regular theme function to theme the block you are retrieving

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜