Add new comment

Basic Hooks: Frequently, Hooks uses in Drupal7?

1) hook_form_alter(&$form, &$form_state, $form_id)
    - Perform alterations before a form is rendered.

2) hook_form_FORM_ID_alter(&$form, &$form_state, $form_id)
    -  Provide a form-specific alteration instead of the global hook_form_alter().
 
3) hook_form_BASE_FORM_ID_alter(&$form, &$form_state, $form_id)
    -  Provide a form-specific alteration for shared ('base') forms.
     
4) hook_node_insert($node)  
    - Respond to creation of a new node.

5)  hook_node_presave($node)
    - Act on a node being inserted or updated.

6) hook_node_submit($node, $form, &$form_state) 
     - Act on a node after validated form values have been copied to it.

7) hook_delete($node)
    - Respond to node deletion.

8) hook_node_submit($node, $form, &$form_state)
    - Act on a node after validated form values have been copied to it.

9) hook_entity_delete($entity, $type)  
    - Act on entities when deleted.

10) hook_node_view_alter(&$build) 
    - Alter the results of node_view().

11) hook_theme($existing, $type, $theme, $path)
     - Register a module (or theme's) theme implementations.
 
12) hook_theme_registry_alter(&$theme_registry)
      -  Alter the theme registry information returned from hook_theme().
 
13) hook_token_info()
    - Provide information about available placeholder tokens and token types.

14) hook_tokens($type, $tokens, array $data = array(), array $options = array())
     - Provide replacement values for placeholder tokens.
 
15)  hook_permission()
     - Define user permissions.
 
16)  hook_init()
      - Perform setup tasks for non-cached page requests.

17)  hook_menu()
      -  Define menu items and page callbacks.
 
18) hook_menu_alter(&$items)
      - Alter the data being saved to the {menu_router} table after hook_menu is invoked.
 
19)  hook_schema()
   - Define the current version of the database schema.

20) hook_schema_alter(&$schema)
    - Perform alterations to existing database schemas.
 
21) hook_install()
  -  Perform setup tasks when the module is installed.
 
22) hook_uninstall()
   -  Remove any information that the module sets.
 
23) hook_update_N(&$sandbox)
   - Perform a single update.

24) hook_cron()
   - Perform periodic actions.
 
25) hook_custom_theme()
    - Return the machine-readable name of the theme to use for the current page.
 
26) hook_library()
   - Registers JavaScript/CSS libraries associated with a module.

27) hook_mail($key, &$message, $params)
    - Prepare a message based on parameters; called from drupal_mail().
 
28)  hook_mail_alter(&$message)
     -  Alter an email message created with the drupal_mail() function.
 
29) hook_block_info()
     - Define all blocks provided by the module.
 
30) hook_block_view($delta = '')
      - Return a rendered or renderable view of a block.
 

EX Note: 
Trying to use hook_form_FORM_ID_alter() with node forms is a pain because the form ID is always "[node-type]_node_form" - that is, it's different for every node type. The Drupal 6 workaround is to use hook_form_alter() and check the form to see if it's a node form (doing something like isset($form['#node'])), but in D7, there's a better way; you can use hook_form_BASE_FORM_ID_alter(). With nodes, the base form ID is "node_form," so you can just create an implementation of hook_form_node_form_alter(). Ah, much better.

Tags

Restricted HTML

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.
1 + 2 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.