开发者

How to render block programmatically with standard theme

开发者 https://www.devze.com 2023-01-17 14:43 出处:网络
I know how to get block data by module_invoke(), but how to use standard block theme for rendering it.

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

精彩评论

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

关注公众号