How to place drupal blocks anywhere in content.

If you're looking to place a block anywhere inside your content, simply do the following:

go to /admin/build/block

select the block you want to insert into your content to get the proper block references...

e.g. I created a custom views block called "latest_news" which, if you click it's url looks like:
/admin/build/block/configure/views/latest_news-block

so basically, you'll use "views" at the beginning of the function reference and "latest_news-block" at the end:

Drupal 7 method

Menu block

<?php
$block
= block_load('menu', 'name-of-menu');
$output = drupal_render(_block_get_renderable_array(_block_render_blocks(array($block))));
print
$output;
?>

Views block

<?php
$block
= block_load('view', 'name-of-view');
$output = drupal_render(_block_get_renderable_array(_block_render_blocks(array($block))));
print
$output;
?>

Regular block

<?php
$block
= block_load('block', 'name-of-view');
$output = drupal_render(_block_get_renderable_array(_block_render_blocks(array($block))));
print
$output;
?>

Drupal 6 method

<?php
$block
= module_invoke('views', 'block', 'view', 'latest_news-block');
print
$block['content'];
?>

Or if you want to do just a regular block... just click on it to get the url...

e.g. /admin/build/block/configure/block/10

<?php
$block
= module_invoke('block', 'block', 'view', 10);
print
$block['content'];
?>

Or, you may be using the event module, and would want to show it's block somewhere...

<?php
$block
= module_invoke('event', 'block', 'view', 1);
print
$block['content'];
?>

or if you want to show a menu block:

<?php
$block
= module_invoke('menu', 'block', 'view', 'name-of-menu');
print
$block['content'];
?>

Tags: Drupal blocks