Skip to main content

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:

<?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'];
?>

Post new comment

The content of this field is kept private and will not be shown publicly.