0

I've created a custom template (node--<mytype>.tpl.php), and I'd like to display the calendars from the Availability Calendars module. I don't understand how to load them.

I've tried with this, but it doesn't work:

$block = module_invoke('availability_calendar', 'block_view');

Can you help me?

  • You should specify the version of Drupal. – niksmac Apr 17 '12 at 4:24
  • You are right, we are using D7 – wezzy Apr 17 '12 at 8:36
1

First, you have to make your block available inside your node.tpl.php, so edit template.php and add the following:

function YOURTHEME_preprocess_node($variables) {
  $YOURBLOCK = block_load('MODULENAME', 'BLOCKDELTA');
  $variables['YOURBLOCK'] = drupal_render(_block_get_renderable_array(_block_render_blocks(array($block))));
}

Then, on your node.tpl.php you can print $YOURBLOCK; anywhere you want.

And yes, you have to call two "private" functions from block module, see http://api.drupal.org/api/drupal/includes%21module.inc/function/module_invoke/7#comment-15884

0

You can do it with print $block['content'];

Make sure that you're using appropriate arguments for module_invoke API

$block = module_invoke('block', 'block_view', 30);

@arg 1 : module name
@arg 2 : hook name like block_view, block_info
@arg 3 : id or delta of the block e.g 30, map-block_1

in D7 you can also try block_load API

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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