I've created some blocks (not related to any other module, just through the "add block" option) and I am attempting to call them in the correct places in my homepage template.

I found the following code:

$block = module_invoke('block', 'block', 'view', '1'); //where 1 is block delta
print $block['content'];

But this only allows me to display the block content. Is there a way to get the block title too? I did find some people using $block['title'] or $block['subject'] but my $block array only seems to have the content in and nothing else.

Apologies if this is a common question but I couldn't seem to find an answer for the life of me!

2 Answers 2


http://drupal.org/node/26502 - A nice write up on displaying a block using code. There are a couple of examples toward the bottom that show displaying the entire block (including the subject).

One in particular you could try, using Drupal's theme() function:

    $block = (object) module_invoke('[target_module]', 'block', 'view', "[target_block_ID]");
    print theme('block', $block);

Above is a D6 answer, although the link supplied gives details on solutions for D6 and D7.

Try this for D7.

$block = (object) module_invoke('[target_module]', 'block_view', "target_block_ID]");
print theme('block', $block);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.