When there is a need to call a function inside a module, some of you say- it is good to use module_invoke()
inside the template pages to call the function(it looks great-since I can pass arguments too).
Using Drupal 7. So for the first time, it is okay. Even for the second time, it makes a bit extra effort in the code, but somehow I can manage it.
Now it is invoking again and again, the same module. Say if the module is block
, and the function is hook_block_view()
- I doubt, it could affect the Drupal site performance(the time for loading the page contents), what do you think?
Is there a solution for this problem?
<?php
$header_block = module_invoke('block', 'block_view', '2');
print drupal_render($header_block);
$news_block = module_invoke('block', 'block_view', '3');
print drupal_render($news_block);
...
...
$footer_block = module_invoke('block', 'block_view', '12');
print drupal_render($footer_block);
?>
- Is it a good idea to use the
module_invoke()
every time when I have to callhook_block_view()
with different arguments? - Is there any other function that can be used for calling the same function or any other function in the module after one-
module_invoke()
? - Is there any other way of doing thing?