KAndy – Live

Drupal: Render any block using php code

Posted by: mrkandy on: Март 24, 2010

Sometimes you want to be able to embed a block in the middle of a page, in the header or footer of a view.
To do that, you can actually invoke the block wherever you want using the following php code:

/**
* Render block
* @param int|string $id block id
* @param string $module module name (default: block)
* @return string block markup
*/
function block_render($id, $module = 'block') {
    $block = (object)module_invoke($module, 'block', 'view', $id);
    $block->module = $module;
    $block->delta = $id;
    return theme('block', $block);
}

Метки: ,

Добавить комментарий

Fill in your details below or click an icon to log in:

Логотип WordPress.com

You are commenting using your WordPress.com account. Log Out / Изменить )

Фотография Twitter

You are commenting using your Twitter account. Log Out / Изменить )

Фотография Facebook

You are commenting using your Facebook account. Log Out / Изменить )

Connecting to %s

Рубрики

Обновления Twitter

Follow

Get every new post delivered to your Inbox.