Loading a Block

If you need to load a block into a custompage and you want it to have all the proper wrappers of a block: Use this method:

<?php
$block_name
= block_load($module, $block_name);
$renderable_block_name = _block_get_renderable_array(_block_render_blocks(array($block_name)));
$block_name_render = drupal_render($renderable_block_name);
?>

Example:

<?php
 
$block_search
= block_load('search', 'form');
$renderable_block_search = _block_get_renderable_array(_block_render_blocks(array($block_search)));
$block_search_render = drupal_render($renderable_block_search);
?>

This will load the block fully wrapped. If you need to load a block with an argument, for example a Views Block, you will still need to use either http://api.drupal.org/api/views/views.module/function/views_embed_view/7 or module invoke using this: http://api.drupal.org/api/drupal/includes%21module.inc/function/module_i... Notice that after $hook, you can include arguments.

If you want less that the full wrappers you can use
module_invoke(module name , 'block_view', block delta)

Then output either the markup or the content.

<?php
 
   
// get profile page address block
   
$block_profile_page_address = module_invoke('mmg_custom_profile_page', 'block_view', 'profile_page_address');

    $output_profile_page_address = $block_profile_page_address['content']['#markup'];
// OR
 
$output_profile_page_address = $block_profile_page_address['content'];
?>

Use ['content'] if you want an array that has the block title and wrappers, or use ['#markup'] if you want just the 'guts of the block' straight off the tpl.

section: