Module_invoke

The function of yesterday is module_invoke. This is a very powerfull function that allows you to reuse behavior of other hooks in your own module. Just give the function call the module name and hook you want to use and the arguments of the hook and you are done!

An Example always helps...

"Case: lets say you want a show a block on a location but it is in the middle of you own code. So the regions won't help you."

Solution with module_invoke


$block = module_invoke('block', 'block', 'view', 1);
// arg 1 = module
// arg 2 = hook
// arg 3 = arg 1 of the hook => $op
// arg 4 = arg 2 of the hook => $delta
$block_content = print_r ($block['content'],1);
// $object has been retrieve and we can do with what we want.
// bool arg of print function to capture the output of print_r

But you can use this function for tons of other things and it makes development easy, solid and short

http://api.drupal.org/api/function/module_invoke/6
http://api.drupal.org/api/function/block_block/6

hi

i am a spam comment.

It could imitate

It could imitate constructive for my work. Thanks due to nine-to-five marvelous information. Currently i am practicality a interest of netting developer & doing a job at software house , where we provide useful & efficient solutions to organizations

Really nice

It could be beneficial for my work. Thanks for posting awesome information. Currently i am doing a job of web developer & also have a blog about Free Seo Tips, where u can find useful tips to optimize your websites by yourself.