Using hook_menu

This screencasts introduces the concept of *hooks* – functions that, thanks to their names, are recognized and called by Drupal at certain events.
In particular, this screencast shows how a module registers new paths on your Drupal site, by implementing "hook_menu". It shows some aspects of using this hook:

  • Declaring new paths
  • Declaring a callback function
  • Setting access to the path
  • Setting which menu the page should appear

This screencast also points out that you'll need to clear the cache to see changes in the menu items.

Code added to wordlist.module

/**
* Implements hook_menu().
*/
function wordlist_menu() {
$items['admin/config/content/wordlist'] = array(
'title' => 'Word list',
'description' => 'Manage the list of globally available words on your site.',
'page callback' => 'wordlist_page',
'access callback' => 'user_access',
'access arguments' => array('administer_site_configuration'),
'menu_name' => 'management',
);

return $items;
}


/**
* Builds the page for configuring Word list.
*/
function wordlist_page() {
return 'Hello world!';
}