MyHook allows module developers to define on-the-fly custom hooks. It is like having a custom module working instantly without creating/installing module files.

The package includes

  1. myhook.module: An empty module creating myhook namespace for custom hooks.
  2. myhookadmin.module: Provides an administrator interface(admin/settings/myhook) allowing the developer define custom hooks for myhook.module.

Example hook_nodeapi() implementation that notifys admin by email of new content

<?php
function myhook_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
  switch (
$op) {
    case
'insert':
     
drupal_mail_send(array(
       
'to' => 'admin@example.com',
       
'subject' => 'New content',
       
'body' => 'New content entered at ' . url('node/' . $node->nid, array('absolute' => TRUE)),
       
'headers' => array('From' => variable_get('site_mail', ini_get('sendmail_from'))),
      ));
      break;
  }
}
?>

Differences from hooker module

Hooker allows to define functions only and you can not define the hooks/functions that hooker already implemented. e.g. hook_menu(), hook_theme(), hook_init(). It executes a separate eval process for each function defined.

OTH, MyHook allows you to write any code as if you are writing your own myhook.module. It provides a new namespace and allows to define all hooks.
It also allows you to keep the custom code in a file, which saves a DB hit and an eval process.

Downloads

Recommended releases

Version Downloads Date Links
7.x-1.0 tar.gz (9.72 KB) | zip (11.86 KB) 2010-Oct-09 Notes
6.x-1.0 tar.gz (9.86 KB) | zip (11.95 KB) 2010-Oct-09 Notes

Development releases

Version Downloads Date Links
7.x-1.x-dev tar.gz (9.65 KB) | zip (11.55 KB) 2011-Feb-25 Notes
6.x-1.x-dev tar.gz (9.81 KB) | zip (11.63 KB) 2011-Feb-25 Notes

Project Information


Maintainers for MyHook

  • ufku - 8 commits
    last: 1 year ago, first: 1 year ago

Issues for MyHook

To avoid duplicates, please search before submitting a new issue.
All issues
Bug reports
Oldest open issue: 1 Sep 10